babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * 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.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * Gets or sets a boolean used to define if the node must be serialized
  420. */
  421. doNotSerialize: boolean;
  422. /** @hidden */
  423. _isDisposed: boolean;
  424. /**
  425. * Gets a list of Animations associated with the node
  426. */
  427. animations: Animation[];
  428. protected _ranges: {
  429. [name: string]: Nullable<AnimationRange>;
  430. };
  431. /**
  432. * Callback raised when the node is ready to be used
  433. */
  434. onReady: (node: Node) => void;
  435. private _isEnabled;
  436. private _isParentEnabled;
  437. private _isReady;
  438. /** @hidden */
  439. _currentRenderId: number;
  440. private _parentRenderId;
  441. protected _childRenderId: number;
  442. /** @hidden */
  443. _waitingParentId: Nullable<string>;
  444. /** @hidden */
  445. _scene: Scene;
  446. /** @hidden */
  447. _cache: any;
  448. private _parentNode;
  449. private _children;
  450. /** @hidden */
  451. _worldMatrix: Matrix;
  452. /** @hidden */
  453. _worldMatrixDeterminant: number;
  454. /** @hidden */
  455. private _sceneRootNodesIndex;
  456. /**
  457. * Gets a boolean indicating if the node has been disposed
  458. * @returns true if the node was disposed
  459. */
  460. isDisposed(): boolean;
  461. /**
  462. * Gets or sets the parent of the node
  463. */
  464. parent: Nullable<Node>;
  465. private addToSceneRootNodes;
  466. private removeFromSceneRootNodes;
  467. private _animationPropertiesOverride;
  468. /**
  469. * Gets or sets the animation properties override
  470. */
  471. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  472. /**
  473. * Gets a string idenfifying the name of the class
  474. * @returns "Node" string
  475. */
  476. getClassName(): string;
  477. /**
  478. * An event triggered when the mesh is disposed
  479. */
  480. onDisposeObservable: Observable<Node>;
  481. private _onDisposeObserver;
  482. /**
  483. * Sets a callback that will be raised when the node will be disposed
  484. */
  485. onDispose: () => void;
  486. /**
  487. * Creates a new Node
  488. * @param name the name and id to be given to this node
  489. * @param scene the scene this node will be added to
  490. * @param addToRootNodes the node will be added to scene.rootNodes
  491. */
  492. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  493. /**
  494. * Gets the scene of the node
  495. * @returns a scene
  496. */
  497. getScene(): Scene;
  498. /**
  499. * Gets the engine of the node
  500. * @returns a Engine
  501. */
  502. getEngine(): Engine;
  503. private _behaviors;
  504. /**
  505. * Attach a behavior to the node
  506. * @see http://doc.babylonjs.com/features/behaviour
  507. * @param behavior defines the behavior to attach
  508. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  509. * @returns the current Node
  510. */
  511. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  512. /**
  513. * Remove an attached behavior
  514. * @see http://doc.babylonjs.com/features/behaviour
  515. * @param behavior defines the behavior to attach
  516. * @returns the current Node
  517. */
  518. removeBehavior(behavior: Behavior<Node>): Node;
  519. /**
  520. * Gets the list of attached behaviors
  521. * @see http://doc.babylonjs.com/features/behaviour
  522. */
  523. readonly behaviors: Behavior<Node>[];
  524. /**
  525. * Gets an attached behavior by name
  526. * @param name defines the name of the behavior to look for
  527. * @see http://doc.babylonjs.com/features/behaviour
  528. * @returns null if behavior was not found else the requested behavior
  529. */
  530. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  531. /**
  532. * Returns the latest update of the World matrix
  533. * @returns a Matrix
  534. */
  535. getWorldMatrix(): Matrix;
  536. /** @hidden */
  537. _getWorldMatrixDeterminant(): number;
  538. /**
  539. * Returns directly the latest state of the mesh World matrix.
  540. * A Matrix is returned.
  541. */
  542. readonly worldMatrixFromCache: Matrix;
  543. /** @hidden */
  544. _initCache(): void;
  545. /** @hidden */
  546. updateCache(force?: boolean): void;
  547. /** @hidden */
  548. _updateCache(ignoreParentClass?: boolean): void;
  549. /** @hidden */
  550. _isSynchronized(): boolean;
  551. /** @hidden */
  552. _markSyncedWithParent(): void;
  553. /** @hidden */
  554. isSynchronizedWithParent(): boolean;
  555. /** @hidden */
  556. isSynchronized(): boolean;
  557. /**
  558. * Is this node ready to be used/rendered
  559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  560. * @return true if the node is ready
  561. */
  562. isReady(completeCheck?: boolean): boolean;
  563. /**
  564. * Is this node enabled?
  565. * 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
  566. * @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
  567. * @return whether this node (and its parent) is enabled
  568. */
  569. isEnabled(checkAncestors?: boolean): boolean;
  570. /** @hidden */
  571. protected _syncParentEnabledState(): void;
  572. /**
  573. * Set the enabled state of this node
  574. * @param value defines the new enabled state
  575. */
  576. setEnabled(value: boolean): void;
  577. /**
  578. * Is this node a descendant of the given node?
  579. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  580. * @param ancestor defines the parent node to inspect
  581. * @returns a boolean indicating if this node is a descendant of the given node
  582. */
  583. isDescendantOf(ancestor: Node): boolean;
  584. /** @hidden */
  585. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  586. /**
  587. * Will return all nodes that have this node as ascendant
  588. * @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
  589. * @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
  590. * @return all children nodes of all types
  591. */
  592. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  593. /**
  594. * Get all child-meshes of this node
  595. * @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
  596. * @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
  597. * @returns an array of AbstractMesh
  598. */
  599. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  600. /**
  601. * Get all child-transformNodes of this node
  602. * @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
  603. * @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
  604. * @returns an array of TransformNode
  605. */
  606. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  607. /**
  608. * Get all direct children of this node
  609. * @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
  610. * @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)
  611. * @returns an array of Node
  612. */
  613. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  614. /** @hidden */
  615. _setReady(state: boolean): void;
  616. /**
  617. * Get an animation by name
  618. * @param name defines the name of the animation to look for
  619. * @returns null if not found else the requested animation
  620. */
  621. getAnimationByName(name: string): Nullable<Animation>;
  622. /**
  623. * Creates an animation range for this node
  624. * @param name defines the name of the range
  625. * @param from defines the starting key
  626. * @param to defines the end key
  627. */
  628. createAnimationRange(name: string, from: number, to: number): void;
  629. /**
  630. * Delete a specific animation range
  631. * @param name defines the name of the range to delete
  632. * @param deleteFrames defines if animation frames from the range must be deleted as well
  633. */
  634. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  635. /**
  636. * Get an animation range by name
  637. * @param name defines the name of the animation range to look for
  638. * @returns null if not found else the requested animation range
  639. */
  640. getAnimationRange(name: string): Nullable<AnimationRange>;
  641. /**
  642. * Will start the animation sequence
  643. * @param name defines the range frames for animation sequence
  644. * @param loop defines if the animation should loop (false by default)
  645. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  646. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  647. * @returns the object created for this animation. If range does not exist, it will return null
  648. */
  649. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  650. /**
  651. * Serialize animation ranges into a JSON compatible object
  652. * @returns serialization object
  653. */
  654. serializeAnimationRanges(): any;
  655. /**
  656. * Computes the world matrix of the node
  657. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  658. * @returns the world matrix
  659. */
  660. computeWorldMatrix(force?: boolean): Matrix;
  661. /**
  662. * Releases resources associated with this node.
  663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  665. */
  666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  667. /**
  668. * Parse animation range data from a serialization object and store them into a given node
  669. * @param node defines where to store the animation ranges
  670. * @param parsedNode defines the serialization object to read data from
  671. * @param scene defines the hosting scene
  672. */
  673. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  674. }
  675. }
  676. declare module BABYLON {
  677. /**
  678. * Define an interface for all classes that will hold resources
  679. */
  680. interface IDisposable {
  681. /**
  682. * Releases all held resources
  683. */
  684. dispose(): void;
  685. }
  686. /**
  687. * This class is used by the onRenderingGroupObservable
  688. */
  689. class RenderingGroupInfo {
  690. /**
  691. * The Scene that being rendered
  692. */
  693. scene: Scene;
  694. /**
  695. * The camera currently used for the rendering pass
  696. */
  697. camera: Nullable<Camera>;
  698. /**
  699. * The ID of the renderingGroup being processed
  700. */
  701. renderingGroupId: number;
  702. }
  703. /** Interface defining initialization parameters for Scene class */
  704. interface SceneOptions {
  705. /**
  706. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  707. * It will improve performance when the number of geometries becomes important.
  708. */
  709. useGeometryIdsMap?: boolean;
  710. /**
  711. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  712. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  713. */
  714. useMaterialMeshMap?: boolean;
  715. /**
  716. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  717. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  718. */
  719. useClonedMeshhMap?: boolean;
  720. }
  721. /**
  722. * Represents a scene to be rendered by the engine.
  723. * @see http://doc.babylonjs.com/features/scene
  724. */
  725. class Scene extends AbstractScene implements IAnimatable {
  726. private static _uniqueIdCounter;
  727. /** The fog is deactivated */
  728. static readonly FOGMODE_NONE: number;
  729. /** The fog density is following an exponential function */
  730. static readonly FOGMODE_EXP: number;
  731. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  732. static readonly FOGMODE_EXP2: number;
  733. /** The fog density is following a linear function. */
  734. static readonly FOGMODE_LINEAR: number;
  735. /**
  736. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  738. */
  739. static MinDeltaTime: number;
  740. /**
  741. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  743. */
  744. static MaxDeltaTime: number;
  745. /**
  746. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  747. */
  748. autoClear: boolean;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  751. */
  752. autoClearDepthAndStencil: boolean;
  753. /**
  754. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  755. */
  756. clearColor: Color4;
  757. /**
  758. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  759. */
  760. ambientColor: Color3;
  761. /** @hidden */
  762. _environmentBRDFTexture: BaseTexture;
  763. /** @hidden */
  764. protected _environmentTexture: Nullable<BaseTexture>;
  765. /**
  766. * Texture used in all pbr material as the reflection texture.
  767. * As in the majority of the scene they are the same (exception for multi room and so on),
  768. * this is easier to reference from here than from all the materials.
  769. */
  770. /**
  771. * Texture used in all pbr material as the reflection texture.
  772. * As in the majority of the scene they are the same (exception for multi room and so on),
  773. * this is easier to set here than in all the materials.
  774. */
  775. environmentTexture: Nullable<BaseTexture>;
  776. /** @hidden */
  777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  778. /**
  779. * Default image processing configuration used either in the rendering
  780. * Forward main pass or through the imageProcessingPostProcess if present.
  781. * As in the majority of the scene they are the same (exception for multi camera),
  782. * this is easier to reference from here than from all the materials and post process.
  783. *
  784. * No setter as we it is a shared configuration, you can set the values instead.
  785. */
  786. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  787. private _forceWireframe;
  788. /**
  789. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  790. */
  791. forceWireframe: boolean;
  792. private _forcePointsCloud;
  793. /**
  794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  795. */
  796. forcePointsCloud: boolean;
  797. /**
  798. * Gets or sets the active clipplane 1
  799. */
  800. clipPlane: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 2
  803. */
  804. clipPlane2: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 3
  807. */
  808. clipPlane3: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 4
  811. */
  812. clipPlane4: Nullable<Plane>;
  813. /**
  814. * Gets or sets a boolean indicating if animations are enabled
  815. */
  816. animationsEnabled: boolean;
  817. private _animationPropertiesOverride;
  818. /**
  819. * Gets or sets the animation properties override
  820. */
  821. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  822. /**
  823. * Gets or sets a boolean indicating if a constant deltatime has to be used
  824. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  825. */
  826. useConstantAnimationDeltaTime: boolean;
  827. /**
  828. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  829. * Please note that it requires to run a ray cast through the scene on every frame
  830. */
  831. constantlyUpdateMeshUnderPointer: boolean;
  832. /**
  833. * Defines the HTML cursor to use when hovering over interactive elements
  834. */
  835. hoverCursor: string;
  836. /**
  837. * Defines the HTML default cursor to use (empty by default)
  838. */
  839. defaultCursor: string;
  840. /**
  841. * This is used to call preventDefault() on pointer down
  842. * in order to block unwanted artifacts like system double clicks
  843. */
  844. preventDefaultOnPointerDown: boolean;
  845. /**
  846. * This is used to call preventDefault() on pointer up
  847. * in order to block unwanted artifacts like system double clicks
  848. */
  849. preventDefaultOnPointerUp: boolean;
  850. /**
  851. * Gets or sets user defined metadata
  852. */
  853. metadata: any;
  854. /**
  855. * Gets the name of the plugin used to load this scene (null by default)
  856. */
  857. loadingPluginName: string;
  858. /**
  859. * Use this array to add regular expressions used to disable offline support for specific urls
  860. */
  861. disableOfflineSupportExceptionRules: RegExp[];
  862. /**
  863. * An event triggered when the scene is disposed.
  864. */
  865. onDisposeObservable: Observable<Scene>;
  866. private _onDisposeObserver;
  867. /** Sets a function to be executed when this scene is disposed. */
  868. onDispose: () => void;
  869. /**
  870. * An event triggered before rendering the scene (right after animations and physics)
  871. */
  872. onBeforeRenderObservable: Observable<Scene>;
  873. private _onBeforeRenderObserver;
  874. /** Sets a function to be executed before rendering this scene */
  875. beforeRender: Nullable<() => void>;
  876. /**
  877. * An event triggered after rendering the scene
  878. */
  879. onAfterRenderObservable: Observable<Scene>;
  880. private _onAfterRenderObserver;
  881. /** Sets a function to be executed after rendering this scene */
  882. afterRender: Nullable<() => void>;
  883. /**
  884. * An event triggered before animating the scene
  885. */
  886. onBeforeAnimationsObservable: Observable<Scene>;
  887. /**
  888. * An event triggered after animations processing
  889. */
  890. onAfterAnimationsObservable: Observable<Scene>;
  891. /**
  892. * An event triggered before draw calls are ready to be sent
  893. */
  894. onBeforeDrawPhaseObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after draw calls have been sent
  897. */
  898. onAfterDrawPhaseObservable: Observable<Scene>;
  899. /**
  900. * An event triggered when the scene is ready
  901. */
  902. onReadyObservable: Observable<Scene>;
  903. /**
  904. * An event triggered before rendering a camera
  905. */
  906. onBeforeCameraRenderObservable: Observable<Camera>;
  907. private _onBeforeCameraRenderObserver;
  908. /** Sets a function to be executed before rendering a camera*/
  909. beforeCameraRender: () => void;
  910. /**
  911. * An event triggered after rendering a camera
  912. */
  913. onAfterCameraRenderObservable: Observable<Camera>;
  914. private _onAfterCameraRenderObserver;
  915. /** Sets a function to be executed after rendering a camera*/
  916. afterCameraRender: () => void;
  917. /**
  918. * An event triggered when active meshes evaluation is about to start
  919. */
  920. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  921. /**
  922. * An event triggered when active meshes evaluation is done
  923. */
  924. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  925. /**
  926. * An event triggered when particles rendering is about to start
  927. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  928. */
  929. onBeforeParticlesRenderingObservable: Observable<Scene>;
  930. /**
  931. * An event triggered when particles rendering is done
  932. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  933. */
  934. onAfterParticlesRenderingObservable: Observable<Scene>;
  935. /**
  936. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  937. */
  938. onDataLoadedObservable: Observable<Scene>;
  939. /**
  940. * An event triggered when a camera is created
  941. */
  942. onNewCameraAddedObservable: Observable<Camera>;
  943. /**
  944. * An event triggered when a camera is removed
  945. */
  946. onCameraRemovedObservable: Observable<Camera>;
  947. /**
  948. * An event triggered when a light is created
  949. */
  950. onNewLightAddedObservable: Observable<Light>;
  951. /**
  952. * An event triggered when a light is removed
  953. */
  954. onLightRemovedObservable: Observable<Light>;
  955. /**
  956. * An event triggered when a geometry is created
  957. */
  958. onNewGeometryAddedObservable: Observable<Geometry>;
  959. /**
  960. * An event triggered when a geometry is removed
  961. */
  962. onGeometryRemovedObservable: Observable<Geometry>;
  963. /**
  964. * An event triggered when a transform node is created
  965. */
  966. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  967. /**
  968. * An event triggered when a transform node is removed
  969. */
  970. onTransformNodeRemovedObservable: Observable<TransformNode>;
  971. /**
  972. * An event triggered when a mesh is created
  973. */
  974. onNewMeshAddedObservable: Observable<AbstractMesh>;
  975. /**
  976. * An event triggered when a mesh is removed
  977. */
  978. onMeshRemovedObservable: Observable<AbstractMesh>;
  979. /**
  980. * An event triggered when a material is created
  981. */
  982. onNewMaterialAddedObservable: Observable<Material>;
  983. /**
  984. * An event triggered when a material is removed
  985. */
  986. onMaterialRemovedObservable: Observable<Material>;
  987. /**
  988. * An event triggered when a texture is created
  989. */
  990. onNewTextureAddedObservable: Observable<BaseTexture>;
  991. /**
  992. * An event triggered when a texture is removed
  993. */
  994. onTextureRemovedObservable: Observable<BaseTexture>;
  995. /**
  996. * An event triggered when render targets are about to be rendered
  997. * Can happen multiple times per frame.
  998. */
  999. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1000. /**
  1001. * An event triggered when render targets were rendered.
  1002. * Can happen multiple times per frame.
  1003. */
  1004. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1005. /**
  1006. * An event triggered before calculating deterministic simulation step
  1007. */
  1008. onBeforeStepObservable: Observable<Scene>;
  1009. /**
  1010. * An event triggered after calculating deterministic simulation step
  1011. */
  1012. onAfterStepObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered when the activeCamera property is updated
  1015. */
  1016. onActiveCameraChanged: Observable<Scene>;
  1017. /**
  1018. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1019. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1020. * 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)
  1021. */
  1022. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1023. /**
  1024. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1025. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1026. * 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)
  1027. */
  1028. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1029. /**
  1030. * This Observable will when a mesh has been imported into the scene.
  1031. */
  1032. onMeshImportedObservable: Observable<AbstractMesh>;
  1033. private _registeredForLateAnimationBindings;
  1034. /**
  1035. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1036. */
  1037. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1038. /**
  1039. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1040. */
  1041. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1044. */
  1045. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1046. private _onPointerMove;
  1047. private _onPointerDown;
  1048. private _onPointerUp;
  1049. /** Callback called when a pointer move is detected */
  1050. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1051. /** Callback called when a pointer down is detected */
  1052. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1053. /** Callback called when a pointer up is detected */
  1054. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1055. /** Callback called when a pointer pick is detected */
  1056. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1057. /**
  1058. * 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).
  1059. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1060. */
  1061. onPrePointerObservable: Observable<PointerInfoPre>;
  1062. /**
  1063. * Observable event triggered each time an input event is received from the rendering canvas
  1064. */
  1065. onPointerObservable: Observable<PointerInfo>;
  1066. /**
  1067. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1068. */
  1069. readonly unTranslatedPointer: Vector2;
  1070. /** The distance in pixel that you have to move to prevent some events */
  1071. static DragMovementThreshold: number;
  1072. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1073. static LongPressDelay: number;
  1074. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1075. static DoubleClickDelay: number;
  1076. /** If you need to check double click without raising a single click at first click, enable this flag */
  1077. static ExclusiveDoubleClickMode: boolean;
  1078. private _initClickEvent;
  1079. private _initActionManager;
  1080. private _delayedSimpleClick;
  1081. private _delayedSimpleClickTimeout;
  1082. private _previousDelayedSimpleClickTimeout;
  1083. private _meshPickProceed;
  1084. private _previousButtonPressed;
  1085. private _currentPickResult;
  1086. private _previousPickResult;
  1087. private _totalPointersPressed;
  1088. private _doubleClickOccured;
  1089. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1090. cameraToUseForPointers: Nullable<Camera>;
  1091. private _pointerX;
  1092. private _pointerY;
  1093. private _unTranslatedPointerX;
  1094. private _unTranslatedPointerY;
  1095. private _startingPointerPosition;
  1096. private _previousStartingPointerPosition;
  1097. private _startingPointerTime;
  1098. private _previousStartingPointerTime;
  1099. private _pointerCaptures;
  1100. private _timeAccumulator;
  1101. private _currentStepId;
  1102. private _currentInternalStep;
  1103. /** @hidden */
  1104. _mirroredCameraPosition: Nullable<Vector3>;
  1105. /**
  1106. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1107. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1108. */
  1109. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1110. /**
  1111. * Observable event triggered each time an keyboard event is received from the hosting window
  1112. */
  1113. onKeyboardObservable: Observable<KeyboardInfo>;
  1114. private _onKeyDown;
  1115. private _onKeyUp;
  1116. private _onCanvasFocusObserver;
  1117. private _onCanvasBlurObserver;
  1118. private _useRightHandedSystem;
  1119. /**
  1120. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1121. */
  1122. useRightHandedSystem: boolean;
  1123. /**
  1124. * Sets the step Id used by deterministic lock step
  1125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1126. * @param newStepId defines the step Id
  1127. */
  1128. setStepId(newStepId: number): void;
  1129. /**
  1130. * Gets the step Id used by deterministic lock step
  1131. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1132. * @returns the step Id
  1133. */
  1134. getStepId(): number;
  1135. /**
  1136. * Gets the internal step used by deterministic lock step
  1137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1138. * @returns the internal step
  1139. */
  1140. getInternalStep(): number;
  1141. private _fogEnabled;
  1142. /**
  1143. * Gets or sets a boolean indicating if fog is enabled on this scene
  1144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1145. * (Default is true)
  1146. */
  1147. fogEnabled: boolean;
  1148. private _fogMode;
  1149. /**
  1150. * Gets or sets the fog mode to use
  1151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1152. * | mode | value |
  1153. * | --- | --- |
  1154. * | FOGMODE_NONE | 0 |
  1155. * | FOGMODE_EXP | 1 |
  1156. * | FOGMODE_EXP2 | 2 |
  1157. * | FOGMODE_LINEAR | 3 |
  1158. */
  1159. fogMode: number;
  1160. /**
  1161. * Gets or sets the fog color to use
  1162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1163. * (Default is Color3(0.2, 0.2, 0.3))
  1164. */
  1165. fogColor: Color3;
  1166. /**
  1167. * Gets or sets the fog density to use
  1168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1169. * (Default is 0.1)
  1170. */
  1171. fogDensity: number;
  1172. /**
  1173. * Gets or sets the fog start distance to use
  1174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1175. * (Default is 0)
  1176. */
  1177. fogStart: number;
  1178. /**
  1179. * Gets or sets the fog end distance to use
  1180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1181. * (Default is 1000)
  1182. */
  1183. fogEnd: number;
  1184. private _shadowsEnabled;
  1185. /**
  1186. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1187. */
  1188. shadowsEnabled: boolean;
  1189. private _lightsEnabled;
  1190. /**
  1191. * Gets or sets a boolean indicating if lights are enabled on this scene
  1192. */
  1193. lightsEnabled: boolean;
  1194. /** All of the active cameras added to this scene. */
  1195. activeCameras: Camera[];
  1196. private _activeCamera;
  1197. /** Gets or sets the current active camera */
  1198. activeCamera: Nullable<Camera>;
  1199. private _defaultMaterial;
  1200. /** The default material used on meshes when no material is affected */
  1201. /** The default material used on meshes when no material is affected */
  1202. defaultMaterial: Material;
  1203. private _texturesEnabled;
  1204. /**
  1205. * Gets or sets a boolean indicating if textures are enabled on this scene
  1206. */
  1207. texturesEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if particles are enabled on this scene
  1210. */
  1211. particlesEnabled: boolean;
  1212. /**
  1213. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1214. */
  1215. spritesEnabled: boolean;
  1216. private _skeletonsEnabled;
  1217. /**
  1218. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1219. */
  1220. skeletonsEnabled: boolean;
  1221. /**
  1222. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1223. */
  1224. lensFlaresEnabled: boolean;
  1225. /**
  1226. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1228. */
  1229. collisionsEnabled: boolean;
  1230. private _workerCollisions;
  1231. /** @hidden */
  1232. collisionCoordinator: ICollisionCoordinator;
  1233. /**
  1234. * Defines the gravity applied to this scene (used only for collisions)
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. gravity: Vector3;
  1238. /**
  1239. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1240. */
  1241. postProcessesEnabled: boolean;
  1242. /**
  1243. * The list of postprocesses added to the scene
  1244. */
  1245. postProcesses: PostProcess[];
  1246. /**
  1247. * Gets the current postprocess manager
  1248. */
  1249. postProcessManager: PostProcessManager;
  1250. /**
  1251. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1252. */
  1253. renderTargetsEnabled: boolean;
  1254. /**
  1255. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1256. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1257. */
  1258. dumpNextRenderTargets: boolean;
  1259. /**
  1260. * The list of user defined render targets added to the scene
  1261. */
  1262. customRenderTargets: RenderTargetTexture[];
  1263. /**
  1264. * Defines if texture loading must be delayed
  1265. * If true, textures will only be loaded when they need to be rendered
  1266. */
  1267. useDelayedTextureLoading: boolean;
  1268. /**
  1269. * Gets the list of meshes imported to the scene through SceneLoader
  1270. */
  1271. importedMeshesFiles: String[];
  1272. /**
  1273. * Gets or sets a boolean indicating if probes are enabled on this scene
  1274. */
  1275. probesEnabled: boolean;
  1276. /**
  1277. * Gets or sets the current offline provider to use to store scene data
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. offlineProvider: IOfflineProvider;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. private _meshesForIntersections;
  1287. /**
  1288. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1289. */
  1290. proceduralTexturesEnabled: boolean;
  1291. private _engine;
  1292. private _totalVertices;
  1293. /** @hidden */
  1294. _activeIndices: PerfCounter;
  1295. /** @hidden */
  1296. _activeParticles: PerfCounter;
  1297. /** @hidden */
  1298. _activeBones: PerfCounter;
  1299. private _animationRatio;
  1300. private _animationTimeLast;
  1301. private _animationTime;
  1302. /**
  1303. * Gets or sets a general scale for animation speed
  1304. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1305. */
  1306. animationTimeScale: number;
  1307. /** @hidden */
  1308. _cachedMaterial: Nullable<Material>;
  1309. /** @hidden */
  1310. _cachedEffect: Nullable<Effect>;
  1311. /** @hidden */
  1312. _cachedVisibility: Nullable<number>;
  1313. private _renderId;
  1314. private _frameId;
  1315. private _executeWhenReadyTimeoutId;
  1316. private _intermediateRendering;
  1317. private _viewUpdateFlag;
  1318. private _projectionUpdateFlag;
  1319. private _alternateViewUpdateFlag;
  1320. private _alternateProjectionUpdateFlag;
  1321. /** @hidden */
  1322. _toBeDisposed: Nullable<IDisposable>[];
  1323. private _activeRequests;
  1324. private _pendingData;
  1325. private _isDisposed;
  1326. /**
  1327. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1328. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1329. */
  1330. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1331. private _activeMeshes;
  1332. private _processedMaterials;
  1333. private _renderTargets;
  1334. /** @hidden */
  1335. _activeParticleSystems: SmartArray<IParticleSystem>;
  1336. private _activeSkeletons;
  1337. private _softwareSkinnedMeshes;
  1338. private _renderingManager;
  1339. /** @hidden */
  1340. _activeAnimatables: Animatable[];
  1341. private _transformMatrix;
  1342. private _sceneUbo;
  1343. private _alternateSceneUbo;
  1344. private _pickWithRayInverseMatrix;
  1345. private _viewMatrix;
  1346. private _projectionMatrix;
  1347. private _alternateViewMatrix;
  1348. private _alternateProjectionMatrix;
  1349. private _alternateTransformMatrix;
  1350. private _useAlternateCameraConfiguration;
  1351. private _alternateRendering;
  1352. private _wheelEventName;
  1353. /** @hidden */
  1354. _forcedViewPosition: Nullable<Vector3>;
  1355. /** @hidden */
  1356. readonly _isAlternateRenderingEnabled: boolean;
  1357. private _frustumPlanes;
  1358. /**
  1359. * Gets the list of frustum planes (built from the active camera)
  1360. */
  1361. readonly frustumPlanes: Plane[];
  1362. /**
  1363. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1364. * This is useful if there are more lights that the maximum simulteanous authorized
  1365. */
  1366. requireLightSorting: boolean;
  1367. /** @hidden */
  1368. readonly useMaterialMeshMap: boolean;
  1369. /** @hidden */
  1370. readonly useClonedMeshhMap: boolean;
  1371. private _pointerOverMesh;
  1372. private _pickedDownMesh;
  1373. private _pickedUpMesh;
  1374. private _externalData;
  1375. private _uid;
  1376. /**
  1377. * @hidden
  1378. * Backing store of defined scene components.
  1379. */
  1380. _components: ISceneComponent[];
  1381. /**
  1382. * @hidden
  1383. * Backing store of defined scene components.
  1384. */
  1385. _serializableComponents: ISceneSerializableComponent[];
  1386. /**
  1387. * List of components to register on the next registration step.
  1388. */
  1389. private _transientComponents;
  1390. /**
  1391. * Registers the transient components if needed.
  1392. */
  1393. private _registerTransientComponents;
  1394. /**
  1395. * @hidden
  1396. * Add a component to the scene.
  1397. * Note that the ccomponent could be registered on th next frame if this is called after
  1398. * the register component stage.
  1399. * @param component Defines the component to add to the scene
  1400. */
  1401. _addComponent(component: ISceneComponent): void;
  1402. /**
  1403. * @hidden
  1404. * Gets a component from the scene.
  1405. * @param name defines the name of the component to retrieve
  1406. * @returns the component or null if not present
  1407. */
  1408. _getComponent(name: string): Nullable<ISceneComponent>;
  1409. /**
  1410. * @hidden
  1411. * Defines the actions happening before camera updates.
  1412. */
  1413. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1414. /**
  1415. * @hidden
  1416. * Defines the actions happening before clear the canvas.
  1417. */
  1418. _beforeClearStage: Stage<SimpleStageAction>;
  1419. /**
  1420. * @hidden
  1421. * Defines the actions when collecting render targets for the frame.
  1422. */
  1423. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1424. /**
  1425. * @hidden
  1426. * Defines the actions happening for one camera in the frame.
  1427. */
  1428. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1429. /**
  1430. * @hidden
  1431. * Defines the actions happening during the per mesh ready checks.
  1432. */
  1433. _isReadyForMeshStage: Stage<MeshStageAction>;
  1434. /**
  1435. * @hidden
  1436. * Defines the actions happening before evaluate active mesh checks.
  1437. */
  1438. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1439. /**
  1440. * @hidden
  1441. * Defines the actions happening during the evaluate sub mesh checks.
  1442. */
  1443. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1444. /**
  1445. * @hidden
  1446. * Defines the actions happening during the active mesh stage.
  1447. */
  1448. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1449. /**
  1450. * @hidden
  1451. * Defines the actions happening during the per camera render target step.
  1452. */
  1453. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1454. /**
  1455. * @hidden
  1456. * Defines the actions happening just before the active camera is drawing.
  1457. */
  1458. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1459. /**
  1460. * @hidden
  1461. * Defines the actions happening just before a render target is drawing.
  1462. */
  1463. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1464. /**
  1465. * @hidden
  1466. * Defines the actions happening just before a rendering group is drawing.
  1467. */
  1468. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1469. /**
  1470. * @hidden
  1471. * Defines the actions happening just before a mesh is drawing.
  1472. */
  1473. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1474. /**
  1475. * @hidden
  1476. * Defines the actions happening just after a mesh has been drawn.
  1477. */
  1478. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1479. /**
  1480. * @hidden
  1481. * Defines the actions happening just after a rendering group has been drawn.
  1482. */
  1483. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1484. /**
  1485. * @hidden
  1486. * Defines the actions happening just after the active camera has been drawn.
  1487. */
  1488. _afterCameraDrawStage: Stage<CameraStageAction>;
  1489. /**
  1490. * @hidden
  1491. * Defines the actions happening just after a render target has been drawn.
  1492. */
  1493. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1494. /**
  1495. * @hidden
  1496. * Defines the actions happening just after rendering all cameras and computing intersections.
  1497. */
  1498. _afterRenderStage: Stage<SimpleStageAction>;
  1499. /**
  1500. * @hidden
  1501. * Defines the actions happening when a pointer move event happens.
  1502. */
  1503. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1504. /**
  1505. * @hidden
  1506. * Defines the actions happening when a pointer down event happens.
  1507. */
  1508. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1509. /**
  1510. * @hidden
  1511. * Defines the actions happening when a pointer up event happens.
  1512. */
  1513. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1514. /**
  1515. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1516. */
  1517. private geometriesById;
  1518. /**
  1519. * Creates a new Scene
  1520. * @param engine defines the engine to use to render this scene
  1521. */
  1522. constructor(engine: Engine, options?: SceneOptions);
  1523. private _defaultMeshCandidates;
  1524. /**
  1525. * @hidden
  1526. */
  1527. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1528. private _defaultSubMeshCandidates;
  1529. /**
  1530. * @hidden
  1531. */
  1532. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1533. /**
  1534. * Sets the default candidate providers for the scene.
  1535. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1536. * and getCollidingSubMeshCandidates to their default function
  1537. */
  1538. setDefaultCandidateProviders(): void;
  1539. /**
  1540. * Gets a boolean indicating if collisions are processed on a web worker
  1541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1542. */
  1543. workerCollisions: boolean;
  1544. /**
  1545. * Gets the mesh that is currently under the pointer
  1546. */
  1547. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1548. /**
  1549. * Gets the current on-screen X position of the pointer
  1550. */
  1551. readonly pointerX: number;
  1552. /**
  1553. * Gets the current on-screen Y position of the pointer
  1554. */
  1555. readonly pointerY: number;
  1556. /**
  1557. * Gets the cached material (ie. the latest rendered one)
  1558. * @returns the cached material
  1559. */
  1560. getCachedMaterial(): Nullable<Material>;
  1561. /**
  1562. * Gets the cached effect (ie. the latest rendered one)
  1563. * @returns the cached effect
  1564. */
  1565. getCachedEffect(): Nullable<Effect>;
  1566. /**
  1567. * Gets the cached visibility state (ie. the latest rendered one)
  1568. * @returns the cached visibility state
  1569. */
  1570. getCachedVisibility(): Nullable<number>;
  1571. /**
  1572. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1573. * @param material defines the current material
  1574. * @param effect defines the current effect
  1575. * @param visibility defines the current visibility state
  1576. * @returns true if one parameter is not cached
  1577. */
  1578. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1579. /**
  1580. * Gets the engine associated with the scene
  1581. * @returns an Engine
  1582. */
  1583. getEngine(): Engine;
  1584. /**
  1585. * Gets the total number of vertices rendered per frame
  1586. * @returns the total number of vertices rendered per frame
  1587. */
  1588. getTotalVertices(): number;
  1589. /**
  1590. * Gets the performance counter for total vertices
  1591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1592. */
  1593. readonly totalVerticesPerfCounter: PerfCounter;
  1594. /**
  1595. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1596. * @returns the total number of active indices rendered per frame
  1597. */
  1598. getActiveIndices(): number;
  1599. /**
  1600. * Gets the performance counter for active indices
  1601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1602. */
  1603. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1604. /**
  1605. * Gets the total number of active particles rendered per frame
  1606. * @returns the total number of active particles rendered per frame
  1607. */
  1608. getActiveParticles(): number;
  1609. /**
  1610. * Gets the performance counter for active particles
  1611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1612. */
  1613. readonly activeParticlesPerfCounter: PerfCounter;
  1614. /**
  1615. * Gets the total number of active bones rendered per frame
  1616. * @returns the total number of active bones rendered per frame
  1617. */
  1618. getActiveBones(): number;
  1619. /**
  1620. * Gets the performance counter for active bones
  1621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1622. */
  1623. readonly activeBonesPerfCounter: PerfCounter;
  1624. /**
  1625. * Gets the array of active meshes
  1626. * @returns an array of AbstractMesh
  1627. */
  1628. getActiveMeshes(): SmartArray<AbstractMesh>;
  1629. /**
  1630. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1631. * @returns a number
  1632. */
  1633. getAnimationRatio(): number;
  1634. /**
  1635. * Gets an unique Id for the current render phase
  1636. * @returns a number
  1637. */
  1638. getRenderId(): number;
  1639. /**
  1640. * Gets an unique Id for the current frame
  1641. * @returns a number
  1642. */
  1643. getFrameId(): number;
  1644. /** Call this function if you want to manually increment the render Id*/
  1645. incrementRenderId(): void;
  1646. private _updatePointerPosition;
  1647. private _createUbo;
  1648. private _createAlternateUbo;
  1649. private _setRayOnPointerInfo;
  1650. /**
  1651. * Use this method to simulate a pointer move on a mesh
  1652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1655. * @returns the current scene
  1656. */
  1657. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1658. private _processPointerMove;
  1659. private _checkPrePointerObservable;
  1660. /**
  1661. * Use this method to simulate a pointer down on a mesh
  1662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1665. * @returns the current scene
  1666. */
  1667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1668. private _processPointerDown;
  1669. /**
  1670. * Use this method to simulate a pointer up on a mesh
  1671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1675. * @returns the current scene
  1676. */
  1677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1678. private _processPointerUp;
  1679. /**
  1680. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1681. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1682. * @returns true if the pointer was captured
  1683. */
  1684. isPointerCaptured(pointerId?: number): boolean;
  1685. /** @hidden */
  1686. _isPointerSwiping(): boolean;
  1687. /**
  1688. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1689. * @param attachUp defines if you want to attach events to pointerup
  1690. * @param attachDown defines if you want to attach events to pointerdown
  1691. * @param attachMove defines if you want to attach events to pointermove
  1692. */
  1693. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1694. /** Detaches all event handlers*/
  1695. detachControl(): void;
  1696. /**
  1697. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1698. * Delay loaded resources are not taking in account
  1699. * @return true if all required resources are ready
  1700. */
  1701. isReady(): boolean;
  1702. /** Resets all cached information relative to material (including effect and visibility) */
  1703. resetCachedMaterial(): void;
  1704. /**
  1705. * Registers a function to be called before every frame render
  1706. * @param func defines the function to register
  1707. */
  1708. registerBeforeRender(func: () => void): void;
  1709. /**
  1710. * Unregisters a function called before every frame render
  1711. * @param func defines the function to unregister
  1712. */
  1713. unregisterBeforeRender(func: () => void): void;
  1714. /**
  1715. * Registers a function to be called after every frame render
  1716. * @param func defines the function to register
  1717. */
  1718. registerAfterRender(func: () => void): void;
  1719. /**
  1720. * Unregisters a function called after every frame render
  1721. * @param func defines the function to unregister
  1722. */
  1723. unregisterAfterRender(func: () => void): void;
  1724. private _executeOnceBeforeRender;
  1725. /**
  1726. * The provided function will run before render once and will be disposed afterwards.
  1727. * A timeout delay can be provided so that the function will be executed in N ms.
  1728. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1729. * @param func The function to be executed.
  1730. * @param timeout optional delay in ms
  1731. */
  1732. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1733. /** @hidden */
  1734. _addPendingData(data: any): void;
  1735. /** @hidden */
  1736. _removePendingData(data: any): void;
  1737. /**
  1738. * Returns the number of items waiting to be loaded
  1739. * @returns the number of items waiting to be loaded
  1740. */
  1741. getWaitingItemsCount(): number;
  1742. /**
  1743. * Returns a boolean indicating if the scene is still loading data
  1744. */
  1745. readonly isLoading: boolean;
  1746. /**
  1747. * Registers a function to be executed when the scene is ready
  1748. * @param {Function} func - the function to be executed
  1749. */
  1750. executeWhenReady(func: () => void): void;
  1751. /**
  1752. * Returns a promise that resolves when the scene is ready
  1753. * @returns A promise that resolves when the scene is ready
  1754. */
  1755. whenReadyAsync(): Promise<void>;
  1756. /** @hidden */
  1757. _checkIsReady(): void;
  1758. /**
  1759. * Will start the animation sequence of a given target
  1760. * @param target defines the target
  1761. * @param from defines from which frame should animation start
  1762. * @param to defines until which frame should animation run.
  1763. * @param weight defines the weight to apply to the animation (1.0 by default)
  1764. * @param loop defines if the animation loops
  1765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1766. * @param onAnimationEnd defines the function to be executed when the animation ends
  1767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1769. * @returns the animatable object created for this animation
  1770. */
  1771. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target
  1774. * @param target defines the target
  1775. * @param from defines from which frame should animation start
  1776. * @param to defines until which frame should animation run.
  1777. * @param loop defines if the animation loops
  1778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1779. * @param onAnimationEnd defines the function to be executed when the animation ends
  1780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1782. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1783. * @returns the animatable object created for this animation
  1784. */
  1785. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1786. /**
  1787. * Will start the animation sequence of a given target and its hierarchy
  1788. * @param target defines the target
  1789. * @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.
  1790. * @param from defines from which frame should animation start
  1791. * @param to defines until which frame should animation run.
  1792. * @param loop defines if the animation loops
  1793. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1794. * @param onAnimationEnd defines the function to be executed when the animation ends
  1795. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1796. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1797. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1798. * @returns the list of created animatables
  1799. */
  1800. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1801. /**
  1802. * Begin a new animation on a given node
  1803. * @param target defines the target where the animation will take place
  1804. * @param animations defines the list of animations to start
  1805. * @param from defines the initial value
  1806. * @param to defines the final value
  1807. * @param loop defines if you want animation to loop (off by default)
  1808. * @param speedRatio defines the speed ratio to apply to all animations
  1809. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1810. * @returns the list of created animatables
  1811. */
  1812. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1813. /**
  1814. * Begin a new animation on a given node and its hierarchy
  1815. * @param target defines the root node where the animation will take place
  1816. * @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.
  1817. * @param animations defines the list of animations to start
  1818. * @param from defines the initial value
  1819. * @param to defines the final value
  1820. * @param loop defines if you want animation to loop (off by default)
  1821. * @param speedRatio defines the speed ratio to apply to all animations
  1822. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1823. * @returns the list of animatables created for all nodes
  1824. */
  1825. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1826. /**
  1827. * Gets the animatable associated with a specific target
  1828. * @param target defines the target of the animatable
  1829. * @returns the required animatable if found
  1830. */
  1831. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1832. /**
  1833. * Gets all animatables associated with a given target
  1834. * @param target defines the target to look animatables for
  1835. * @returns an array of Animatables
  1836. */
  1837. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1838. /**
  1839. * Gets all animatable attached to the scene
  1840. */
  1841. readonly animatables: Animatable[];
  1842. /**
  1843. * Will stop the animation of the given target
  1844. * @param target - the target
  1845. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1846. * @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)
  1847. */
  1848. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1849. /**
  1850. * Stops and removes all animations that have been applied to the scene
  1851. */
  1852. stopAllAnimations(): void;
  1853. private _animate;
  1854. /** @hidden */
  1855. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1856. private _processLateAnimationBindingsForMatrices;
  1857. private _processLateAnimationBindingsForQuaternions;
  1858. private _processLateAnimationBindings;
  1859. /** @hidden */
  1860. _switchToAlternateCameraConfiguration(active: boolean): void;
  1861. /**
  1862. * Gets the current view matrix
  1863. * @returns a Matrix
  1864. */
  1865. getViewMatrix(): Matrix;
  1866. /**
  1867. * Gets the current projection matrix
  1868. * @returns a Matrix
  1869. */
  1870. getProjectionMatrix(): Matrix;
  1871. /**
  1872. * Gets the current transform matrix
  1873. * @returns a Matrix made of View * Projection
  1874. */
  1875. getTransformMatrix(): Matrix;
  1876. /**
  1877. * Sets the current transform matrix
  1878. * @param view defines the View matrix to use
  1879. * @param projection defines the Projection matrix to use
  1880. */
  1881. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1882. /** @hidden */
  1883. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1884. /**
  1885. * Gets the uniform buffer used to store scene data
  1886. * @returns a UniformBuffer
  1887. */
  1888. getSceneUniformBuffer(): UniformBuffer;
  1889. /**
  1890. * Gets an unique (relatively to the current scene) Id
  1891. * @returns an unique number for the scene
  1892. */
  1893. getUniqueId(): number;
  1894. /**
  1895. * Add a mesh to the list of scene's meshes
  1896. * @param newMesh defines the mesh to add
  1897. * @param recursive if all child meshes should also be added to the scene
  1898. */
  1899. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1900. /**
  1901. * Remove a mesh for the list of scene's meshes
  1902. * @param toRemove defines the mesh to remove
  1903. * @param recursive if all child meshes should also be removed from the scene
  1904. * @returns the index where the mesh was in the mesh list
  1905. */
  1906. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1907. /**
  1908. * Add a transform node to the list of scene's transform nodes
  1909. * @param newTransformNode defines the transform node to add
  1910. */
  1911. addTransformNode(newTransformNode: TransformNode): void;
  1912. /**
  1913. * Remove a transform node for the list of scene's transform nodes
  1914. * @param toRemove defines the transform node to remove
  1915. * @returns the index where the transform node was in the transform node list
  1916. */
  1917. removeTransformNode(toRemove: TransformNode): number;
  1918. /**
  1919. * Remove a skeleton for the list of scene's skeletons
  1920. * @param toRemove defines the skeleton to remove
  1921. * @returns the index where the skeleton was in the skeleton list
  1922. */
  1923. removeSkeleton(toRemove: Skeleton): number;
  1924. /**
  1925. * Remove a morph target for the list of scene's morph targets
  1926. * @param toRemove defines the morph target to remove
  1927. * @returns the index where the morph target was in the morph target list
  1928. */
  1929. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1930. /**
  1931. * Remove a light for the list of scene's lights
  1932. * @param toRemove defines the light to remove
  1933. * @returns the index where the light was in the light list
  1934. */
  1935. removeLight(toRemove: Light): number;
  1936. /**
  1937. * Remove a camera for the list of scene's cameras
  1938. * @param toRemove defines the camera to remove
  1939. * @returns the index where the camera was in the camera list
  1940. */
  1941. removeCamera(toRemove: Camera): number;
  1942. /**
  1943. * Remove a particle system for the list of scene's particle systems
  1944. * @param toRemove defines the particle system to remove
  1945. * @returns the index where the particle system was in the particle system list
  1946. */
  1947. removeParticleSystem(toRemove: IParticleSystem): number;
  1948. /**
  1949. * Remove a animation for the list of scene's animations
  1950. * @param toRemove defines the animation to remove
  1951. * @returns the index where the animation was in the animation list
  1952. */
  1953. removeAnimation(toRemove: Animation): number;
  1954. /**
  1955. * Removes the given animation group from this scene.
  1956. * @param toRemove The animation group to remove
  1957. * @returns The index of the removed animation group
  1958. */
  1959. removeAnimationGroup(toRemove: AnimationGroup): number;
  1960. /**
  1961. * Removes the given multi-material from this scene.
  1962. * @param toRemove The multi-material to remove
  1963. * @returns The index of the removed multi-material
  1964. */
  1965. removeMultiMaterial(toRemove: MultiMaterial): number;
  1966. /**
  1967. * Removes the given material from this scene.
  1968. * @param toRemove The material to remove
  1969. * @returns The index of the removed material
  1970. */
  1971. removeMaterial(toRemove: Material): number;
  1972. /**
  1973. * Removes the given action manager from this scene.
  1974. * @param toRemove The action manager to remove
  1975. * @returns The index of the removed action manager
  1976. */
  1977. removeActionManager(toRemove: ActionManager): number;
  1978. /**
  1979. * Removes the given texture from this scene.
  1980. * @param toRemove The texture to remove
  1981. * @returns The index of the removed texture
  1982. */
  1983. removeTexture(toRemove: BaseTexture): number;
  1984. /**
  1985. * Adds the given light to this scene
  1986. * @param newLight The light to add
  1987. */
  1988. addLight(newLight: Light): void;
  1989. /**
  1990. * Sorts the list list based on light priorities
  1991. */
  1992. sortLightsByPriority(): void;
  1993. /**
  1994. * Adds the given camera to this scene
  1995. * @param newCamera The camera to add
  1996. */
  1997. addCamera(newCamera: Camera): void;
  1998. /**
  1999. * Adds the given skeleton to this scene
  2000. * @param newSkeleton The skeleton to add
  2001. */
  2002. addSkeleton(newSkeleton: Skeleton): void;
  2003. /**
  2004. * Adds the given particle system to this scene
  2005. * @param newParticleSystem The particle system to add
  2006. */
  2007. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2008. /**
  2009. * Adds the given animation to this scene
  2010. * @param newAnimation The animation to add
  2011. */
  2012. addAnimation(newAnimation: Animation): void;
  2013. /**
  2014. * Adds the given animation group to this scene.
  2015. * @param newAnimationGroup The animation group to add
  2016. */
  2017. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2018. /**
  2019. * Adds the given multi-material to this scene
  2020. * @param newMultiMaterial The multi-material to add
  2021. */
  2022. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2023. /**
  2024. * Adds the given material to this scene
  2025. * @param newMaterial The material to add
  2026. */
  2027. addMaterial(newMaterial: Material): void;
  2028. /**
  2029. * Adds the given morph target to this scene
  2030. * @param newMorphTargetManager The morph target to add
  2031. */
  2032. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2033. /**
  2034. * Adds the given geometry to this scene
  2035. * @param newGeometry The geometry to add
  2036. */
  2037. addGeometry(newGeometry: Geometry): void;
  2038. /**
  2039. * Adds the given action manager to this scene
  2040. * @param newActionManager The action manager to add
  2041. */
  2042. addActionManager(newActionManager: ActionManager): void;
  2043. /**
  2044. * Adds the given texture to this scene.
  2045. * @param newTexture The texture to add
  2046. */
  2047. addTexture(newTexture: BaseTexture): void;
  2048. /**
  2049. * Switch active camera
  2050. * @param newCamera defines the new active camera
  2051. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2052. */
  2053. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2054. /**
  2055. * sets the active camera of the scene using its ID
  2056. * @param id defines the camera's ID
  2057. * @return the new active camera or null if none found.
  2058. */
  2059. setActiveCameraByID(id: string): Nullable<Camera>;
  2060. /**
  2061. * sets the active camera of the scene using its name
  2062. * @param name defines the camera's name
  2063. * @returns the new active camera or null if none found.
  2064. */
  2065. setActiveCameraByName(name: string): Nullable<Camera>;
  2066. /**
  2067. * get an animation group using its name
  2068. * @param name defines the material's name
  2069. * @return the animation group or null if none found.
  2070. */
  2071. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2072. /**
  2073. * get a material using its id
  2074. * @param id defines the material's ID
  2075. * @return the material or null if none found.
  2076. */
  2077. getMaterialByID(id: string): Nullable<Material>;
  2078. /**
  2079. * Gets a material using its name
  2080. * @param name defines the material's name
  2081. * @return the material or null if none found.
  2082. */
  2083. getMaterialByName(name: string): Nullable<Material>;
  2084. /**
  2085. * Gets a camera using its id
  2086. * @param id defines the id to look for
  2087. * @returns the camera or null if not found
  2088. */
  2089. getCameraByID(id: string): Nullable<Camera>;
  2090. /**
  2091. * Gets a camera using its unique id
  2092. * @param uniqueId defines the unique id to look for
  2093. * @returns the camera or null if not found
  2094. */
  2095. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2096. /**
  2097. * Gets a camera using its name
  2098. * @param name defines the camera's name
  2099. * @return the camera or null if none found.
  2100. */
  2101. getCameraByName(name: string): Nullable<Camera>;
  2102. /**
  2103. * Gets a bone using its id
  2104. * @param id defines the bone's id
  2105. * @return the bone or null if not found
  2106. */
  2107. getBoneByID(id: string): Nullable<Bone>;
  2108. /**
  2109. * Gets a bone using its id
  2110. * @param name defines the bone's name
  2111. * @return the bone or null if not found
  2112. */
  2113. getBoneByName(name: string): Nullable<Bone>;
  2114. /**
  2115. * Gets a light node using its name
  2116. * @param name defines the the light's name
  2117. * @return the light or null if none found.
  2118. */
  2119. getLightByName(name: string): Nullable<Light>;
  2120. /**
  2121. * Gets a light node using its id
  2122. * @param id defines the light's id
  2123. * @return the light or null if none found.
  2124. */
  2125. getLightByID(id: string): Nullable<Light>;
  2126. /**
  2127. * Gets a light node using its scene-generated unique ID
  2128. * @param uniqueId defines the light's unique id
  2129. * @return the light or null if none found.
  2130. */
  2131. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2132. /**
  2133. * Gets a particle system by id
  2134. * @param id defines the particle system id
  2135. * @return the corresponding system or null if none found
  2136. */
  2137. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2138. /**
  2139. * Gets a geometry using its ID
  2140. * @param id defines the geometry's id
  2141. * @return the geometry or null if none found.
  2142. */
  2143. getGeometryByID(id: string): Nullable<Geometry>;
  2144. private _getGeometryByUniqueID;
  2145. /**
  2146. * Add a new geometry to this scene
  2147. * @param geometry defines the geometry to be added to the scene.
  2148. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2149. * @return a boolean defining if the geometry was added or not
  2150. */
  2151. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2152. /**
  2153. * Removes an existing geometry
  2154. * @param geometry defines the geometry to be removed from the scene
  2155. * @return a boolean defining if the geometry was removed or not
  2156. */
  2157. removeGeometry(geometry: Geometry): boolean;
  2158. /**
  2159. * Gets the list of geometries attached to the scene
  2160. * @returns an array of Geometry
  2161. */
  2162. getGeometries(): Geometry[];
  2163. /**
  2164. * Gets the first added mesh found of a given ID
  2165. * @param id defines the id to search for
  2166. * @return the mesh found or null if not found at all
  2167. */
  2168. getMeshByID(id: string): Nullable<AbstractMesh>;
  2169. /**
  2170. * Gets a list of meshes using their id
  2171. * @param id defines the id to search for
  2172. * @returns a list of meshes
  2173. */
  2174. getMeshesByID(id: string): Array<AbstractMesh>;
  2175. /**
  2176. * Gets the first added transform node found of a given ID
  2177. * @param id defines the id to search for
  2178. * @return the found transform node or null if not found at all.
  2179. */
  2180. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2181. /**
  2182. * Gets a list of transform nodes using their id
  2183. * @param id defines the id to search for
  2184. * @returns a list of transform nodes
  2185. */
  2186. getTransformNodesByID(id: string): Array<TransformNode>;
  2187. /**
  2188. * Gets a mesh with its auto-generated unique id
  2189. * @param uniqueId defines the unique id to search for
  2190. * @return the found mesh or null if not found at all.
  2191. */
  2192. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2193. /**
  2194. * Gets a the last added mesh using a given id
  2195. * @param id defines the id to search for
  2196. * @return the found mesh or null if not found at all.
  2197. */
  2198. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2199. /**
  2200. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2201. * @param id defines the id to search for
  2202. * @return the found node or null if not found at all
  2203. */
  2204. getLastEntryByID(id: string): Nullable<Node>;
  2205. /**
  2206. * Gets a node (Mesh, Camera, Light) using a given id
  2207. * @param id defines the id to search for
  2208. * @return the found node or null if not found at all
  2209. */
  2210. getNodeByID(id: string): Nullable<Node>;
  2211. /**
  2212. * Gets a node (Mesh, Camera, Light) using a given name
  2213. * @param name defines the name to search for
  2214. * @return the found node or null if not found at all.
  2215. */
  2216. getNodeByName(name: string): Nullable<Node>;
  2217. /**
  2218. * Gets a mesh using a given name
  2219. * @param name defines the name to search for
  2220. * @return the found mesh or null if not found at all.
  2221. */
  2222. getMeshByName(name: string): Nullable<AbstractMesh>;
  2223. /**
  2224. * Gets a transform node using a given name
  2225. * @param name defines the name to search for
  2226. * @return the found transform node or null if not found at all.
  2227. */
  2228. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2229. /**
  2230. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2231. * @param id defines the id to search for
  2232. * @return the found skeleton or null if not found at all.
  2233. */
  2234. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2235. /**
  2236. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2237. * @param id defines the id to search for
  2238. * @return the found skeleton or null if not found at all.
  2239. */
  2240. getSkeletonById(id: string): Nullable<Skeleton>;
  2241. /**
  2242. * Gets a skeleton using a given name
  2243. * @param name defines the name to search for
  2244. * @return the found skeleton or null if not found at all.
  2245. */
  2246. getSkeletonByName(name: string): Nullable<Skeleton>;
  2247. /**
  2248. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2249. * @param id defines the id to search for
  2250. * @return the found morph target manager or null if not found at all.
  2251. */
  2252. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2253. /**
  2254. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2255. * @param id defines the id to search for
  2256. * @return the found morph target or null if not found at all.
  2257. */
  2258. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2259. /**
  2260. * Gets a boolean indicating if the given mesh is active
  2261. * @param mesh defines the mesh to look for
  2262. * @returns true if the mesh is in the active list
  2263. */
  2264. isActiveMesh(mesh: AbstractMesh): boolean;
  2265. /**
  2266. * Return a unique id as a string which can serve as an identifier for the scene
  2267. */
  2268. readonly uid: string;
  2269. /**
  2270. * Add an externaly attached data from its key.
  2271. * This method call will fail and return false, if such key already exists.
  2272. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2273. * @param key the unique key that identifies the data
  2274. * @param data the data object to associate to the key for this Engine instance
  2275. * @return true if no such key were already present and the data was added successfully, false otherwise
  2276. */
  2277. addExternalData<T>(key: string, data: T): boolean;
  2278. /**
  2279. * Get an externaly attached data from its key
  2280. * @param key the unique key that identifies the data
  2281. * @return the associated data, if present (can be null), or undefined if not present
  2282. */
  2283. getExternalData<T>(key: string): Nullable<T>;
  2284. /**
  2285. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2286. * @param key the unique key that identifies the data
  2287. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2288. * @return the associated data, can be null if the factory returned null.
  2289. */
  2290. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2291. /**
  2292. * Remove an externaly attached data from the Engine instance
  2293. * @param key the unique key that identifies the data
  2294. * @return true if the data was successfully removed, false if it doesn't exist
  2295. */
  2296. removeExternalData(key: string): boolean;
  2297. private _evaluateSubMesh;
  2298. /**
  2299. * Clear the processed materials smart array preventing retention point in material dispose.
  2300. */
  2301. freeProcessedMaterials(): void;
  2302. private _preventFreeActiveMeshesAndRenderingGroups;
  2303. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2304. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2305. * when disposing several meshes in a row or a hierarchy of meshes.
  2306. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2307. */
  2308. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2309. /**
  2310. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2311. */
  2312. freeActiveMeshes(): void;
  2313. /**
  2314. * Clear the info related to rendering groups preventing retention points during dispose.
  2315. */
  2316. freeRenderingGroups(): void;
  2317. /** @hidden */
  2318. _isInIntermediateRendering(): boolean;
  2319. /**
  2320. * Lambda returning the list of potentially active meshes.
  2321. */
  2322. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2323. /**
  2324. * Lambda returning the list of potentially active sub meshes.
  2325. */
  2326. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2327. /**
  2328. * Lambda returning the list of potentially intersecting sub meshes.
  2329. */
  2330. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially colliding sub meshes.
  2333. */
  2334. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2335. private _activeMeshesFrozen;
  2336. /**
  2337. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2338. * @returns the current scene
  2339. */
  2340. freezeActiveMeshes(): Scene;
  2341. /**
  2342. * Use this function to restart evaluating active meshes on every frame
  2343. * @returns the current scene
  2344. */
  2345. unfreezeActiveMeshes(): Scene;
  2346. private _evaluateActiveMeshes;
  2347. private _activeMesh;
  2348. /**
  2349. * Update the transform matrix to update from the current active camera
  2350. * @param force defines a boolean used to force the update even if cache is up to date
  2351. */
  2352. updateTransformMatrix(force?: boolean): void;
  2353. /**
  2354. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2355. * @param alternateCamera defines the camera to use
  2356. */
  2357. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2358. /** @hidden */
  2359. _allowPostProcessClearColor: boolean;
  2360. private _renderForCamera;
  2361. private _processSubCameras;
  2362. private _checkIntersections;
  2363. /** @hidden */
  2364. _advancePhysicsEngineStep(step: number): void;
  2365. /**
  2366. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2367. */
  2368. getDeterministicFrameTime: () => number;
  2369. /**
  2370. * Render the scene
  2371. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2372. */
  2373. render(updateCameras?: boolean): void;
  2374. /**
  2375. * Freeze all materials
  2376. * A frozen material will not be updatable but should be faster to render
  2377. */
  2378. freezeMaterials(): void;
  2379. /**
  2380. * Unfreeze all materials
  2381. * A frozen material will not be updatable but should be faster to render
  2382. */
  2383. unfreezeMaterials(): void;
  2384. /**
  2385. * Releases all held ressources
  2386. */
  2387. dispose(): void;
  2388. /**
  2389. * Gets if the scene is already disposed
  2390. */
  2391. readonly isDisposed: boolean;
  2392. /**
  2393. * Call this function to reduce memory footprint of the scene.
  2394. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2395. */
  2396. clearCachedVertexData(): void;
  2397. /**
  2398. * This function will remove the local cached buffer data from texture.
  2399. * It will save memory but will prevent the texture from being rebuilt
  2400. */
  2401. cleanCachedTextureBuffer(): void;
  2402. /**
  2403. * Get the world extend vectors with an optional filter
  2404. *
  2405. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2406. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2407. */
  2408. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2409. min: Vector3;
  2410. max: Vector3;
  2411. };
  2412. /**
  2413. * Creates a ray that can be used to pick in the scene
  2414. * @param x defines the x coordinate of the origin (on-screen)
  2415. * @param y defines the y coordinate of the origin (on-screen)
  2416. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2417. * @param camera defines the camera to use for the picking
  2418. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2419. * @returns a Ray
  2420. */
  2421. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2422. /**
  2423. * Creates a ray that can be used to pick in the scene
  2424. * @param x defines the x coordinate of the origin (on-screen)
  2425. * @param y defines the y coordinate of the origin (on-screen)
  2426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2427. * @param result defines the ray where to store the picking ray
  2428. * @param camera defines the camera to use for the picking
  2429. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2430. * @returns the current scene
  2431. */
  2432. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2433. /**
  2434. * Creates a ray that can be used to pick in the scene
  2435. * @param x defines the x coordinate of the origin (on-screen)
  2436. * @param y defines the y coordinate of the origin (on-screen)
  2437. * @param camera defines the camera to use for the picking
  2438. * @returns a Ray
  2439. */
  2440. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2441. /**
  2442. * Creates a ray that can be used to pick in the scene
  2443. * @param x defines the x coordinate of the origin (on-screen)
  2444. * @param y defines the y coordinate of the origin (on-screen)
  2445. * @param result defines the ray where to store the picking ray
  2446. * @param camera defines the camera to use for the picking
  2447. * @returns the current scene
  2448. */
  2449. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2450. private _internalPick;
  2451. private _internalMultiPick;
  2452. private _tempPickingRay;
  2453. /** Launch a ray to try to pick a mesh in the scene
  2454. * @param x position on screen
  2455. * @param y position on screen
  2456. * @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
  2457. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2458. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2459. * @returns a PickingInfo
  2460. */
  2461. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2462. private _cachedRayForTransform;
  2463. /** Use the given ray to pick a mesh in the scene
  2464. * @param ray The ray to use to pick meshes
  2465. * @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
  2466. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2467. * @returns a PickingInfo
  2468. */
  2469. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2470. /**
  2471. * Launch a ray to try to pick a mesh in the scene
  2472. * @param x X position on screen
  2473. * @param y Y position on screen
  2474. * @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
  2475. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2476. * @returns an array of PickingInfo
  2477. */
  2478. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2479. /**
  2480. * Launch a ray to try to pick a mesh in the scene
  2481. * @param ray Ray to use
  2482. * @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
  2483. * @returns an array of PickingInfo
  2484. */
  2485. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2486. /**
  2487. * Force the value of meshUnderPointer
  2488. * @param mesh defines the mesh to use
  2489. */
  2490. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2491. /**
  2492. * Gets the mesh under the pointer
  2493. * @returns a Mesh or null if no mesh is under the pointer
  2494. */
  2495. getPointerOverMesh(): Nullable<AbstractMesh>;
  2496. /** @hidden */
  2497. _rebuildGeometries(): void;
  2498. /** @hidden */
  2499. _rebuildTextures(): void;
  2500. private _getByTags;
  2501. /**
  2502. * Get a list of meshes by tags
  2503. * @param tagsQuery defines the tags query to use
  2504. * @param forEach defines a predicate used to filter results
  2505. * @returns an array of Mesh
  2506. */
  2507. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2508. /**
  2509. * Get a list of cameras by tags
  2510. * @param tagsQuery defines the tags query to use
  2511. * @param forEach defines a predicate used to filter results
  2512. * @returns an array of Camera
  2513. */
  2514. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2515. /**
  2516. * Get a list of lights by tags
  2517. * @param tagsQuery defines the tags query to use
  2518. * @param forEach defines a predicate used to filter results
  2519. * @returns an array of Light
  2520. */
  2521. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2522. /**
  2523. * Get a list of materials by tags
  2524. * @param tagsQuery defines the tags query to use
  2525. * @param forEach defines a predicate used to filter results
  2526. * @returns an array of Material
  2527. */
  2528. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2529. /**
  2530. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2531. * This allowed control for front to back rendering or reversly depending of the special needs.
  2532. *
  2533. * @param renderingGroupId The rendering group id corresponding to its index
  2534. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2535. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2536. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2537. */
  2538. 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;
  2539. /**
  2540. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2541. *
  2542. * @param renderingGroupId The rendering group id corresponding to its index
  2543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2544. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2545. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2546. */
  2547. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2548. /**
  2549. * Gets the current auto clear configuration for one rendering group of the rendering
  2550. * manager.
  2551. * @param index the rendering group index to get the information for
  2552. * @returns The auto clear setup for the requested rendering group
  2553. */
  2554. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2555. private _blockMaterialDirtyMechanism;
  2556. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2557. blockMaterialDirtyMechanism: boolean;
  2558. /**
  2559. * Will flag all materials as dirty to trigger new shader compilation
  2560. * @param flag defines the flag used to specify which material part must be marked as dirty
  2561. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2562. */
  2563. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2564. /** @hidden */
  2565. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2566. /** @hidden */
  2567. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2568. }
  2569. }
  2570. declare module BABYLON {
  2571. /**
  2572. * Groups all the scene component constants in one place to ease maintenance.
  2573. * @hidden
  2574. */
  2575. class SceneComponentConstants {
  2576. static readonly NAME_EFFECTLAYER: string;
  2577. static readonly NAME_LAYER: string;
  2578. static readonly NAME_LENSFLARESYSTEM: string;
  2579. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2580. static readonly NAME_PARTICLESYSTEM: string;
  2581. static readonly NAME_GAMEPAD: string;
  2582. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2583. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2584. static readonly NAME_DEPTHRENDERER: string;
  2585. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2586. static readonly NAME_SPRITE: string;
  2587. static readonly NAME_OUTLINERENDERER: string;
  2588. static readonly NAME_PROCEDURALTEXTURE: string;
  2589. static readonly NAME_SHADOWGENERATOR: string;
  2590. static readonly NAME_OCTREE: string;
  2591. static readonly NAME_PHYSICSENGINE: string;
  2592. static readonly NAME_AUDIO: string;
  2593. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2594. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2595. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2596. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2597. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2598. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2599. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2600. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2601. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2602. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2603. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2604. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2606. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2607. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2608. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2610. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2611. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2613. static readonly STEP_AFTERRENDER_AUDIO: number;
  2614. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2615. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2616. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2617. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2618. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2619. static readonly STEP_POINTERMOVE_SPRITE: number;
  2620. static readonly STEP_POINTERDOWN_SPRITE: number;
  2621. static readonly STEP_POINTERUP_SPRITE: number;
  2622. }
  2623. /**
  2624. * This represents a scene component.
  2625. *
  2626. * This is used to decouple the dependency the scene is having on the different workloads like
  2627. * layers, post processes...
  2628. */
  2629. interface ISceneComponent {
  2630. /**
  2631. * The name of the component. Each component must have a unique name.
  2632. */
  2633. name: string;
  2634. /**
  2635. * The scene the component belongs to.
  2636. */
  2637. scene: Scene;
  2638. /**
  2639. * Register the component to one instance of a scene.
  2640. */
  2641. register(): void;
  2642. /**
  2643. * Rebuilds the elements related to this component in case of
  2644. * context lost for instance.
  2645. */
  2646. rebuild(): void;
  2647. /**
  2648. * Disposes the component and the associated ressources.
  2649. */
  2650. dispose(): void;
  2651. }
  2652. /**
  2653. * This represents a SERIALIZABLE scene component.
  2654. *
  2655. * This extends Scene Component to add Serialization methods on top.
  2656. */
  2657. interface ISceneSerializableComponent extends ISceneComponent {
  2658. /**
  2659. * Adds all the element from the container to the scene
  2660. * @param container the container holding the elements
  2661. */
  2662. addFromContainer(container: AbstractScene): void;
  2663. /**
  2664. * Removes all the elements in the container from the scene
  2665. * @param container contains the elements to remove
  2666. */
  2667. removeFromContainer(container: AbstractScene): void;
  2668. /**
  2669. * Serializes the component data to the specified json object
  2670. * @param serializationObject The object to serialize to
  2671. */
  2672. serialize(serializationObject: any): void;
  2673. }
  2674. /**
  2675. * Strong typing of a Mesh related stage step action
  2676. */
  2677. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2678. /**
  2679. * Strong typing of a Evaluate Sub Mesh related stage step action
  2680. */
  2681. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2682. /**
  2683. * Strong typing of a Active Mesh related stage step action
  2684. */
  2685. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2686. /**
  2687. * Strong typing of a Camera related stage step action
  2688. */
  2689. type CameraStageAction = (camera: Camera) => void;
  2690. /**
  2691. * Strong typing of a Render Target related stage step action
  2692. */
  2693. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2694. /**
  2695. * Strong typing of a RenderingGroup related stage step action
  2696. */
  2697. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2698. /**
  2699. * Strong typing of a Mesh Render related stage step action
  2700. */
  2701. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2702. /**
  2703. * Strong typing of a simple stage step action
  2704. */
  2705. type SimpleStageAction = () => void;
  2706. /**
  2707. * Strong typing of a render target action.
  2708. */
  2709. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2710. /**
  2711. * Strong typing of a pointer move action.
  2712. */
  2713. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2714. /**
  2715. * Strong typing of a pointer up/down action.
  2716. */
  2717. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2718. /**
  2719. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2720. * @hidden
  2721. */
  2722. class Stage<T extends Function> extends Array<{
  2723. index: number;
  2724. component: ISceneComponent;
  2725. action: T;
  2726. }> {
  2727. /**
  2728. * Hide ctor from the rest of the world.
  2729. * @param items The items to add.
  2730. */
  2731. private constructor();
  2732. /**
  2733. * Creates a new Stage.
  2734. * @returns A new instance of a Stage
  2735. */
  2736. static Create<T extends Function>(): Stage<T>;
  2737. /**
  2738. * Registers a step in an ordered way in the targeted stage.
  2739. * @param index Defines the position to register the step in
  2740. * @param component Defines the component attached to the step
  2741. * @param action Defines the action to launch during the step
  2742. */
  2743. registerStep(index: number, component: ISceneComponent, action: T): void;
  2744. /**
  2745. * Clears all the steps from the stage.
  2746. */
  2747. clear(): void;
  2748. }
  2749. }
  2750. declare module BABYLON {
  2751. /** Alias type for value that can be null */
  2752. type Nullable<T> = T | null;
  2753. /**
  2754. * Alias type for number that are floats
  2755. * @ignorenaming
  2756. */
  2757. type float = number;
  2758. /**
  2759. * Alias type for number that are doubles.
  2760. * @ignorenaming
  2761. */
  2762. type double = number;
  2763. /**
  2764. * Alias type for number that are integer
  2765. * @ignorenaming
  2766. */
  2767. type int = number;
  2768. /** Alias type for number array or Float32Array */
  2769. type FloatArray = number[] | Float32Array;
  2770. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2771. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2772. /**
  2773. * Alias for types that can be used by a Buffer or VertexBuffer.
  2774. */
  2775. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2776. /**
  2777. * Alias type for primitive types
  2778. * @ignorenaming
  2779. */
  2780. type Primitive = undefined | null | boolean | string | number | Function;
  2781. /**
  2782. * Type modifier to make all the properties of an object Readonly
  2783. */
  2784. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2785. /**
  2786. * Type modifier to make all the properties of an object Readonly recursively
  2787. */
  2788. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2789. /** @hidden */
  2790. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2791. }
  2792. /** @hidden */
  2793. /** @hidden */
  2794. type DeepImmutableObject<T> = {
  2795. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2796. };
  2797. }
  2798. declare module BABYLON {
  2799. /**
  2800. * The action to be carried out following a trigger
  2801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2802. */
  2803. class Action {
  2804. /** the trigger, with or without parameters, for the action */
  2805. triggerOptions: any;
  2806. /**
  2807. * Trigger for the action
  2808. */
  2809. trigger: number;
  2810. /**
  2811. * Internal only - manager for action
  2812. * @hidden
  2813. */
  2814. _actionManager: ActionManager;
  2815. private _nextActiveAction;
  2816. private _child;
  2817. private _condition?;
  2818. private _triggerParameter;
  2819. /**
  2820. * An event triggered prior to action being executed.
  2821. */
  2822. onBeforeExecuteObservable: Observable<Action>;
  2823. /**
  2824. * Creates a new Action
  2825. * @param triggerOptions the trigger, with or without parameters, for the action
  2826. * @param condition an optional determinant of action
  2827. */
  2828. constructor(
  2829. /** the trigger, with or without parameters, for the action */
  2830. triggerOptions: any, condition?: Condition);
  2831. /**
  2832. * Internal only
  2833. * @hidden
  2834. */
  2835. _prepare(): void;
  2836. /**
  2837. * Gets the trigger parameters
  2838. * @returns the trigger parameters
  2839. */
  2840. getTriggerParameter(): any;
  2841. /**
  2842. * Internal only - executes current action event
  2843. * @hidden
  2844. */
  2845. _executeCurrent(evt?: ActionEvent): void;
  2846. /**
  2847. * Execute placeholder for child classes
  2848. * @param evt optional action event
  2849. */
  2850. execute(evt?: ActionEvent): void;
  2851. /**
  2852. * Skips to next active action
  2853. */
  2854. skipToNextActiveAction(): void;
  2855. /**
  2856. * Adds action to chain of actions, may be a DoNothingAction
  2857. * @param action defines the next action to execute
  2858. * @returns The action passed in
  2859. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2860. */
  2861. then(action: Action): Action;
  2862. /**
  2863. * Internal only
  2864. * @hidden
  2865. */
  2866. _getProperty(propertyPath: string): string;
  2867. /**
  2868. * Internal only
  2869. * @hidden
  2870. */
  2871. _getEffectiveTarget(target: any, propertyPath: string): any;
  2872. /**
  2873. * Serialize placeholder for child classes
  2874. * @param parent of child
  2875. * @returns the serialized object
  2876. */
  2877. serialize(parent: any): any;
  2878. /**
  2879. * Internal only called by serialize
  2880. * @hidden
  2881. */
  2882. protected _serialize(serializedAction: any, parent?: any): any;
  2883. /**
  2884. * Internal only
  2885. * @hidden
  2886. */
  2887. static _SerializeValueAsString: (value: any) => string;
  2888. /**
  2889. * Internal only
  2890. * @hidden
  2891. */
  2892. static _GetTargetProperty: (target: Scene | Node) => {
  2893. name: string;
  2894. targetType: string;
  2895. value: string;
  2896. };
  2897. }
  2898. }
  2899. declare module BABYLON {
  2900. /**
  2901. * ActionEvent is the event being sent when an action is triggered.
  2902. */
  2903. class ActionEvent {
  2904. /** The mesh or sprite that triggered the action */
  2905. source: any;
  2906. /** The X mouse cursor position at the time of the event */
  2907. pointerX: number;
  2908. /** The Y mouse cursor position at the time of the event */
  2909. pointerY: number;
  2910. /** The mesh that is currently pointed at (can be null) */
  2911. meshUnderPointer: Nullable<AbstractMesh>;
  2912. /** the original (browser) event that triggered the ActionEvent */
  2913. sourceEvent?: any;
  2914. /** additional data for the event */
  2915. additionalData?: any;
  2916. /**
  2917. * Creates a new ActionEvent
  2918. * @param source The mesh or sprite that triggered the action
  2919. * @param pointerX The X mouse cursor position at the time of the event
  2920. * @param pointerY The Y mouse cursor position at the time of the event
  2921. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2922. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2923. * @param additionalData additional data for the event
  2924. */
  2925. constructor(
  2926. /** The mesh or sprite that triggered the action */
  2927. source: any,
  2928. /** The X mouse cursor position at the time of the event */
  2929. pointerX: number,
  2930. /** The Y mouse cursor position at the time of the event */
  2931. pointerY: number,
  2932. /** The mesh that is currently pointed at (can be null) */
  2933. meshUnderPointer: Nullable<AbstractMesh>,
  2934. /** the original (browser) event that triggered the ActionEvent */
  2935. sourceEvent?: any,
  2936. /** additional data for the event */
  2937. additionalData?: any);
  2938. /**
  2939. * Helper function to auto-create an ActionEvent from a source mesh.
  2940. * @param source The source mesh that triggered the event
  2941. * @param evt The original (browser) event
  2942. * @param additionalData additional data for the event
  2943. * @returns the new ActionEvent
  2944. */
  2945. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source sprite
  2948. * @param source The source sprite that triggered the event
  2949. * @param scene Scene associated with the sprite
  2950. * @param evt The original (browser) event
  2951. * @param additionalData additional data for the event
  2952. * @returns the new ActionEvent
  2953. */
  2954. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2955. /**
  2956. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2957. * @param scene the scene where the event occurred
  2958. * @param evt The original (browser) event
  2959. * @returns the new ActionEvent
  2960. */
  2961. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2962. /**
  2963. * Helper function to auto-create an ActionEvent from a primitive
  2964. * @param prim defines the target primitive
  2965. * @param pointerPos defines the pointer position
  2966. * @param evt The original (browser) event
  2967. * @param additionalData additional data for the event
  2968. * @returns the new ActionEvent
  2969. */
  2970. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2971. }
  2972. /**
  2973. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2974. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2976. */
  2977. class ActionManager {
  2978. /**
  2979. * Nothing
  2980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2981. */
  2982. static readonly NothingTrigger: number;
  2983. /**
  2984. * On pick
  2985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2986. */
  2987. static readonly OnPickTrigger: number;
  2988. /**
  2989. * On left pick
  2990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2991. */
  2992. static readonly OnLeftPickTrigger: number;
  2993. /**
  2994. * On right pick
  2995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2996. */
  2997. static readonly OnRightPickTrigger: number;
  2998. /**
  2999. * On center pick
  3000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3001. */
  3002. static readonly OnCenterPickTrigger: number;
  3003. /**
  3004. * On pick down
  3005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3006. */
  3007. static readonly OnPickDownTrigger: number;
  3008. /**
  3009. * On double pick
  3010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3011. */
  3012. static readonly OnDoublePickTrigger: number;
  3013. /**
  3014. * On pick up
  3015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3016. */
  3017. static readonly OnPickUpTrigger: number;
  3018. /**
  3019. * On pick out.
  3020. * This trigger will only be raised if you also declared a OnPickDown
  3021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3022. */
  3023. static readonly OnPickOutTrigger: number;
  3024. /**
  3025. * On long press
  3026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3027. */
  3028. static readonly OnLongPressTrigger: number;
  3029. /**
  3030. * On pointer over
  3031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3032. */
  3033. static readonly OnPointerOverTrigger: number;
  3034. /**
  3035. * On pointer out
  3036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3037. */
  3038. static readonly OnPointerOutTrigger: number;
  3039. /**
  3040. * On every frame
  3041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3042. */
  3043. static readonly OnEveryFrameTrigger: number;
  3044. /**
  3045. * On intersection enter
  3046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3047. */
  3048. static readonly OnIntersectionEnterTrigger: number;
  3049. /**
  3050. * On intersection exit
  3051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3052. */
  3053. static readonly OnIntersectionExitTrigger: number;
  3054. /**
  3055. * On key down
  3056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3057. */
  3058. static readonly OnKeyDownTrigger: number;
  3059. /**
  3060. * On key up
  3061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3062. */
  3063. static readonly OnKeyUpTrigger: number;
  3064. /** Gets the list of active triggers */
  3065. static Triggers: {
  3066. [key: string]: number;
  3067. };
  3068. /** Gets the list of actions */
  3069. actions: Action[];
  3070. /** Gets the cursor to use when hovering items */
  3071. hoverCursor: string;
  3072. private _scene;
  3073. /**
  3074. * Creates a new action manager
  3075. * @param scene defines the hosting scene
  3076. */
  3077. constructor(scene: Scene);
  3078. /**
  3079. * Releases all associated resources
  3080. */
  3081. dispose(): void;
  3082. /**
  3083. * Gets hosting scene
  3084. * @returns the hosting scene
  3085. */
  3086. getScene(): Scene;
  3087. /**
  3088. * Does this action manager handles actions of any of the given triggers
  3089. * @param triggers defines the triggers to be tested
  3090. * @return a boolean indicating whether one (or more) of the triggers is handled
  3091. */
  3092. hasSpecificTriggers(triggers: number[]): boolean;
  3093. /**
  3094. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3095. * speed.
  3096. * @param triggerA defines the trigger to be tested
  3097. * @param triggerB defines the trigger to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3101. /**
  3102. * Does this action manager handles actions of a given trigger
  3103. * @param trigger defines the trigger to be tested
  3104. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3105. * @return whether the trigger is handled
  3106. */
  3107. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3108. /**
  3109. * Does this action manager has pointer triggers
  3110. */
  3111. readonly hasPointerTriggers: boolean;
  3112. /**
  3113. * Does this action manager has pick triggers
  3114. */
  3115. readonly hasPickTriggers: boolean;
  3116. /**
  3117. * Does exist one action manager with at least one trigger
  3118. **/
  3119. static readonly HasTriggers: boolean;
  3120. /**
  3121. * Does exist one action manager with at least one pick trigger
  3122. **/
  3123. static readonly HasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager that handles actions of a given trigger
  3126. * @param trigger defines the trigger to be tested
  3127. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3128. **/
  3129. static HasSpecificTrigger(trigger: number): boolean;
  3130. /**
  3131. * Registers an action to this action manager
  3132. * @param action defines the action to be registered
  3133. * @return the action amended (prepared) after registration
  3134. */
  3135. registerAction(action: Action): Nullable<Action>;
  3136. /**
  3137. * Unregisters an action to this action manager
  3138. * @param action defines the action to be unregistered
  3139. * @return a boolean indicating whether the action has been unregistered
  3140. */
  3141. unregisterAction(action: Action): Boolean;
  3142. /**
  3143. * Process a specific trigger
  3144. * @param trigger defines the trigger to process
  3145. * @param evt defines the event details to be processed
  3146. */
  3147. processTrigger(trigger: number, evt?: ActionEvent): void;
  3148. /** @hidden */
  3149. _getEffectiveTarget(target: any, propertyPath: string): any;
  3150. /** @hidden */
  3151. _getProperty(propertyPath: string): string;
  3152. /**
  3153. * Serialize this manager to a JSON object
  3154. * @param name defines the property name to store this manager
  3155. * @returns a JSON representation of this manager
  3156. */
  3157. serialize(name: string): any;
  3158. /**
  3159. * Creates a new ActionManager from a JSON data
  3160. * @param parsedActions defines the JSON data to read from
  3161. * @param object defines the hosting mesh
  3162. * @param scene defines the hosting scene
  3163. */
  3164. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3165. /**
  3166. * Get a trigger name by index
  3167. * @param trigger defines the trigger index
  3168. * @returns a trigger name
  3169. */
  3170. static GetTriggerName(trigger: number): string;
  3171. }
  3172. }
  3173. declare module BABYLON {
  3174. /**
  3175. * A Condition applied to an Action
  3176. */
  3177. class Condition {
  3178. /**
  3179. * Internal only - manager for action
  3180. * @hidden
  3181. */
  3182. _actionManager: ActionManager;
  3183. /**
  3184. * Internal only
  3185. * @hidden
  3186. */
  3187. _evaluationId: number;
  3188. /**
  3189. * Internal only
  3190. * @hidden
  3191. */
  3192. _currentResult: boolean;
  3193. /**
  3194. * Creates a new Condition
  3195. * @param actionManager the manager of the action the condition is applied to
  3196. */
  3197. constructor(actionManager: ActionManager);
  3198. /**
  3199. * Check if the current condition is valid
  3200. * @returns a boolean
  3201. */
  3202. isValid(): boolean;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. _getProperty(propertyPath: string): string;
  3208. /**
  3209. * Internal only
  3210. * @hidden
  3211. */
  3212. _getEffectiveTarget(target: any, propertyPath: string): any;
  3213. /**
  3214. * Serialize placeholder for child classes
  3215. * @returns the serialized object
  3216. */
  3217. serialize(): any;
  3218. /**
  3219. * Internal only
  3220. * @hidden
  3221. */
  3222. protected _serialize(serializedCondition: any): any;
  3223. }
  3224. /**
  3225. * Defines specific conditional operators as extensions of Condition
  3226. */
  3227. class ValueCondition extends Condition {
  3228. /** path to specify the property of the target the conditional operator uses */
  3229. propertyPath: string;
  3230. /** the value compared by the conditional operator against the current value of the property */
  3231. value: any;
  3232. /** the conditional operator, default ValueCondition.IsEqual */
  3233. operator: number;
  3234. /**
  3235. * Internal only
  3236. * @hidden
  3237. */
  3238. private static _IsEqual;
  3239. /**
  3240. * Internal only
  3241. * @hidden
  3242. */
  3243. private static _IsDifferent;
  3244. /**
  3245. * Internal only
  3246. * @hidden
  3247. */
  3248. private static _IsGreater;
  3249. /**
  3250. * Internal only
  3251. * @hidden
  3252. */
  3253. private static _IsLesser;
  3254. /**
  3255. * returns the number for IsEqual
  3256. */
  3257. static readonly IsEqual: number;
  3258. /**
  3259. * Returns the number for IsDifferent
  3260. */
  3261. static readonly IsDifferent: number;
  3262. /**
  3263. * Returns the number for IsGreater
  3264. */
  3265. static readonly IsGreater: number;
  3266. /**
  3267. * Returns the number for IsLesser
  3268. */
  3269. static readonly IsLesser: number;
  3270. /**
  3271. * Internal only The action manager for the condition
  3272. * @hidden
  3273. */
  3274. _actionManager: ActionManager;
  3275. /**
  3276. * Internal only
  3277. * @hidden
  3278. */
  3279. private _target;
  3280. /**
  3281. * Internal only
  3282. * @hidden
  3283. */
  3284. private _effectiveTarget;
  3285. /**
  3286. * Internal only
  3287. * @hidden
  3288. */
  3289. private _property;
  3290. /**
  3291. * Creates a new ValueCondition
  3292. * @param actionManager manager for the action the condition applies to
  3293. * @param target for the action
  3294. * @param propertyPath path to specify the property of the target the conditional operator uses
  3295. * @param value the value compared by the conditional operator against the current value of the property
  3296. * @param operator the conditional operator, default ValueCondition.IsEqual
  3297. */
  3298. constructor(actionManager: ActionManager, target: any,
  3299. /** path to specify the property of the target the conditional operator uses */
  3300. propertyPath: string,
  3301. /** the value compared by the conditional operator against the current value of the property */
  3302. value: any,
  3303. /** the conditional operator, default ValueCondition.IsEqual */
  3304. operator?: number);
  3305. /**
  3306. * Compares the given value with the property value for the specified conditional operator
  3307. * @returns the result of the comparison
  3308. */
  3309. isValid(): boolean;
  3310. /**
  3311. * Serialize the ValueCondition into a JSON compatible object
  3312. * @returns serialization object
  3313. */
  3314. serialize(): any;
  3315. /**
  3316. * Gets the name of the conditional operator for the ValueCondition
  3317. * @param operator the conditional operator
  3318. * @returns the name
  3319. */
  3320. static GetOperatorName(operator: number): string;
  3321. }
  3322. /**
  3323. * Defines a predicate condition as an extension of Condition
  3324. */
  3325. class PredicateCondition extends Condition {
  3326. /** defines the predicate function used to validate the condition */
  3327. predicate: () => boolean;
  3328. /**
  3329. * Internal only - manager for action
  3330. * @hidden
  3331. */
  3332. _actionManager: ActionManager;
  3333. /**
  3334. * Creates a new PredicateCondition
  3335. * @param actionManager manager for the action the condition applies to
  3336. * @param predicate defines the predicate function used to validate the condition
  3337. */
  3338. constructor(actionManager: ActionManager,
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean);
  3341. /**
  3342. * @returns the validity of the predicate condition
  3343. */
  3344. isValid(): boolean;
  3345. }
  3346. /**
  3347. * Defines a state condition as an extension of Condition
  3348. */
  3349. class StateCondition extends Condition {
  3350. /** Value to compare with target state */
  3351. value: string;
  3352. /**
  3353. * Internal only - manager for action
  3354. * @hidden
  3355. */
  3356. _actionManager: ActionManager;
  3357. /**
  3358. * Internal only
  3359. * @hidden
  3360. */
  3361. private _target;
  3362. /**
  3363. * Creates a new StateCondition
  3364. * @param actionManager manager for the action the condition applies to
  3365. * @param target of the condition
  3366. * @param value to compare with target state
  3367. */
  3368. constructor(actionManager: ActionManager, target: any,
  3369. /** Value to compare with target state */
  3370. value: string);
  3371. /**
  3372. * Gets a boolean indicating if the current condition is met
  3373. * @returns the validity of the state
  3374. */
  3375. isValid(): boolean;
  3376. /**
  3377. * Serialize the StateCondition into a JSON compatible object
  3378. * @returns serialization object
  3379. */
  3380. serialize(): any;
  3381. }
  3382. }
  3383. declare module BABYLON {
  3384. /**
  3385. * This defines an action responsible to toggle a boolean once triggered.
  3386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3387. */
  3388. class SwitchBooleanAction extends Action {
  3389. /**
  3390. * The path to the boolean property in the target object
  3391. */
  3392. propertyPath: string;
  3393. private _target;
  3394. private _effectiveTarget;
  3395. private _property;
  3396. /**
  3397. * Instantiate the action
  3398. * @param triggerOptions defines the trigger options
  3399. * @param target defines the object containing the boolean
  3400. * @param propertyPath defines the path to the boolean property in the target object
  3401. * @param condition defines the trigger related conditions
  3402. */
  3403. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3404. /** @hidden */
  3405. _prepare(): void;
  3406. /**
  3407. * Execute the action toggle the boolean value.
  3408. */
  3409. execute(): void;
  3410. /**
  3411. * Serializes the actions and its related information.
  3412. * @param parent defines the object to serialize in
  3413. * @returns the serialized object
  3414. */
  3415. serialize(parent: any): any;
  3416. }
  3417. /**
  3418. * This defines an action responsible to set a the state field of the target
  3419. * to a desired value once triggered.
  3420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3421. */
  3422. class SetStateAction extends Action {
  3423. /**
  3424. * The value to store in the state field.
  3425. */
  3426. value: string;
  3427. private _target;
  3428. /**
  3429. * Instantiate the action
  3430. * @param triggerOptions defines the trigger options
  3431. * @param target defines the object containing the state property
  3432. * @param value defines the value to store in the state field
  3433. * @param condition defines the trigger related conditions
  3434. */
  3435. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3436. /**
  3437. * Execute the action and store the value on the target state property.
  3438. */
  3439. execute(): void;
  3440. /**
  3441. * Serializes the actions and its related information.
  3442. * @param parent defines the object to serialize in
  3443. * @returns the serialized object
  3444. */
  3445. serialize(parent: any): any;
  3446. }
  3447. /**
  3448. * This defines an action responsible to set a property of the target
  3449. * to a desired value once triggered.
  3450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3451. */
  3452. class SetValueAction extends Action {
  3453. /**
  3454. * The path of the property to set in the target.
  3455. */
  3456. propertyPath: string;
  3457. /**
  3458. * The value to set in the property
  3459. */
  3460. value: any;
  3461. private _target;
  3462. private _effectiveTarget;
  3463. private _property;
  3464. /**
  3465. * Instantiate the action
  3466. * @param triggerOptions defines the trigger options
  3467. * @param target defines the object containing the property
  3468. * @param propertyPath defines the path of the property to set in the target
  3469. * @param value defines the value to set in the property
  3470. * @param condition defines the trigger related conditions
  3471. */
  3472. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3473. /** @hidden */
  3474. _prepare(): void;
  3475. /**
  3476. * Execute the action and set the targetted property to the desired value.
  3477. */
  3478. execute(): void;
  3479. /**
  3480. * Serializes the actions and its related information.
  3481. * @param parent defines the object to serialize in
  3482. * @returns the serialized object
  3483. */
  3484. serialize(parent: any): any;
  3485. }
  3486. /**
  3487. * This defines an action responsible to increment the target value
  3488. * to a desired value once triggered.
  3489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3490. */
  3491. class IncrementValueAction extends Action {
  3492. /**
  3493. * The path of the property to increment in the target.
  3494. */
  3495. propertyPath: string;
  3496. /**
  3497. * The value we should increment the property by.
  3498. */
  3499. value: any;
  3500. private _target;
  3501. private _effectiveTarget;
  3502. private _property;
  3503. /**
  3504. * Instantiate the action
  3505. * @param triggerOptions defines the trigger options
  3506. * @param target defines the object containing the property
  3507. * @param propertyPath defines the path of the property to increment in the target
  3508. * @param value defines the value value we should increment the property by
  3509. * @param condition defines the trigger related conditions
  3510. */
  3511. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3512. /** @hidden */
  3513. _prepare(): void;
  3514. /**
  3515. * Execute the action and increment the target of the value amount.
  3516. */
  3517. execute(): void;
  3518. /**
  3519. * Serializes the actions and its related information.
  3520. * @param parent defines the object to serialize in
  3521. * @returns the serialized object
  3522. */
  3523. serialize(parent: any): any;
  3524. }
  3525. /**
  3526. * This defines an action responsible to start an animation once triggered.
  3527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3528. */
  3529. class PlayAnimationAction extends Action {
  3530. /**
  3531. * Where the animation should start (animation frame)
  3532. */
  3533. from: number;
  3534. /**
  3535. * Where the animation should stop (animation frame)
  3536. */
  3537. to: number;
  3538. /**
  3539. * Define if the animation should loop or stop after the first play.
  3540. */
  3541. loop?: boolean;
  3542. private _target;
  3543. /**
  3544. * Instantiate the action
  3545. * @param triggerOptions defines the trigger options
  3546. * @param target defines the target animation or animation name
  3547. * @param from defines from where the animation should start (animation frame)
  3548. * @param end defines where the animation should stop (animation frame)
  3549. * @param loop defines if the animation should loop or stop after the first play
  3550. * @param condition defines the trigger related conditions
  3551. */
  3552. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3553. /** @hidden */
  3554. _prepare(): void;
  3555. /**
  3556. * Execute the action and play the animation.
  3557. */
  3558. execute(): void;
  3559. /**
  3560. * Serializes the actions and its related information.
  3561. * @param parent defines the object to serialize in
  3562. * @returns the serialized object
  3563. */
  3564. serialize(parent: any): any;
  3565. }
  3566. /**
  3567. * This defines an action responsible to stop an animation once triggered.
  3568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3569. */
  3570. class StopAnimationAction extends Action {
  3571. private _target;
  3572. /**
  3573. * Instantiate the action
  3574. * @param triggerOptions defines the trigger options
  3575. * @param target defines the target animation or animation name
  3576. * @param condition defines the trigger related conditions
  3577. */
  3578. constructor(triggerOptions: any, target: any, condition?: Condition);
  3579. /** @hidden */
  3580. _prepare(): void;
  3581. /**
  3582. * Execute the action and stop the animation.
  3583. */
  3584. execute(): void;
  3585. /**
  3586. * Serializes the actions and its related information.
  3587. * @param parent defines the object to serialize in
  3588. * @returns the serialized object
  3589. */
  3590. serialize(parent: any): any;
  3591. }
  3592. /**
  3593. * This defines an action responsible that does nothing once triggered.
  3594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3595. */
  3596. class DoNothingAction extends Action {
  3597. /**
  3598. * Instantiate the action
  3599. * @param triggerOptions defines the trigger options
  3600. * @param condition defines the trigger related conditions
  3601. */
  3602. constructor(triggerOptions?: any, condition?: Condition);
  3603. /**
  3604. * Execute the action and do nothing.
  3605. */
  3606. execute(): void;
  3607. /**
  3608. * Serializes the actions and its related information.
  3609. * @param parent defines the object to serialize in
  3610. * @returns the serialized object
  3611. */
  3612. serialize(parent: any): any;
  3613. }
  3614. /**
  3615. * This defines an action responsible to trigger several actions once triggered.
  3616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3617. */
  3618. class CombineAction extends Action {
  3619. /**
  3620. * The list of aggregated animations to run.
  3621. */
  3622. children: Action[];
  3623. /**
  3624. * Instantiate the action
  3625. * @param triggerOptions defines the trigger options
  3626. * @param children defines the list of aggregated animations to run
  3627. * @param condition defines the trigger related conditions
  3628. */
  3629. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3630. /** @hidden */
  3631. _prepare(): void;
  3632. /**
  3633. * Execute the action and executes all the aggregated actions.
  3634. */
  3635. execute(evt: ActionEvent): void;
  3636. /**
  3637. * Serializes the actions and its related information.
  3638. * @param parent defines the object to serialize in
  3639. * @returns the serialized object
  3640. */
  3641. serialize(parent: any): any;
  3642. }
  3643. /**
  3644. * This defines an action responsible to run code (external event) once triggered.
  3645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3646. */
  3647. class ExecuteCodeAction extends Action {
  3648. /**
  3649. * The callback function to run.
  3650. */
  3651. func: (evt: ActionEvent) => void;
  3652. /**
  3653. * Instantiate the action
  3654. * @param triggerOptions defines the trigger options
  3655. * @param func defines the callback function to run
  3656. * @param condition defines the trigger related conditions
  3657. */
  3658. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3659. /**
  3660. * Execute the action and run the attached code.
  3661. */
  3662. execute(evt: ActionEvent): void;
  3663. }
  3664. /**
  3665. * This defines an action responsible to set the parent property of the target once triggered.
  3666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3667. */
  3668. class SetParentAction extends Action {
  3669. private _parent;
  3670. private _target;
  3671. /**
  3672. * Instantiate the action
  3673. * @param triggerOptions defines the trigger options
  3674. * @param target defines the target containing the parent property
  3675. * @param parent defines from where the animation should start (animation frame)
  3676. * @param condition defines the trigger related conditions
  3677. */
  3678. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3679. /** @hidden */
  3680. _prepare(): void;
  3681. /**
  3682. * Execute the action and set the parent property.
  3683. */
  3684. execute(): void;
  3685. /**
  3686. * Serializes the actions and its related information.
  3687. * @param parent defines the object to serialize in
  3688. * @returns the serialized object
  3689. */
  3690. serialize(parent: any): any;
  3691. }
  3692. }
  3693. declare module BABYLON {
  3694. /**
  3695. * This defines an action helpful to play a defined sound on a triggered action.
  3696. */
  3697. class PlaySoundAction extends Action {
  3698. private _sound;
  3699. /**
  3700. * Instantiate the action
  3701. * @param triggerOptions defines the trigger options
  3702. * @param sound defines the sound to play
  3703. * @param condition defines the trigger related conditions
  3704. */
  3705. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3706. /** @hidden */
  3707. _prepare(): void;
  3708. /**
  3709. * Execute the action and play the sound.
  3710. */
  3711. execute(): void;
  3712. /**
  3713. * Serializes the actions and its related information.
  3714. * @param parent defines the object to serialize in
  3715. * @returns the serialized object
  3716. */
  3717. serialize(parent: any): any;
  3718. }
  3719. /**
  3720. * This defines an action helpful to stop a defined sound on a triggered action.
  3721. */
  3722. class StopSoundAction extends Action {
  3723. private _sound;
  3724. /**
  3725. * Instantiate the action
  3726. * @param triggerOptions defines the trigger options
  3727. * @param sound defines the sound to stop
  3728. * @param condition defines the trigger related conditions
  3729. */
  3730. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3731. /** @hidden */
  3732. _prepare(): void;
  3733. /**
  3734. * Execute the action and stop the sound.
  3735. */
  3736. execute(): void;
  3737. /**
  3738. * Serializes the actions and its related information.
  3739. * @param parent defines the object to serialize in
  3740. * @returns the serialized object
  3741. */
  3742. serialize(parent: any): any;
  3743. }
  3744. }
  3745. declare module BABYLON {
  3746. /**
  3747. * This defines an action responsible to change the value of a property
  3748. * by interpolating between its current value and the newly set one once triggered.
  3749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3750. */
  3751. class InterpolateValueAction extends Action {
  3752. /**
  3753. * Defines the path of the property where the value should be interpolated
  3754. */
  3755. propertyPath: string;
  3756. /**
  3757. * Defines the target value at the end of the interpolation.
  3758. */
  3759. value: any;
  3760. /**
  3761. * Defines the time it will take for the property to interpolate to the value.
  3762. */
  3763. duration: number;
  3764. /**
  3765. * Defines if the other scene animations should be stopped when the action has been triggered
  3766. */
  3767. stopOtherAnimations?: boolean;
  3768. /**
  3769. * Defines a callback raised once the interpolation animation has been done.
  3770. */
  3771. onInterpolationDone?: () => void;
  3772. /**
  3773. * Observable triggered once the interpolation animation has been done.
  3774. */
  3775. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3776. private _target;
  3777. private _effectiveTarget;
  3778. private _property;
  3779. /**
  3780. * Instantiate the action
  3781. * @param triggerOptions defines the trigger options
  3782. * @param target defines the object containing the value to interpolate
  3783. * @param propertyPath defines the path to the property in the target object
  3784. * @param value defines the target value at the end of the interpolation
  3785. * @param duration deines the time it will take for the property to interpolate to the value.
  3786. * @param condition defines the trigger related conditions
  3787. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3788. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3789. */
  3790. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3791. /** @hidden */
  3792. _prepare(): void;
  3793. /**
  3794. * Execute the action starts the value interpolation.
  3795. */
  3796. execute(): void;
  3797. /**
  3798. * Serializes the actions and its related information.
  3799. * @param parent defines the object to serialize in
  3800. * @returns the serialized object
  3801. */
  3802. serialize(parent: any): any;
  3803. }
  3804. }
  3805. declare module BABYLON {
  3806. /**
  3807. * Class used to store an actual running animation
  3808. */
  3809. class Animatable {
  3810. /** defines the target object */
  3811. target: any;
  3812. /** defines the starting frame number (default is 0) */
  3813. fromFrame: number;
  3814. /** defines the ending frame number (default is 100) */
  3815. toFrame: number;
  3816. /** defines if the animation must loop (default is false) */
  3817. loopAnimation: boolean;
  3818. /** defines a callback to call when animation ends if it is not looping */
  3819. onAnimationEnd?: (() => void) | null | undefined;
  3820. private _localDelayOffset;
  3821. private _pausedDelay;
  3822. private _runtimeAnimations;
  3823. private _paused;
  3824. private _scene;
  3825. private _speedRatio;
  3826. private _weight;
  3827. private _syncRoot;
  3828. /**
  3829. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3830. * This will only apply for non looping animation (default is true)
  3831. */
  3832. disposeOnEnd: boolean;
  3833. /**
  3834. * Gets a boolean indicating if the animation has started
  3835. */
  3836. animationStarted: boolean;
  3837. /**
  3838. * Observer raised when the animation ends
  3839. */
  3840. onAnimationEndObservable: Observable<Animatable>;
  3841. /**
  3842. * Gets the root Animatable used to synchronize and normalize animations
  3843. */
  3844. readonly syncRoot: Animatable;
  3845. /**
  3846. * Gets the current frame of the first RuntimeAnimation
  3847. * Used to synchronize Animatables
  3848. */
  3849. readonly masterFrame: number;
  3850. /**
  3851. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3852. */
  3853. weight: number;
  3854. /**
  3855. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3856. */
  3857. speedRatio: number;
  3858. /**
  3859. * Creates a new Animatable
  3860. * @param scene defines the hosting scene
  3861. * @param target defines the target object
  3862. * @param fromFrame defines the starting frame number (default is 0)
  3863. * @param toFrame defines the ending frame number (default is 100)
  3864. * @param loopAnimation defines if the animation must loop (default is false)
  3865. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3866. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3867. * @param animations defines a group of animation to add to the new Animatable
  3868. */
  3869. constructor(scene: Scene,
  3870. /** defines the target object */
  3871. target: any,
  3872. /** defines the starting frame number (default is 0) */
  3873. fromFrame?: number,
  3874. /** defines the ending frame number (default is 100) */
  3875. toFrame?: number,
  3876. /** defines if the animation must loop (default is false) */
  3877. loopAnimation?: boolean, speedRatio?: number,
  3878. /** defines a callback to call when animation ends if it is not looping */
  3879. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3880. /**
  3881. * Synchronize and normalize current Animatable with a source Animatable
  3882. * This is useful when using animation weights and when animations are not of the same length
  3883. * @param root defines the root Animatable to synchronize with
  3884. * @returns the current Animatable
  3885. */
  3886. syncWith(root: Animatable): Animatable;
  3887. /**
  3888. * Gets the list of runtime animations
  3889. * @returns an array of RuntimeAnimation
  3890. */
  3891. getAnimations(): RuntimeAnimation[];
  3892. /**
  3893. * Adds more animations to the current animatable
  3894. * @param target defines the target of the animations
  3895. * @param animations defines the new animations to add
  3896. */
  3897. appendAnimations(target: any, animations: Animation[]): void;
  3898. /**
  3899. * Gets the source animation for a specific property
  3900. * @param property defines the propertyu to look for
  3901. * @returns null or the source animation for the given property
  3902. */
  3903. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3904. /**
  3905. * Gets the runtime animation for a specific property
  3906. * @param property defines the propertyu to look for
  3907. * @returns null or the runtime animation for the given property
  3908. */
  3909. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3910. /**
  3911. * Resets the animatable to its original state
  3912. */
  3913. reset(): void;
  3914. /**
  3915. * Allows the animatable to blend with current running animations
  3916. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3917. * @param blendingSpeed defines the blending speed to use
  3918. */
  3919. enableBlending(blendingSpeed: number): void;
  3920. /**
  3921. * Disable animation blending
  3922. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3923. */
  3924. disableBlending(): void;
  3925. /**
  3926. * Jump directly to a given frame
  3927. * @param frame defines the frame to jump to
  3928. */
  3929. goToFrame(frame: number): void;
  3930. /**
  3931. * Pause the animation
  3932. */
  3933. pause(): void;
  3934. /**
  3935. * Restart the animation
  3936. */
  3937. restart(): void;
  3938. private _raiseOnAnimationEnd;
  3939. /**
  3940. * Stop and delete the current animation
  3941. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3942. * @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)
  3943. */
  3944. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3945. /**
  3946. * Wait asynchronously for the animation to end
  3947. * @returns a promise which will be fullfilled when the animation ends
  3948. */
  3949. waitAsync(): Promise<Animatable>;
  3950. /** @hidden */
  3951. _animate(delay: number): boolean;
  3952. }
  3953. }
  3954. declare module BABYLON {
  3955. /**
  3956. * Represents the range of an animation
  3957. */
  3958. class AnimationRange {
  3959. /**The name of the animation range**/
  3960. name: string;
  3961. /**The starting frame of the animation */
  3962. from: number;
  3963. /**The ending frame of the animation*/
  3964. to: number;
  3965. /**
  3966. * Initializes the range of an animation
  3967. * @param name The name of the animation range
  3968. * @param from The starting frame of the animation
  3969. * @param to The ending frame of the animation
  3970. */
  3971. constructor(
  3972. /**The name of the animation range**/
  3973. name: string,
  3974. /**The starting frame of the animation */
  3975. from: number,
  3976. /**The ending frame of the animation*/
  3977. to: number);
  3978. /**
  3979. * Makes a copy of the animation range
  3980. * @returns A copy of the animation range
  3981. */
  3982. clone(): AnimationRange;
  3983. }
  3984. /**
  3985. * Composed of a frame, and an action function
  3986. */
  3987. class AnimationEvent {
  3988. /** The frame for which the event is triggered **/
  3989. frame: number;
  3990. /** The event to perform when triggered **/
  3991. action: (currentFrame: number) => void;
  3992. /** Specifies if the event should be triggered only once**/
  3993. onlyOnce?: boolean | undefined;
  3994. /**
  3995. * Specifies if the animation event is done
  3996. */
  3997. isDone: boolean;
  3998. /**
  3999. * Initializes the animation event
  4000. * @param frame The frame for which the event is triggered
  4001. * @param action The event to perform when triggered
  4002. * @param onlyOnce Specifies if the event should be triggered only once
  4003. */
  4004. constructor(
  4005. /** The frame for which the event is triggered **/
  4006. frame: number,
  4007. /** The event to perform when triggered **/
  4008. action: (currentFrame: number) => void,
  4009. /** Specifies if the event should be triggered only once**/
  4010. onlyOnce?: boolean | undefined);
  4011. /** @hidden */
  4012. _clone(): AnimationEvent;
  4013. }
  4014. /**
  4015. * A cursor which tracks a point on a path
  4016. */
  4017. class PathCursor {
  4018. private path;
  4019. /**
  4020. * Stores path cursor callbacks for when an onchange event is triggered
  4021. */
  4022. private _onchange;
  4023. /**
  4024. * The value of the path cursor
  4025. */
  4026. value: number;
  4027. /**
  4028. * The animation array of the path cursor
  4029. */
  4030. animations: Animation[];
  4031. /**
  4032. * Initializes the path cursor
  4033. * @param path The path to track
  4034. */
  4035. constructor(path: Path2);
  4036. /**
  4037. * Gets the cursor point on the path
  4038. * @returns A point on the path cursor at the cursor location
  4039. */
  4040. getPoint(): Vector3;
  4041. /**
  4042. * Moves the cursor ahead by the step amount
  4043. * @param step The amount to move the cursor forward
  4044. * @returns This path cursor
  4045. */
  4046. moveAhead(step?: number): PathCursor;
  4047. /**
  4048. * Moves the cursor behind by the step amount
  4049. * @param step The amount to move the cursor back
  4050. * @returns This path cursor
  4051. */
  4052. moveBack(step?: number): PathCursor;
  4053. /**
  4054. * Moves the cursor by the step amount
  4055. * If the step amount is greater than one, an exception is thrown
  4056. * @param step The amount to move the cursor
  4057. * @returns This path cursor
  4058. */
  4059. move(step: number): PathCursor;
  4060. /**
  4061. * Ensures that the value is limited between zero and one
  4062. * @returns This path cursor
  4063. */
  4064. private ensureLimits;
  4065. /**
  4066. * Runs onchange callbacks on change (used by the animation engine)
  4067. * @returns This path cursor
  4068. */
  4069. private raiseOnChange;
  4070. /**
  4071. * Executes a function on change
  4072. * @param f A path cursor onchange callback
  4073. * @returns This path cursor
  4074. */
  4075. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4076. }
  4077. /**
  4078. * Defines an interface which represents an animation key frame
  4079. */
  4080. interface IAnimationKey {
  4081. /**
  4082. * Frame of the key frame
  4083. */
  4084. frame: number;
  4085. /**
  4086. * Value at the specifies key frame
  4087. */
  4088. value: any;
  4089. /**
  4090. * The input tangent for the cubic hermite spline
  4091. */
  4092. inTangent?: any;
  4093. /**
  4094. * The output tangent for the cubic hermite spline
  4095. */
  4096. outTangent?: any;
  4097. /**
  4098. * The animation interpolation type
  4099. */
  4100. interpolation?: AnimationKeyInterpolation;
  4101. }
  4102. /**
  4103. * Enum for the animation key frame interpolation type
  4104. */
  4105. enum AnimationKeyInterpolation {
  4106. /**
  4107. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4108. */
  4109. STEP = 1
  4110. }
  4111. /**
  4112. * Class used to store any kind of animation
  4113. */
  4114. class Animation {
  4115. /**Name of the animation */
  4116. name: string;
  4117. /**Property to animate */
  4118. targetProperty: string;
  4119. /**The frames per second of the animation */
  4120. framePerSecond: number;
  4121. /**The data type of the animation */
  4122. dataType: number;
  4123. /**The loop mode of the animation */
  4124. loopMode?: number | undefined;
  4125. /**Specifies if blending should be enabled */
  4126. enableBlending?: boolean | undefined;
  4127. /**
  4128. * Use matrix interpolation instead of using direct key value when animating matrices
  4129. */
  4130. static AllowMatricesInterpolation: boolean;
  4131. /**
  4132. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4133. */
  4134. static AllowMatrixDecomposeForInterpolation: boolean;
  4135. /**
  4136. * Stores the key frames of the animation
  4137. */
  4138. private _keys;
  4139. /**
  4140. * Stores the easing function of the animation
  4141. */
  4142. private _easingFunction;
  4143. /**
  4144. * @hidden Internal use only
  4145. */
  4146. _runtimeAnimations: RuntimeAnimation[];
  4147. /**
  4148. * The set of event that will be linked to this animation
  4149. */
  4150. private _events;
  4151. /**
  4152. * Stores an array of target property paths
  4153. */
  4154. targetPropertyPath: string[];
  4155. /**
  4156. * Stores the blending speed of the animation
  4157. */
  4158. blendingSpeed: number;
  4159. /**
  4160. * Stores the animation ranges for the animation
  4161. */
  4162. private _ranges;
  4163. /**
  4164. * @hidden Internal use
  4165. */
  4166. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4167. /**
  4168. * Sets up an animation
  4169. * @param property The property to animate
  4170. * @param animationType The animation type to apply
  4171. * @param framePerSecond The frames per second of the animation
  4172. * @param easingFunction The easing function used in the animation
  4173. * @returns The created animation
  4174. */
  4175. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4176. /**
  4177. * Create and start an animation on a node
  4178. * @param name defines the name of the global animation that will be run on all nodes
  4179. * @param node defines the root node where the animation will take place
  4180. * @param targetProperty defines property to animate
  4181. * @param framePerSecond defines the number of frame per second yo use
  4182. * @param totalFrame defines the number of frames in total
  4183. * @param from defines the initial value
  4184. * @param to defines the final value
  4185. * @param loopMode defines which loop mode you want to use (off by default)
  4186. * @param easingFunction defines the easing function to use (linear by default)
  4187. * @param onAnimationEnd defines the callback to call when animation end
  4188. * @returns the animatable created for this animation
  4189. */
  4190. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4191. /**
  4192. * Create and start an animation on a node and its descendants
  4193. * @param name defines the name of the global animation that will be run on all nodes
  4194. * @param node defines the root node where the animation will take place
  4195. * @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
  4196. * @param targetProperty defines property to animate
  4197. * @param framePerSecond defines the number of frame per second to use
  4198. * @param totalFrame defines the number of frames in total
  4199. * @param from defines the initial value
  4200. * @param to defines the final value
  4201. * @param loopMode defines which loop mode you want to use (off by default)
  4202. * @param easingFunction defines the easing function to use (linear by default)
  4203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4204. * @returns the list of animatables created for all nodes
  4205. * @example https://www.babylonjs-playground.com/#MH0VLI
  4206. */
  4207. 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[]>;
  4208. /**
  4209. * Creates a new animation, merges it with the existing animations and starts it
  4210. * @param name Name of the animation
  4211. * @param node Node which contains the scene that begins the animations
  4212. * @param targetProperty Specifies which property to animate
  4213. * @param framePerSecond The frames per second of the animation
  4214. * @param totalFrame The total number of frames
  4215. * @param from The frame at the beginning of the animation
  4216. * @param to The frame at the end of the animation
  4217. * @param loopMode Specifies the loop mode of the animation
  4218. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4219. * @param onAnimationEnd Callback to run once the animation is complete
  4220. * @returns Nullable animation
  4221. */
  4222. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4223. /**
  4224. * Transition property of an host to the target Value
  4225. * @param property The property to transition
  4226. * @param targetValue The target Value of the property
  4227. * @param host The object where the property to animate belongs
  4228. * @param scene Scene used to run the animation
  4229. * @param frameRate Framerate (in frame/s) to use
  4230. * @param transition The transition type we want to use
  4231. * @param duration The duration of the animation, in milliseconds
  4232. * @param onAnimationEnd Callback trigger at the end of the animation
  4233. * @returns Nullable animation
  4234. */
  4235. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4236. /**
  4237. * Return the array of runtime animations currently using this animation
  4238. */
  4239. readonly runtimeAnimations: RuntimeAnimation[];
  4240. /**
  4241. * Specifies if any of the runtime animations are currently running
  4242. */
  4243. readonly hasRunningRuntimeAnimations: boolean;
  4244. /**
  4245. * Initializes the animation
  4246. * @param name Name of the animation
  4247. * @param targetProperty Property to animate
  4248. * @param framePerSecond The frames per second of the animation
  4249. * @param dataType The data type of the animation
  4250. * @param loopMode The loop mode of the animation
  4251. * @param enableBlendings Specifies if blending should be enabled
  4252. */
  4253. constructor(
  4254. /**Name of the animation */
  4255. name: string,
  4256. /**Property to animate */
  4257. targetProperty: string,
  4258. /**The frames per second of the animation */
  4259. framePerSecond: number,
  4260. /**The data type of the animation */
  4261. dataType: number,
  4262. /**The loop mode of the animation */
  4263. loopMode?: number | undefined,
  4264. /**Specifies if blending should be enabled */
  4265. enableBlending?: boolean | undefined);
  4266. /**
  4267. * Converts the animation to a string
  4268. * @param fullDetails support for multiple levels of logging within scene loading
  4269. * @returns String form of the animation
  4270. */
  4271. toString(fullDetails?: boolean): string;
  4272. /**
  4273. * Add an event to this animation
  4274. * @param event Event to add
  4275. */
  4276. addEvent(event: AnimationEvent): void;
  4277. /**
  4278. * Remove all events found at the given frame
  4279. * @param frame The frame to remove events from
  4280. */
  4281. removeEvents(frame: number): void;
  4282. /**
  4283. * Retrieves all the events from the animation
  4284. * @returns Events from the animation
  4285. */
  4286. getEvents(): AnimationEvent[];
  4287. /**
  4288. * Creates an animation range
  4289. * @param name Name of the animation range
  4290. * @param from Starting frame of the animation range
  4291. * @param to Ending frame of the animation
  4292. */
  4293. createRange(name: string, from: number, to: number): void;
  4294. /**
  4295. * Deletes an animation range by name
  4296. * @param name Name of the animation range to delete
  4297. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4298. */
  4299. deleteRange(name: string, deleteFrames?: boolean): void;
  4300. /**
  4301. * Gets the animation range by name, or null if not defined
  4302. * @param name Name of the animation range
  4303. * @returns Nullable animation range
  4304. */
  4305. getRange(name: string): Nullable<AnimationRange>;
  4306. /**
  4307. * Gets the key frames from the animation
  4308. * @returns The key frames of the animation
  4309. */
  4310. getKeys(): Array<IAnimationKey>;
  4311. /**
  4312. * Gets the highest frame rate of the animation
  4313. * @returns Highest frame rate of the animation
  4314. */
  4315. getHighestFrame(): number;
  4316. /**
  4317. * Gets the easing function of the animation
  4318. * @returns Easing function of the animation
  4319. */
  4320. getEasingFunction(): IEasingFunction;
  4321. /**
  4322. * Sets the easing function of the animation
  4323. * @param easingFunction A custom mathematical formula for animation
  4324. */
  4325. setEasingFunction(easingFunction: EasingFunction): void;
  4326. /**
  4327. * Interpolates a scalar linearly
  4328. * @param startValue Start value of the animation curve
  4329. * @param endValue End value of the animation curve
  4330. * @param gradient Scalar amount to interpolate
  4331. * @returns Interpolated scalar value
  4332. */
  4333. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4334. /**
  4335. * Interpolates a scalar cubically
  4336. * @param startValue Start value of the animation curve
  4337. * @param outTangent End tangent of the animation
  4338. * @param endValue End value of the animation curve
  4339. * @param inTangent Start tangent of the animation curve
  4340. * @param gradient Scalar amount to interpolate
  4341. * @returns Interpolated scalar value
  4342. */
  4343. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4344. /**
  4345. * Interpolates a quaternion using a spherical linear interpolation
  4346. * @param startValue Start value of the animation curve
  4347. * @param endValue End value of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated quaternion value
  4350. */
  4351. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4352. /**
  4353. * Interpolates a quaternion cubically
  4354. * @param startValue Start value of the animation curve
  4355. * @param outTangent End tangent of the animation curve
  4356. * @param endValue End value of the animation curve
  4357. * @param inTangent Start tangent of the animation curve
  4358. * @param gradient Scalar amount to interpolate
  4359. * @returns Interpolated quaternion value
  4360. */
  4361. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4362. /**
  4363. * Interpolates a Vector3 linearl
  4364. * @param startValue Start value of the animation curve
  4365. * @param endValue End value of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated scalar value
  4368. */
  4369. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4370. /**
  4371. * Interpolates a Vector3 cubically
  4372. * @param startValue Start value of the animation curve
  4373. * @param outTangent End tangent of the animation
  4374. * @param endValue End value of the animation curve
  4375. * @param inTangent Start tangent of the animation curve
  4376. * @param gradient Scalar amount to interpolate
  4377. * @returns InterpolatedVector3 value
  4378. */
  4379. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4380. /**
  4381. * Interpolates a Vector2 linearly
  4382. * @param startValue Start value of the animation curve
  4383. * @param endValue End value of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns Interpolated Vector2 value
  4386. */
  4387. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4388. /**
  4389. * Interpolates a Vector2 cubically
  4390. * @param startValue Start value of the animation curve
  4391. * @param outTangent End tangent of the animation
  4392. * @param endValue End value of the animation curve
  4393. * @param inTangent Start tangent of the animation curve
  4394. * @param gradient Scalar amount to interpolate
  4395. * @returns Interpolated Vector2 value
  4396. */
  4397. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4398. /**
  4399. * Interpolates a size linearly
  4400. * @param startValue Start value of the animation curve
  4401. * @param endValue End value of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Size value
  4404. */
  4405. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4406. /**
  4407. * Interpolates a Color3 linearly
  4408. * @param startValue Start value of the animation curve
  4409. * @param endValue End value of the animation curve
  4410. * @param gradient Scalar amount to interpolate
  4411. * @returns Interpolated Color3 value
  4412. */
  4413. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4414. /**
  4415. * @hidden Internal use only
  4416. */
  4417. _getKeyValue(value: any): any;
  4418. /**
  4419. * @hidden Internal use only
  4420. */
  4421. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4422. /**
  4423. * Defines the function to use to interpolate matrices
  4424. * @param startValue defines the start matrix
  4425. * @param endValue defines the end matrix
  4426. * @param gradient defines the gradient between both matrices
  4427. * @param result defines an optional target matrix where to store the interpolation
  4428. * @returns the interpolated matrix
  4429. */
  4430. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4431. /**
  4432. * Makes a copy of the animation
  4433. * @returns Cloned animation
  4434. */
  4435. clone(): Animation;
  4436. /**
  4437. * Sets the key frames of the animation
  4438. * @param values The animation key frames to set
  4439. */
  4440. setKeys(values: Array<IAnimationKey>): void;
  4441. /**
  4442. * Serializes the animation to an object
  4443. * @returns Serialized object
  4444. */
  4445. serialize(): any;
  4446. /**
  4447. * Float animation type
  4448. */
  4449. private static _ANIMATIONTYPE_FLOAT;
  4450. /**
  4451. * Vector3 animation type
  4452. */
  4453. private static _ANIMATIONTYPE_VECTOR3;
  4454. /**
  4455. * Quaternion animation type
  4456. */
  4457. private static _ANIMATIONTYPE_QUATERNION;
  4458. /**
  4459. * Matrix animation type
  4460. */
  4461. private static _ANIMATIONTYPE_MATRIX;
  4462. /**
  4463. * Color3 animation type
  4464. */
  4465. private static _ANIMATIONTYPE_COLOR3;
  4466. /**
  4467. * Vector2 animation type
  4468. */
  4469. private static _ANIMATIONTYPE_VECTOR2;
  4470. /**
  4471. * Size animation type
  4472. */
  4473. private static _ANIMATIONTYPE_SIZE;
  4474. /**
  4475. * Relative Loop Mode
  4476. */
  4477. private static _ANIMATIONLOOPMODE_RELATIVE;
  4478. /**
  4479. * Cycle Loop Mode
  4480. */
  4481. private static _ANIMATIONLOOPMODE_CYCLE;
  4482. /**
  4483. * Constant Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_CONSTANT;
  4486. /**
  4487. * Get the float animation type
  4488. */
  4489. static readonly ANIMATIONTYPE_FLOAT: number;
  4490. /**
  4491. * Get the Vector3 animation type
  4492. */
  4493. static readonly ANIMATIONTYPE_VECTOR3: number;
  4494. /**
  4495. * Get the Vector2 animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_VECTOR2: number;
  4498. /**
  4499. * Get the Size animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_SIZE: number;
  4502. /**
  4503. * Get the Quaternion animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_QUATERNION: number;
  4506. /**
  4507. * Get the Matrix animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_MATRIX: number;
  4510. /**
  4511. * Get the Color3 animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_COLOR3: number;
  4514. /**
  4515. * Get the Relative Loop Mode
  4516. */
  4517. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4518. /**
  4519. * Get the Cycle Loop Mode
  4520. */
  4521. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4522. /**
  4523. * Get the Constant Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4526. /** @hidden */
  4527. static _UniversalLerp(left: any, right: any, amount: number): any;
  4528. /**
  4529. * Parses an animation object and creates an animation
  4530. * @param parsedAnimation Parsed animation object
  4531. * @returns Animation object
  4532. */
  4533. static Parse(parsedAnimation: any): Animation;
  4534. /**
  4535. * Appends the serialized animations from the source animations
  4536. * @param source Source containing the animations
  4537. * @param destination Target to store the animations
  4538. */
  4539. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4540. }
  4541. }
  4542. declare module BABYLON {
  4543. /**
  4544. * This class defines the direct association between an animation and a target
  4545. */
  4546. class TargetedAnimation {
  4547. /**
  4548. * Animation to perform
  4549. */
  4550. animation: Animation;
  4551. /**
  4552. * Target to animate
  4553. */
  4554. target: any;
  4555. }
  4556. /**
  4557. * Use this class to create coordinated animations on multiple targets
  4558. */
  4559. class AnimationGroup implements IDisposable {
  4560. /** The name of the animation group */
  4561. name: string;
  4562. private _scene;
  4563. private _targetedAnimations;
  4564. private _animatables;
  4565. private _from;
  4566. private _to;
  4567. private _isStarted;
  4568. private _speedRatio;
  4569. /**
  4570. * This observable will notify when one animation have ended.
  4571. */
  4572. onAnimationEndObservable: Observable<TargetedAnimation>;
  4573. /**
  4574. * This observable will notify when all animations have ended.
  4575. */
  4576. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4577. /**
  4578. * This observable will notify when all animations have paused.
  4579. */
  4580. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4581. /**
  4582. * Gets the first frame
  4583. */
  4584. readonly from: number;
  4585. /**
  4586. * Gets the last frame
  4587. */
  4588. readonly to: number;
  4589. /**
  4590. * Define if the animations are started
  4591. */
  4592. readonly isStarted: boolean;
  4593. /**
  4594. * Gets or sets the speed ratio to use for all animations
  4595. */
  4596. /**
  4597. * Gets or sets the speed ratio to use for all animations
  4598. */
  4599. speedRatio: number;
  4600. /**
  4601. * Gets the targeted animations for this animation group
  4602. */
  4603. readonly targetedAnimations: Array<TargetedAnimation>;
  4604. /**
  4605. * returning the list of animatables controlled by this animation group.
  4606. */
  4607. readonly animatables: Array<Animatable>;
  4608. /**
  4609. * Instantiates a new Animation Group.
  4610. * This helps managing several animations at once.
  4611. * @see http://doc.babylonjs.com/how_to/group
  4612. * @param name Defines the name of the group
  4613. * @param scene Defines the scene the group belongs to
  4614. */
  4615. constructor(
  4616. /** The name of the animation group */
  4617. name: string, scene?: Nullable<Scene>);
  4618. /**
  4619. * Add an animation (with its target) in the group
  4620. * @param animation defines the animation we want to add
  4621. * @param target defines the target of the animation
  4622. * @returns the TargetedAnimation object
  4623. */
  4624. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4625. /**
  4626. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4627. * It can add constant keys at begin or end
  4628. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4629. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4630. * @returns the animation group
  4631. */
  4632. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4633. /**
  4634. * Start all animations on given targets
  4635. * @param loop defines if animations must loop
  4636. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4637. * @param from defines the from key (optional)
  4638. * @param to defines the to key (optional)
  4639. * @returns the current animation group
  4640. */
  4641. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4642. /**
  4643. * Pause all animations
  4644. * @returns the animation group
  4645. */
  4646. pause(): AnimationGroup;
  4647. /**
  4648. * Play all animations to initial state
  4649. * This function will start() the animations if they were not started or will restart() them if they were paused
  4650. * @param loop defines if animations must loop
  4651. * @returns the animation group
  4652. */
  4653. play(loop?: boolean): AnimationGroup;
  4654. /**
  4655. * Reset all animations to initial state
  4656. * @returns the animation group
  4657. */
  4658. reset(): AnimationGroup;
  4659. /**
  4660. * Restart animations from key 0
  4661. * @returns the animation group
  4662. */
  4663. restart(): AnimationGroup;
  4664. /**
  4665. * Stop all animations
  4666. * @returns the animation group
  4667. */
  4668. stop(): AnimationGroup;
  4669. /**
  4670. * Set animation weight for all animatables
  4671. * @param weight defines the weight to use
  4672. * @return the animationGroup
  4673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4674. */
  4675. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4676. /**
  4677. * Synchronize and normalize all animatables with a source animatable
  4678. * @param root defines the root animatable to synchronize with
  4679. * @return the animationGroup
  4680. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4681. */
  4682. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4683. /**
  4684. * Goes to a specific frame in this animation group
  4685. * @param frame the frame number to go to
  4686. * @return the animationGroup
  4687. */
  4688. goToFrame(frame: number): AnimationGroup;
  4689. /**
  4690. * Dispose all associated resources
  4691. */
  4692. dispose(): void;
  4693. private _checkAnimationGroupEnded;
  4694. /**
  4695. * Returns a new AnimationGroup object parsed from the source provided.
  4696. * @param parsedAnimationGroup defines the source
  4697. * @param scene defines the scene that will receive the animationGroup
  4698. * @returns a new AnimationGroup
  4699. */
  4700. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4701. /**
  4702. * Returns the string "AnimationGroup"
  4703. * @returns "AnimationGroup"
  4704. */
  4705. getClassName(): string;
  4706. /**
  4707. * Creates a detailled string about the object
  4708. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4709. * @returns a string representing the object
  4710. */
  4711. toString(fullDetails?: boolean): string;
  4712. }
  4713. }
  4714. declare module BABYLON {
  4715. /**
  4716. * Class used to override all child animations of a given target
  4717. */
  4718. class AnimationPropertiesOverride {
  4719. /**
  4720. * Gets or sets a value indicating if animation blending must be used
  4721. */
  4722. enableBlending: boolean;
  4723. /**
  4724. * Gets or sets the blending speed to use when enableBlending is true
  4725. */
  4726. blendingSpeed: number;
  4727. /**
  4728. * Gets or sets the default loop mode to use
  4729. */
  4730. loopMode: number;
  4731. }
  4732. }
  4733. declare module BABYLON {
  4734. /**
  4735. * This represents the main contract an easing function should follow.
  4736. * Easing functions are used throughout the animation system.
  4737. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4738. */
  4739. interface IEasingFunction {
  4740. /**
  4741. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4742. * of the easing function.
  4743. * The link below provides some of the most common examples of easing functions.
  4744. * @see https://easings.net/
  4745. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4746. * @returns the corresponding value on the curve defined by the easing function
  4747. */
  4748. ease(gradient: number): number;
  4749. }
  4750. /**
  4751. * Base class used for every default easing function.
  4752. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4753. */
  4754. class EasingFunction implements IEasingFunction {
  4755. /**
  4756. * Interpolation follows the mathematical formula associated with the easing function.
  4757. */
  4758. static readonly EASINGMODE_EASEIN: number;
  4759. /**
  4760. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4761. */
  4762. static readonly EASINGMODE_EASEOUT: number;
  4763. /**
  4764. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4765. */
  4766. static readonly EASINGMODE_EASEINOUT: number;
  4767. private _easingMode;
  4768. /**
  4769. * Sets the easing mode of the current function.
  4770. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4771. */
  4772. setEasingMode(easingMode: number): void;
  4773. /**
  4774. * Gets the current easing mode.
  4775. * @returns the easing mode
  4776. */
  4777. getEasingMode(): number;
  4778. /**
  4779. * @hidden
  4780. */
  4781. easeInCore(gradient: number): number;
  4782. /**
  4783. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4784. * of the easing function.
  4785. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4786. * @returns the corresponding value on the curve defined by the easing function
  4787. */
  4788. ease(gradient: number): number;
  4789. }
  4790. /**
  4791. * Easing function with a circle shape (see link below).
  4792. * @see https://easings.net/#easeInCirc
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. class CircleEase extends EasingFunction implements IEasingFunction {
  4796. /** @hidden */
  4797. easeInCore(gradient: number): number;
  4798. }
  4799. /**
  4800. * Easing function with a ease back shape (see link below).
  4801. * @see https://easings.net/#easeInBack
  4802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4803. */
  4804. class BackEase extends EasingFunction implements IEasingFunction {
  4805. /** Defines the amplitude of the function */
  4806. amplitude: number;
  4807. /**
  4808. * Instantiates a back ease easing
  4809. * @see https://easings.net/#easeInBack
  4810. * @param amplitude Defines the amplitude of the function
  4811. */
  4812. constructor(
  4813. /** Defines the amplitude of the function */
  4814. amplitude?: number);
  4815. /** @hidden */
  4816. easeInCore(gradient: number): number;
  4817. }
  4818. /**
  4819. * Easing function with a bouncing shape (see link below).
  4820. * @see https://easings.net/#easeInBounce
  4821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4822. */
  4823. class BounceEase extends EasingFunction implements IEasingFunction {
  4824. /** Defines the number of bounces */
  4825. bounces: number;
  4826. /** Defines the amplitude of the bounce */
  4827. bounciness: number;
  4828. /**
  4829. * Instantiates a bounce easing
  4830. * @see https://easings.net/#easeInBounce
  4831. * @param bounces Defines the number of bounces
  4832. * @param bounciness Defines the amplitude of the bounce
  4833. */
  4834. constructor(
  4835. /** Defines the number of bounces */
  4836. bounces?: number,
  4837. /** Defines the amplitude of the bounce */
  4838. bounciness?: number);
  4839. /** @hidden */
  4840. easeInCore(gradient: number): number;
  4841. }
  4842. /**
  4843. * Easing function with a power of 3 shape (see link below).
  4844. * @see https://easings.net/#easeInCubic
  4845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4846. */
  4847. class CubicEase extends EasingFunction implements IEasingFunction {
  4848. /** @hidden */
  4849. easeInCore(gradient: number): number;
  4850. }
  4851. /**
  4852. * Easing function with an elastic shape (see link below).
  4853. * @see https://easings.net/#easeInElastic
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. class ElasticEase extends EasingFunction implements IEasingFunction {
  4857. /** Defines the number of oscillations*/
  4858. oscillations: number;
  4859. /** Defines the amplitude of the oscillations*/
  4860. springiness: number;
  4861. /**
  4862. * Instantiates an elastic easing function
  4863. * @see https://easings.net/#easeInElastic
  4864. * @param oscillations Defines the number of oscillations
  4865. * @param springiness Defines the amplitude of the oscillations
  4866. */
  4867. constructor(
  4868. /** Defines the number of oscillations*/
  4869. oscillations?: number,
  4870. /** Defines the amplitude of the oscillations*/
  4871. springiness?: number);
  4872. /** @hidden */
  4873. easeInCore(gradient: number): number;
  4874. }
  4875. /**
  4876. * Easing function with an exponential shape (see link below).
  4877. * @see https://easings.net/#easeInExpo
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4881. /** Defines the exponent of the function */
  4882. exponent: number;
  4883. /**
  4884. * Instantiates an exponential easing function
  4885. * @see https://easings.net/#easeInExpo
  4886. * @param exponent Defines the exponent of the function
  4887. */
  4888. constructor(
  4889. /** Defines the exponent of the function */
  4890. exponent?: number);
  4891. /** @hidden */
  4892. easeInCore(gradient: number): number;
  4893. }
  4894. /**
  4895. * Easing function with a power shape (see link below).
  4896. * @see https://easings.net/#easeInQuad
  4897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4898. */
  4899. class PowerEase extends EasingFunction implements IEasingFunction {
  4900. /** Defines the power of the function */
  4901. power: number;
  4902. /**
  4903. * Instantiates an power base easing function
  4904. * @see https://easings.net/#easeInQuad
  4905. * @param power Defines the power of the function
  4906. */
  4907. constructor(
  4908. /** Defines the power of the function */
  4909. power?: number);
  4910. /** @hidden */
  4911. easeInCore(gradient: number): number;
  4912. }
  4913. /**
  4914. * Easing function with a power of 2 shape (see link below).
  4915. * @see https://easings.net/#easeInQuad
  4916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4917. */
  4918. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4919. /** @hidden */
  4920. easeInCore(gradient: number): number;
  4921. }
  4922. /**
  4923. * Easing function with a power of 4 shape (see link below).
  4924. * @see https://easings.net/#easeInQuart
  4925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4926. */
  4927. class QuarticEase extends EasingFunction implements IEasingFunction {
  4928. /** @hidden */
  4929. easeInCore(gradient: number): number;
  4930. }
  4931. /**
  4932. * Easing function with a power of 5 shape (see link below).
  4933. * @see https://easings.net/#easeInQuint
  4934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4935. */
  4936. class QuinticEase extends EasingFunction implements IEasingFunction {
  4937. /** @hidden */
  4938. easeInCore(gradient: number): number;
  4939. }
  4940. /**
  4941. * Easing function with a sin shape (see link below).
  4942. * @see https://easings.net/#easeInSine
  4943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4944. */
  4945. class SineEase extends EasingFunction implements IEasingFunction {
  4946. /** @hidden */
  4947. easeInCore(gradient: number): number;
  4948. }
  4949. /**
  4950. * Easing function with a bezier shape (see link below).
  4951. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4953. */
  4954. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4955. /** Defines the x component of the start tangent in the bezier curve */
  4956. x1: number;
  4957. /** Defines the y component of the start tangent in the bezier curve */
  4958. y1: number;
  4959. /** Defines the x component of the end tangent in the bezier curve */
  4960. x2: number;
  4961. /** Defines the y component of the end tangent in the bezier curve */
  4962. y2: number;
  4963. /**
  4964. * Instantiates a bezier function
  4965. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4966. * @param x1 Defines the x component of the start tangent in the bezier curve
  4967. * @param y1 Defines the y component of the start tangent in the bezier curve
  4968. * @param x2 Defines the x component of the end tangent in the bezier curve
  4969. * @param y2 Defines the y component of the end tangent in the bezier curve
  4970. */
  4971. constructor(
  4972. /** Defines the x component of the start tangent in the bezier curve */
  4973. x1?: number,
  4974. /** Defines the y component of the start tangent in the bezier curve */
  4975. y1?: number,
  4976. /** Defines the x component of the end tangent in the bezier curve */
  4977. x2?: number,
  4978. /** Defines the y component of the end tangent in the bezier curve */
  4979. y2?: number);
  4980. /** @hidden */
  4981. easeInCore(gradient: number): number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /**
  4986. * Defines a runtime animation
  4987. */
  4988. class RuntimeAnimation {
  4989. private _events;
  4990. /**
  4991. * The current frame of the runtime animation
  4992. */
  4993. private _currentFrame;
  4994. /**
  4995. * The animation used by the runtime animation
  4996. */
  4997. private _animation;
  4998. /**
  4999. * The target of the runtime animation
  5000. */
  5001. private _target;
  5002. /**
  5003. * The initiating animatable
  5004. */
  5005. private _host;
  5006. /**
  5007. * The original value of the runtime animation
  5008. */
  5009. private _originalValue;
  5010. /**
  5011. * The original blend value of the runtime animation
  5012. */
  5013. private _originalBlendValue;
  5014. /**
  5015. * The offsets cache of the runtime animation
  5016. */
  5017. private _offsetsCache;
  5018. /**
  5019. * The high limits cache of the runtime animation
  5020. */
  5021. private _highLimitsCache;
  5022. /**
  5023. * Specifies if the runtime animation has been stopped
  5024. */
  5025. private _stopped;
  5026. /**
  5027. * The blending factor of the runtime animation
  5028. */
  5029. private _blendingFactor;
  5030. /**
  5031. * The BabylonJS scene
  5032. */
  5033. private _scene;
  5034. /**
  5035. * The current value of the runtime animation
  5036. */
  5037. private _currentValue;
  5038. /** @hidden */
  5039. _workValue: any;
  5040. /**
  5041. * The active target of the runtime animation
  5042. */
  5043. private _activeTarget;
  5044. /**
  5045. * The target path of the runtime animation
  5046. */
  5047. private _targetPath;
  5048. /**
  5049. * The weight of the runtime animation
  5050. */
  5051. private _weight;
  5052. /**
  5053. * The ratio offset of the runtime animation
  5054. */
  5055. private _ratioOffset;
  5056. /**
  5057. * The previous delay of the runtime animation
  5058. */
  5059. private _previousDelay;
  5060. /**
  5061. * The previous ratio of the runtime animation
  5062. */
  5063. private _previousRatio;
  5064. /**
  5065. * Gets the current frame of the runtime animation
  5066. */
  5067. readonly currentFrame: number;
  5068. /**
  5069. * Gets the weight of the runtime animation
  5070. */
  5071. readonly weight: number;
  5072. /**
  5073. * Gets the current value of the runtime animation
  5074. */
  5075. readonly currentValue: any;
  5076. /**
  5077. * Gets the target path of the runtime animation
  5078. */
  5079. readonly targetPath: string;
  5080. /**
  5081. * Gets the actual target of the runtime animation
  5082. */
  5083. readonly target: any;
  5084. /**
  5085. * Create a new RuntimeAnimation object
  5086. * @param target defines the target of the animation
  5087. * @param animation defines the source animation object
  5088. * @param scene defines the hosting scene
  5089. * @param host defines the initiating Animatable
  5090. */
  5091. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5092. /**
  5093. * Gets the animation from the runtime animation
  5094. */
  5095. readonly animation: Animation;
  5096. /**
  5097. * Resets the runtime animation to the beginning
  5098. * @param restoreOriginal defines whether to restore the target property to the original value
  5099. */
  5100. reset(restoreOriginal?: boolean): void;
  5101. /**
  5102. * Specifies if the runtime animation is stopped
  5103. * @returns Boolean specifying if the runtime animation is stopped
  5104. */
  5105. isStopped(): boolean;
  5106. /**
  5107. * Disposes of the runtime animation
  5108. */
  5109. dispose(): void;
  5110. /**
  5111. * Interpolates the animation from the current frame
  5112. * @param currentFrame The frame to interpolate the animation to
  5113. * @param repeatCount The number of times that the animation should loop
  5114. * @param loopMode The type of looping mode to use
  5115. * @param offsetValue Animation offset value
  5116. * @param highLimitValue The high limit value
  5117. * @returns The interpolated value
  5118. */
  5119. private _interpolate;
  5120. /**
  5121. * Apply the interpolated value to the target
  5122. * @param currentValue defines the value computed by the animation
  5123. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5124. */
  5125. setValue(currentValue: any, weight?: number): void;
  5126. private _setValue;
  5127. /**
  5128. * Gets the loop pmode of the runtime animation
  5129. * @returns Loop Mode
  5130. */
  5131. private _getCorrectLoopMode;
  5132. /**
  5133. * Move the current animation to a given frame
  5134. * @param frame defines the frame to move to
  5135. */
  5136. goToFrame(frame: number): void;
  5137. /**
  5138. * @hidden Internal use only
  5139. */
  5140. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5141. /**
  5142. * Execute the current animation
  5143. * @param delay defines the delay to add to the current frame
  5144. * @param from defines the lower bound of the animation range
  5145. * @param to defines the upper bound of the animation range
  5146. * @param loop defines if the current animation must loop
  5147. * @param speedRatio defines the current speed ratio
  5148. * @param weight defines the weight of the animation (default is -1 so no weight)
  5149. * @returns a boolean indicating if the animation is running
  5150. */
  5151. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5152. }
  5153. }
  5154. declare module BABYLON {
  5155. /**
  5156. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5158. */
  5159. class Analyser {
  5160. /**
  5161. * Gets or sets the smoothing
  5162. * @ignorenaming
  5163. */
  5164. SMOOTHING: number;
  5165. /**
  5166. * Gets or sets the FFT table size
  5167. * @ignorenaming
  5168. */
  5169. FFT_SIZE: number;
  5170. /**
  5171. * Gets or sets the bar graph amplitude
  5172. * @ignorenaming
  5173. */
  5174. BARGRAPHAMPLITUDE: number;
  5175. /**
  5176. * Gets or sets the position of the debug canvas
  5177. * @ignorenaming
  5178. */
  5179. DEBUGCANVASPOS: {
  5180. x: number;
  5181. y: number;
  5182. };
  5183. /**
  5184. * Gets or sets the debug canvas size
  5185. * @ignorenaming
  5186. */
  5187. DEBUGCANVASSIZE: {
  5188. width: number;
  5189. height: number;
  5190. };
  5191. private _byteFreqs;
  5192. private _byteTime;
  5193. private _floatFreqs;
  5194. private _webAudioAnalyser;
  5195. private _debugCanvas;
  5196. private _debugCanvasContext;
  5197. private _scene;
  5198. private _registerFunc;
  5199. private _audioEngine;
  5200. /**
  5201. * Creates a new analyser
  5202. * @param scene defines hosting scene
  5203. */
  5204. constructor(scene: Scene);
  5205. /**
  5206. * Get the number of data values you will have to play with for the visualization
  5207. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5208. * @returns a number
  5209. */
  5210. getFrequencyBinCount(): number;
  5211. /**
  5212. * Gets the current frequency data as a byte array
  5213. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5214. * @returns a Uint8Array
  5215. */
  5216. getByteFrequencyData(): Uint8Array;
  5217. /**
  5218. * Gets the current waveform as a byte array
  5219. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5220. * @returns a Uint8Array
  5221. */
  5222. getByteTimeDomainData(): Uint8Array;
  5223. /**
  5224. * Gets the current frequency data as a float array
  5225. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5226. * @returns a Float32Array
  5227. */
  5228. getFloatFrequencyData(): Float32Array;
  5229. /**
  5230. * Renders the debug canvas
  5231. */
  5232. drawDebugCanvas(): void;
  5233. /**
  5234. * Stops rendering the debug canvas and removes it
  5235. */
  5236. stopDebugCanvas(): void;
  5237. /**
  5238. * Connects two audio nodes
  5239. * @param inputAudioNode defines first node to connect
  5240. * @param outputAudioNode defines second node to connect
  5241. */
  5242. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5243. /**
  5244. * Releases all associated resources
  5245. */
  5246. dispose(): void;
  5247. }
  5248. }
  5249. declare module BABYLON {
  5250. /**
  5251. * This represents an audio engine and it is responsible
  5252. * to play, synchronize and analyse sounds throughout the application.
  5253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5254. */
  5255. interface IAudioEngine extends IDisposable {
  5256. /**
  5257. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5258. */
  5259. readonly canUseWebAudio: boolean;
  5260. /**
  5261. * Gets the current AudioContext if available.
  5262. */
  5263. readonly audioContext: Nullable<AudioContext>;
  5264. /**
  5265. * The master gain node defines the global audio volume of your audio engine.
  5266. */
  5267. readonly masterGain: GainNode;
  5268. /**
  5269. * Gets whether or not mp3 are supported by your browser.
  5270. */
  5271. readonly isMP3supported: boolean;
  5272. /**
  5273. * Gets whether or not ogg are supported by your browser.
  5274. */
  5275. readonly isOGGsupported: boolean;
  5276. /**
  5277. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5278. * @ignoreNaming
  5279. */
  5280. WarnedWebAudioUnsupported: boolean;
  5281. /**
  5282. * Defines if the audio engine relies on a custom unlocked button.
  5283. * In this case, the embedded button will not be displayed.
  5284. */
  5285. useCustomUnlockedButton: boolean;
  5286. /**
  5287. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5288. */
  5289. readonly unlocked: boolean;
  5290. /**
  5291. * Event raised when audio has been unlocked on the browser.
  5292. */
  5293. onAudioUnlockedObservable: Observable<AudioEngine>;
  5294. /**
  5295. * Event raised when audio has been locked on the browser.
  5296. */
  5297. onAudioLockedObservable: Observable<AudioEngine>;
  5298. /**
  5299. * Flags the audio engine in Locked state.
  5300. * This happens due to new browser policies preventing audio to autoplay.
  5301. */
  5302. lock(): void;
  5303. /**
  5304. * Unlocks the audio engine once a user action has been done on the dom.
  5305. * This is helpful to resume play once browser policies have been satisfied.
  5306. */
  5307. unlock(): void;
  5308. }
  5309. /**
  5310. * This represents the default audio engine used in babylon.
  5311. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5313. */
  5314. class AudioEngine implements IAudioEngine {
  5315. private _audioContext;
  5316. private _audioContextInitialized;
  5317. private _muteButton;
  5318. private _hostElement;
  5319. /**
  5320. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5321. */
  5322. canUseWebAudio: boolean;
  5323. /**
  5324. * The master gain node defines the global audio volume of your audio engine.
  5325. */
  5326. masterGain: GainNode;
  5327. /**
  5328. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5329. * @ignoreNaming
  5330. */
  5331. WarnedWebAudioUnsupported: boolean;
  5332. /**
  5333. * Gets whether or not mp3 are supported by your browser.
  5334. */
  5335. isMP3supported: boolean;
  5336. /**
  5337. * Gets whether or not ogg are supported by your browser.
  5338. */
  5339. isOGGsupported: boolean;
  5340. /**
  5341. * Gets whether audio has been unlocked on the device.
  5342. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5343. * a user interaction has happened.
  5344. */
  5345. unlocked: boolean;
  5346. /**
  5347. * Defines if the audio engine relies on a custom unlocked button.
  5348. * In this case, the embedded button will not be displayed.
  5349. */
  5350. useCustomUnlockedButton: boolean;
  5351. /**
  5352. * Event raised when audio has been unlocked on the browser.
  5353. */
  5354. onAudioUnlockedObservable: Observable<AudioEngine>;
  5355. /**
  5356. * Event raised when audio has been locked on the browser.
  5357. */
  5358. onAudioLockedObservable: Observable<AudioEngine>;
  5359. /**
  5360. * Gets the current AudioContext if available.
  5361. */
  5362. readonly audioContext: Nullable<AudioContext>;
  5363. private _connectedAnalyser;
  5364. /**
  5365. * Instantiates a new audio engine.
  5366. *
  5367. * There should be only one per page as some browsers restrict the number
  5368. * of audio contexts you can create.
  5369. * @param hostElement defines the host element where to display the mute icon if necessary
  5370. */
  5371. constructor(hostElement?: Nullable<HTMLElement>);
  5372. /**
  5373. * Flags the audio engine in Locked state.
  5374. * This happens due to new browser policies preventing audio to autoplay.
  5375. */
  5376. lock(): void;
  5377. /**
  5378. * Unlocks the audio engine once a user action has been done on the dom.
  5379. * This is helpful to resume play once browser policies have been satisfied.
  5380. */
  5381. unlock(): void;
  5382. private _resumeAudioContext;
  5383. private _initializeAudioContext;
  5384. private _tryToRun;
  5385. private _triggerRunningState;
  5386. private _triggerSuspendedState;
  5387. private _displayMuteButton;
  5388. private _moveButtonToTopLeft;
  5389. private _onResize;
  5390. private _hideMuteButton;
  5391. /**
  5392. * Destroy and release the resources associated with the audio ccontext.
  5393. */
  5394. dispose(): void;
  5395. /**
  5396. * Gets the global volume sets on the master gain.
  5397. * @returns the global volume if set or -1 otherwise
  5398. */
  5399. getGlobalVolume(): number;
  5400. /**
  5401. * Sets the global volume of your experience (sets on the master gain).
  5402. * @param newVolume Defines the new global volume of the application
  5403. */
  5404. setGlobalVolume(newVolume: number): void;
  5405. /**
  5406. * Connect the audio engine to an audio analyser allowing some amazing
  5407. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5409. * @param analyser The analyser to connect to the engine
  5410. */
  5411. connectToAnalyser(analyser: Analyser): void;
  5412. }
  5413. }
  5414. declare module BABYLON {
  5415. interface AbstractScene {
  5416. /**
  5417. * The list of sounds used in the scene.
  5418. */
  5419. sounds: Nullable<Array<Sound>>;
  5420. }
  5421. interface Scene {
  5422. /**
  5423. * @hidden
  5424. * Backing field
  5425. */
  5426. _mainSoundTrack: SoundTrack;
  5427. /**
  5428. * The main sound track played by the scene.
  5429. * It cotains your primary collection of sounds.
  5430. */
  5431. mainSoundTrack: SoundTrack;
  5432. /**
  5433. * The list of sound tracks added to the scene
  5434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5435. */
  5436. soundTracks: Nullable<Array<SoundTrack>>;
  5437. /**
  5438. * Gets a sound using a given name
  5439. * @param name defines the name to search for
  5440. * @return the found sound or null if not found at all.
  5441. */
  5442. getSoundByName(name: string): Nullable<Sound>;
  5443. /**
  5444. * Gets or sets if audio support is enabled
  5445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5446. */
  5447. audioEnabled: boolean;
  5448. /**
  5449. * Gets or sets if audio will be output to headphones
  5450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5451. */
  5452. headphone: boolean;
  5453. }
  5454. /**
  5455. * Defines the sound scene component responsible to manage any sounds
  5456. * in a given scene.
  5457. */
  5458. class AudioSceneComponent implements ISceneSerializableComponent {
  5459. /**
  5460. * The component name helpfull to identify the component in the list of scene components.
  5461. */
  5462. readonly name: string;
  5463. /**
  5464. * The scene the component belongs to.
  5465. */
  5466. scene: Scene;
  5467. private _audioEnabled;
  5468. /**
  5469. * Gets whether audio is enabled or not.
  5470. * Please use related enable/disable method to switch state.
  5471. */
  5472. readonly audioEnabled: boolean;
  5473. private _headphone;
  5474. /**
  5475. * Gets whether audio is outputing to headphone or not.
  5476. * Please use the according Switch methods to change output.
  5477. */
  5478. readonly headphone: boolean;
  5479. /**
  5480. * Creates a new instance of the component for the given scene
  5481. * @param scene Defines the scene to register the component in
  5482. */
  5483. constructor(scene: Scene);
  5484. /**
  5485. * Registers the component in a given scene
  5486. */
  5487. register(): void;
  5488. /**
  5489. * Rebuilds the elements related to this component in case of
  5490. * context lost for instance.
  5491. */
  5492. rebuild(): void;
  5493. /**
  5494. * Serializes the component data to the specified json object
  5495. * @param serializationObject The object to serialize to
  5496. */
  5497. serialize(serializationObject: any): void;
  5498. /**
  5499. * Adds all the element from the container to the scene
  5500. * @param container the container holding the elements
  5501. */
  5502. addFromContainer(container: AbstractScene): void;
  5503. /**
  5504. * Removes all the elements in the container from the scene
  5505. * @param container contains the elements to remove
  5506. */
  5507. removeFromContainer(container: AbstractScene): void;
  5508. /**
  5509. * Disposes the component and the associated ressources.
  5510. */
  5511. dispose(): void;
  5512. /**
  5513. * Disables audio in the associated scene.
  5514. */
  5515. disableAudio(): void;
  5516. /**
  5517. * Enables audio in the associated scene.
  5518. */
  5519. enableAudio(): void;
  5520. /**
  5521. * Switch audio to headphone output.
  5522. */
  5523. switchAudioModeForHeadphones(): void;
  5524. /**
  5525. * Switch audio to normal speakers.
  5526. */
  5527. switchAudioModeForNormalSpeakers(): void;
  5528. private _afterRender;
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines a sound that can be played in the application.
  5534. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5536. */
  5537. class Sound {
  5538. /**
  5539. * The name of the sound in the scene.
  5540. */
  5541. name: string;
  5542. /**
  5543. * Does the sound autoplay once loaded.
  5544. */
  5545. autoplay: boolean;
  5546. /**
  5547. * Does the sound loop after it finishes playing once.
  5548. */
  5549. loop: boolean;
  5550. /**
  5551. * Does the sound use a custom attenuation curve to simulate the falloff
  5552. * happening when the source gets further away from the camera.
  5553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5554. */
  5555. useCustomAttenuation: boolean;
  5556. /**
  5557. * The sound track id this sound belongs to.
  5558. */
  5559. soundTrackId: number;
  5560. /**
  5561. * Is this sound currently played.
  5562. */
  5563. isPlaying: boolean;
  5564. /**
  5565. * Is this sound currently paused.
  5566. */
  5567. isPaused: boolean;
  5568. /**
  5569. * Does this sound enables spatial sound.
  5570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5571. */
  5572. spatialSound: boolean;
  5573. /**
  5574. * Define the reference distance the sound should be heard perfectly.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5576. */
  5577. refDistance: number;
  5578. /**
  5579. * Define the roll off factor of spatial sounds.
  5580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5581. */
  5582. rolloffFactor: number;
  5583. /**
  5584. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5586. */
  5587. maxDistance: number;
  5588. /**
  5589. * Define the distance attenuation model the sound will follow.
  5590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5591. */
  5592. distanceModel: string;
  5593. /**
  5594. * @hidden
  5595. * Back Compat
  5596. **/
  5597. onended: () => any;
  5598. /**
  5599. * Observable event when the current playing sound finishes.
  5600. */
  5601. onEndedObservable: Observable<Sound>;
  5602. private _panningModel;
  5603. private _playbackRate;
  5604. private _streaming;
  5605. private _startTime;
  5606. private _startOffset;
  5607. private _position;
  5608. /** @hidden */
  5609. _positionInEmitterSpace: boolean;
  5610. private _localDirection;
  5611. private _volume;
  5612. private _isReadyToPlay;
  5613. private _isDirectional;
  5614. private _readyToPlayCallback;
  5615. private _audioBuffer;
  5616. private _soundSource;
  5617. private _streamingSource;
  5618. private _soundPanner;
  5619. private _soundGain;
  5620. private _inputAudioNode;
  5621. private _outputAudioNode;
  5622. private _coneInnerAngle;
  5623. private _coneOuterAngle;
  5624. private _coneOuterGain;
  5625. private _scene;
  5626. private _connectedTransformNode;
  5627. private _customAttenuationFunction;
  5628. private _registerFunc;
  5629. private _isOutputConnected;
  5630. private _htmlAudioElement;
  5631. private _urlType;
  5632. /**
  5633. * Create a sound and attach it to a scene
  5634. * @param name Name of your sound
  5635. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5636. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5637. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5638. */
  5639. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5640. /**
  5641. * Release the sound and its associated resources
  5642. */
  5643. dispose(): void;
  5644. /**
  5645. * Gets if the sounds is ready to be played or not.
  5646. * @returns true if ready, otherwise false
  5647. */
  5648. isReady(): boolean;
  5649. private _soundLoaded;
  5650. /**
  5651. * Sets the data of the sound from an audiobuffer
  5652. * @param audioBuffer The audioBuffer containing the data
  5653. */
  5654. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5655. /**
  5656. * Updates the current sounds options such as maxdistance, loop...
  5657. * @param options A JSON object containing values named as the object properties
  5658. */
  5659. updateOptions(options: any): void;
  5660. private _createSpatialParameters;
  5661. private _updateSpatialParameters;
  5662. /**
  5663. * Switch the panning model to HRTF:
  5664. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5666. */
  5667. switchPanningModelToHRTF(): void;
  5668. /**
  5669. * Switch the panning model to Equal Power:
  5670. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5672. */
  5673. switchPanningModelToEqualPower(): void;
  5674. private _switchPanningModel;
  5675. /**
  5676. * Connect this sound to a sound track audio node like gain...
  5677. * @param soundTrackAudioNode the sound track audio node to connect to
  5678. */
  5679. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5680. /**
  5681. * Transform this sound into a directional source
  5682. * @param coneInnerAngle Size of the inner cone in degree
  5683. * @param coneOuterAngle Size of the outer cone in degree
  5684. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5685. */
  5686. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5687. /**
  5688. * Gets or sets the inner angle for the directional cone.
  5689. */
  5690. /**
  5691. * Gets or sets the inner angle for the directional cone.
  5692. */
  5693. directionalConeInnerAngle: number;
  5694. /**
  5695. * Gets or sets the outer angle for the directional cone.
  5696. */
  5697. /**
  5698. * Gets or sets the outer angle for the directional cone.
  5699. */
  5700. directionalConeOuterAngle: number;
  5701. /**
  5702. * Sets the position of the emitter if spatial sound is enabled
  5703. * @param newPosition Defines the new posisiton
  5704. */
  5705. setPosition(newPosition: Vector3): void;
  5706. /**
  5707. * Sets the local direction of the emitter if spatial sound is enabled
  5708. * @param newLocalDirection Defines the new local direction
  5709. */
  5710. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5711. private _updateDirection;
  5712. /** @hidden */
  5713. updateDistanceFromListener(): void;
  5714. /**
  5715. * Sets a new custom attenuation function for the sound.
  5716. * @param callback Defines the function used for the attenuation
  5717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5718. */
  5719. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5720. /**
  5721. * Play the sound
  5722. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5723. * @param offset (optional) Start the sound setting it at a specific time
  5724. */
  5725. play(time?: number, offset?: number): void;
  5726. private _onended;
  5727. /**
  5728. * Stop the sound
  5729. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5730. */
  5731. stop(time?: number): void;
  5732. /**
  5733. * Put the sound in pause
  5734. */
  5735. pause(): void;
  5736. /**
  5737. * Sets a dedicated volume for this sounds
  5738. * @param newVolume Define the new volume of the sound
  5739. * @param time Define in how long the sound should be at this value
  5740. */
  5741. setVolume(newVolume: number, time?: number): void;
  5742. /**
  5743. * Set the sound play back rate
  5744. * @param newPlaybackRate Define the playback rate the sound should be played at
  5745. */
  5746. setPlaybackRate(newPlaybackRate: number): void;
  5747. /**
  5748. * Gets the volume of the sound.
  5749. * @returns the volume of the sound
  5750. */
  5751. getVolume(): number;
  5752. /**
  5753. * Attach the sound to a dedicated mesh
  5754. * @param transformNode The transform node to connect the sound with
  5755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5756. */
  5757. attachToMesh(transformNode: TransformNode): void;
  5758. /**
  5759. * Detach the sound from the previously attached mesh
  5760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5761. */
  5762. detachFromMesh(): void;
  5763. private _onRegisterAfterWorldMatrixUpdate;
  5764. /**
  5765. * Clone the current sound in the scene.
  5766. * @returns the new sound clone
  5767. */
  5768. clone(): Nullable<Sound>;
  5769. /**
  5770. * Gets the current underlying audio buffer containing the data
  5771. * @returns the audio buffer
  5772. */
  5773. getAudioBuffer(): Nullable<AudioBuffer>;
  5774. /**
  5775. * Serializes the Sound in a JSON representation
  5776. * @returns the JSON representation of the sound
  5777. */
  5778. serialize(): any;
  5779. /**
  5780. * Parse a JSON representation of a sound to innstantiate in a given scene
  5781. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5782. * @param scene Define the scene the new parsed sound should be created in
  5783. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5784. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5785. * @returns the newly parsed sound
  5786. */
  5787. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5788. }
  5789. }
  5790. declare module BABYLON {
  5791. /**
  5792. * Options allowed during the creation of a sound track.
  5793. */
  5794. interface ISoundTrackOptions {
  5795. /**
  5796. * The volume the sound track should take during creation
  5797. */
  5798. volume?: number;
  5799. /**
  5800. * Define if the sound track is the main sound track of the scene
  5801. */
  5802. mainTrack?: boolean;
  5803. }
  5804. /**
  5805. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5806. * It will be also used in a future release to apply effects on a specific track.
  5807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5808. */
  5809. class SoundTrack {
  5810. /**
  5811. * The unique identifier of the sound track in the scene.
  5812. */
  5813. id: number;
  5814. /**
  5815. * The list of sounds included in the sound track.
  5816. */
  5817. soundCollection: Array<Sound>;
  5818. private _outputAudioNode;
  5819. private _scene;
  5820. private _isMainTrack;
  5821. private _connectedAnalyser;
  5822. private _options;
  5823. private _isInitialized;
  5824. /**
  5825. * Creates a new sound track.
  5826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5827. * @param scene Define the scene the sound track belongs to
  5828. * @param options
  5829. */
  5830. constructor(scene: Scene, options?: ISoundTrackOptions);
  5831. private _initializeSoundTrackAudioGraph;
  5832. /**
  5833. * Release the sound track and its associated resources
  5834. */
  5835. dispose(): void;
  5836. /**
  5837. * Adds a sound to this sound track
  5838. * @param sound define the cound to add
  5839. * @ignoreNaming
  5840. */
  5841. AddSound(sound: Sound): void;
  5842. /**
  5843. * Removes a sound to this sound track
  5844. * @param sound define the cound to remove
  5845. * @ignoreNaming
  5846. */
  5847. RemoveSound(sound: Sound): void;
  5848. /**
  5849. * Set a global volume for the full sound track.
  5850. * @param newVolume Define the new volume of the sound track
  5851. */
  5852. setVolume(newVolume: number): void;
  5853. /**
  5854. * Switch the panning model to HRTF:
  5855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5857. */
  5858. switchPanningModelToHRTF(): void;
  5859. /**
  5860. * Switch the panning model to Equal Power:
  5861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5863. */
  5864. switchPanningModelToEqualPower(): void;
  5865. /**
  5866. * Connect the sound track to an audio analyser allowing some amazing
  5867. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5869. * @param analyser The analyser to connect to the engine
  5870. */
  5871. connectToAnalyser(analyser: Analyser): void;
  5872. }
  5873. }
  5874. declare module BABYLON {
  5875. /**
  5876. * Wraps one or more Sound objects and selects one with random weight for playback.
  5877. */
  5878. class WeightedSound {
  5879. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5880. loop: boolean;
  5881. private _coneInnerAngle;
  5882. private _coneOuterAngle;
  5883. private _volume;
  5884. /** A Sound is currently playing. */
  5885. isPlaying: boolean;
  5886. /** A Sound is currently paused. */
  5887. isPaused: boolean;
  5888. private _sounds;
  5889. private _weights;
  5890. private _currentIndex?;
  5891. /**
  5892. * Creates a new WeightedSound from the list of sounds given.
  5893. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5894. * @param sounds Array of Sounds that will be selected from.
  5895. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5896. */
  5897. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5898. /**
  5899. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5900. */
  5901. /**
  5902. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5903. */
  5904. directionalConeInnerAngle: number;
  5905. /**
  5906. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5907. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5908. */
  5909. /**
  5910. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5911. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5912. */
  5913. directionalConeOuterAngle: number;
  5914. /**
  5915. * Playback volume.
  5916. */
  5917. /**
  5918. * Playback volume.
  5919. */
  5920. volume: number;
  5921. private _onended;
  5922. /**
  5923. * Suspend playback
  5924. */
  5925. pause(): void;
  5926. /**
  5927. * Stop playback
  5928. */
  5929. stop(): void;
  5930. /**
  5931. * Start playback.
  5932. * @param startOffset Position the clip head at a specific time in seconds.
  5933. */
  5934. play(startOffset?: number): void;
  5935. }
  5936. }
  5937. declare module BABYLON {
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module BABYLON {
  5983. /**
  5984. * Class used to store bone information
  5985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5986. */
  5987. class Bone extends Node {
  5988. /**
  5989. * defines the bone name
  5990. */
  5991. name: string;
  5992. private static _tmpVecs;
  5993. private static _tmpQuat;
  5994. private static _tmpMats;
  5995. /**
  5996. * Gets the list of child bones
  5997. */
  5998. children: Bone[];
  5999. /** Gets the animations associated with this bone */
  6000. animations: Animation[];
  6001. /**
  6002. * Gets or sets bone length
  6003. */
  6004. length: number;
  6005. /**
  6006. * @hidden Internal only
  6007. * Set this value to map this bone to a different index in the transform matrices
  6008. * Set this value to -1 to exclude the bone from the transform matrices
  6009. */
  6010. _index: Nullable<number>;
  6011. private _skeleton;
  6012. private _localMatrix;
  6013. private _restPose;
  6014. private _baseMatrix;
  6015. private _absoluteTransform;
  6016. private _invertedAbsoluteTransform;
  6017. private _parent;
  6018. private _scalingDeterminant;
  6019. private _worldTransform;
  6020. private _localScaling;
  6021. private _localRotation;
  6022. private _localPosition;
  6023. private _needToDecompose;
  6024. private _needToCompose;
  6025. /** @hidden */
  6026. /** @hidden */
  6027. _matrix: Matrix;
  6028. /**
  6029. * Create a new bone
  6030. * @param name defines the bone name
  6031. * @param skeleton defines the parent skeleton
  6032. * @param parentBone defines the parent (can be null if the bone is the root)
  6033. * @param localMatrix defines the local matrix
  6034. * @param restPose defines the rest pose matrix
  6035. * @param baseMatrix defines the base matrix
  6036. * @param index defines index of the bone in the hiearchy
  6037. */
  6038. constructor(
  6039. /**
  6040. * defines the bone name
  6041. */
  6042. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6043. /**
  6044. * Gets the parent skeleton
  6045. * @returns a skeleton
  6046. */
  6047. getSkeleton(): Skeleton;
  6048. /**
  6049. * Gets parent bone
  6050. * @returns a bone or null if the bone is the root of the bone hierarchy
  6051. */
  6052. getParent(): Nullable<Bone>;
  6053. /**
  6054. * Sets the parent bone
  6055. * @param parent defines the parent (can be null if the bone is the root)
  6056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6057. */
  6058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6059. /**
  6060. * Gets the local matrix
  6061. * @returns a matrix
  6062. */
  6063. getLocalMatrix(): Matrix;
  6064. /**
  6065. * Gets the base matrix (initial matrix which remains unchanged)
  6066. * @returns a matrix
  6067. */
  6068. getBaseMatrix(): Matrix;
  6069. /**
  6070. * Gets the rest pose matrix
  6071. * @returns a matrix
  6072. */
  6073. getRestPose(): Matrix;
  6074. /**
  6075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6076. */
  6077. getWorldMatrix(): Matrix;
  6078. /**
  6079. * Sets the local matrix to rest pose matrix
  6080. */
  6081. returnToRest(): void;
  6082. /**
  6083. * Gets the inverse of the absolute transform matrix.
  6084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6085. * @returns a matrix
  6086. */
  6087. getInvertedAbsoluteTransform(): Matrix;
  6088. /**
  6089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6090. * @returns a matrix
  6091. */
  6092. getAbsoluteTransform(): Matrix;
  6093. /** Gets or sets current position (in local space) */
  6094. position: Vector3;
  6095. /** Gets or sets current rotation (in local space) */
  6096. rotation: Vector3;
  6097. /** Gets or sets current rotation quaternion (in local space) */
  6098. rotationQuaternion: Quaternion;
  6099. /** Gets or sets current scaling (in local space) */
  6100. scaling: Vector3;
  6101. /**
  6102. * Gets the animation properties override
  6103. */
  6104. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6105. private _decompose;
  6106. private _compose;
  6107. /**
  6108. * Update the base and local matrices
  6109. * @param matrix defines the new base or local matrix
  6110. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6111. * @param updateLocalMatrix defines if the local matrix should be updated
  6112. */
  6113. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6114. /** @hidden */
  6115. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6116. /**
  6117. * Flag the bone as dirty (Forcing it to update everything)
  6118. */
  6119. markAsDirty(): void;
  6120. private _markAsDirtyAndCompose;
  6121. private _markAsDirtyAndDecompose;
  6122. /**
  6123. * Copy an animation range from another bone
  6124. * @param source defines the source bone
  6125. * @param rangeName defines the range name to copy
  6126. * @param frameOffset defines the frame offset
  6127. * @param rescaleAsRequired defines if rescaling must be applied if required
  6128. * @param skelDimensionsRatio defines the scaling ratio
  6129. * @returns true if operation was successful
  6130. */
  6131. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6132. /**
  6133. * Translate the bone in local or world space
  6134. * @param vec The amount to translate the bone
  6135. * @param space The space that the translation is in
  6136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6137. */
  6138. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6139. /**
  6140. * Set the postion of the bone in local or world space
  6141. * @param position The position to set the bone
  6142. * @param space The space that the position is in
  6143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6144. */
  6145. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6146. /**
  6147. * Set the absolute position of the bone (world space)
  6148. * @param position The position to set the bone
  6149. * @param mesh The mesh that this bone is attached to
  6150. */
  6151. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6152. /**
  6153. * Scale the bone on the x, y and z axes (in local space)
  6154. * @param x The amount to scale the bone on the x axis
  6155. * @param y The amount to scale the bone on the y axis
  6156. * @param z The amount to scale the bone on the z axis
  6157. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6158. */
  6159. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6160. /**
  6161. * Set the bone scaling in local space
  6162. * @param scale defines the scaling vector
  6163. */
  6164. setScale(scale: Vector3): void;
  6165. /**
  6166. * Gets the current scaling in local space
  6167. * @returns the current scaling vector
  6168. */
  6169. getScale(): Vector3;
  6170. /**
  6171. * Gets the current scaling in local space and stores it in a target vector
  6172. * @param result defines the target vector
  6173. */
  6174. getScaleToRef(result: Vector3): void;
  6175. /**
  6176. * Set the yaw, pitch, and roll of the bone in local or world space
  6177. * @param yaw The rotation of the bone on the y axis
  6178. * @param pitch The rotation of the bone on the x axis
  6179. * @param roll The rotation of the bone on the z axis
  6180. * @param space The space that the axes of rotation are in
  6181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6182. */
  6183. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6184. /**
  6185. * Add a rotation to the bone on an axis in local or world space
  6186. * @param axis The axis to rotate the bone on
  6187. * @param amount The amount to rotate the bone
  6188. * @param space The space that the axis is in
  6189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6190. */
  6191. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6192. /**
  6193. * Set the rotation of the bone to a particular axis angle in local or world space
  6194. * @param axis The axis to rotate the bone on
  6195. * @param angle The angle that the bone should be rotated to
  6196. * @param space The space that the axis is in
  6197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6198. */
  6199. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Set the euler rotation of the bone in local of world space
  6202. * @param rotation The euler rotation that the bone should be set to
  6203. * @param space The space that the rotation is in
  6204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6205. */
  6206. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6207. /**
  6208. * Set the quaternion rotation of the bone in local of world space
  6209. * @param quat The quaternion rotation that the bone should be set to
  6210. * @param space The space that the rotation is in
  6211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6212. */
  6213. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6214. /**
  6215. * Set the rotation matrix of the bone in local of world space
  6216. * @param rotMat The rotation matrix that the bone should be set to
  6217. * @param space The space that the rotation is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6221. private _rotateWithMatrix;
  6222. private _getNegativeRotationToRef;
  6223. /**
  6224. * Get the position of the bone in local or world space
  6225. * @param space The space that the returned position is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. * @returns The position of the bone
  6228. */
  6229. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6230. /**
  6231. * Copy the position of the bone to a vector3 in local or world space
  6232. * @param space The space that the returned position is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. * @param result The vector3 to copy the position to
  6235. */
  6236. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6237. /**
  6238. * Get the absolute position of the bone (world space)
  6239. * @param mesh The mesh that this bone is attached to
  6240. * @returns The absolute position of the bone
  6241. */
  6242. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6243. /**
  6244. * Copy the absolute position of the bone (world space) to the result param
  6245. * @param mesh The mesh that this bone is attached to
  6246. * @param result The vector3 to copy the absolute position to
  6247. */
  6248. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6249. /**
  6250. * Compute the absolute transforms of this bone and its children
  6251. */
  6252. computeAbsoluteTransforms(): void;
  6253. /**
  6254. * Get the world direction from an axis that is in the local space of the bone
  6255. * @param localAxis The local direction that is used to compute the world direction
  6256. * @param mesh The mesh that this bone is attached to
  6257. * @returns The world direction
  6258. */
  6259. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6260. /**
  6261. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6262. * @param localAxis The local direction that is used to compute the world direction
  6263. * @param mesh The mesh that this bone is attached to
  6264. * @param result The vector3 that the world direction will be copied to
  6265. */
  6266. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6267. /**
  6268. * Get the euler rotation of the bone in local or world space
  6269. * @param space The space that the rotation should be in
  6270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6271. * @returns The euler rotation
  6272. */
  6273. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6274. /**
  6275. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6276. * @param space The space that the rotation should be in
  6277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6278. * @param result The vector3 that the rotation should be copied to
  6279. */
  6280. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6281. /**
  6282. * Get the quaternion rotation of the bone in either local or world space
  6283. * @param space The space that the rotation should be in
  6284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6285. * @returns The quaternion rotation
  6286. */
  6287. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6288. /**
  6289. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6290. * @param space The space that the rotation should be in
  6291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6292. * @param result The quaternion that the rotation should be copied to
  6293. */
  6294. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6295. /**
  6296. * Get the rotation matrix of the bone in local or world space
  6297. * @param space The space that the rotation should be in
  6298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6299. * @returns The rotation matrix
  6300. */
  6301. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6302. /**
  6303. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6304. * @param space The space that the rotation should be in
  6305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6306. * @param result The quaternion that the rotation should be copied to
  6307. */
  6308. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6309. /**
  6310. * Get the world position of a point that is in the local space of the bone
  6311. * @param position The local position
  6312. * @param mesh The mesh that this bone is attached to
  6313. * @returns The world position
  6314. */
  6315. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6316. /**
  6317. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6318. * @param position The local position
  6319. * @param mesh The mesh that this bone is attached to
  6320. * @param result The vector3 that the world position should be copied to
  6321. */
  6322. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6323. /**
  6324. * Get the local position of a point that is in world space
  6325. * @param position The world position
  6326. * @param mesh The mesh that this bone is attached to
  6327. * @returns The local position
  6328. */
  6329. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6330. /**
  6331. * Get the local position of a point that is in world space and copy it to the result param
  6332. * @param position The world position
  6333. * @param mesh The mesh that this bone is attached to
  6334. * @param result The vector3 that the local position should be copied to
  6335. */
  6336. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6337. }
  6338. }
  6339. declare module BABYLON {
  6340. /**
  6341. * Class used to apply inverse kinematics to bones
  6342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6343. */
  6344. class BoneIKController {
  6345. private static _tmpVecs;
  6346. private static _tmpQuat;
  6347. private static _tmpMats;
  6348. /**
  6349. * Gets or sets the target mesh
  6350. */
  6351. targetMesh: AbstractMesh;
  6352. /** Gets or sets the mesh used as pole */
  6353. poleTargetMesh: AbstractMesh;
  6354. /**
  6355. * Gets or sets the bone used as pole
  6356. */
  6357. poleTargetBone: Nullable<Bone>;
  6358. /**
  6359. * Gets or sets the target position
  6360. */
  6361. targetPosition: Vector3;
  6362. /**
  6363. * Gets or sets the pole target position
  6364. */
  6365. poleTargetPosition: Vector3;
  6366. /**
  6367. * Gets or sets the pole target local offset
  6368. */
  6369. poleTargetLocalOffset: Vector3;
  6370. /**
  6371. * Gets or sets the pole angle
  6372. */
  6373. poleAngle: number;
  6374. /**
  6375. * Gets or sets the mesh associated with the controller
  6376. */
  6377. mesh: AbstractMesh;
  6378. /**
  6379. * 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)
  6380. */
  6381. slerpAmount: number;
  6382. private _bone1Quat;
  6383. private _bone1Mat;
  6384. private _bone2Ang;
  6385. private _bone1;
  6386. private _bone2;
  6387. private _bone1Length;
  6388. private _bone2Length;
  6389. private _maxAngle;
  6390. private _maxReach;
  6391. private _rightHandedSystem;
  6392. private _bendAxis;
  6393. private _slerping;
  6394. private _adjustRoll;
  6395. /**
  6396. * Gets or sets maximum allowed angle
  6397. */
  6398. maxAngle: number;
  6399. /**
  6400. * Creates a new BoneIKController
  6401. * @param mesh defines the mesh to control
  6402. * @param bone defines the bone to control
  6403. * @param options defines options to set up the controller
  6404. */
  6405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6406. targetMesh?: AbstractMesh;
  6407. poleTargetMesh?: AbstractMesh;
  6408. poleTargetBone?: Bone;
  6409. poleTargetLocalOffset?: Vector3;
  6410. poleAngle?: number;
  6411. bendAxis?: Vector3;
  6412. maxAngle?: number;
  6413. slerpAmount?: number;
  6414. });
  6415. private _setMaxAngle;
  6416. /**
  6417. * Force the controller to update the bones
  6418. */
  6419. update(): void;
  6420. }
  6421. }
  6422. declare module BABYLON {
  6423. /**
  6424. * Class used to make a bone look toward a point in space
  6425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6426. */
  6427. class BoneLookController {
  6428. private static _tmpVecs;
  6429. private static _tmpQuat;
  6430. private static _tmpMats;
  6431. /**
  6432. * The target Vector3 that the bone will look at
  6433. */
  6434. target: Vector3;
  6435. /**
  6436. * The mesh that the bone is attached to
  6437. */
  6438. mesh: AbstractMesh;
  6439. /**
  6440. * The bone that will be looking to the target
  6441. */
  6442. bone: Bone;
  6443. /**
  6444. * The up axis of the coordinate system that is used when the bone is rotated
  6445. */
  6446. upAxis: Vector3;
  6447. /**
  6448. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6449. */
  6450. upAxisSpace: Space;
  6451. /**
  6452. * Used to make an adjustment to the yaw of the bone
  6453. */
  6454. adjustYaw: number;
  6455. /**
  6456. * Used to make an adjustment to the pitch of the bone
  6457. */
  6458. adjustPitch: number;
  6459. /**
  6460. * Used to make an adjustment to the roll of the bone
  6461. */
  6462. adjustRoll: number;
  6463. /**
  6464. * 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)
  6465. */
  6466. slerpAmount: number;
  6467. private _minYaw;
  6468. private _maxYaw;
  6469. private _minPitch;
  6470. private _maxPitch;
  6471. private _minYawSin;
  6472. private _minYawCos;
  6473. private _maxYawSin;
  6474. private _maxYawCos;
  6475. private _midYawConstraint;
  6476. private _minPitchTan;
  6477. private _maxPitchTan;
  6478. private _boneQuat;
  6479. private _slerping;
  6480. private _transformYawPitch;
  6481. private _transformYawPitchInv;
  6482. private _firstFrameSkipped;
  6483. private _yawRange;
  6484. private _fowardAxis;
  6485. /**
  6486. * Gets or sets the minimum yaw angle that the bone can look to
  6487. */
  6488. minYaw: number;
  6489. /**
  6490. * Gets or sets the maximum yaw angle that the bone can look to
  6491. */
  6492. maxYaw: number;
  6493. /**
  6494. * Gets or sets the minimum pitch angle that the bone can look to
  6495. */
  6496. minPitch: number;
  6497. /**
  6498. * Gets or sets the maximum pitch angle that the bone can look to
  6499. */
  6500. maxPitch: number;
  6501. /**
  6502. * Create a BoneLookController
  6503. * @param mesh the mesh that the bone belongs to
  6504. * @param bone the bone that will be looking to the target
  6505. * @param target the target Vector3 to look at
  6506. * @param settings optional settings:
  6507. * * maxYaw: the maximum angle the bone will yaw to
  6508. * * minYaw: the minimum angle the bone will yaw to
  6509. * * maxPitch: the maximum angle the bone will pitch to
  6510. * * minPitch: the minimum angle the bone will yaw to
  6511. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6512. * * upAxis: the up axis of the coordinate system
  6513. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6514. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6515. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6516. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6517. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6518. * * adjustRoll: used to make an adjustment to the roll of the bone
  6519. **/
  6520. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6521. maxYaw?: number;
  6522. minYaw?: number;
  6523. maxPitch?: number;
  6524. minPitch?: number;
  6525. slerpAmount?: number;
  6526. upAxis?: Vector3;
  6527. upAxisSpace?: Space;
  6528. yawAxis?: Vector3;
  6529. pitchAxis?: Vector3;
  6530. adjustYaw?: number;
  6531. adjustPitch?: number;
  6532. adjustRoll?: number;
  6533. });
  6534. /**
  6535. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6536. */
  6537. update(): void;
  6538. private _getAngleDiff;
  6539. private _getAngleBetween;
  6540. private _isAngleBetween;
  6541. }
  6542. }
  6543. declare module BABYLON {
  6544. /**
  6545. * Class used to handle skinning animations
  6546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6547. */
  6548. class Skeleton implements IAnimatable {
  6549. /** defines the skeleton name */
  6550. name: string;
  6551. /** defines the skeleton Id */
  6552. id: string;
  6553. /**
  6554. * Gets the list of child bones
  6555. */
  6556. bones: Bone[];
  6557. /**
  6558. * Gets an estimate of the dimension of the skeleton at rest
  6559. */
  6560. dimensionsAtRest: Vector3;
  6561. /**
  6562. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6563. */
  6564. needInitialSkinMatrix: boolean;
  6565. /**
  6566. * Gets the list of animations attached to this skeleton
  6567. */
  6568. animations: Array<Animation>;
  6569. private _scene;
  6570. private _isDirty;
  6571. private _transformMatrices;
  6572. private _transformMatrixTexture;
  6573. private _meshesWithPoseMatrix;
  6574. private _animatables;
  6575. private _identity;
  6576. private _synchronizedWithMesh;
  6577. private _ranges;
  6578. private _lastAbsoluteTransformsUpdateId;
  6579. private _canUseTextureForBones;
  6580. /**
  6581. * Specifies if the skeleton should be serialized
  6582. */
  6583. doNotSerialize: boolean;
  6584. /**
  6585. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6586. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6587. */
  6588. useTextureToStoreBoneMatrices: boolean;
  6589. private _animationPropertiesOverride;
  6590. /**
  6591. * Gets or sets the animation properties override
  6592. */
  6593. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6594. /**
  6595. * An observable triggered before computing the skeleton's matrices
  6596. */
  6597. onBeforeComputeObservable: Observable<Skeleton>;
  6598. /**
  6599. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6600. */
  6601. readonly isUsingTextureForMatrices: boolean;
  6602. /**
  6603. * Creates a new skeleton
  6604. * @param name defines the skeleton name
  6605. * @param id defines the skeleton Id
  6606. * @param scene defines the hosting scene
  6607. */
  6608. constructor(
  6609. /** defines the skeleton name */
  6610. name: string,
  6611. /** defines the skeleton Id */
  6612. id: string, scene: Scene);
  6613. /**
  6614. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6615. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6616. * @returns a Float32Array containing matrices data
  6617. */
  6618. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6619. /**
  6620. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6621. * @returns a raw texture containing the data
  6622. */
  6623. getTransformMatrixTexture(): Nullable<RawTexture>;
  6624. /**
  6625. * Gets the current hosting scene
  6626. * @returns a scene object
  6627. */
  6628. getScene(): Scene;
  6629. /**
  6630. * Gets a string representing the current skeleton data
  6631. * @param fullDetails defines a boolean indicating if we want a verbose version
  6632. * @returns a string representing the current skeleton data
  6633. */
  6634. toString(fullDetails?: boolean): string;
  6635. /**
  6636. * Get bone's index searching by name
  6637. * @param name defines bone's name to search for
  6638. * @return the indice of the bone. Returns -1 if not found
  6639. */
  6640. getBoneIndexByName(name: string): number;
  6641. /**
  6642. * Creater a new animation range
  6643. * @param name defines the name of the range
  6644. * @param from defines the start key
  6645. * @param to defines the end key
  6646. */
  6647. createAnimationRange(name: string, from: number, to: number): void;
  6648. /**
  6649. * Delete a specific animation range
  6650. * @param name defines the name of the range
  6651. * @param deleteFrames defines if frames must be removed as well
  6652. */
  6653. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6654. /**
  6655. * Gets a specific animation range
  6656. * @param name defines the name of the range to look for
  6657. * @returns the requested animation range or null if not found
  6658. */
  6659. getAnimationRange(name: string): Nullable<AnimationRange>;
  6660. /**
  6661. * Gets the list of all animation ranges defined on this skeleton
  6662. * @returns an array
  6663. */
  6664. getAnimationRanges(): Nullable<AnimationRange>[];
  6665. /**
  6666. * Copy animation range from a source skeleton.
  6667. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6668. * @param source defines the source skeleton
  6669. * @param name defines the name of the range to copy
  6670. * @param rescaleAsRequired defines if rescaling must be applied if required
  6671. * @returns true if operation was successful
  6672. */
  6673. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6674. /**
  6675. * Forces the skeleton to go to rest pose
  6676. */
  6677. returnToRest(): void;
  6678. private _getHighestAnimationFrame;
  6679. /**
  6680. * Begin a specific animation range
  6681. * @param name defines the name of the range to start
  6682. * @param loop defines if looping must be turned on (false by default)
  6683. * @param speedRatio defines the speed ratio to apply (1 by default)
  6684. * @param onAnimationEnd defines a callback which will be called when animation will end
  6685. * @returns a new animatable
  6686. */
  6687. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6688. /** @hidden */
  6689. _markAsDirty(): void;
  6690. /** @hidden */
  6691. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6692. /** @hidden */
  6693. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6694. private _computeTransformMatrices;
  6695. /**
  6696. * Build all resources required to render a skeleton
  6697. */
  6698. prepare(): void;
  6699. /**
  6700. * Gets the list of animatables currently running for this skeleton
  6701. * @returns an array of animatables
  6702. */
  6703. getAnimatables(): IAnimatable[];
  6704. /**
  6705. * Clone the current skeleton
  6706. * @param name defines the name of the new skeleton
  6707. * @param id defines the id of the enw skeleton
  6708. * @returns the new skeleton
  6709. */
  6710. clone(name: string, id: string): Skeleton;
  6711. /**
  6712. * Enable animation blending for this skeleton
  6713. * @param blendingSpeed defines the blending speed to apply
  6714. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6715. */
  6716. enableBlending(blendingSpeed?: number): void;
  6717. /**
  6718. * Releases all resources associated with the current skeleton
  6719. */
  6720. dispose(): void;
  6721. /**
  6722. * Serialize the skeleton in a JSON object
  6723. * @returns a JSON object
  6724. */
  6725. serialize(): any;
  6726. /**
  6727. * Creates a new skeleton from serialized data
  6728. * @param parsedSkeleton defines the serialized data
  6729. * @param scene defines the hosting scene
  6730. * @returns a new skeleton
  6731. */
  6732. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6733. /**
  6734. * Compute all node absolute transforms
  6735. * @param forceUpdate defines if computation must be done even if cache is up to date
  6736. */
  6737. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6738. /**
  6739. * Gets the root pose matrix
  6740. * @returns a matrix
  6741. */
  6742. getPoseMatrix(): Nullable<Matrix>;
  6743. /**
  6744. * Sorts bones per internal index
  6745. */
  6746. sortBones(): void;
  6747. private _sortBones;
  6748. }
  6749. }
  6750. declare module BABYLON {
  6751. /**
  6752. * This represents an orbital type of camera.
  6753. *
  6754. * 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.
  6755. * 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.
  6756. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6757. */
  6758. class ArcRotateCamera extends TargetCamera {
  6759. /**
  6760. * Defines the rotation angle of the camera along the longitudinal axis.
  6761. */
  6762. alpha: number;
  6763. /**
  6764. * Defines the rotation angle of the camera along the latitudinal axis.
  6765. */
  6766. beta: number;
  6767. /**
  6768. * Defines the radius of the camera from it s target point.
  6769. */
  6770. radius: number;
  6771. protected _target: Vector3;
  6772. protected _targetHost: Nullable<AbstractMesh>;
  6773. /**
  6774. * Defines the target point of the camera.
  6775. * The camera looks towards it form the radius distance.
  6776. */
  6777. target: Vector3;
  6778. /**
  6779. * Current inertia value on the longitudinal axis.
  6780. * The bigger this number the longer it will take for the camera to stop.
  6781. */
  6782. inertialAlphaOffset: number;
  6783. /**
  6784. * Current inertia value on the latitudinal axis.
  6785. * The bigger this number the longer it will take for the camera to stop.
  6786. */
  6787. inertialBetaOffset: number;
  6788. /**
  6789. * Current inertia value on the radius axis.
  6790. * The bigger this number the longer it will take for the camera to stop.
  6791. */
  6792. inertialRadiusOffset: number;
  6793. /**
  6794. * Minimum allowed angle on the longitudinal axis.
  6795. * This can help limiting how the Camera is able to move in the scene.
  6796. */
  6797. lowerAlphaLimit: Nullable<number>;
  6798. /**
  6799. * Maximum allowed angle on the longitudinal axis.
  6800. * This can help limiting how the Camera is able to move in the scene.
  6801. */
  6802. upperAlphaLimit: Nullable<number>;
  6803. /**
  6804. * Minimum allowed angle on the latitudinal axis.
  6805. * This can help limiting how the Camera is able to move in the scene.
  6806. */
  6807. lowerBetaLimit: number;
  6808. /**
  6809. * Maximum allowed angle on the latitudinal axis.
  6810. * This can help limiting how the Camera is able to move in the scene.
  6811. */
  6812. upperBetaLimit: number;
  6813. /**
  6814. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6815. * This can help limiting how the Camera is able to move in the scene.
  6816. */
  6817. lowerRadiusLimit: Nullable<number>;
  6818. /**
  6819. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6820. * This can help limiting how the Camera is able to move in the scene.
  6821. */
  6822. upperRadiusLimit: Nullable<number>;
  6823. /**
  6824. * Defines the current inertia value used during panning of the camera along the X axis.
  6825. */
  6826. inertialPanningX: number;
  6827. /**
  6828. * Defines the current inertia value used during panning of the camera along the Y axis.
  6829. */
  6830. inertialPanningY: number;
  6831. /**
  6832. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6833. * Basically if your fingers moves away from more than this distance you will be considered
  6834. * in pinch mode.
  6835. */
  6836. pinchToPanMaxDistance: number;
  6837. /**
  6838. * Defines the maximum distance the camera can pan.
  6839. * This could help keeping the cammera always in your scene.
  6840. */
  6841. panningDistanceLimit: Nullable<number>;
  6842. /**
  6843. * Defines the target of the camera before paning.
  6844. */
  6845. panningOriginTarget: Vector3;
  6846. /**
  6847. * Defines the value of the inertia used during panning.
  6848. * 0 would mean stop inertia and one would mean no decelleration at all.
  6849. */
  6850. panningInertia: number;
  6851. /**
  6852. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6853. */
  6854. angularSensibilityX: number;
  6855. /**
  6856. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6857. */
  6858. angularSensibilityY: number;
  6859. /**
  6860. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6861. */
  6862. pinchPrecision: number;
  6863. /**
  6864. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6865. * It will be used instead of pinchDeltaPrecision if different from 0.
  6866. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6867. */
  6868. pinchDeltaPercentage: number;
  6869. /**
  6870. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6871. */
  6872. panningSensibility: number;
  6873. /**
  6874. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6875. */
  6876. keysUp: number[];
  6877. /**
  6878. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6879. */
  6880. keysDown: number[];
  6881. /**
  6882. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6883. */
  6884. keysLeft: number[];
  6885. /**
  6886. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6887. */
  6888. keysRight: number[];
  6889. /**
  6890. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6891. */
  6892. wheelPrecision: number;
  6893. /**
  6894. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6895. * It will be used instead of pinchDeltaPrecision if different from 0.
  6896. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6897. */
  6898. wheelDeltaPercentage: number;
  6899. /**
  6900. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6901. */
  6902. zoomOnFactor: number;
  6903. /**
  6904. * Defines a screen offset for the camera position.
  6905. */
  6906. targetScreenOffset: Vector2;
  6907. /**
  6908. * Allows the camera to be completely reversed.
  6909. * If false the camera can not arrive upside down.
  6910. */
  6911. allowUpsideDown: boolean;
  6912. /**
  6913. * Define if double tap/click is used to restore the previously saved state of the camera.
  6914. */
  6915. useInputToRestoreState: boolean;
  6916. /** @hidden */
  6917. _viewMatrix: Matrix;
  6918. /** @hidden */
  6919. _useCtrlForPanning: boolean;
  6920. /** @hidden */
  6921. _panningMouseButton: number;
  6922. /**
  6923. * Defines the inpute associated to the camera.
  6924. */
  6925. inputs: ArcRotateCameraInputsManager;
  6926. /** @hidden */
  6927. _reset: () => void;
  6928. /**
  6929. * Defines the allowed panning axis.
  6930. */
  6931. panningAxis: Vector3;
  6932. protected _localDirection: Vector3;
  6933. protected _transformedDirection: Vector3;
  6934. private _bouncingBehavior;
  6935. /**
  6936. * Gets the bouncing behavior of the camera if it has been enabled.
  6937. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6938. */
  6939. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6940. /**
  6941. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6943. */
  6944. useBouncingBehavior: boolean;
  6945. private _framingBehavior;
  6946. /**
  6947. * Gets the framing behavior of the camera if it has been enabled.
  6948. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6949. */
  6950. readonly framingBehavior: Nullable<FramingBehavior>;
  6951. /**
  6952. * Defines if the framing behavior of the camera is enabled on the camera.
  6953. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6954. */
  6955. useFramingBehavior: boolean;
  6956. private _autoRotationBehavior;
  6957. /**
  6958. * Gets the auto rotation behavior of the camera if it has been enabled.
  6959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6960. */
  6961. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6962. /**
  6963. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6965. */
  6966. useAutoRotationBehavior: boolean;
  6967. /**
  6968. * Observable triggered when the mesh target has been changed on the camera.
  6969. */
  6970. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6971. /**
  6972. * Event raised when the camera is colliding with a mesh.
  6973. */
  6974. onCollide: (collidedMesh: AbstractMesh) => void;
  6975. /**
  6976. * Defines whether the camera should check collision with the objects oh the scene.
  6977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6978. */
  6979. checkCollisions: boolean;
  6980. /**
  6981. * Defines the collision radius of the camera.
  6982. * This simulates a sphere around the camera.
  6983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6984. */
  6985. collisionRadius: Vector3;
  6986. protected _collider: Collider;
  6987. protected _previousPosition: Vector3;
  6988. protected _collisionVelocity: Vector3;
  6989. protected _newPosition: Vector3;
  6990. protected _previousAlpha: number;
  6991. protected _previousBeta: number;
  6992. protected _previousRadius: number;
  6993. protected _collisionTriggered: boolean;
  6994. protected _targetBoundingCenter: Nullable<Vector3>;
  6995. private _computationVector;
  6996. /**
  6997. * Instantiates a new ArcRotateCamera in a given scene
  6998. * @param name Defines the name of the camera
  6999. * @param alpha Defines the camera rotation along the logitudinal axis
  7000. * @param beta Defines the camera rotation along the latitudinal axis
  7001. * @param radius Defines the camera distance from its target
  7002. * @param target Defines the camera target
  7003. * @param scene Defines the scene the camera belongs to
  7004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7005. */
  7006. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7007. /** @hidden */
  7008. _initCache(): void;
  7009. /** @hidden */
  7010. _updateCache(ignoreParentClass?: boolean): void;
  7011. protected _getTargetPosition(): Vector3;
  7012. private _storedAlpha;
  7013. private _storedBeta;
  7014. private _storedRadius;
  7015. private _storedTarget;
  7016. /**
  7017. * Stores the current state of the camera (alpha, beta, radius and target)
  7018. * @returns the camera itself
  7019. */
  7020. storeState(): Camera;
  7021. /**
  7022. * @hidden
  7023. * Restored camera state. You must call storeState() first
  7024. */
  7025. _restoreStateValues(): boolean;
  7026. /** @hidden */
  7027. _isSynchronizedViewMatrix(): boolean;
  7028. /**
  7029. * Attached controls to the current camera.
  7030. * @param element Defines the element the controls should be listened from
  7031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7032. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7033. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7034. */
  7035. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7036. /**
  7037. * Detach the current controls from the camera.
  7038. * The camera will stop reacting to inputs.
  7039. * @param element Defines the element to stop listening the inputs from
  7040. */
  7041. detachControl(element: HTMLElement): void;
  7042. /** @hidden */
  7043. _checkInputs(): void;
  7044. protected _checkLimits(): void;
  7045. /**
  7046. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7047. */
  7048. rebuildAnglesAndRadius(): void;
  7049. /**
  7050. * Use a position to define the current camera related information like aplha, beta and radius
  7051. * @param position Defines the position to set the camera at
  7052. */
  7053. setPosition(position: Vector3): void;
  7054. /**
  7055. * Defines the target the camera should look at.
  7056. * This will automatically adapt alpha beta and radius to fit within the new target.
  7057. * @param target Defines the new target as a Vector or a mesh
  7058. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7059. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7060. */
  7061. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7062. /** @hidden */
  7063. _getViewMatrix(): Matrix;
  7064. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7065. /**
  7066. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7067. * @param meshes Defines the mesh to zoom on
  7068. * @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)
  7069. */
  7070. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7071. /**
  7072. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7073. * The target will be changed but the radius
  7074. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7075. * @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)
  7076. */
  7077. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7078. min: Vector3;
  7079. max: Vector3;
  7080. distance: number;
  7081. }, doNotUpdateMaxZ?: boolean): void;
  7082. /**
  7083. * @override
  7084. * Override Camera.createRigCamera
  7085. */
  7086. createRigCamera(name: string, cameraIndex: number): Camera;
  7087. /**
  7088. * @hidden
  7089. * @override
  7090. * Override Camera._updateRigCameras
  7091. */
  7092. _updateRigCameras(): void;
  7093. /**
  7094. * Destroy the camera and release the current resources hold by it.
  7095. */
  7096. dispose(): void;
  7097. /**
  7098. * Gets the current object class name.
  7099. * @return the class name
  7100. */
  7101. getClassName(): string;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Default Inputs manager for the ArcRotateCamera.
  7107. * It groups all the default supported inputs for ease of use.
  7108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7109. */
  7110. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7111. /**
  7112. * Instantiates a new ArcRotateCameraInputsManager.
  7113. * @param camera Defines the camera the inputs belong to
  7114. */
  7115. constructor(camera: ArcRotateCamera);
  7116. /**
  7117. * Add mouse wheel input support to the input manager.
  7118. * @returns the current input manager
  7119. */
  7120. addMouseWheel(): ArcRotateCameraInputsManager;
  7121. /**
  7122. * Add pointers input support to the input manager.
  7123. * @returns the current input manager
  7124. */
  7125. addPointers(): ArcRotateCameraInputsManager;
  7126. /**
  7127. * Add keyboard input support to the input manager.
  7128. * @returns the current input manager
  7129. */
  7130. addKeyboard(): ArcRotateCameraInputsManager;
  7131. /**
  7132. * Add orientation input support to the input manager.
  7133. * @returns the current input manager
  7134. */
  7135. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7136. }
  7137. }
  7138. declare module BABYLON {
  7139. /**
  7140. * This is the base class of all the camera used in the application.
  7141. * @see http://doc.babylonjs.com/features/cameras
  7142. */
  7143. class Camera extends Node {
  7144. /**
  7145. * This is the default projection mode used by the cameras.
  7146. * It helps recreating a feeling of perspective and better appreciate depth.
  7147. * This is the best way to simulate real life cameras.
  7148. */
  7149. static readonly PERSPECTIVE_CAMERA: number;
  7150. /**
  7151. * This helps creating camera with an orthographic mode.
  7152. * 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.
  7153. */
  7154. static readonly ORTHOGRAPHIC_CAMERA: number;
  7155. /**
  7156. * This is the default FOV mode for perspective cameras.
  7157. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7158. */
  7159. static readonly FOVMODE_VERTICAL_FIXED: number;
  7160. /**
  7161. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7162. */
  7163. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7164. /**
  7165. * This specifies ther is no need for a camera rig.
  7166. * Basically only one eye is rendered corresponding to the camera.
  7167. */
  7168. static readonly RIG_MODE_NONE: number;
  7169. /**
  7170. * Simulates a camera Rig with one blue eye and one red eye.
  7171. * This can be use with 3d blue and red glasses.
  7172. */
  7173. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7174. /**
  7175. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7176. */
  7177. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7178. /**
  7179. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7180. */
  7181. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7182. /**
  7183. * Defines that both eyes of the camera will be rendered over under each other.
  7184. */
  7185. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7186. /**
  7187. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7188. */
  7189. static readonly RIG_MODE_VR: number;
  7190. /**
  7191. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7192. */
  7193. static readonly RIG_MODE_WEBVR: number;
  7194. /**
  7195. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7196. */
  7197. static readonly RIG_MODE_CUSTOM: number;
  7198. /**
  7199. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7200. */
  7201. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7202. /**
  7203. * @hidden
  7204. * Might be removed once multiview will be a thing
  7205. */
  7206. static UseAlternateWebVRRendering: boolean;
  7207. /**
  7208. * Define the input manager associated with the camera.
  7209. */
  7210. inputs: CameraInputsManager<Camera>;
  7211. /**
  7212. * Define the current local position of the camera in the scene
  7213. */
  7214. position: Vector3;
  7215. /**
  7216. * The vector the camera should consider as up.
  7217. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7218. */
  7219. upVector: Vector3;
  7220. /**
  7221. * Define the current limit on the left side for an orthographic camera
  7222. * In scene unit
  7223. */
  7224. orthoLeft: Nullable<number>;
  7225. /**
  7226. * Define the current limit on the right side for an orthographic camera
  7227. * In scene unit
  7228. */
  7229. orthoRight: Nullable<number>;
  7230. /**
  7231. * Define the current limit on the bottom side for an orthographic camera
  7232. * In scene unit
  7233. */
  7234. orthoBottom: Nullable<number>;
  7235. /**
  7236. * Define the current limit on the top side for an orthographic camera
  7237. * In scene unit
  7238. */
  7239. orthoTop: Nullable<number>;
  7240. /**
  7241. * Field Of View is set in Radians. (default is 0.8)
  7242. */
  7243. fov: number;
  7244. /**
  7245. * Define the minimum distance the camera can see from.
  7246. * This is important to note that the depth buffer are not infinite and the closer it starts
  7247. * the more your scene might encounter depth fighting issue.
  7248. */
  7249. minZ: number;
  7250. /**
  7251. * Define the maximum distance the camera can see to.
  7252. * This is important to note that the depth buffer are not infinite and the further it end
  7253. * the more your scene might encounter depth fighting issue.
  7254. */
  7255. maxZ: number;
  7256. /**
  7257. * Define the default inertia of the camera.
  7258. * This helps giving a smooth feeling to the camera movement.
  7259. */
  7260. inertia: number;
  7261. /**
  7262. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7263. */
  7264. mode: number;
  7265. /**
  7266. * Define wether the camera is intermediate.
  7267. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7268. */
  7269. isIntermediate: boolean;
  7270. /**
  7271. * Define the viewport of the camera.
  7272. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7273. */
  7274. viewport: Viewport;
  7275. /**
  7276. * Restricts the camera to viewing objects with the same layerMask.
  7277. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7278. */
  7279. layerMask: number;
  7280. /**
  7281. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7282. */
  7283. fovMode: number;
  7284. /**
  7285. * Rig mode of the camera.
  7286. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7287. * This is normally controlled byt the camera themselves as internal use.
  7288. */
  7289. cameraRigMode: number;
  7290. /**
  7291. * Defines the distance between both "eyes" in case of a RIG
  7292. */
  7293. interaxialDistance: number;
  7294. /**
  7295. * Defines if stereoscopic rendering is done side by side or over under.
  7296. */
  7297. isStereoscopicSideBySide: boolean;
  7298. /**
  7299. * 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
  7300. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7301. * else in the scene.
  7302. */
  7303. customRenderTargets: RenderTargetTexture[];
  7304. /**
  7305. * When set, the camera will render to this render target instead of the default canvas
  7306. */
  7307. outputRenderTarget: Nullable<RenderTargetTexture>;
  7308. /**
  7309. * Observable triggered when the camera view matrix has changed.
  7310. */
  7311. onViewMatrixChangedObservable: Observable<Camera>;
  7312. /**
  7313. * Observable triggered when the camera Projection matrix has changed.
  7314. */
  7315. onProjectionMatrixChangedObservable: Observable<Camera>;
  7316. /**
  7317. * Observable triggered when the inputs have been processed.
  7318. */
  7319. onAfterCheckInputsObservable: Observable<Camera>;
  7320. /**
  7321. * Observable triggered when reset has been called and applied to the camera.
  7322. */
  7323. onRestoreStateObservable: Observable<Camera>;
  7324. /** @hidden */
  7325. _cameraRigParams: any;
  7326. /** @hidden */
  7327. _rigCameras: Camera[];
  7328. /** @hidden */
  7329. _rigPostProcess: Nullable<PostProcess>;
  7330. protected _webvrViewMatrix: Matrix;
  7331. /** @hidden */
  7332. _skipRendering: boolean;
  7333. /** @hidden */
  7334. _alternateCamera: Camera;
  7335. /** @hidden */
  7336. _projectionMatrix: Matrix;
  7337. /** @hidden */
  7338. _postProcesses: Nullable<PostProcess>[];
  7339. /** @hidden */
  7340. _activeMeshes: SmartArray<AbstractMesh>;
  7341. protected _globalPosition: Vector3;
  7342. /** hidden */
  7343. _computedViewMatrix: Matrix;
  7344. private _doNotComputeProjectionMatrix;
  7345. private _transformMatrix;
  7346. private _frustumPlanes;
  7347. private _refreshFrustumPlanes;
  7348. private _storedFov;
  7349. private _stateStored;
  7350. /**
  7351. * Instantiates a new camera object.
  7352. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7353. * @see http://doc.babylonjs.com/features/cameras
  7354. * @param name Defines the name of the camera in the scene
  7355. * @param position Defines the position of the camera
  7356. * @param scene Defines the scene the camera belongs too
  7357. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7358. */
  7359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7360. /**
  7361. * Store current camera state (fov, position, etc..)
  7362. * @returns the camera
  7363. */
  7364. storeState(): Camera;
  7365. /**
  7366. * Restores the camera state values if it has been stored. You must call storeState() first
  7367. */
  7368. protected _restoreStateValues(): boolean;
  7369. /**
  7370. * Restored camera state. You must call storeState() first.
  7371. * @returns true if restored and false otherwise
  7372. */
  7373. restoreState(): boolean;
  7374. /**
  7375. * Gets the class name of the camera.
  7376. * @returns the class name
  7377. */
  7378. getClassName(): string;
  7379. /**
  7380. * Gets a string representation of the camera useful for debug purpose.
  7381. * @param fullDetails Defines that a more verboe level of logging is required
  7382. * @returns the string representation
  7383. */
  7384. toString(fullDetails?: boolean): string;
  7385. /**
  7386. * Gets the current world space position of the camera.
  7387. */
  7388. readonly globalPosition: Vector3;
  7389. /**
  7390. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7391. * @returns the active meshe list
  7392. */
  7393. getActiveMeshes(): SmartArray<AbstractMesh>;
  7394. /**
  7395. * Check wether a mesh is part of the current active mesh list of the camera
  7396. * @param mesh Defines the mesh to check
  7397. * @returns true if active, false otherwise
  7398. */
  7399. isActiveMesh(mesh: Mesh): boolean;
  7400. /**
  7401. * Is this camera ready to be used/rendered
  7402. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7403. * @return true if the camera is ready
  7404. */
  7405. isReady(completeCheck?: boolean): boolean;
  7406. /** @hidden */
  7407. _initCache(): void;
  7408. /** @hidden */
  7409. _updateCache(ignoreParentClass?: boolean): void;
  7410. /** @hidden */
  7411. _isSynchronized(): boolean;
  7412. /** @hidden */
  7413. _isSynchronizedViewMatrix(): boolean;
  7414. /** @hidden */
  7415. _isSynchronizedProjectionMatrix(): boolean;
  7416. /**
  7417. * Attach the input controls to a specific dom element to get the input from.
  7418. * @param element Defines the element the controls should be listened from
  7419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7420. */
  7421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7422. /**
  7423. * Detach the current controls from the specified dom element.
  7424. * @param element Defines the element to stop listening the inputs from
  7425. */
  7426. detachControl(element: HTMLElement): void;
  7427. /**
  7428. * Update the camera state according to the different inputs gathered during the frame.
  7429. */
  7430. update(): void;
  7431. /** @hidden */
  7432. _checkInputs(): void;
  7433. /** @hidden */
  7434. readonly rigCameras: Camera[];
  7435. /**
  7436. * Gets the post process used by the rig cameras
  7437. */
  7438. readonly rigPostProcess: Nullable<PostProcess>;
  7439. /**
  7440. * Internal, gets the first post proces.
  7441. * @returns the first post process to be run on this camera.
  7442. */
  7443. _getFirstPostProcess(): Nullable<PostProcess>;
  7444. private _cascadePostProcessesToRigCams;
  7445. /**
  7446. * Attach a post process to the camera.
  7447. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7448. * @param postProcess The post process to attach to the camera
  7449. * @param insertAt The position of the post process in case several of them are in use in the scene
  7450. * @returns the position the post process has been inserted at
  7451. */
  7452. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7453. /**
  7454. * Detach a post process to the camera.
  7455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7456. * @param postProcess The post process to detach from the camera
  7457. */
  7458. detachPostProcess(postProcess: PostProcess): void;
  7459. /**
  7460. * Gets the current world matrix of the camera
  7461. */
  7462. getWorldMatrix(): Matrix;
  7463. /** @hidden */
  7464. protected _getViewMatrix(): Matrix;
  7465. /**
  7466. * Gets the current view matrix of the camera.
  7467. * @param force forces the camera to recompute the matrix without looking at the cached state
  7468. * @returns the view matrix
  7469. */
  7470. getViewMatrix(force?: boolean): Matrix;
  7471. /**
  7472. * Freeze the projection matrix.
  7473. * It will prevent the cache check of the camera projection compute and can speed up perf
  7474. * if no parameter of the camera are meant to change
  7475. * @param projection Defines manually a projection if necessary
  7476. */
  7477. freezeProjectionMatrix(projection?: Matrix): void;
  7478. /**
  7479. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7480. */
  7481. unfreezeProjectionMatrix(): void;
  7482. /**
  7483. * Gets the current projection matrix of the camera.
  7484. * @param force forces the camera to recompute the matrix without looking at the cached state
  7485. * @returns the projection matrix
  7486. */
  7487. getProjectionMatrix(force?: boolean): Matrix;
  7488. /**
  7489. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7490. * @returns a Matrix
  7491. */
  7492. getTransformationMatrix(): Matrix;
  7493. private _updateFrustumPlanes;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7497. * @param target The object to check
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isInFrustum(target: ICullable): boolean;
  7501. /**
  7502. * Checks if a cullable object (mesh...) is in the camera frustum
  7503. * Unlike isInFrustum this cheks the full bounding box
  7504. * @param target The object to check
  7505. * @returns true if the object is in frustum otherwise false
  7506. */
  7507. isCompletelyInFrustum(target: ICullable): boolean;
  7508. /**
  7509. * Gets a ray in the forward direction from the camera.
  7510. * @param length Defines the length of the ray to create
  7511. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7512. * @param origin Defines the start point of the ray which defaults to the camera position
  7513. * @returns the forward ray
  7514. */
  7515. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7516. /**
  7517. * Releases resources associated with this node.
  7518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7520. */
  7521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7522. /**
  7523. * Gets the left camera of a rig setup in case of Rigged Camera
  7524. */
  7525. readonly leftCamera: Nullable<FreeCamera>;
  7526. /**
  7527. * Gets the right camera of a rig setup in case of Rigged Camera
  7528. */
  7529. readonly rightCamera: Nullable<FreeCamera>;
  7530. /**
  7531. * Gets the left camera target of a rig setup in case of Rigged Camera
  7532. * @returns the target position
  7533. */
  7534. getLeftTarget(): Nullable<Vector3>;
  7535. /**
  7536. * Gets the right camera target of a rig setup in case of Rigged Camera
  7537. * @returns the target position
  7538. */
  7539. getRightTarget(): Nullable<Vector3>;
  7540. /**
  7541. * @hidden
  7542. */
  7543. setCameraRigMode(mode: number, rigParams: any): void;
  7544. private _getVRProjectionMatrix;
  7545. protected _updateCameraRotationMatrix(): void;
  7546. protected _updateWebVRCameraRotationMatrix(): void;
  7547. /**
  7548. * This function MUST be overwritten by the different WebVR cameras available.
  7549. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7550. */
  7551. protected _getWebVRProjectionMatrix(): Matrix;
  7552. /**
  7553. * This function MUST be overwritten by the different WebVR cameras available.
  7554. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7555. */
  7556. protected _getWebVRViewMatrix(): Matrix;
  7557. /** @hidden */
  7558. setCameraRigParameter(name: string, value: any): void;
  7559. /**
  7560. * needs to be overridden by children so sub has required properties to be copied
  7561. * @hidden
  7562. */
  7563. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7564. /**
  7565. * May need to be overridden by children
  7566. * @hidden
  7567. */
  7568. _updateRigCameras(): void;
  7569. /** @hidden */
  7570. _setupInputs(): void;
  7571. /**
  7572. * Serialiaze the camera setup to a json represention
  7573. * @returns the JSON representation
  7574. */
  7575. serialize(): any;
  7576. /**
  7577. * Clones the current camera.
  7578. * @param name The cloned camera name
  7579. * @returns the cloned camera
  7580. */
  7581. clone(name: string): Camera;
  7582. /**
  7583. * Gets the direction of the camera relative to a given local axis.
  7584. * @param localAxis Defines the reference axis to provide a relative direction.
  7585. * @return the direction
  7586. */
  7587. getDirection(localAxis: Vector3): Vector3;
  7588. /**
  7589. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7590. * @param localAxis Defines the reference axis to provide a relative direction.
  7591. * @param result Defines the vector to store the result in
  7592. */
  7593. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7594. /**
  7595. * Gets a camera constructor for a given camera type
  7596. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7597. * @param name The name of the camera the result will be able to instantiate
  7598. * @param scene The scene the result will construct the camera in
  7599. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7600. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7601. * @returns a factory method to construc the camera
  7602. */
  7603. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7604. /**
  7605. * Compute the world matrix of the camera.
  7606. * @returns the camera workd matrix
  7607. */
  7608. computeWorldMatrix(): Matrix;
  7609. /**
  7610. * Parse a JSON and creates the camera from the parsed information
  7611. * @param parsedCamera The JSON to parse
  7612. * @param scene The scene to instantiate the camera in
  7613. * @returns the newly constructed camera
  7614. */
  7615. static Parse(parsedCamera: any, scene: Scene): Camera;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * @ignore
  7621. * This is a list of all the different input types that are available in the application.
  7622. * Fo instance: ArcRotateCameraGamepadInput...
  7623. */
  7624. var CameraInputTypes: {};
  7625. /**
  7626. * This is the contract to implement in order to create a new input class.
  7627. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7628. */
  7629. interface ICameraInput<TCamera extends Camera> {
  7630. /**
  7631. * Defines the camera the input is attached to.
  7632. */
  7633. camera: Nullable<TCamera>;
  7634. /**
  7635. * Gets the class name of the current intput.
  7636. * @returns the class name
  7637. */
  7638. getClassName(): string;
  7639. /**
  7640. * Get the friendly name associated with the input class.
  7641. * @returns the input friendly name
  7642. */
  7643. getSimpleName(): string;
  7644. /**
  7645. * Attach the input controls to a specific dom element to get the input from.
  7646. * @param element Defines the element the controls should be listened from
  7647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7648. */
  7649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7650. /**
  7651. * Detach the current controls from the specified dom element.
  7652. * @param element Defines the element to stop listening the inputs from
  7653. */
  7654. detachControl(element: Nullable<HTMLElement>): void;
  7655. /**
  7656. * Update the current camera state depending on the inputs that have been used this frame.
  7657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7658. */
  7659. checkInputs?: () => void;
  7660. }
  7661. /**
  7662. * Represents a map of input types to input instance or input index to input instance.
  7663. */
  7664. interface CameraInputsMap<TCamera extends Camera> {
  7665. /**
  7666. * Accessor to the input by input type.
  7667. */
  7668. [name: string]: ICameraInput<TCamera>;
  7669. /**
  7670. * Accessor to the input by input index.
  7671. */
  7672. [idx: number]: ICameraInput<TCamera>;
  7673. }
  7674. /**
  7675. * This represents the input manager used within a camera.
  7676. * It helps dealing with all the different kind of input attached to a camera.
  7677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7678. */
  7679. class CameraInputsManager<TCamera extends Camera> {
  7680. /**
  7681. * Defines the list of inputs attahed to the camera.
  7682. */
  7683. attached: CameraInputsMap<TCamera>;
  7684. /**
  7685. * Defines the dom element the camera is collecting inputs from.
  7686. * This is null if the controls have not been attached.
  7687. */
  7688. attachedElement: Nullable<HTMLElement>;
  7689. /**
  7690. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7691. */
  7692. noPreventDefault: boolean;
  7693. /**
  7694. * Defined the camera the input manager belongs to.
  7695. */
  7696. camera: TCamera;
  7697. /**
  7698. * Update the current camera state depending on the inputs that have been used this frame.
  7699. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7700. */
  7701. checkInputs: () => void;
  7702. /**
  7703. * Instantiate a new Camera Input Manager.
  7704. * @param camera Defines the camera the input manager blongs to
  7705. */
  7706. constructor(camera: TCamera);
  7707. /**
  7708. * Add an input method to a camera
  7709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7710. * @param input camera input method
  7711. */
  7712. add(input: ICameraInput<TCamera>): void;
  7713. /**
  7714. * Remove a specific input method from a camera
  7715. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7716. * @param inputToRemove camera input method
  7717. */
  7718. remove(inputToRemove: ICameraInput<TCamera>): void;
  7719. /**
  7720. * Remove a specific input type from a camera
  7721. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7722. * @param inputType the type of the input to remove
  7723. */
  7724. removeByType(inputType: string): void;
  7725. private _addCheckInputs;
  7726. /**
  7727. * Attach the input controls to the currently attached dom element to listen the events from.
  7728. * @param input Defines the input to attach
  7729. */
  7730. attachInput(input: ICameraInput<TCamera>): void;
  7731. /**
  7732. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7733. * @param element Defines the dom element to collect the events from
  7734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7735. */
  7736. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7737. /**
  7738. * Detach the current manager inputs controls from a specific dom element.
  7739. * @param element Defines the dom element to collect the events from
  7740. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7741. */
  7742. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7743. /**
  7744. * Rebuild the dynamic inputCheck function from the current list of
  7745. * defined inputs in the manager.
  7746. */
  7747. rebuildInputCheck(): void;
  7748. /**
  7749. * Remove all attached input methods from a camera
  7750. */
  7751. clear(): void;
  7752. /**
  7753. * Serialize the current input manager attached to a camera.
  7754. * This ensures than once parsed,
  7755. * the input associated to the camera will be identical to the current ones
  7756. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7757. */
  7758. serialize(serializedCamera: any): void;
  7759. /**
  7760. * Parses an input manager serialized JSON to restore the previous list of inputs
  7761. * and states associated to a camera.
  7762. * @param parsedCamera Defines the JSON to parse
  7763. */
  7764. parse(parsedCamera: any): void;
  7765. }
  7766. }
  7767. declare module BABYLON {
  7768. /**
  7769. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7770. * being tilted forward or back and left or right.
  7771. */
  7772. class DeviceOrientationCamera extends FreeCamera {
  7773. private _initialQuaternion;
  7774. private _quaternionCache;
  7775. /**
  7776. * Creates a new device orientation camera
  7777. * @param name The name of the camera
  7778. * @param position The start position camera
  7779. * @param scene The scene the camera belongs to
  7780. */
  7781. constructor(name: string, position: Vector3, scene: Scene);
  7782. /**
  7783. * Gets the current instance class name ("DeviceOrientationCamera").
  7784. * This helps avoiding instanceof at run time.
  7785. * @returns the class name
  7786. */
  7787. getClassName(): string;
  7788. /**
  7789. * @hidden
  7790. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7791. */
  7792. _checkInputs(): void;
  7793. /**
  7794. * Reset the camera to its default orientation on the specified axis only.
  7795. * @param axis The axis to reset
  7796. */
  7797. resetToCurrentRotation(axis?: Axis): void;
  7798. }
  7799. }
  7800. declare module BABYLON {
  7801. /**
  7802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7803. * such as in a 3D Space Shooter or a Flight Simulator.
  7804. */
  7805. class FlyCamera extends TargetCamera {
  7806. /**
  7807. * Define the collision ellipsoid of the camera.
  7808. * This is helpful for simulating a camera body, like a player's body.
  7809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7810. */
  7811. ellipsoid: Vector3;
  7812. /**
  7813. * Define an offset for the position of the ellipsoid around the camera.
  7814. * This can be helpful if the camera is attached away from the player's body center,
  7815. * such as at its head.
  7816. */
  7817. ellipsoidOffset: Vector3;
  7818. /**
  7819. * Enable or disable collisions of the camera with the rest of the scene objects.
  7820. */
  7821. checkCollisions: boolean;
  7822. /**
  7823. * Enable or disable gravity on the camera.
  7824. */
  7825. applyGravity: boolean;
  7826. /**
  7827. * Define the current direction the camera is moving to.
  7828. */
  7829. cameraDirection: Vector3;
  7830. /**
  7831. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7832. * This overrides and empties cameraRotation.
  7833. */
  7834. rotationQuaternion: BABYLON.Quaternion;
  7835. /**
  7836. * Track Roll to maintain the wanted Rolling when looking around.
  7837. */
  7838. _trackRoll: number;
  7839. /**
  7840. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7841. */
  7842. rollCorrect: number;
  7843. /**
  7844. * Mimic a banked turn, Rolling the camera when Yawing.
  7845. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7846. */
  7847. bankedTurn: boolean;
  7848. /**
  7849. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7850. */
  7851. bankedTurnLimit: number;
  7852. /**
  7853. * Value of 0 disables the banked Roll.
  7854. * Value of 1 is equal to the Yaw angle in radians.
  7855. */
  7856. bankedTurnMultiplier: number;
  7857. /**
  7858. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7859. */
  7860. inputs: FlyCameraInputsManager;
  7861. /**
  7862. * Gets the input sensibility for mouse input.
  7863. * Higher values reduce sensitivity.
  7864. */
  7865. /**
  7866. * Sets the input sensibility for a mouse input.
  7867. * Higher values reduce sensitivity.
  7868. */
  7869. angularSensibility: number;
  7870. /**
  7871. * Get the keys for camera movement forward.
  7872. */
  7873. /**
  7874. * Set the keys for camera movement forward.
  7875. */
  7876. keysForward: number[];
  7877. /**
  7878. * Get the keys for camera movement backward.
  7879. */
  7880. keysBackward: number[];
  7881. /**
  7882. * Get the keys for camera movement up.
  7883. */
  7884. /**
  7885. * Set the keys for camera movement up.
  7886. */
  7887. keysUp: number[];
  7888. /**
  7889. * Get the keys for camera movement down.
  7890. */
  7891. /**
  7892. * Set the keys for camera movement down.
  7893. */
  7894. keysDown: number[];
  7895. /**
  7896. * Get the keys for camera movement left.
  7897. */
  7898. /**
  7899. * Set the keys for camera movement left.
  7900. */
  7901. keysLeft: number[];
  7902. /**
  7903. * Set the keys for camera movement right.
  7904. */
  7905. /**
  7906. * Set the keys for camera movement right.
  7907. */
  7908. keysRight: number[];
  7909. /**
  7910. * Event raised when the camera collides with a mesh in the scene.
  7911. */
  7912. onCollide: (collidedMesh: AbstractMesh) => void;
  7913. private _collider;
  7914. private _needMoveForGravity;
  7915. private _oldPosition;
  7916. private _diffPosition;
  7917. private _newPosition;
  7918. /** @hidden */
  7919. _localDirection: Vector3;
  7920. /** @hidden */
  7921. _transformedDirection: Vector3;
  7922. /**
  7923. * Instantiates a FlyCamera.
  7924. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7925. * such as in a 3D Space Shooter or a Flight Simulator.
  7926. * @param name Define the name of the camera in the scene.
  7927. * @param position Define the starting position of the camera in the scene.
  7928. * @param scene Define the scene the camera belongs to.
  7929. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7930. */
  7931. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7932. /**
  7933. * Attach a control to the HTML DOM element.
  7934. * @param element Defines the element that listens to the input events.
  7935. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7936. */
  7937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7938. /**
  7939. * Detach a control from the HTML DOM element.
  7940. * The camera will stop reacting to that input.
  7941. * @param element Defines the element that listens to the input events.
  7942. */
  7943. detachControl(element: HTMLElement): void;
  7944. private _collisionMask;
  7945. /**
  7946. * Get the mask that the camera ignores in collision events.
  7947. */
  7948. /**
  7949. * Set the mask that the camera ignores in collision events.
  7950. */
  7951. collisionMask: number;
  7952. /** @hidden */
  7953. _collideWithWorld(displacement: Vector3): void;
  7954. /** @hidden */
  7955. private _onCollisionPositionChange;
  7956. /** @hidden */
  7957. _checkInputs(): void;
  7958. /** @hidden */
  7959. _decideIfNeedsToMove(): boolean;
  7960. /** @hidden */
  7961. _updatePosition(): void;
  7962. /**
  7963. * Restore the Roll to its target value at the rate specified.
  7964. * @param rate - Higher means slower restoring.
  7965. * @hidden
  7966. */
  7967. restoreRoll(rate: number): void;
  7968. /**
  7969. * Destroy the camera and release the current resources held by it.
  7970. */
  7971. dispose(): void;
  7972. /**
  7973. * Get the current object class name.
  7974. * @returns the class name.
  7975. */
  7976. getClassName(): string;
  7977. }
  7978. }
  7979. declare module BABYLON {
  7980. /**
  7981. * Default Inputs manager for the FlyCamera.
  7982. * It groups all the default supported inputs for ease of use.
  7983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7984. */
  7985. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7986. /**
  7987. * Instantiates a new FlyCameraInputsManager.
  7988. * @param camera Defines the camera the inputs belong to.
  7989. */
  7990. constructor(camera: FlyCamera);
  7991. /**
  7992. * Add keyboard input support to the input manager.
  7993. * @returns the new FlyCameraKeyboardMoveInput().
  7994. */
  7995. addKeyboard(): FlyCameraInputsManager;
  7996. /**
  7997. * Add mouse input support to the input manager.
  7998. * @param touchEnabled Enable touch screen support.
  7999. * @returns the new FlyCameraMouseInput().
  8000. */
  8001. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8002. }
  8003. }
  8004. declare module BABYLON {
  8005. /**
  8006. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8007. * an arc rotate version arcFollowCamera are available.
  8008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8009. */
  8010. class FollowCamera extends TargetCamera {
  8011. /**
  8012. * Distance the follow camera should follow an object at
  8013. */
  8014. radius: number;
  8015. /**
  8016. * Define a rotation offset between the camera and the object it follows
  8017. */
  8018. rotationOffset: number;
  8019. /**
  8020. * Define a height offset between the camera and the object it follows.
  8021. * It can help following an object from the top (like a car chaing a plane)
  8022. */
  8023. heightOffset: number;
  8024. /**
  8025. * Define how fast the camera can accelerate to follow it s target.
  8026. */
  8027. cameraAcceleration: number;
  8028. /**
  8029. * Define the speed limit of the camera following an object.
  8030. */
  8031. maxCameraSpeed: number;
  8032. /**
  8033. * Define the target of the camera.
  8034. */
  8035. lockedTarget: Nullable<AbstractMesh>;
  8036. /**
  8037. * Instantiates the follow camera.
  8038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8039. * @param name Define the name of the camera in the scene
  8040. * @param position Define the position of the camera
  8041. * @param scene Define the scene the camera belong to
  8042. * @param lockedTarget Define the target of the camera
  8043. */
  8044. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8045. private _follow;
  8046. /** @hidden */
  8047. _checkInputs(): void;
  8048. /**
  8049. * Gets the camera class name.
  8050. * @returns the class name
  8051. */
  8052. getClassName(): string;
  8053. }
  8054. /**
  8055. * Arc Rotate version of the follow camera.
  8056. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8057. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8058. */
  8059. class ArcFollowCamera extends TargetCamera {
  8060. /** The longitudinal angle of the camera */
  8061. alpha: number;
  8062. /** The latitudinal angle of the camera */
  8063. beta: number;
  8064. /** The radius of the camera from its target */
  8065. radius: number;
  8066. /** Define the camera target (the messh it should follow) */
  8067. target: Nullable<AbstractMesh>;
  8068. private _cartesianCoordinates;
  8069. /**
  8070. * Instantiates a new ArcFollowCamera
  8071. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8072. * @param name Define the name of the camera
  8073. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8074. * @param beta Define the rotation angle of the camera around the elevation axis
  8075. * @param radius Define the radius of the camera from its target point
  8076. * @param target Define the target of the camera
  8077. * @param scene Define the scene the camera belongs to
  8078. */
  8079. constructor(name: string,
  8080. /** The longitudinal angle of the camera */
  8081. alpha: number,
  8082. /** The latitudinal angle of the camera */
  8083. beta: number,
  8084. /** The radius of the camera from its target */
  8085. radius: number,
  8086. /** Define the camera target (the messh it should follow) */
  8087. target: Nullable<AbstractMesh>, scene: Scene);
  8088. private _follow;
  8089. /** @hidden */
  8090. _checkInputs(): void;
  8091. /**
  8092. * Returns the class name of the object.
  8093. * It is mostly used internally for serialization purposes.
  8094. */
  8095. getClassName(): string;
  8096. }
  8097. }
  8098. declare module BABYLON {
  8099. /**
  8100. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8101. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8103. */
  8104. class FreeCamera extends TargetCamera {
  8105. /**
  8106. * Define the collision ellipsoid of the camera.
  8107. * This is helpful to simulate a camera body like the player body around the camera
  8108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8109. */
  8110. ellipsoid: Vector3;
  8111. /**
  8112. * Define an offset for the position of the ellipsoid around the camera.
  8113. * This can be helpful to determine the center of the body near the gravity center of the body
  8114. * instead of its head.
  8115. */
  8116. ellipsoidOffset: Vector3;
  8117. /**
  8118. * Enable or disable collisions of the camera with the rest of the scene objects.
  8119. */
  8120. checkCollisions: boolean;
  8121. /**
  8122. * Enable or disable gravity on the camera.
  8123. */
  8124. applyGravity: boolean;
  8125. /**
  8126. * Define the input manager associated to the camera.
  8127. */
  8128. inputs: FreeCameraInputsManager;
  8129. /**
  8130. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8131. * Higher values reduce sensitivity.
  8132. */
  8133. /**
  8134. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8135. * Higher values reduce sensitivity.
  8136. */
  8137. angularSensibility: number;
  8138. /**
  8139. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8140. */
  8141. keysUp: number[];
  8142. /**
  8143. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8144. */
  8145. keysDown: number[];
  8146. /**
  8147. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8148. */
  8149. keysLeft: number[];
  8150. /**
  8151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8152. */
  8153. keysRight: number[];
  8154. /**
  8155. * Event raised when the camera collide with a mesh in the scene.
  8156. */
  8157. onCollide: (collidedMesh: AbstractMesh) => void;
  8158. private _collider;
  8159. private _needMoveForGravity;
  8160. private _oldPosition;
  8161. private _diffPosition;
  8162. private _newPosition;
  8163. /** @hidden */
  8164. _localDirection: Vector3;
  8165. /** @hidden */
  8166. _transformedDirection: Vector3;
  8167. /**
  8168. * Instantiates a Free Camera.
  8169. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8170. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8172. * @param name Define the name of the camera in the scene
  8173. * @param position Define the start position of the camera in the scene
  8174. * @param scene Define the scene the camera belongs to
  8175. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8176. */
  8177. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8178. /**
  8179. * Attached controls to the current camera.
  8180. * @param element Defines the element the controls should be listened from
  8181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8182. */
  8183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8184. /**
  8185. * Detach the current controls from the camera.
  8186. * The camera will stop reacting to inputs.
  8187. * @param element Defines the element to stop listening the inputs from
  8188. */
  8189. detachControl(element: HTMLElement): void;
  8190. private _collisionMask;
  8191. /**
  8192. * Define a collision mask to limit the list of object the camera can collide with
  8193. */
  8194. collisionMask: number;
  8195. /** @hidden */
  8196. _collideWithWorld(displacement: Vector3): void;
  8197. private _onCollisionPositionChange;
  8198. /** @hidden */
  8199. _checkInputs(): void;
  8200. /** @hidden */
  8201. _decideIfNeedsToMove(): boolean;
  8202. /** @hidden */
  8203. _updatePosition(): void;
  8204. /**
  8205. * Destroy the camera and release the current resources hold by it.
  8206. */
  8207. dispose(): void;
  8208. /**
  8209. * Gets the current object class name.
  8210. * @return the class name
  8211. */
  8212. getClassName(): string;
  8213. }
  8214. }
  8215. declare module BABYLON {
  8216. /**
  8217. * Default Inputs manager for the FreeCamera.
  8218. * It groups all the default supported inputs for ease of use.
  8219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8220. */
  8221. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8222. /**
  8223. * Instantiates a new FreeCameraInputsManager.
  8224. * @param camera Defines the camera the inputs belong to
  8225. */
  8226. constructor(camera: FreeCamera);
  8227. /**
  8228. * Add keyboard input support to the input manager.
  8229. * @returns the current input manager
  8230. */
  8231. addKeyboard(): FreeCameraInputsManager;
  8232. /**
  8233. * Add mouse input support to the input manager.
  8234. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8235. * @returns the current input manager
  8236. */
  8237. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8238. /**
  8239. * Add orientation input support to the input manager.
  8240. * @returns the current input manager
  8241. */
  8242. addDeviceOrientation(): FreeCameraInputsManager;
  8243. /**
  8244. * Add touch input support to the input manager.
  8245. * @returns the current input manager
  8246. */
  8247. addTouch(): FreeCameraInputsManager;
  8248. /**
  8249. * Add virtual joystick input support to the input manager.
  8250. * @returns the current input manager
  8251. */
  8252. addVirtualJoystick(): FreeCameraInputsManager;
  8253. }
  8254. }
  8255. declare module BABYLON {
  8256. /**
  8257. * This represents a FPS type of camera. This is only here for back compat purpose.
  8258. * Please use the UniversalCamera instead as both are identical.
  8259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8260. */
  8261. class GamepadCamera extends UniversalCamera {
  8262. /**
  8263. * Instantiates a new Gamepad Camera
  8264. * This represents a FPS type of camera. This is only here for back compat purpose.
  8265. * Please use the UniversalCamera instead as both are identical.
  8266. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8267. * @param name Define the name of the camera in the scene
  8268. * @param position Define the start position of the camera in the scene
  8269. * @param scene Define the scene the camera belongs to
  8270. */
  8271. constructor(name: string, position: Vector3, scene: Scene);
  8272. /**
  8273. * Gets the current object class name.
  8274. * @return the class name
  8275. */
  8276. getClassName(): string;
  8277. }
  8278. }
  8279. declare module BABYLON {
  8280. /**
  8281. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8282. * This is the base of the follow, arc rotate cameras and Free camera
  8283. * @see http://doc.babylonjs.com/features/cameras
  8284. */
  8285. class TargetCamera extends Camera {
  8286. private static _RigCamTransformMatrix;
  8287. private static _TargetTransformMatrix;
  8288. /**
  8289. * Define the current direction the camera is moving to
  8290. */
  8291. cameraDirection: Vector3;
  8292. /**
  8293. * Define the current rotation the camera is rotating to
  8294. */
  8295. cameraRotation: Vector2;
  8296. /**
  8297. * When set, the up vector of the camera will be updated by the rotation of the camera
  8298. */
  8299. updateUpVectorFromRotation: boolean;
  8300. private _tmpQuaternion;
  8301. /**
  8302. * Define the current rotation of the camera
  8303. */
  8304. rotation: Vector3;
  8305. /**
  8306. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8307. */
  8308. rotationQuaternion: Quaternion;
  8309. /**
  8310. * Define the current speed of the camera
  8311. */
  8312. speed: number;
  8313. /**
  8314. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8315. * around all axis.
  8316. */
  8317. noRotationConstraint: boolean;
  8318. /**
  8319. * Define the current target of the camera as an object or a position.
  8320. */
  8321. lockedTarget: any;
  8322. /** @hidden */
  8323. _currentTarget: Vector3;
  8324. /** @hidden */
  8325. _viewMatrix: Matrix;
  8326. /** @hidden */
  8327. _camMatrix: Matrix;
  8328. /** @hidden */
  8329. _cameraTransformMatrix: Matrix;
  8330. /** @hidden */
  8331. _cameraRotationMatrix: Matrix;
  8332. /** @hidden */
  8333. _referencePoint: Vector3;
  8334. /** @hidden */
  8335. _transformedReferencePoint: Vector3;
  8336. protected _globalCurrentTarget: Vector3;
  8337. protected _globalCurrentUpVector: Vector3;
  8338. /** @hidden */
  8339. _reset: () => void;
  8340. private _defaultUp;
  8341. /**
  8342. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8343. * This is the base of the follow, arc rotate cameras and Free camera
  8344. * @see http://doc.babylonjs.com/features/cameras
  8345. * @param name Defines the name of the camera in the scene
  8346. * @param position Defines the start position of the camera in the scene
  8347. * @param scene Defines the scene the camera belongs to
  8348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8349. */
  8350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8351. /**
  8352. * Gets the position in front of the camera at a given distance.
  8353. * @param distance The distance from the camera we want the position to be
  8354. * @returns the position
  8355. */
  8356. getFrontPosition(distance: number): Vector3;
  8357. /** @hidden */
  8358. _getLockedTargetPosition(): Nullable<Vector3>;
  8359. private _storedPosition;
  8360. private _storedRotation;
  8361. private _storedRotationQuaternion;
  8362. /**
  8363. * Store current camera state of the camera (fov, position, rotation, etc..)
  8364. * @returns the camera
  8365. */
  8366. storeState(): Camera;
  8367. /**
  8368. * Restored camera state. You must call storeState() first
  8369. * @returns whether it was successful or not
  8370. * @hidden
  8371. */
  8372. _restoreStateValues(): boolean;
  8373. /** @hidden */
  8374. _initCache(): void;
  8375. /** @hidden */
  8376. _updateCache(ignoreParentClass?: boolean): void;
  8377. /** @hidden */
  8378. _isSynchronizedViewMatrix(): boolean;
  8379. /** @hidden */
  8380. _computeLocalCameraSpeed(): number;
  8381. /** @hidden */
  8382. setTarget(target: Vector3): void;
  8383. /**
  8384. * Return the current target position of the camera. This value is expressed in local space.
  8385. * @returns the target position
  8386. */
  8387. getTarget(): Vector3;
  8388. /** @hidden */
  8389. _decideIfNeedsToMove(): boolean;
  8390. /** @hidden */
  8391. _updatePosition(): void;
  8392. /** @hidden */
  8393. _checkInputs(): void;
  8394. protected _updateCameraRotationMatrix(): void;
  8395. /**
  8396. * 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)
  8397. * @returns the current camera
  8398. */
  8399. private _rotateUpVectorWithCameraRotationMatrix;
  8400. private _cachedRotationZ;
  8401. private _cachedQuaternionRotationZ;
  8402. /** @hidden */
  8403. _getViewMatrix(): Matrix;
  8404. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8405. /**
  8406. * @hidden
  8407. */
  8408. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8409. /**
  8410. * @hidden
  8411. */
  8412. _updateRigCameras(): void;
  8413. private _getRigCamPosition;
  8414. /**
  8415. * Gets the current object class name.
  8416. * @return the class name
  8417. */
  8418. getClassName(): string;
  8419. }
  8420. }
  8421. declare module BABYLON {
  8422. /**
  8423. * This represents a FPS type of camera controlled by touch.
  8424. * This is like a universal camera minus the Gamepad controls.
  8425. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8426. */
  8427. class TouchCamera extends FreeCamera {
  8428. /**
  8429. * Defines the touch sensibility for rotation.
  8430. * The higher the faster.
  8431. */
  8432. touchAngularSensibility: number;
  8433. /**
  8434. * Defines the touch sensibility for move.
  8435. * The higher the faster.
  8436. */
  8437. touchMoveSensibility: number;
  8438. /**
  8439. * Instantiates a new touch camera.
  8440. * This represents a FPS type of camera controlled by touch.
  8441. * This is like a universal camera minus the Gamepad controls.
  8442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8443. * @param name Define the name of the camera in the scene
  8444. * @param position Define the start position of the camera in the scene
  8445. * @param scene Define the scene the camera belongs to
  8446. */
  8447. constructor(name: string, position: Vector3, scene: Scene);
  8448. /**
  8449. * Gets the current object class name.
  8450. * @return the class name
  8451. */
  8452. getClassName(): string;
  8453. /** @hidden */
  8454. _setupInputs(): void;
  8455. }
  8456. }
  8457. declare module BABYLON {
  8458. /**
  8459. * 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,
  8460. * which still works and will still be found in many Playgrounds.
  8461. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8462. */
  8463. class UniversalCamera extends TouchCamera {
  8464. /**
  8465. * Defines the gamepad rotation sensiblity.
  8466. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8467. */
  8468. gamepadAngularSensibility: number;
  8469. /**
  8470. * Defines the gamepad move sensiblity.
  8471. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8472. */
  8473. gamepadMoveSensibility: number;
  8474. /**
  8475. * 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,
  8476. * which still works and will still be found in many Playgrounds.
  8477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8478. * @param name Define the name of the camera in the scene
  8479. * @param position Define the start position of the camera in the scene
  8480. * @param scene Define the scene the camera belongs to
  8481. */
  8482. constructor(name: string, position: Vector3, scene: Scene);
  8483. /**
  8484. * Gets the current object class name.
  8485. * @return the class name
  8486. */
  8487. getClassName(): string;
  8488. }
  8489. }
  8490. declare module BABYLON {
  8491. /**
  8492. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8493. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8494. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8495. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8496. */
  8497. class VirtualJoysticksCamera extends FreeCamera {
  8498. /**
  8499. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8500. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8501. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8502. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8503. * @param name Define the name of the camera in the scene
  8504. * @param position Define the start position of the camera in the scene
  8505. * @param scene Define the scene the camera belongs to
  8506. */
  8507. constructor(name: string, position: Vector3, scene: Scene);
  8508. /**
  8509. * Gets the current object class name.
  8510. * @return the class name
  8511. */
  8512. getClassName(): string;
  8513. }
  8514. }
  8515. interface VRDisplay extends EventTarget {
  8516. /**
  8517. * Dictionary of capabilities describing the VRDisplay.
  8518. */
  8519. readonly capabilities: VRDisplayCapabilities;
  8520. /**
  8521. * z-depth defining the far plane of the eye view frustum
  8522. * enables mapping of values in the render target depth
  8523. * attachment to scene coordinates. Initially set to 10000.0.
  8524. */
  8525. depthFar: number;
  8526. /**
  8527. * z-depth defining the near plane of the eye view frustum
  8528. * enables mapping of values in the render target depth
  8529. * attachment to scene coordinates. Initially set to 0.01.
  8530. */
  8531. depthNear: number;
  8532. /**
  8533. * An identifier for this distinct VRDisplay. Used as an
  8534. * association point in the Gamepad API.
  8535. */
  8536. readonly displayId: number;
  8537. /**
  8538. * A display name, a user-readable name identifying it.
  8539. */
  8540. readonly displayName: string;
  8541. readonly isConnected: boolean;
  8542. readonly isPresenting: boolean;
  8543. /**
  8544. * If this VRDisplay supports room-scale experiences, the optional
  8545. * stage attribute contains details on the room-scale parameters.
  8546. */
  8547. readonly stageParameters: VRStageParameters | null;
  8548. /**
  8549. * Passing the value returned by `requestAnimationFrame` to
  8550. * `cancelAnimationFrame` will unregister the callback.
  8551. * @param handle Define the hanle of the request to cancel
  8552. */
  8553. cancelAnimationFrame(handle: number): void;
  8554. /**
  8555. * Stops presenting to the VRDisplay.
  8556. * @returns a promise to know when it stopped
  8557. */
  8558. exitPresent(): Promise<void>;
  8559. /**
  8560. * Return the current VREyeParameters for the given eye.
  8561. * @param whichEye Define the eye we want the parameter for
  8562. * @returns the eye parameters
  8563. */
  8564. getEyeParameters(whichEye: string): VREyeParameters;
  8565. /**
  8566. * Populates the passed VRFrameData with the information required to render
  8567. * the current frame.
  8568. * @param frameData Define the data structure to populate
  8569. * @returns true if ok otherwise false
  8570. */
  8571. getFrameData(frameData: VRFrameData): boolean;
  8572. /**
  8573. * Get the layers currently being presented.
  8574. * @returns the list of VR layers
  8575. */
  8576. getLayers(): VRLayer[];
  8577. /**
  8578. * Return a VRPose containing the future predicted pose of the VRDisplay
  8579. * when the current frame will be presented. The value returned will not
  8580. * change until JavaScript has returned control to the browser.
  8581. *
  8582. * The VRPose will contain the position, orientation, velocity,
  8583. * and acceleration of each of these properties.
  8584. * @returns the pose object
  8585. */
  8586. getPose(): VRPose;
  8587. /**
  8588. * Return the current instantaneous pose of the VRDisplay, with no
  8589. * prediction applied.
  8590. * @returns the current instantaneous pose
  8591. */
  8592. getImmediatePose(): VRPose;
  8593. /**
  8594. * The callback passed to `requestAnimationFrame` will be called
  8595. * any time a new frame should be rendered. When the VRDisplay is
  8596. * presenting the callback will be called at the native refresh
  8597. * rate of the HMD. When not presenting this function acts
  8598. * identically to how window.requestAnimationFrame acts. Content should
  8599. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8600. * asynchronously from other displays and at differing refresh rates.
  8601. * @param callback Define the eaction to run next frame
  8602. * @returns the request handle it
  8603. */
  8604. requestAnimationFrame(callback: FrameRequestCallback): number;
  8605. /**
  8606. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8607. * Repeat calls while already presenting will update the VRLayers being displayed.
  8608. * @param layers Define the list of layer to present
  8609. * @returns a promise to know when the request has been fulfilled
  8610. */
  8611. requestPresent(layers: VRLayer[]): Promise<void>;
  8612. /**
  8613. * Reset the pose for this display, treating its current position and
  8614. * orientation as the "origin/zero" values. VRPose.position,
  8615. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8616. * updated when calling resetPose(). This should be called in only
  8617. * sitting-space experiences.
  8618. */
  8619. resetPose(): void;
  8620. /**
  8621. * The VRLayer provided to the VRDisplay will be captured and presented
  8622. * in the HMD. Calling this function has the same effect on the source
  8623. * canvas as any other operation that uses its source image, and canvases
  8624. * created without preserveDrawingBuffer set to true will be cleared.
  8625. * @param pose Define the pose to submit
  8626. */
  8627. submitFrame(pose?: VRPose): void;
  8628. }
  8629. declare var VRDisplay: {
  8630. prototype: VRDisplay;
  8631. new (): VRDisplay;
  8632. };
  8633. interface VRLayer {
  8634. leftBounds?: number[] | Float32Array | null;
  8635. rightBounds?: number[] | Float32Array | null;
  8636. source?: HTMLCanvasElement | null;
  8637. }
  8638. interface VRDisplayCapabilities {
  8639. readonly canPresent: boolean;
  8640. readonly hasExternalDisplay: boolean;
  8641. readonly hasOrientation: boolean;
  8642. readonly hasPosition: boolean;
  8643. readonly maxLayers: number;
  8644. }
  8645. interface VREyeParameters {
  8646. /** @deprecated */
  8647. readonly fieldOfView: VRFieldOfView;
  8648. readonly offset: Float32Array;
  8649. readonly renderHeight: number;
  8650. readonly renderWidth: number;
  8651. }
  8652. interface VRFieldOfView {
  8653. readonly downDegrees: number;
  8654. readonly leftDegrees: number;
  8655. readonly rightDegrees: number;
  8656. readonly upDegrees: number;
  8657. }
  8658. interface VRFrameData {
  8659. readonly leftProjectionMatrix: Float32Array;
  8660. readonly leftViewMatrix: Float32Array;
  8661. readonly pose: VRPose;
  8662. readonly rightProjectionMatrix: Float32Array;
  8663. readonly rightViewMatrix: Float32Array;
  8664. readonly timestamp: number;
  8665. }
  8666. interface VRPose {
  8667. readonly angularAcceleration: Float32Array | null;
  8668. readonly angularVelocity: Float32Array | null;
  8669. readonly linearAcceleration: Float32Array | null;
  8670. readonly linearVelocity: Float32Array | null;
  8671. readonly orientation: Float32Array | null;
  8672. readonly position: Float32Array | null;
  8673. readonly timestamp: number;
  8674. }
  8675. interface VRStageParameters {
  8676. sittingToStandingTransform?: Float32Array;
  8677. sizeX?: number;
  8678. sizeY?: number;
  8679. }
  8680. interface Navigator {
  8681. getVRDisplays(): Promise<VRDisplay[]>;
  8682. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8683. }
  8684. interface Window {
  8685. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8686. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8687. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8688. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8689. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8690. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8691. }
  8692. interface Gamepad {
  8693. readonly displayId: number;
  8694. }
  8695. declare module BABYLON {
  8696. /** @hidden */
  8697. class Collider {
  8698. /** Define if a collision was found */
  8699. collisionFound: boolean;
  8700. /**
  8701. * Define last intersection point in local space
  8702. */
  8703. intersectionPoint: Vector3;
  8704. /**
  8705. * Define last collided mesh
  8706. */
  8707. collidedMesh: Nullable<AbstractMesh>;
  8708. private _collisionPoint;
  8709. private _planeIntersectionPoint;
  8710. private _tempVector;
  8711. private _tempVector2;
  8712. private _tempVector3;
  8713. private _tempVector4;
  8714. private _edge;
  8715. private _baseToVertex;
  8716. private _destinationPoint;
  8717. private _slidePlaneNormal;
  8718. private _displacementVector;
  8719. /** @hidden */
  8720. _radius: Vector3;
  8721. /** @hidden */
  8722. _retry: number;
  8723. private _velocity;
  8724. private _basePoint;
  8725. private _epsilon;
  8726. /** @hidden */
  8727. _velocityWorldLength: number;
  8728. /** @hidden */
  8729. _basePointWorld: Vector3;
  8730. private _velocityWorld;
  8731. private _normalizedVelocity;
  8732. /** @hidden */
  8733. _initialVelocity: Vector3;
  8734. /** @hidden */
  8735. _initialPosition: Vector3;
  8736. private _nearestDistance;
  8737. private _collisionMask;
  8738. collisionMask: number;
  8739. /**
  8740. * Gets the plane normal used to compute the sliding response (in local space)
  8741. */
  8742. readonly slidePlaneNormal: Vector3;
  8743. /** @hidden */
  8744. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8745. /** @hidden */
  8746. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8747. /** @hidden */
  8748. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8749. /** @hidden */
  8750. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8751. /** @hidden */
  8752. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8753. /** @hidden */
  8754. _getResponse(pos: Vector3, vel: Vector3): void;
  8755. }
  8756. }
  8757. declare module BABYLON {
  8758. /** @hidden */
  8759. var CollisionWorker: string;
  8760. /** @hidden */
  8761. interface ICollisionCoordinator {
  8762. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8763. init(scene: Scene): void;
  8764. destroy(): void;
  8765. onMeshAdded(mesh: AbstractMesh): void;
  8766. onMeshUpdated(mesh: AbstractMesh): void;
  8767. onMeshRemoved(mesh: AbstractMesh): void;
  8768. onGeometryAdded(geometry: Geometry): void;
  8769. onGeometryUpdated(geometry: Geometry): void;
  8770. onGeometryDeleted(geometry: Geometry): void;
  8771. }
  8772. /** @hidden */
  8773. interface SerializedMesh {
  8774. id: string;
  8775. name: string;
  8776. uniqueId: number;
  8777. geometryId: Nullable<string>;
  8778. sphereCenter: Array<number>;
  8779. sphereRadius: number;
  8780. boxMinimum: Array<number>;
  8781. boxMaximum: Array<number>;
  8782. worldMatrixFromCache: any;
  8783. subMeshes: Array<SerializedSubMesh>;
  8784. checkCollisions: boolean;
  8785. }
  8786. /** @hidden */
  8787. interface SerializedSubMesh {
  8788. position: number;
  8789. verticesStart: number;
  8790. verticesCount: number;
  8791. indexStart: number;
  8792. indexCount: number;
  8793. hasMaterial: boolean;
  8794. sphereCenter: Array<number>;
  8795. sphereRadius: number;
  8796. boxMinimum: Array<number>;
  8797. boxMaximum: Array<number>;
  8798. }
  8799. /**
  8800. * Interface describing the value associated with a geometry.
  8801. * @hidden
  8802. */
  8803. interface SerializedGeometry {
  8804. /**
  8805. * Defines the unique ID of the geometry
  8806. */
  8807. id: string;
  8808. /**
  8809. * Defines the array containing the positions
  8810. */
  8811. positions: Float32Array;
  8812. /**
  8813. * Defines the array containing the indices
  8814. */
  8815. indices: Uint32Array;
  8816. /**
  8817. * Defines the array containing the normals
  8818. */
  8819. normals: Float32Array;
  8820. }
  8821. /** @hidden */
  8822. interface BabylonMessage {
  8823. taskType: WorkerTaskType;
  8824. payload: InitPayload | CollidePayload | UpdatePayload;
  8825. }
  8826. /** @hidden */
  8827. interface SerializedColliderToWorker {
  8828. position: Array<number>;
  8829. velocity: Array<number>;
  8830. radius: Array<number>;
  8831. }
  8832. /** Defines supported task for worker process */
  8833. enum WorkerTaskType {
  8834. /** Initialization */
  8835. INIT = 0,
  8836. /** Update of geometry */
  8837. UPDATE = 1,
  8838. /** Evaluate collision */
  8839. COLLIDE = 2
  8840. }
  8841. /** @hidden */
  8842. interface WorkerReply {
  8843. error: WorkerReplyType;
  8844. taskType: WorkerTaskType;
  8845. payload?: any;
  8846. }
  8847. /** @hidden */
  8848. interface CollisionReplyPayload {
  8849. newPosition: Array<number>;
  8850. collisionId: number;
  8851. collidedMeshUniqueId: number;
  8852. }
  8853. /** @hidden */
  8854. interface InitPayload {
  8855. }
  8856. /** @hidden */
  8857. interface CollidePayload {
  8858. collisionId: number;
  8859. collider: SerializedColliderToWorker;
  8860. maximumRetry: number;
  8861. excludedMeshUniqueId: Nullable<number>;
  8862. }
  8863. /** @hidden */
  8864. interface UpdatePayload {
  8865. updatedMeshes: {
  8866. [n: number]: SerializedMesh;
  8867. };
  8868. updatedGeometries: {
  8869. [s: string]: SerializedGeometry;
  8870. };
  8871. removedMeshes: Array<number>;
  8872. removedGeometries: Array<string>;
  8873. }
  8874. /** Defines kind of replies returned by worker */
  8875. enum WorkerReplyType {
  8876. /** Success */
  8877. SUCCESS = 0,
  8878. /** Unkown error */
  8879. UNKNOWN_ERROR = 1
  8880. }
  8881. /** @hidden */
  8882. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  8883. private _scene;
  8884. private _scaledPosition;
  8885. private _scaledVelocity;
  8886. private _collisionsCallbackArray;
  8887. private _init;
  8888. private _runningUpdated;
  8889. private _worker;
  8890. private _addUpdateMeshesList;
  8891. private _addUpdateGeometriesList;
  8892. private _toRemoveMeshesArray;
  8893. private _toRemoveGeometryArray;
  8894. constructor();
  8895. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  8896. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  8897. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8898. init(scene: Scene): void;
  8899. destroy(): void;
  8900. onMeshAdded(mesh: AbstractMesh): void;
  8901. onMeshUpdated: (transformNode: TransformNode) => void;
  8902. onMeshRemoved(mesh: AbstractMesh): void;
  8903. onGeometryAdded(geometry: Geometry): void;
  8904. onGeometryUpdated: (geometry: Geometry) => void;
  8905. onGeometryDeleted(geometry: Geometry): void;
  8906. private _afterRender;
  8907. private _onMessageFromWorker;
  8908. }
  8909. /** @hidden */
  8910. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  8911. private _scene;
  8912. private _scaledPosition;
  8913. private _scaledVelocity;
  8914. private _finalPosition;
  8915. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8916. init(scene: Scene): void;
  8917. destroy(): void;
  8918. onMeshAdded(mesh: AbstractMesh): void;
  8919. onMeshUpdated(mesh: AbstractMesh): void;
  8920. onMeshRemoved(mesh: AbstractMesh): void;
  8921. onGeometryAdded(geometry: Geometry): void;
  8922. onGeometryUpdated(geometry: Geometry): void;
  8923. onGeometryDeleted(geometry: Geometry): void;
  8924. private _collideWithWorld;
  8925. }
  8926. }
  8927. declare function importScripts(...urls: string[]): void;
  8928. declare const safePostMessage: any;
  8929. declare module BABYLON {
  8930. /** @hidden */
  8931. var WorkerIncluded: boolean;
  8932. /** @hidden */
  8933. class CollisionCache {
  8934. private _meshes;
  8935. private _geometries;
  8936. getMeshes(): {
  8937. [n: number]: SerializedMesh;
  8938. };
  8939. getGeometries(): {
  8940. [s: number]: SerializedGeometry;
  8941. };
  8942. getMesh(id: any): SerializedMesh;
  8943. addMesh(mesh: SerializedMesh): void;
  8944. removeMesh(uniqueId: number): void;
  8945. getGeometry(id: string): SerializedGeometry;
  8946. addGeometry(geometry: SerializedGeometry): void;
  8947. removeGeometry(id: string): void;
  8948. }
  8949. /** @hidden */
  8950. class CollideWorker {
  8951. collider: Collider;
  8952. private _collisionCache;
  8953. private finalPosition;
  8954. private collisionsScalingMatrix;
  8955. private collisionTranformationMatrix;
  8956. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  8957. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  8958. private checkCollision;
  8959. private processCollisionsForSubMeshes;
  8960. private collideForSubMesh;
  8961. private checkSubmeshCollision;
  8962. }
  8963. /** @hidden */
  8964. interface ICollisionDetector {
  8965. onInit(payload: InitPayload): void;
  8966. onUpdate(payload: UpdatePayload): void;
  8967. onCollision(payload: CollidePayload): void;
  8968. }
  8969. /** @hidden */
  8970. class CollisionDetectorTransferable implements ICollisionDetector {
  8971. private _collisionCache;
  8972. onInit(payload: InitPayload): void;
  8973. onUpdate(payload: UpdatePayload): void;
  8974. onCollision(payload: CollidePayload): void;
  8975. }
  8976. }
  8977. declare module BABYLON {
  8978. /**
  8979. * @hidden
  8980. */
  8981. class IntersectionInfo {
  8982. bu: Nullable<number>;
  8983. bv: Nullable<number>;
  8984. distance: number;
  8985. faceId: number;
  8986. subMeshId: number;
  8987. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  8988. }
  8989. /**
  8990. * Information about the result of picking within a scene
  8991. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  8992. */
  8993. class PickingInfo {
  8994. /**
  8995. * If the pick collided with an object
  8996. */
  8997. hit: boolean;
  8998. /**
  8999. * Distance away where the pick collided
  9000. */
  9001. distance: number;
  9002. /**
  9003. * The location of pick collision
  9004. */
  9005. pickedPoint: Nullable<Vector3>;
  9006. /**
  9007. * The mesh corresponding the the pick collision
  9008. */
  9009. pickedMesh: Nullable<AbstractMesh>;
  9010. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9011. bu: number;
  9012. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9013. bv: number;
  9014. /** The id of the face on the mesh that was picked */
  9015. faceId: number;
  9016. /** Id of the the submesh that was picked */
  9017. subMeshId: number;
  9018. /** If a sprite was picked, this will be the sprite the pick collided with */
  9019. pickedSprite: Nullable<Sprite>;
  9020. /**
  9021. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9022. */
  9023. originMesh: Nullable<AbstractMesh>;
  9024. /**
  9025. * The ray that was used to perform the picking.
  9026. */
  9027. ray: Nullable<Ray>;
  9028. /**
  9029. * Gets the normal correspodning to the face the pick collided with
  9030. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9031. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9032. * @returns The normal correspodning to the face the pick collided with
  9033. */
  9034. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9035. /**
  9036. * Gets the texture coordinates of where the pick occured
  9037. * @returns the vector containing the coordnates of the texture
  9038. */
  9039. getTextureCoordinates(): Nullable<Vector2>;
  9040. }
  9041. }
  9042. declare module BABYLON {
  9043. /**
  9044. * Class used to store bounding box information
  9045. */
  9046. class BoundingBox implements ICullable {
  9047. /**
  9048. * Gets the 8 vectors representing the bounding box in local space
  9049. */
  9050. readonly vectors: Vector3[];
  9051. /**
  9052. * Gets the center of the bounding box in local space
  9053. */
  9054. readonly center: Vector3;
  9055. /**
  9056. * Gets the center of the bounding box in world space
  9057. */
  9058. readonly centerWorld: Vector3;
  9059. /**
  9060. * Gets the extend size in local space
  9061. */
  9062. readonly extendSize: Vector3;
  9063. /**
  9064. * Gets the extend size in world space
  9065. */
  9066. readonly extendSizeWorld: Vector3;
  9067. /**
  9068. * Gets the OBB (object bounding box) directions
  9069. */
  9070. readonly directions: Vector3[];
  9071. /**
  9072. * Gets the 8 vectors representing the bounding box in world space
  9073. */
  9074. readonly vectorsWorld: Vector3[];
  9075. /**
  9076. * Gets the minimum vector in world space
  9077. */
  9078. readonly minimumWorld: Vector3;
  9079. /**
  9080. * Gets the maximum vector in world space
  9081. */
  9082. readonly maximumWorld: Vector3;
  9083. /**
  9084. * Gets the minimum vector in local space
  9085. */
  9086. readonly minimum: Vector3;
  9087. /**
  9088. * Gets the maximum vector in local space
  9089. */
  9090. readonly maximum: Vector3;
  9091. private _worldMatrix;
  9092. private static readonly TmpVector3;
  9093. /**
  9094. * @hidden
  9095. */
  9096. _tag: number;
  9097. /**
  9098. * Creates a new bounding box
  9099. * @param min defines the minimum vector (in local space)
  9100. * @param max defines the maximum vector (in local space)
  9101. * @param worldMatrix defines the new world matrix
  9102. */
  9103. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9104. /**
  9105. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9106. * @param min defines the new minimum vector (in local space)
  9107. * @param max defines the new maximum vector (in local space)
  9108. * @param worldMatrix defines the new world matrix
  9109. */
  9110. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9111. /**
  9112. * Scale the current bounding box by applying a scale factor
  9113. * @param factor defines the scale factor to apply
  9114. * @returns the current bounding box
  9115. */
  9116. scale(factor: number): BoundingBox;
  9117. /**
  9118. * Gets the world matrix of the bounding box
  9119. * @returns a matrix
  9120. */
  9121. getWorldMatrix(): DeepImmutable<Matrix>;
  9122. /** @hidden */
  9123. _update(world: DeepImmutable<Matrix>): void;
  9124. /**
  9125. * Tests if the bounding box is intersecting the frustum planes
  9126. * @param frustumPlanes defines the frustum planes to test
  9127. * @returns true if there is an intersection
  9128. */
  9129. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9130. /**
  9131. * Tests if the bounding box is entirely inside the frustum planes
  9132. * @param frustumPlanes defines the frustum planes to test
  9133. * @returns true if there is an inclusion
  9134. */
  9135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9136. /**
  9137. * Tests if a point is inside the bounding box
  9138. * @param point defines the point to test
  9139. * @returns true if the point is inside the bounding box
  9140. */
  9141. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9142. /**
  9143. * Tests if the bounding box intersects with a bounding sphere
  9144. * @param sphere defines the sphere to test
  9145. * @returns true if there is an intersection
  9146. */
  9147. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9148. /**
  9149. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9150. * @param min defines the min vector to use
  9151. * @param max defines the max vector to use
  9152. * @returns true if there is an intersection
  9153. */
  9154. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9155. /**
  9156. * Tests if two bounding boxes are intersections
  9157. * @param box0 defines the first box to test
  9158. * @param box1 defines the second box to test
  9159. * @returns true if there is an intersection
  9160. */
  9161. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9162. /**
  9163. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9164. * @param minPoint defines the minimum vector of the bounding box
  9165. * @param maxPoint defines the maximum vector of the bounding box
  9166. * @param sphereCenter defines the sphere center
  9167. * @param sphereRadius defines the sphere radius
  9168. * @returns true if there is an intersection
  9169. */
  9170. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9171. /**
  9172. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9173. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9174. * @param frustumPlanes defines the frustum planes to test
  9175. * @return true if there is an inclusion
  9176. */
  9177. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9178. /**
  9179. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9180. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9181. * @param frustumPlanes defines the frustum planes to test
  9182. * @return true if there is an intersection
  9183. */
  9184. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9185. }
  9186. }
  9187. declare module BABYLON {
  9188. /**
  9189. * Interface for cullable objects
  9190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9191. */
  9192. interface ICullable {
  9193. /**
  9194. * Checks if the object or part of the object is in the frustum
  9195. * @param frustumPlanes Camera near/planes
  9196. * @returns true if the object is in frustum otherwise false
  9197. */
  9198. isInFrustum(frustumPlanes: Plane[]): boolean;
  9199. /**
  9200. * Checks if a cullable object (mesh...) is in the camera frustum
  9201. * Unlike isInFrustum this cheks the full bounding box
  9202. * @param frustumPlanes Camera near/planes
  9203. * @returns true if the object is in frustum otherwise false
  9204. */
  9205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9206. }
  9207. /**
  9208. * Info for a bounding data of a mesh
  9209. */
  9210. class BoundingInfo implements ICullable {
  9211. /**
  9212. * Bounding box for the mesh
  9213. */
  9214. readonly boundingBox: BoundingBox;
  9215. /**
  9216. * Bounding sphere for the mesh
  9217. */
  9218. readonly boundingSphere: BoundingSphere;
  9219. private _isLocked;
  9220. private static readonly TmpVector3;
  9221. /**
  9222. * Constructs bounding info
  9223. * @param minimum min vector of the bounding box/sphere
  9224. * @param maximum max vector of the bounding box/sphere
  9225. * @param worldMatrix defines the new world matrix
  9226. */
  9227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9228. /**
  9229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9230. * @param min defines the new minimum vector (in local space)
  9231. * @param max defines the new maximum vector (in local space)
  9232. * @param worldMatrix defines the new world matrix
  9233. */
  9234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9235. /**
  9236. * min vector of the bounding box/sphere
  9237. */
  9238. readonly minimum: Vector3;
  9239. /**
  9240. * max vector of the bounding box/sphere
  9241. */
  9242. readonly maximum: Vector3;
  9243. /**
  9244. * If the info is locked and won't be updated to avoid perf overhead
  9245. */
  9246. isLocked: boolean;
  9247. /**
  9248. * Updates the bounding sphere and box
  9249. * @param world world matrix to be used to update
  9250. */
  9251. update(world: DeepImmutable<Matrix>): void;
  9252. /**
  9253. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9254. * @param center New center of the bounding info
  9255. * @param extend New extend of the bounding info
  9256. * @returns the current bounding info
  9257. */
  9258. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9259. /**
  9260. * Scale the current bounding info by applying a scale factor
  9261. * @param factor defines the scale factor to apply
  9262. * @returns the current bounding info
  9263. */
  9264. scale(factor: number): BoundingInfo;
  9265. /**
  9266. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9267. * @param frustumPlanes defines the frustum to test
  9268. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9269. * @returns true if the bounding info is in the frustum planes
  9270. */
  9271. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9272. /**
  9273. * Gets the world distance between the min and max points of the bounding box
  9274. */
  9275. readonly diagonalLength: number;
  9276. /**
  9277. * Checks if a cullable object (mesh...) is in the camera frustum
  9278. * Unlike isInFrustum this cheks the full bounding box
  9279. * @param frustumPlanes Camera near/planes
  9280. * @returns true if the object is in frustum otherwise false
  9281. */
  9282. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9283. /** @hidden */
  9284. _checkCollision(collider: Collider): boolean;
  9285. /**
  9286. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9287. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9288. * @param point the point to check intersection with
  9289. * @returns if the point intersects
  9290. */
  9291. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9292. /**
  9293. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9294. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9295. * @param boundingInfo the bounding info to check intersection with
  9296. * @param precise if the intersection should be done using OBB
  9297. * @returns if the bounding info intersects
  9298. */
  9299. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9300. }
  9301. }
  9302. declare module BABYLON {
  9303. /**
  9304. * Class used to store bounding sphere information
  9305. */
  9306. class BoundingSphere {
  9307. /**
  9308. * Gets the center of the bounding sphere in local space
  9309. */
  9310. readonly center: Vector3;
  9311. /**
  9312. * Radius of the bounding sphere in local space
  9313. */
  9314. radius: number;
  9315. /**
  9316. * Gets the center of the bounding sphere in world space
  9317. */
  9318. readonly centerWorld: Vector3;
  9319. /**
  9320. * Radius of the bounding sphere in world space
  9321. */
  9322. radiusWorld: number;
  9323. /**
  9324. * Gets the minimum vector in local space
  9325. */
  9326. readonly minimum: Vector3;
  9327. /**
  9328. * Gets the maximum vector in local space
  9329. */
  9330. readonly maximum: Vector3;
  9331. private _worldMatrix;
  9332. private static readonly TmpVector3;
  9333. /**
  9334. * Creates a new bounding sphere
  9335. * @param min defines the minimum vector (in local space)
  9336. * @param max defines the maximum vector (in local space)
  9337. * @param worldMatrix defines the new world matrix
  9338. */
  9339. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9340. /**
  9341. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9342. * @param min defines the new minimum vector (in local space)
  9343. * @param max defines the new maximum vector (in local space)
  9344. * @param worldMatrix defines the new world matrix
  9345. */
  9346. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9347. /**
  9348. * Scale the current bounding sphere by applying a scale factor
  9349. * @param factor defines the scale factor to apply
  9350. * @returns the current bounding box
  9351. */
  9352. scale(factor: number): BoundingSphere;
  9353. /**
  9354. * Gets the world matrix of the bounding box
  9355. * @returns a matrix
  9356. */
  9357. getWorldMatrix(): DeepImmutable<Matrix>;
  9358. /** @hidden */
  9359. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9360. /**
  9361. * Tests if the bounding sphere is intersecting the frustum planes
  9362. * @param frustumPlanes defines the frustum planes to test
  9363. * @returns true if there is an intersection
  9364. */
  9365. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9366. /**
  9367. * Tests if a point is inside the bounding sphere
  9368. * @param point defines the point to test
  9369. * @returns true if the point is inside the bounding sphere
  9370. */
  9371. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9372. /**
  9373. * Checks if two sphere intersct
  9374. * @param sphere0 sphere 0
  9375. * @param sphere1 sphere 1
  9376. * @returns true if the speres intersect
  9377. */
  9378. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Class representing a ray with position and direction
  9384. */
  9385. class Ray {
  9386. /** origin point */
  9387. origin: Vector3;
  9388. /** direction */
  9389. direction: Vector3;
  9390. /** length of the ray */
  9391. length: number;
  9392. private static readonly TmpVector3;
  9393. private _tmpRay;
  9394. /**
  9395. * Creates a new ray
  9396. * @param origin origin point
  9397. * @param direction direction
  9398. * @param length length of the ray
  9399. */
  9400. constructor(
  9401. /** origin point */
  9402. origin: Vector3,
  9403. /** direction */
  9404. direction: Vector3,
  9405. /** length of the ray */
  9406. length?: number);
  9407. /**
  9408. * Checks if the ray intersects a box
  9409. * @param minimum bound of the box
  9410. * @param maximum bound of the box
  9411. * @param intersectionTreshold extra extend to be added to the box in all direction
  9412. * @returns if the box was hit
  9413. */
  9414. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9415. /**
  9416. * Checks if the ray intersects a box
  9417. * @param box the bounding box to check
  9418. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9419. * @returns if the box was hit
  9420. */
  9421. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9422. /**
  9423. * If the ray hits a sphere
  9424. * @param sphere the bounding sphere to check
  9425. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9426. * @returns true if it hits the sphere
  9427. */
  9428. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9429. /**
  9430. * If the ray hits a triange
  9431. * @param vertex0 triangle vertex
  9432. * @param vertex1 triangle vertex
  9433. * @param vertex2 triangle vertex
  9434. * @returns intersection information if hit
  9435. */
  9436. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9437. /**
  9438. * Checks if ray intersects a plane
  9439. * @param plane the plane to check
  9440. * @returns the distance away it was hit
  9441. */
  9442. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9443. /**
  9444. * Checks if ray intersects a mesh
  9445. * @param mesh the mesh to check
  9446. * @param fastCheck if only the bounding box should checked
  9447. * @returns picking info of the intersecton
  9448. */
  9449. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9450. /**
  9451. * Checks if ray intersects a mesh
  9452. * @param meshes the meshes to check
  9453. * @param fastCheck if only the bounding box should checked
  9454. * @param results array to store result in
  9455. * @returns Array of picking infos
  9456. */
  9457. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9458. private _comparePickingInfo;
  9459. private static smallnum;
  9460. private static rayl;
  9461. /**
  9462. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9463. * @param sega the first point of the segment to test the intersection against
  9464. * @param segb the second point of the segment to test the intersection against
  9465. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9466. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9467. */
  9468. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9469. /**
  9470. * Update the ray from viewport position
  9471. * @param x position
  9472. * @param y y position
  9473. * @param viewportWidth viewport width
  9474. * @param viewportHeight viewport height
  9475. * @param world world matrix
  9476. * @param view view matrix
  9477. * @param projection projection matrix
  9478. * @returns this ray updated
  9479. */
  9480. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9481. /**
  9482. * Creates a ray with origin and direction of 0,0,0
  9483. * @returns the new ray
  9484. */
  9485. static Zero(): Ray;
  9486. /**
  9487. * Creates a new ray from screen space and viewport
  9488. * @param x position
  9489. * @param y y position
  9490. * @param viewportWidth viewport width
  9491. * @param viewportHeight viewport height
  9492. * @param world world matrix
  9493. * @param view view matrix
  9494. * @param projection projection matrix
  9495. * @returns new ray
  9496. */
  9497. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9498. /**
  9499. * 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
  9500. * transformed to the given world matrix.
  9501. * @param origin The origin point
  9502. * @param end The end point
  9503. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9504. * @returns the new ray
  9505. */
  9506. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9507. /**
  9508. * Transforms a ray by a matrix
  9509. * @param ray ray to transform
  9510. * @param matrix matrix to apply
  9511. * @returns the resulting new ray
  9512. */
  9513. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9514. /**
  9515. * Transforms a ray by a matrix
  9516. * @param ray ray to transform
  9517. * @param matrix matrix to apply
  9518. * @param result ray to store result in
  9519. */
  9520. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9521. }
  9522. }
  9523. /**
  9524. * Module Debug contains the (visual) components to debug a scene correctly
  9525. */
  9526. declare module BABYLON.Debug {
  9527. /**
  9528. * The Axes viewer will show 3 axes in a specific point in space
  9529. */
  9530. class AxesViewer {
  9531. private _xline;
  9532. private _yline;
  9533. private _zline;
  9534. private _xmesh;
  9535. private _ymesh;
  9536. private _zmesh;
  9537. /**
  9538. * Gets the hosting scene
  9539. */
  9540. scene: Nullable<Scene>;
  9541. /**
  9542. * Gets or sets a number used to scale line length
  9543. */
  9544. scaleLines: number;
  9545. /** Gets the mesh used to render x-axis */
  9546. readonly xAxisMesh: Nullable<LinesMesh>;
  9547. /** Gets the mesh used to render x-axis */
  9548. readonly yAxisMesh: Nullable<LinesMesh>;
  9549. /** Gets the mesh used to render x-axis */
  9550. readonly zAxisMesh: Nullable<LinesMesh>;
  9551. /**
  9552. * Creates a new AxesViewer
  9553. * @param scene defines the hosting scene
  9554. * @param scaleLines defines a number used to scale line length (1 by default)
  9555. */
  9556. constructor(scene: Scene, scaleLines?: number);
  9557. /**
  9558. * Force the viewer to update
  9559. * @param position defines the position of the viewer
  9560. * @param xaxis defines the x axis of the viewer
  9561. * @param yaxis defines the y axis of the viewer
  9562. * @param zaxis defines the z axis of the viewer
  9563. */
  9564. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9565. /** Releases resources */
  9566. dispose(): void;
  9567. }
  9568. }
  9569. declare module BABYLON.Debug {
  9570. /**
  9571. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9572. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9573. */
  9574. class BoneAxesViewer extends AxesViewer {
  9575. /**
  9576. * Gets or sets the target mesh where to display the axes viewer
  9577. */
  9578. mesh: Nullable<Mesh>;
  9579. /**
  9580. * Gets or sets the target bone where to display the axes viewer
  9581. */
  9582. bone: Nullable<Bone>;
  9583. /** Gets current position */
  9584. pos: Vector3;
  9585. /** Gets direction of X axis */
  9586. xaxis: Vector3;
  9587. /** Gets direction of Y axis */
  9588. yaxis: Vector3;
  9589. /** Gets direction of Z axis */
  9590. zaxis: Vector3;
  9591. /**
  9592. * Creates a new BoneAxesViewer
  9593. * @param scene defines the hosting scene
  9594. * @param bone defines the target bone
  9595. * @param mesh defines the target mesh
  9596. * @param scaleLines defines a scaling factor for line length (1 by default)
  9597. */
  9598. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9599. /**
  9600. * Force the viewer to update
  9601. */
  9602. update(): void;
  9603. /** Releases resources */
  9604. dispose(): void;
  9605. }
  9606. }
  9607. declare module BABYLON {
  9608. /**
  9609. * Interface used to define scene explorer extensibility option
  9610. */
  9611. interface IExplorerExtensibilityOption {
  9612. /**
  9613. * Define the option label
  9614. */
  9615. label: string;
  9616. /**
  9617. * Defines the action to execute on click
  9618. */
  9619. action: (entity: any) => void;
  9620. }
  9621. /**
  9622. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9623. */
  9624. interface IExplorerExtensibilityGroup {
  9625. /**
  9626. * Defines a predicate to test if a given type mut be extended
  9627. */
  9628. predicate: (entity: any) => boolean;
  9629. /**
  9630. * Gets the list of options added to a type
  9631. */
  9632. entries: IExplorerExtensibilityOption[];
  9633. }
  9634. /**
  9635. * Interface used to define the options to use to create the Inspector
  9636. */
  9637. interface IInspectorOptions {
  9638. /**
  9639. * Display in overlay mode (default: false)
  9640. */
  9641. overlay?: boolean;
  9642. /**
  9643. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9644. */
  9645. globalRoot?: HTMLElement;
  9646. /**
  9647. * Display the Scene explorer
  9648. */
  9649. showExplorer?: boolean;
  9650. /**
  9651. * Display the property inspector
  9652. */
  9653. showInspector?: boolean;
  9654. /**
  9655. * Display in embed mode (both panes on the right)
  9656. */
  9657. embedMode?: boolean;
  9658. /**
  9659. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9660. */
  9661. handleResize?: boolean;
  9662. /**
  9663. * Allow the panes to popup (default: true)
  9664. */
  9665. enablePopup?: boolean;
  9666. /**
  9667. * Optional list of extensibility entries
  9668. */
  9669. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9670. }
  9671. interface Scene {
  9672. /**
  9673. * @hidden
  9674. * Backing field
  9675. */
  9676. _debugLayer: DebugLayer;
  9677. /**
  9678. * Gets the debug layer (aka Inspector) associated with the scene
  9679. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9680. */
  9681. debugLayer: DebugLayer;
  9682. }
  9683. /**
  9684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9685. * what is happening in your scene
  9686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9687. */
  9688. class DebugLayer {
  9689. /**
  9690. * Define the url to get the inspector script from.
  9691. * By default it uses the babylonjs CDN.
  9692. * @ignoreNaming
  9693. */
  9694. static InspectorURL: string;
  9695. private _scene;
  9696. private BJSINSPECTOR;
  9697. /**
  9698. * Observable triggered when a property is changed through the inspector.
  9699. */
  9700. onPropertyChangedObservable: Observable<{
  9701. object: any;
  9702. property: string;
  9703. value: any;
  9704. initialValue: any;
  9705. }>;
  9706. /**
  9707. * Instantiates a new debug layer.
  9708. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9709. * what is happening in your scene
  9710. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9711. * @param scene Defines the scene to inspect
  9712. */
  9713. constructor(scene: Scene);
  9714. /** Creates the inspector window. */
  9715. private _createInspector;
  9716. /**
  9717. * Get if the inspector is visible or not.
  9718. * @returns true if visible otherwise, false
  9719. */
  9720. isVisible(): boolean;
  9721. /**
  9722. * Hide the inspector and close its window.
  9723. */
  9724. hide(): void;
  9725. /**
  9726. * Launch the debugLayer.
  9727. * @param config Define the configuration of the inspector
  9728. */
  9729. show(config?: IInspectorOptions): void;
  9730. }
  9731. }
  9732. declare module BABYLON.Debug {
  9733. /**
  9734. * Used to show the physics impostor around the specific mesh
  9735. */
  9736. class PhysicsViewer {
  9737. /** @hidden */
  9738. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9739. /** @hidden */
  9740. protected _meshes: Array<Nullable<AbstractMesh>>;
  9741. /** @hidden */
  9742. protected _scene: Nullable<Scene>;
  9743. /** @hidden */
  9744. protected _numMeshes: number;
  9745. /** @hidden */
  9746. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9747. private _renderFunction;
  9748. private _debugBoxMesh;
  9749. private _debugSphereMesh;
  9750. private _debugMaterial;
  9751. /**
  9752. * Creates a new PhysicsViewer
  9753. * @param scene defines the hosting scene
  9754. */
  9755. constructor(scene: Scene);
  9756. /** @hidden */
  9757. protected _updateDebugMeshes(): void;
  9758. /**
  9759. * Renders a specified physic impostor
  9760. * @param impostor defines the impostor to render
  9761. */
  9762. showImpostor(impostor: PhysicsImpostor): void;
  9763. /**
  9764. * Hides a specified physic impostor
  9765. * @param impostor defines the impostor to hide
  9766. */
  9767. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9768. private _getDebugMaterial;
  9769. private _getDebugBoxMesh;
  9770. private _getDebugSphereMesh;
  9771. private _getDebugMesh;
  9772. /** Releases all resources */
  9773. dispose(): void;
  9774. }
  9775. }
  9776. declare module BABYLON {
  9777. /**
  9778. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9779. * in order to better appreciate the issue one might have.
  9780. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9781. */
  9782. class RayHelper {
  9783. /**
  9784. * Defines the ray we are currently tryin to visualize.
  9785. */
  9786. ray: Nullable<Ray>;
  9787. private _renderPoints;
  9788. private _renderLine;
  9789. private _renderFunction;
  9790. private _scene;
  9791. private _updateToMeshFunction;
  9792. private _attachedToMesh;
  9793. private _meshSpaceDirection;
  9794. private _meshSpaceOrigin;
  9795. /**
  9796. * Helper function to create a colored helper in a scene in one line.
  9797. * @param ray Defines the ray we are currently tryin to visualize
  9798. * @param scene Defines the scene the ray is used in
  9799. * @param color Defines the color we want to see the ray in
  9800. * @returns The newly created ray helper.
  9801. */
  9802. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9803. /**
  9804. * Instantiate a new ray helper.
  9805. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9806. * in order to better appreciate the issue one might have.
  9807. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9808. * @param ray Defines the ray we are currently tryin to visualize
  9809. */
  9810. constructor(ray: Ray);
  9811. /**
  9812. * Shows the ray we are willing to debug.
  9813. * @param scene Defines the scene the ray needs to be rendered in
  9814. * @param color Defines the color the ray needs to be rendered in
  9815. */
  9816. show(scene: Scene, color?: Color3): void;
  9817. /**
  9818. * Hides the ray we are debugging.
  9819. */
  9820. hide(): void;
  9821. private _render;
  9822. /**
  9823. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9824. * @param mesh Defines the mesh we want the helper attached to
  9825. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9826. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9827. * @param length Defines the length of the ray
  9828. */
  9829. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9830. /**
  9831. * Detach the ray helper from the mesh it has previously been attached to.
  9832. */
  9833. detachFromMesh(): void;
  9834. private _updateToMesh;
  9835. /**
  9836. * Dispose the helper and release its associated resources.
  9837. */
  9838. dispose(): void;
  9839. }
  9840. }
  9841. declare module BABYLON.Debug {
  9842. /**
  9843. * Class used to render a debug view of a given skeleton
  9844. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9845. */
  9846. class SkeletonViewer {
  9847. /** defines the skeleton to render */
  9848. skeleton: Skeleton;
  9849. /** defines the mesh attached to the skeleton */
  9850. mesh: AbstractMesh;
  9851. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9852. autoUpdateBonesMatrices: boolean;
  9853. /** defines the rendering group id to use with the viewer */
  9854. renderingGroupId: number;
  9855. /** defines an optional utility layer to render the helper on */
  9856. utilityLayerRenderer?: UtilityLayerRenderer | undefined;
  9857. /** Gets or sets the color used to render the skeleton */
  9858. color: Color3;
  9859. private _scene;
  9860. private _debugLines;
  9861. private _debugMesh;
  9862. private _isEnabled;
  9863. private _renderFunction;
  9864. /**
  9865. * Returns the mesh used to render the bones
  9866. */
  9867. readonly debugMesh: Nullable<LinesMesh>;
  9868. /**
  9869. * Creates a new SkeletonViewer
  9870. * @param skeleton defines the skeleton to render
  9871. * @param mesh defines the mesh attached to the skeleton
  9872. * @param scene defines the hosting scene
  9873. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9874. * @param renderingGroupId defines the rendering group id to use with the viewer
  9875. * @param utilityLayerRenderer defines an optional utility layer to render the helper on
  9876. */
  9877. constructor(
  9878. /** defines the skeleton to render */
  9879. skeleton: Skeleton,
  9880. /** defines the mesh attached to the skeleton */
  9881. mesh: AbstractMesh, scene: Scene,
  9882. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9883. autoUpdateBonesMatrices?: boolean,
  9884. /** defines the rendering group id to use with the viewer */
  9885. renderingGroupId?: number,
  9886. /** defines an optional utility layer to render the helper on */
  9887. utilityLayerRenderer?: UtilityLayerRenderer | undefined);
  9888. /** Gets or sets a boolean indicating if the viewer is enabled */
  9889. isEnabled: boolean;
  9890. private _getBonePosition;
  9891. private _getLinesForBonesWithLength;
  9892. private _getLinesForBonesNoLength;
  9893. /** Update the viewer to sync with current skeleton state */
  9894. update(): void;
  9895. /** Release associated resources */
  9896. dispose(): void;
  9897. }
  9898. }
  9899. declare module BABYLON {
  9900. /**
  9901. * Interface for attribute information associated with buffer instanciation
  9902. */
  9903. class InstancingAttributeInfo {
  9904. /**
  9905. * Index/offset of the attribute in the vertex shader
  9906. */
  9907. index: number;
  9908. /**
  9909. * size of the attribute, 1, 2, 3 or 4
  9910. */
  9911. attributeSize: number;
  9912. /**
  9913. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9914. * default is FLOAT
  9915. */
  9916. attribyteType: number;
  9917. /**
  9918. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9919. */
  9920. normalized: boolean;
  9921. /**
  9922. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9923. */
  9924. offset: number;
  9925. /**
  9926. * Name of the GLSL attribute, for debugging purpose only
  9927. */
  9928. attributeName: string;
  9929. }
  9930. /**
  9931. * Define options used to create a render target texture
  9932. */
  9933. class RenderTargetCreationOptions {
  9934. /**
  9935. * Specifies is mipmaps must be generated
  9936. */
  9937. generateMipMaps?: boolean;
  9938. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9939. generateDepthBuffer?: boolean;
  9940. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9941. generateStencilBuffer?: boolean;
  9942. /** Defines texture type (int by default) */
  9943. type?: number;
  9944. /** Defines sampling mode (trilinear by default) */
  9945. samplingMode?: number;
  9946. /** Defines format (RGBA by default) */
  9947. format?: number;
  9948. }
  9949. /**
  9950. * Define options used to create a depth texture
  9951. */
  9952. class DepthTextureCreationOptions {
  9953. /** Specifies whether or not a stencil should be allocated in the texture */
  9954. generateStencil?: boolean;
  9955. /** Specifies whether or not bilinear filtering is enable on the texture */
  9956. bilinearFiltering?: boolean;
  9957. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9958. comparisonFunction?: number;
  9959. /** Specifies if the created texture is a cube texture */
  9960. isCube?: boolean;
  9961. }
  9962. /**
  9963. * Class used to describe the capabilities of the engine relatively to the current browser
  9964. */
  9965. class EngineCapabilities {
  9966. /** Maximum textures units per fragment shader */
  9967. maxTexturesImageUnits: number;
  9968. /** Maximum texture units per vertex shader */
  9969. maxVertexTextureImageUnits: number;
  9970. /** Maximum textures units in the entire pipeline */
  9971. maxCombinedTexturesImageUnits: number;
  9972. /** Maximum texture size */
  9973. maxTextureSize: number;
  9974. /** Maximum cube texture size */
  9975. maxCubemapTextureSize: number;
  9976. /** Maximum render texture size */
  9977. maxRenderTextureSize: number;
  9978. /** Maximum number of vertex attributes */
  9979. maxVertexAttribs: number;
  9980. /** Maximum number of varyings */
  9981. maxVaryingVectors: number;
  9982. /** Maximum number of uniforms per vertex shader */
  9983. maxVertexUniformVectors: number;
  9984. /** Maximum number of uniforms per fragment shader */
  9985. maxFragmentUniformVectors: number;
  9986. /** Defines if standard derivates (dx/dy) are supported */
  9987. standardDerivatives: boolean;
  9988. /** Defines if s3tc texture compression is supported */
  9989. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9990. /** Defines if pvrtc texture compression is supported */
  9991. pvrtc: any;
  9992. /** Defines if etc1 texture compression is supported */
  9993. etc1: any;
  9994. /** Defines if etc2 texture compression is supported */
  9995. etc2: any;
  9996. /** Defines if astc texture compression is supported */
  9997. astc: any;
  9998. /** Defines if float textures are supported */
  9999. textureFloat: boolean;
  10000. /** Defines if vertex array objects are supported */
  10001. vertexArrayObject: boolean;
  10002. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10003. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10004. /** Gets the maximum level of anisotropy supported */
  10005. maxAnisotropy: number;
  10006. /** Defines if instancing is supported */
  10007. instancedArrays: boolean;
  10008. /** Defines if 32 bits indices are supported */
  10009. uintIndices: boolean;
  10010. /** Defines if high precision shaders are supported */
  10011. highPrecisionShaderSupported: boolean;
  10012. /** Defines if depth reading in the fragment shader is supported */
  10013. fragmentDepthSupported: boolean;
  10014. /** Defines if float texture linear filtering is supported*/
  10015. textureFloatLinearFiltering: boolean;
  10016. /** Defines if rendering to float textures is supported */
  10017. textureFloatRender: boolean;
  10018. /** Defines if half float textures are supported*/
  10019. textureHalfFloat: boolean;
  10020. /** Defines if half float texture linear filtering is supported*/
  10021. textureHalfFloatLinearFiltering: boolean;
  10022. /** Defines if rendering to half float textures is supported */
  10023. textureHalfFloatRender: boolean;
  10024. /** Defines if textureLOD shader command is supported */
  10025. textureLOD: boolean;
  10026. /** Defines if draw buffers extension is supported */
  10027. drawBuffersExtension: boolean;
  10028. /** Defines if depth textures are supported */
  10029. depthTextureExtension: boolean;
  10030. /** Defines if float color buffer are supported */
  10031. colorBufferFloat: boolean;
  10032. /** Gets disjoint timer query extension (null if not supported) */
  10033. timerQuery: EXT_disjoint_timer_query;
  10034. /** Defines if timestamp can be used with timer query */
  10035. canUseTimestampForTimerQuery: boolean;
  10036. /** Function used to let the system compiles shaders in background */
  10037. parallelShaderCompile: {
  10038. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10039. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10040. COMPLETION_STATUS_KHR: number;
  10041. };
  10042. }
  10043. /** Interface defining initialization parameters for Engine class */
  10044. interface EngineOptions extends WebGLContextAttributes {
  10045. /**
  10046. * Defines if the engine should no exceed a specified device ratio
  10047. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10048. */
  10049. limitDeviceRatio?: number;
  10050. /**
  10051. * Defines if webvr should be enabled automatically
  10052. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10053. */
  10054. autoEnableWebVR?: boolean;
  10055. /**
  10056. * Defines if webgl2 should be turned off even if supported
  10057. * @see http://doc.babylonjs.com/features/webgl2
  10058. */
  10059. disableWebGL2Support?: boolean;
  10060. /**
  10061. * Defines if webaudio should be initialized as well
  10062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10063. */
  10064. audioEngine?: boolean;
  10065. /**
  10066. * Defines if animations should run using a deterministic lock step
  10067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10068. */
  10069. deterministicLockstep?: boolean;
  10070. /** Defines the maximum steps to use with deterministic lock step mode */
  10071. lockstepMaxSteps?: number;
  10072. /**
  10073. * Defines that engine should ignore context lost events
  10074. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10075. */
  10076. doNotHandleContextLost?: boolean;
  10077. }
  10078. /**
  10079. * Defines the interface used by display changed events
  10080. */
  10081. interface IDisplayChangedEventArgs {
  10082. /** Gets the vrDisplay object (if any) */
  10083. vrDisplay: Nullable<any>;
  10084. /** Gets a boolean indicating if webVR is supported */
  10085. vrSupported: boolean;
  10086. }
  10087. /**
  10088. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10089. */
  10090. class Engine {
  10091. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10092. static ExceptionList: ({
  10093. key: string;
  10094. capture: string;
  10095. captureConstraint: number;
  10096. targets: string[];
  10097. } | {
  10098. key: string;
  10099. capture: null;
  10100. captureConstraint: null;
  10101. targets: string[];
  10102. })[];
  10103. /** Gets the list of created engines */
  10104. static Instances: Engine[];
  10105. /**
  10106. * Gets the latest created engine
  10107. */
  10108. static readonly LastCreatedEngine: Nullable<Engine>;
  10109. /**
  10110. * Gets the latest created scene
  10111. */
  10112. static readonly LastCreatedScene: Nullable<Scene>;
  10113. /**
  10114. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10115. * @param flag defines which part of the materials must be marked as dirty
  10116. * @param predicate defines a predicate used to filter which materials should be affected
  10117. */
  10118. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10119. /**
  10120. * Hidden
  10121. */
  10122. static _TextureLoaders: IInternalTextureLoader[];
  10123. /** Defines that alpha blending is disabled */
  10124. static readonly ALPHA_DISABLE: number;
  10125. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10126. static readonly ALPHA_ADD: number;
  10127. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10128. static readonly ALPHA_COMBINE: number;
  10129. /** Defines that alpha blending to DEST - SRC * DEST */
  10130. static readonly ALPHA_SUBTRACT: number;
  10131. /** Defines that alpha blending to SRC * DEST */
  10132. static readonly ALPHA_MULTIPLY: number;
  10133. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10134. static readonly ALPHA_MAXIMIZED: number;
  10135. /** Defines that alpha blending to SRC + DEST */
  10136. static readonly ALPHA_ONEONE: number;
  10137. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10138. static readonly ALPHA_PREMULTIPLIED: number;
  10139. /**
  10140. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10141. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10142. */
  10143. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10144. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10145. static readonly ALPHA_INTERPOLATE: number;
  10146. /**
  10147. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10148. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10149. */
  10150. static readonly ALPHA_SCREENMODE: number;
  10151. /** Defines that the ressource is not delayed*/
  10152. static readonly DELAYLOADSTATE_NONE: number;
  10153. /** Defines that the ressource was successfully delay loaded */
  10154. static readonly DELAYLOADSTATE_LOADED: number;
  10155. /** Defines that the ressource is currently delay loading */
  10156. static readonly DELAYLOADSTATE_LOADING: number;
  10157. /** Defines that the ressource is delayed and has not started loading */
  10158. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10159. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10160. static readonly NEVER: number;
  10161. /** 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 */
  10162. static readonly ALWAYS: number;
  10163. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10164. static readonly LESS: number;
  10165. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10166. static readonly EQUAL: number;
  10167. /** 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 */
  10168. static readonly LEQUAL: number;
  10169. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10170. static readonly GREATER: number;
  10171. /** 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 */
  10172. static readonly GEQUAL: number;
  10173. /** 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 */
  10174. static readonly NOTEQUAL: number;
  10175. /** Passed to stencilOperation to specify that stencil value must be kept */
  10176. static readonly KEEP: number;
  10177. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10178. static readonly REPLACE: number;
  10179. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10180. static readonly INCR: number;
  10181. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10182. static readonly DECR: number;
  10183. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10184. static readonly INVERT: number;
  10185. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10186. static readonly INCR_WRAP: number;
  10187. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10188. static readonly DECR_WRAP: number;
  10189. /** Texture is not repeating outside of 0..1 UVs */
  10190. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10191. /** Texture is repeating outside of 0..1 UVs */
  10192. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10193. /** Texture is repeating and mirrored */
  10194. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10195. /** ALPHA */
  10196. static readonly TEXTUREFORMAT_ALPHA: number;
  10197. /** LUMINANCE */
  10198. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10199. /** LUMINANCE_ALPHA */
  10200. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10201. /** RGB */
  10202. static readonly TEXTUREFORMAT_RGB: number;
  10203. /** RGBA */
  10204. static readonly TEXTUREFORMAT_RGBA: number;
  10205. /** RED */
  10206. static readonly TEXTUREFORMAT_RED: number;
  10207. /** RED (2nd reference) */
  10208. static readonly TEXTUREFORMAT_R: number;
  10209. /** RG */
  10210. static readonly TEXTUREFORMAT_RG: number;
  10211. /** RED_INTEGER */
  10212. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10213. /** RED_INTEGER (2nd reference) */
  10214. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10215. /** RG_INTEGER */
  10216. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10217. /** RGB_INTEGER */
  10218. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10219. /** RGBA_INTEGER */
  10220. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10221. /** UNSIGNED_BYTE */
  10222. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10223. /** UNSIGNED_BYTE (2nd reference) */
  10224. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10225. /** FLOAT */
  10226. static readonly TEXTURETYPE_FLOAT: number;
  10227. /** HALF_FLOAT */
  10228. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10229. /** BYTE */
  10230. static readonly TEXTURETYPE_BYTE: number;
  10231. /** SHORT */
  10232. static readonly TEXTURETYPE_SHORT: number;
  10233. /** UNSIGNED_SHORT */
  10234. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10235. /** INT */
  10236. static readonly TEXTURETYPE_INT: number;
  10237. /** UNSIGNED_INT */
  10238. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10239. /** UNSIGNED_SHORT_4_4_4_4 */
  10240. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10241. /** UNSIGNED_SHORT_5_5_5_1 */
  10242. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10243. /** UNSIGNED_SHORT_5_6_5 */
  10244. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10245. /** UNSIGNED_INT_2_10_10_10_REV */
  10246. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10247. /** UNSIGNED_INT_24_8 */
  10248. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10249. /** UNSIGNED_INT_10F_11F_11F_REV */
  10250. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10251. /** UNSIGNED_INT_5_9_9_9_REV */
  10252. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10253. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10254. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10255. /** nearest is mag = nearest and min = nearest and mip = linear */
  10256. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10257. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10258. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10259. /** Trilinear is mag = linear and min = linear and mip = linear */
  10260. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10261. /** nearest is mag = nearest and min = nearest and mip = linear */
  10262. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10263. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10264. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10265. /** Trilinear is mag = linear and min = linear and mip = linear */
  10266. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10267. /** mag = nearest and min = nearest and mip = nearest */
  10268. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10269. /** mag = nearest and min = linear and mip = nearest */
  10270. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10271. /** mag = nearest and min = linear and mip = linear */
  10272. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10273. /** mag = nearest and min = linear and mip = none */
  10274. static readonly TEXTURE_NEAREST_LINEAR: number;
  10275. /** mag = nearest and min = nearest and mip = none */
  10276. static readonly TEXTURE_NEAREST_NEAREST: number;
  10277. /** mag = linear and min = nearest and mip = nearest */
  10278. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10279. /** mag = linear and min = nearest and mip = linear */
  10280. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10281. /** mag = linear and min = linear and mip = none */
  10282. static readonly TEXTURE_LINEAR_LINEAR: number;
  10283. /** mag = linear and min = nearest and mip = none */
  10284. static readonly TEXTURE_LINEAR_NEAREST: number;
  10285. /** Explicit coordinates mode */
  10286. static readonly TEXTURE_EXPLICIT_MODE: number;
  10287. /** Spherical coordinates mode */
  10288. static readonly TEXTURE_SPHERICAL_MODE: number;
  10289. /** Planar coordinates mode */
  10290. static readonly TEXTURE_PLANAR_MODE: number;
  10291. /** Cubic coordinates mode */
  10292. static readonly TEXTURE_CUBIC_MODE: number;
  10293. /** Projection coordinates mode */
  10294. static readonly TEXTURE_PROJECTION_MODE: number;
  10295. /** Skybox coordinates mode */
  10296. static readonly TEXTURE_SKYBOX_MODE: number;
  10297. /** Inverse Cubic coordinates mode */
  10298. static readonly TEXTURE_INVCUBIC_MODE: number;
  10299. /** Equirectangular coordinates mode */
  10300. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10301. /** Equirectangular Fixed coordinates mode */
  10302. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10303. /** Equirectangular Fixed Mirrored coordinates mode */
  10304. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10305. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10306. static readonly SCALEMODE_FLOOR: number;
  10307. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10308. static readonly SCALEMODE_NEAREST: number;
  10309. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10310. static readonly SCALEMODE_CEILING: number;
  10311. /**
  10312. * Returns the current version of the framework
  10313. */
  10314. static readonly Version: string;
  10315. /**
  10316. * Returns a string describing the current engine
  10317. */
  10318. readonly description: string;
  10319. /**
  10320. * Gets or sets the epsilon value used by collision engine
  10321. */
  10322. static CollisionsEpsilon: number;
  10323. /**
  10324. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10325. */
  10326. static CodeRepository: string;
  10327. /**
  10328. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10329. */
  10330. static ShadersRepository: string;
  10331. /**
  10332. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10333. */
  10334. forcePOTTextures: boolean;
  10335. /**
  10336. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10337. */
  10338. isFullscreen: boolean;
  10339. /**
  10340. * Gets a boolean indicating if the pointer is currently locked
  10341. */
  10342. isPointerLock: boolean;
  10343. /**
  10344. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10345. */
  10346. cullBackFaces: boolean;
  10347. /**
  10348. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10349. */
  10350. renderEvenInBackground: boolean;
  10351. /**
  10352. * Gets or sets a boolean indicating that cache can be kept between frames
  10353. */
  10354. preventCacheWipeBetweenFrames: boolean;
  10355. /**
  10356. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10357. **/
  10358. enableOfflineSupport: boolean;
  10359. /**
  10360. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10361. **/
  10362. disableManifestCheck: boolean;
  10363. /**
  10364. * Gets the list of created scenes
  10365. */
  10366. scenes: Scene[];
  10367. /**
  10368. * Event raised when a new scene is created
  10369. */
  10370. onNewSceneAddedObservable: Observable<Scene>;
  10371. /**
  10372. * Gets the list of created postprocesses
  10373. */
  10374. postProcesses: PostProcess[];
  10375. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10376. validateShaderPrograms: boolean;
  10377. /**
  10378. * Observable event triggered each time the rendering canvas is resized
  10379. */
  10380. onResizeObservable: Observable<Engine>;
  10381. /**
  10382. * Observable event triggered each time the canvas loses focus
  10383. */
  10384. onCanvasBlurObservable: Observable<Engine>;
  10385. /**
  10386. * Observable event triggered each time the canvas gains focus
  10387. */
  10388. onCanvasFocusObservable: Observable<Engine>;
  10389. /**
  10390. * Observable event triggered each time the canvas receives pointerout event
  10391. */
  10392. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10393. /**
  10394. * Observable event triggered before each texture is initialized
  10395. */
  10396. onBeforeTextureInitObservable: Observable<Texture>;
  10397. private _vrDisplay;
  10398. private _vrSupported;
  10399. private _oldSize;
  10400. private _oldHardwareScaleFactor;
  10401. private _vrExclusivePointerMode;
  10402. private _webVRInitPromise;
  10403. /**
  10404. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10405. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10406. */
  10407. readonly isInVRExclusivePointerMode: boolean;
  10408. /**
  10409. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10410. */
  10411. disableUniformBuffers: boolean;
  10412. /** @hidden */
  10413. _uniformBuffers: UniformBuffer[];
  10414. /**
  10415. * Gets a boolean indicating that the engine supports uniform buffers
  10416. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10417. */
  10418. readonly supportsUniformBuffers: boolean;
  10419. /**
  10420. * Observable raised when the engine begins a new frame
  10421. */
  10422. onBeginFrameObservable: Observable<Engine>;
  10423. /**
  10424. * If set, will be used to request the next animation frame for the render loop
  10425. */
  10426. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10427. /**
  10428. * Observable raised when the engine ends the current frame
  10429. */
  10430. onEndFrameObservable: Observable<Engine>;
  10431. /**
  10432. * Observable raised when the engine is about to compile a shader
  10433. */
  10434. onBeforeShaderCompilationObservable: Observable<Engine>;
  10435. /**
  10436. * Observable raised when the engine has jsut compiled a shader
  10437. */
  10438. onAfterShaderCompilationObservable: Observable<Engine>;
  10439. /** @hidden */
  10440. _gl: WebGLRenderingContext;
  10441. private _renderingCanvas;
  10442. private _windowIsBackground;
  10443. private _webGLVersion;
  10444. /**
  10445. * Gets a boolean indicating that only power of 2 textures are supported
  10446. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10447. */
  10448. readonly needPOTTextures: boolean;
  10449. /** @hidden */
  10450. _badOS: boolean;
  10451. /** @hidden */
  10452. _badDesktopOS: boolean;
  10453. /**
  10454. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10455. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10456. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10457. */
  10458. disableTextureBindingOptimization: boolean;
  10459. /**
  10460. * Gets the audio engine
  10461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10462. * @ignorenaming
  10463. */
  10464. static audioEngine: IAudioEngine;
  10465. /**
  10466. * Default AudioEngine factory responsible of creating the Audio Engine.
  10467. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10468. */
  10469. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10470. /**
  10471. * Default offline support factory responsible of creating a tool used to store data locally.
  10472. * By default, this will create a Database object if the workload has been embedded.
  10473. */
  10474. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10475. private _onFocus;
  10476. private _onBlur;
  10477. private _onCanvasPointerOut;
  10478. private _onCanvasBlur;
  10479. private _onCanvasFocus;
  10480. private _onFullscreenChange;
  10481. private _onPointerLockChange;
  10482. private _onVRDisplayPointerRestricted;
  10483. private _onVRDisplayPointerUnrestricted;
  10484. private _onVrDisplayConnect;
  10485. private _onVrDisplayDisconnect;
  10486. private _onVrDisplayPresentChange;
  10487. /**
  10488. * Observable signaled when VR display mode changes
  10489. */
  10490. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10491. /**
  10492. * Observable signaled when VR request present is complete
  10493. */
  10494. onVRRequestPresentComplete: Observable<boolean>;
  10495. /**
  10496. * Observable signaled when VR request present starts
  10497. */
  10498. onVRRequestPresentStart: Observable<Engine>;
  10499. private _hardwareScalingLevel;
  10500. /** @hidden */
  10501. protected _caps: EngineCapabilities;
  10502. private _pointerLockRequested;
  10503. private _isStencilEnable;
  10504. private _colorWrite;
  10505. private _loadingScreen;
  10506. /** @hidden */
  10507. _drawCalls: PerfCounter;
  10508. /** @hidden */
  10509. _textureCollisions: PerfCounter;
  10510. private _glVersion;
  10511. private _glRenderer;
  10512. private _glVendor;
  10513. private _videoTextureSupported;
  10514. private _renderingQueueLaunched;
  10515. private _activeRenderLoops;
  10516. private _deterministicLockstep;
  10517. private _lockstepMaxSteps;
  10518. /**
  10519. * Observable signaled when a context lost event is raised
  10520. */
  10521. onContextLostObservable: Observable<Engine>;
  10522. /**
  10523. * Observable signaled when a context restored event is raised
  10524. */
  10525. onContextRestoredObservable: Observable<Engine>;
  10526. private _onContextLost;
  10527. private _onContextRestored;
  10528. private _contextWasLost;
  10529. private _doNotHandleContextLost;
  10530. /**
  10531. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10533. */
  10534. doNotHandleContextLost: boolean;
  10535. private _performanceMonitor;
  10536. private _fps;
  10537. private _deltaTime;
  10538. /**
  10539. * Turn this value on if you want to pause FPS computation when in background
  10540. */
  10541. disablePerformanceMonitorInBackground: boolean;
  10542. /**
  10543. * Gets the performance monitor attached to this engine
  10544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10545. */
  10546. readonly performanceMonitor: PerformanceMonitor;
  10547. /** @hidden */
  10548. protected _depthCullingState: _DepthCullingState;
  10549. /** @hidden */
  10550. protected _stencilState: _StencilState;
  10551. /** @hidden */
  10552. protected _alphaState: _AlphaState;
  10553. /** @hidden */
  10554. protected _alphaMode: number;
  10555. protected _internalTexturesCache: InternalTexture[];
  10556. /** @hidden */
  10557. protected _activeChannel: number;
  10558. private _currentTextureChannel;
  10559. /** @hidden */
  10560. protected _boundTexturesCache: {
  10561. [key: string]: Nullable<InternalTexture>;
  10562. };
  10563. /** @hidden */
  10564. protected _currentEffect: Nullable<Effect>;
  10565. /** @hidden */
  10566. protected _currentProgram: Nullable<WebGLProgram>;
  10567. private _compiledEffects;
  10568. private _vertexAttribArraysEnabled;
  10569. /** @hidden */
  10570. protected _cachedViewport: Nullable<Viewport>;
  10571. private _cachedVertexArrayObject;
  10572. /** @hidden */
  10573. protected _cachedVertexBuffers: any;
  10574. /** @hidden */
  10575. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10576. /** @hidden */
  10577. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10578. /** @hidden */
  10579. protected _currentRenderTarget: Nullable<InternalTexture>;
  10580. private _uintIndicesCurrentlySet;
  10581. private _currentBoundBuffer;
  10582. /** @hidden */
  10583. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10584. private _currentBufferPointers;
  10585. private _currentInstanceLocations;
  10586. private _currentInstanceBuffers;
  10587. private _textureUnits;
  10588. private _firstBoundInternalTextureTracker;
  10589. private _lastBoundInternalTextureTracker;
  10590. private _workingCanvas;
  10591. private _workingContext;
  10592. private _rescalePostProcess;
  10593. private _dummyFramebuffer;
  10594. private _externalData;
  10595. private _bindedRenderFunction;
  10596. private _vaoRecordInProgress;
  10597. private _mustWipeVertexAttributes;
  10598. private _emptyTexture;
  10599. private _emptyCubeTexture;
  10600. private _emptyTexture3D;
  10601. /** @hidden */
  10602. _frameHandler: number;
  10603. private _nextFreeTextureSlots;
  10604. private _maxSimultaneousTextures;
  10605. private _activeRequests;
  10606. private _texturesSupported;
  10607. private _textureFormatInUse;
  10608. /**
  10609. * Gets the list of texture formats supported
  10610. */
  10611. readonly texturesSupported: Array<string>;
  10612. /**
  10613. * Gets the list of texture formats in use
  10614. */
  10615. readonly textureFormatInUse: Nullable<string>;
  10616. /**
  10617. * Gets the current viewport
  10618. */
  10619. readonly currentViewport: Nullable<Viewport>;
  10620. /**
  10621. * Gets the default empty texture
  10622. */
  10623. readonly emptyTexture: InternalTexture;
  10624. /**
  10625. * Gets the default empty 3D texture
  10626. */
  10627. readonly emptyTexture3D: InternalTexture;
  10628. /**
  10629. * Gets the default empty cube texture
  10630. */
  10631. readonly emptyCubeTexture: InternalTexture;
  10632. /**
  10633. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10634. */
  10635. readonly premultipliedAlpha: boolean;
  10636. /**
  10637. * Creates a new engine
  10638. * @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
  10639. * @param antialias defines enable antialiasing (default: false)
  10640. * @param options defines further options to be sent to the getContext() function
  10641. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10642. */
  10643. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10644. private _rebuildInternalTextures;
  10645. private _rebuildEffects;
  10646. /**
  10647. * Gets a boolean indicating if all created effects are ready
  10648. * @returns true if all effects are ready
  10649. */
  10650. areAllEffectsReady(): boolean;
  10651. private _rebuildBuffers;
  10652. private _initGLContext;
  10653. /**
  10654. * Gets version of the current webGL context
  10655. */
  10656. readonly webGLVersion: number;
  10657. /**
  10658. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10659. */
  10660. readonly isStencilEnable: boolean;
  10661. private _prepareWorkingCanvas;
  10662. /**
  10663. * Reset the texture cache to empty state
  10664. */
  10665. resetTextureCache(): void;
  10666. /**
  10667. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10669. * @returns true if engine is in deterministic lock step mode
  10670. */
  10671. isDeterministicLockStep(): boolean;
  10672. /**
  10673. * Gets the max steps when engine is running in deterministic lock step
  10674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10675. * @returns the max steps
  10676. */
  10677. getLockstepMaxSteps(): number;
  10678. /**
  10679. * Gets an object containing information about the current webGL context
  10680. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10681. */
  10682. getGlInfo(): {
  10683. vendor: string;
  10684. renderer: string;
  10685. version: string;
  10686. };
  10687. /**
  10688. * Gets current aspect ratio
  10689. * @param camera defines the camera to use to get the aspect ratio
  10690. * @param useScreen defines if screen size must be used (or the current render target if any)
  10691. * @returns a number defining the aspect ratio
  10692. */
  10693. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10694. /**
  10695. * Gets current screen aspect ratio
  10696. * @returns a number defining the aspect ratio
  10697. */
  10698. getScreenAspectRatio(): number;
  10699. /**
  10700. * Gets the current render width
  10701. * @param useScreen defines if screen size must be used (or the current render target if any)
  10702. * @returns a number defining the current render width
  10703. */
  10704. getRenderWidth(useScreen?: boolean): number;
  10705. /**
  10706. * Gets the current render height
  10707. * @param useScreen defines if screen size must be used (or the current render target if any)
  10708. * @returns a number defining the current render height
  10709. */
  10710. getRenderHeight(useScreen?: boolean): number;
  10711. /**
  10712. * Gets the HTML canvas attached with the current webGL context
  10713. * @returns a HTML canvas
  10714. */
  10715. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10716. /**
  10717. * Gets the client rect of the HTML canvas attached with the current webGL context
  10718. * @returns a client rectanglee
  10719. */
  10720. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10721. /**
  10722. * Defines the hardware scaling level.
  10723. * By default the hardware scaling level is computed from the window device ratio.
  10724. * 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.
  10725. * @param level defines the level to use
  10726. */
  10727. setHardwareScalingLevel(level: number): void;
  10728. /**
  10729. * Gets the current hardware scaling level.
  10730. * By default the hardware scaling level is computed from the window device ratio.
  10731. * 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.
  10732. * @returns a number indicating the current hardware scaling level
  10733. */
  10734. getHardwareScalingLevel(): number;
  10735. /**
  10736. * Gets the list of loaded textures
  10737. * @returns an array containing all loaded textures
  10738. */
  10739. getLoadedTexturesCache(): InternalTexture[];
  10740. /**
  10741. * Gets the object containing all engine capabilities
  10742. * @returns the EngineCapabilities object
  10743. */
  10744. getCaps(): EngineCapabilities;
  10745. /**
  10746. * Gets the current depth function
  10747. * @returns a number defining the depth function
  10748. */
  10749. getDepthFunction(): Nullable<number>;
  10750. /**
  10751. * Sets the current depth function
  10752. * @param depthFunc defines the function to use
  10753. */
  10754. setDepthFunction(depthFunc: number): void;
  10755. /**
  10756. * Sets the current depth function to GREATER
  10757. */
  10758. setDepthFunctionToGreater(): void;
  10759. /**
  10760. * Sets the current depth function to GEQUAL
  10761. */
  10762. setDepthFunctionToGreaterOrEqual(): void;
  10763. /**
  10764. * Sets the current depth function to LESS
  10765. */
  10766. setDepthFunctionToLess(): void;
  10767. /**
  10768. * Sets the current depth function to LEQUAL
  10769. */
  10770. setDepthFunctionToLessOrEqual(): void;
  10771. /**
  10772. * Gets a boolean indicating if stencil buffer is enabled
  10773. * @returns the current stencil buffer state
  10774. */
  10775. getStencilBuffer(): boolean;
  10776. /**
  10777. * Enable or disable the stencil buffer
  10778. * @param enable defines if the stencil buffer must be enabled or disabled
  10779. */
  10780. setStencilBuffer(enable: boolean): void;
  10781. /**
  10782. * Gets the current stencil mask
  10783. * @returns a number defining the new stencil mask to use
  10784. */
  10785. getStencilMask(): number;
  10786. /**
  10787. * Sets the current stencil mask
  10788. * @param mask defines the new stencil mask to use
  10789. */
  10790. setStencilMask(mask: number): void;
  10791. /**
  10792. * Gets the current stencil function
  10793. * @returns a number defining the stencil function to use
  10794. */
  10795. getStencilFunction(): number;
  10796. /**
  10797. * Gets the current stencil reference value
  10798. * @returns a number defining the stencil reference value to use
  10799. */
  10800. getStencilFunctionReference(): number;
  10801. /**
  10802. * Gets the current stencil mask
  10803. * @returns a number defining the stencil mask to use
  10804. */
  10805. getStencilFunctionMask(): number;
  10806. /**
  10807. * Sets the current stencil function
  10808. * @param stencilFunc defines the new stencil function to use
  10809. */
  10810. setStencilFunction(stencilFunc: number): void;
  10811. /**
  10812. * Sets the current stencil reference
  10813. * @param reference defines the new stencil reference to use
  10814. */
  10815. setStencilFunctionReference(reference: number): void;
  10816. /**
  10817. * Sets the current stencil mask
  10818. * @param mask defines the new stencil mask to use
  10819. */
  10820. setStencilFunctionMask(mask: number): void;
  10821. /**
  10822. * Gets the current stencil operation when stencil fails
  10823. * @returns a number defining stencil operation to use when stencil fails
  10824. */
  10825. getStencilOperationFail(): number;
  10826. /**
  10827. * Gets the current stencil operation when depth fails
  10828. * @returns a number defining stencil operation to use when depth fails
  10829. */
  10830. getStencilOperationDepthFail(): number;
  10831. /**
  10832. * Gets the current stencil operation when stencil passes
  10833. * @returns a number defining stencil operation to use when stencil passes
  10834. */
  10835. getStencilOperationPass(): number;
  10836. /**
  10837. * Sets the stencil operation to use when stencil fails
  10838. * @param operation defines the stencil operation to use when stencil fails
  10839. */
  10840. setStencilOperationFail(operation: number): void;
  10841. /**
  10842. * Sets the stencil operation to use when depth fails
  10843. * @param operation defines the stencil operation to use when depth fails
  10844. */
  10845. setStencilOperationDepthFail(operation: number): void;
  10846. /**
  10847. * Sets the stencil operation to use when stencil passes
  10848. * @param operation defines the stencil operation to use when stencil passes
  10849. */
  10850. setStencilOperationPass(operation: number): void;
  10851. /**
  10852. * Sets a boolean indicating if the dithering state is enabled or disabled
  10853. * @param value defines the dithering state
  10854. */
  10855. setDitheringState(value: boolean): void;
  10856. /**
  10857. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10858. * @param value defines the rasterizer state
  10859. */
  10860. setRasterizerState(value: boolean): void;
  10861. /**
  10862. * stop executing a render loop function and remove it from the execution array
  10863. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10864. */
  10865. stopRenderLoop(renderFunction?: () => void): void;
  10866. /** @hidden */
  10867. _renderLoop(): void;
  10868. /**
  10869. * Register and execute a render loop. The engine can have more than one render function
  10870. * @param renderFunction defines the function to continuously execute
  10871. */
  10872. runRenderLoop(renderFunction: () => void): void;
  10873. /**
  10874. * Toggle full screen mode
  10875. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10876. */
  10877. switchFullscreen(requestPointerLock: boolean): void;
  10878. /**
  10879. * Clear the current render buffer or the current render target (if any is set up)
  10880. * @param color defines the color to use
  10881. * @param backBuffer defines if the back buffer must be cleared
  10882. * @param depth defines if the depth buffer must be cleared
  10883. * @param stencil defines if the stencil buffer must be cleared
  10884. */
  10885. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10886. /**
  10887. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10888. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10889. * @param y defines the y-coordinate of the corner of the clear rectangle
  10890. * @param width defines the width of the clear rectangle
  10891. * @param height defines the height of the clear rectangle
  10892. * @param clearColor defines the clear color
  10893. */
  10894. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10895. private _viewportCached;
  10896. /** @hidden */
  10897. _viewport(x: number, y: number, width: number, height: number): void;
  10898. /**
  10899. * Set the WebGL's viewport
  10900. * @param viewport defines the viewport element to be used
  10901. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10902. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10903. */
  10904. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10905. /**
  10906. * Directly set the WebGL Viewport
  10907. * @param x defines the x coordinate of the viewport (in screen space)
  10908. * @param y defines the y coordinate of the viewport (in screen space)
  10909. * @param width defines the width of the viewport (in screen space)
  10910. * @param height defines the height of the viewport (in screen space)
  10911. * @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
  10912. */
  10913. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10914. /**
  10915. * Begin a new frame
  10916. */
  10917. beginFrame(): void;
  10918. /**
  10919. * Enf the current frame
  10920. */
  10921. endFrame(): void;
  10922. /**
  10923. * Resize the view according to the canvas' size
  10924. */
  10925. resize(): void;
  10926. /**
  10927. * Force a specific size of the canvas
  10928. * @param width defines the new canvas' width
  10929. * @param height defines the new canvas' height
  10930. */
  10931. setSize(width: number, height: number): void;
  10932. /**
  10933. * Gets a boolean indicating if a webVR device was detected
  10934. * @returns true if a webVR device was detected
  10935. */
  10936. isVRDevicePresent(): boolean;
  10937. /**
  10938. * Gets the current webVR device
  10939. * @returns the current webVR device (or null)
  10940. */
  10941. getVRDevice(): any;
  10942. /**
  10943. * Initializes a webVR display and starts listening to display change events
  10944. * The onVRDisplayChangedObservable will be notified upon these changes
  10945. * @returns The onVRDisplayChangedObservable
  10946. */
  10947. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10948. /**
  10949. * Initializes a webVR display and starts listening to display change events
  10950. * The onVRDisplayChangedObservable will be notified upon these changes
  10951. * @returns A promise containing a VRDisplay and if vr is supported
  10952. */
  10953. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10954. /**
  10955. * Call this function to switch to webVR mode
  10956. * Will do nothing if webVR is not supported or if there is no webVR device
  10957. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10958. */
  10959. enableVR(): void;
  10960. /**
  10961. * Call this function to leave webVR mode
  10962. * Will do nothing if webVR is not supported or if there is no webVR device
  10963. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10964. */
  10965. disableVR(): void;
  10966. private _onVRFullScreenTriggered;
  10967. private _getVRDisplaysAsync;
  10968. /**
  10969. * Binds the frame buffer to the specified texture.
  10970. * @param texture The texture to render to or null for the default canvas
  10971. * @param faceIndex The face of the texture to render to in case of cube texture
  10972. * @param requiredWidth The width of the target to render to
  10973. * @param requiredHeight The height of the target to render to
  10974. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10975. * @param depthStencilTexture The depth stencil texture to use to render
  10976. * @param lodLevel defines le lod level to bind to the frame buffer
  10977. */
  10978. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10979. private bindUnboundFramebuffer;
  10980. /**
  10981. * Unbind the current render target texture from the webGL context
  10982. * @param texture defines the render target texture to unbind
  10983. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10984. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10985. */
  10986. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10987. /**
  10988. * Unbind a list of render target textures from the webGL context
  10989. * This is used only when drawBuffer extension or webGL2 are active
  10990. * @param textures defines the render target textures to unbind
  10991. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10992. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10993. */
  10994. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10995. /**
  10996. * Force the mipmap generation for the given render target texture
  10997. * @param texture defines the render target texture to use
  10998. */
  10999. generateMipMapsForCubemap(texture: InternalTexture): void;
  11000. /**
  11001. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11002. */
  11003. flushFramebuffer(): void;
  11004. /**
  11005. * Unbind the current render target and bind the default framebuffer
  11006. */
  11007. restoreDefaultFramebuffer(): void;
  11008. /**
  11009. * Create an uniform buffer
  11010. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11011. * @param elements defines the content of the uniform buffer
  11012. * @returns the webGL uniform buffer
  11013. */
  11014. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11015. /**
  11016. * Create a dynamic uniform buffer
  11017. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11018. * @param elements defines the content of the uniform buffer
  11019. * @returns the webGL uniform buffer
  11020. */
  11021. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11022. /**
  11023. * Update an existing uniform buffer
  11024. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11025. * @param uniformBuffer defines the target uniform buffer
  11026. * @param elements defines the content to update
  11027. * @param offset defines the offset in the uniform buffer where update should start
  11028. * @param count defines the size of the data to update
  11029. */
  11030. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11031. private _resetVertexBufferBinding;
  11032. /**
  11033. * Creates a vertex buffer
  11034. * @param data the data for the vertex buffer
  11035. * @returns the new WebGL static buffer
  11036. */
  11037. createVertexBuffer(data: DataArray): WebGLBuffer;
  11038. /**
  11039. * Creates a dynamic vertex buffer
  11040. * @param data the data for the dynamic vertex buffer
  11041. * @returns the new WebGL dynamic buffer
  11042. */
  11043. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11044. /**
  11045. * Update a dynamic index buffer
  11046. * @param indexBuffer defines the target index buffer
  11047. * @param indices defines the data to update
  11048. * @param offset defines the offset in the target index buffer where update should start
  11049. */
  11050. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11051. /**
  11052. * Updates a dynamic vertex buffer.
  11053. * @param vertexBuffer the vertex buffer to update
  11054. * @param data the data used to update the vertex buffer
  11055. * @param byteOffset the byte offset of the data
  11056. * @param byteLength the byte length of the data
  11057. */
  11058. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11059. private _resetIndexBufferBinding;
  11060. /**
  11061. * Creates a new index buffer
  11062. * @param indices defines the content of the index buffer
  11063. * @param updatable defines if the index buffer must be updatable
  11064. * @returns a new webGL buffer
  11065. */
  11066. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11067. /**
  11068. * Bind a webGL buffer to the webGL context
  11069. * @param buffer defines the buffer to bind
  11070. */
  11071. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11072. /**
  11073. * Bind an uniform buffer to the current webGL context
  11074. * @param buffer defines the buffer to bind
  11075. */
  11076. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11077. /**
  11078. * Bind a buffer to the current webGL context at a given location
  11079. * @param buffer defines the buffer to bind
  11080. * @param location defines the index where to bind the buffer
  11081. */
  11082. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11083. /**
  11084. * Bind a specific block at a given index in a specific shader program
  11085. * @param shaderProgram defines the shader program
  11086. * @param blockName defines the block name
  11087. * @param index defines the index where to bind the block
  11088. */
  11089. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11090. private bindIndexBuffer;
  11091. private bindBuffer;
  11092. /**
  11093. * update the bound buffer with the given data
  11094. * @param data defines the data to update
  11095. */
  11096. updateArrayBuffer(data: Float32Array): void;
  11097. private _vertexAttribPointer;
  11098. private _bindIndexBufferWithCache;
  11099. private _bindVertexBuffersAttributes;
  11100. /**
  11101. * Records a vertex array object
  11102. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11103. * @param vertexBuffers defines the list of vertex buffers to store
  11104. * @param indexBuffer defines the index buffer to store
  11105. * @param effect defines the effect to store
  11106. * @returns the new vertex array object
  11107. */
  11108. recordVertexArrayObject(vertexBuffers: {
  11109. [key: string]: VertexBuffer;
  11110. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11111. /**
  11112. * Bind a specific vertex array object
  11113. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11114. * @param vertexArrayObject defines the vertex array object to bind
  11115. * @param indexBuffer defines the index buffer to bind
  11116. */
  11117. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11118. /**
  11119. * Bind webGl buffers directly to the webGL context
  11120. * @param vertexBuffer defines the vertex buffer to bind
  11121. * @param indexBuffer defines the index buffer to bind
  11122. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11123. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11124. * @param effect defines the effect associated with the vertex buffer
  11125. */
  11126. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11127. private _unbindVertexArrayObject;
  11128. /**
  11129. * Bind a list of vertex buffers to the webGL context
  11130. * @param vertexBuffers defines the list of vertex buffers to bind
  11131. * @param indexBuffer defines the index buffer to bind
  11132. * @param effect defines the effect associated with the vertex buffers
  11133. */
  11134. bindBuffers(vertexBuffers: {
  11135. [key: string]: Nullable<VertexBuffer>;
  11136. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11137. /**
  11138. * Unbind all instance attributes
  11139. */
  11140. unbindInstanceAttributes(): void;
  11141. /**
  11142. * Release and free the memory of a vertex array object
  11143. * @param vao defines the vertex array object to delete
  11144. */
  11145. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11146. /** @hidden */
  11147. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11148. /**
  11149. * Creates a webGL buffer to use with instanciation
  11150. * @param capacity defines the size of the buffer
  11151. * @returns the webGL buffer
  11152. */
  11153. createInstancesBuffer(capacity: number): WebGLBuffer;
  11154. /**
  11155. * Delete a webGL buffer used with instanciation
  11156. * @param buffer defines the webGL buffer to delete
  11157. */
  11158. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11159. /**
  11160. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11161. * @param instancesBuffer defines the webGL buffer to update and bind
  11162. * @param data defines the data to store in the buffer
  11163. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11164. */
  11165. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11166. /**
  11167. * Apply all cached states (depth, culling, stencil and alpha)
  11168. */
  11169. applyStates(): void;
  11170. /**
  11171. * Send a draw order
  11172. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11173. * @param indexStart defines the starting index
  11174. * @param indexCount defines the number of index to draw
  11175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11176. */
  11177. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11178. /**
  11179. * Draw a list of points
  11180. * @param verticesStart defines the index of first vertex to draw
  11181. * @param verticesCount defines the count of vertices to draw
  11182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11183. */
  11184. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11185. /**
  11186. * Draw a list of unindexed primitives
  11187. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11188. * @param verticesStart defines the index of first vertex to draw
  11189. * @param verticesCount defines the count of vertices to draw
  11190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11191. */
  11192. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11193. /**
  11194. * Draw a list of indexed primitives
  11195. * @param fillMode defines the primitive to use
  11196. * @param indexStart defines the starting index
  11197. * @param indexCount defines the number of index to draw
  11198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11199. */
  11200. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11201. /**
  11202. * Draw a list of unindexed primitives
  11203. * @param fillMode defines the primitive to use
  11204. * @param verticesStart defines the index of first vertex to draw
  11205. * @param verticesCount defines the count of vertices to draw
  11206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11207. */
  11208. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11209. private _drawMode;
  11210. /** @hidden */
  11211. _releaseEffect(effect: Effect): void;
  11212. /** @hidden */
  11213. _deleteProgram(program: WebGLProgram): void;
  11214. /**
  11215. * Create a new effect (used to store vertex/fragment shaders)
  11216. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11217. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11218. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11219. * @param samplers defines an array of string used to represent textures
  11220. * @param defines defines the string containing the defines to use to compile the shaders
  11221. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11222. * @param onCompiled defines a function to call when the effect creation is successful
  11223. * @param onError defines a function to call when the effect creation has failed
  11224. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11225. * @returns the new Effect
  11226. */
  11227. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  11228. private _compileShader;
  11229. private _compileRawShader;
  11230. /**
  11231. * Directly creates a webGL program
  11232. * @param vertexCode defines the vertex shader code to use
  11233. * @param fragmentCode defines the fragment shader code to use
  11234. * @param context defines the webGL context to use (if not set, the current one will be used)
  11235. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11236. * @returns the new webGL program
  11237. */
  11238. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11239. /**
  11240. * Creates a webGL program
  11241. * @param vertexCode defines the vertex shader code to use
  11242. * @param fragmentCode defines the fragment shader code to use
  11243. * @param defines defines the string containing the defines to use to compile the shaders
  11244. * @param context defines the webGL context to use (if not set, the current one will be used)
  11245. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11246. * @returns the new webGL program
  11247. */
  11248. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11249. private _createShaderProgram;
  11250. private _finalizeProgram;
  11251. /** @hidden */
  11252. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11253. /** @hidden */
  11254. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11255. /**
  11256. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11257. * @param shaderProgram defines the webGL program to use
  11258. * @param uniformsNames defines the list of uniform names
  11259. * @returns an array of webGL uniform locations
  11260. */
  11261. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11262. /**
  11263. * Gets the lsit of active attributes for a given webGL program
  11264. * @param shaderProgram defines the webGL program to use
  11265. * @param attributesNames defines the list of attribute names to get
  11266. * @returns an array of indices indicating the offset of each attribute
  11267. */
  11268. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11269. /**
  11270. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11271. * @param effect defines the effect to activate
  11272. */
  11273. enableEffect(effect: Nullable<Effect>): void;
  11274. /**
  11275. * Set the value of an uniform to an array of int32
  11276. * @param uniform defines the webGL uniform location where to store the value
  11277. * @param array defines the array of int32 to store
  11278. */
  11279. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11280. /**
  11281. * Set the value of an uniform to an array of int32 (stored as vec2)
  11282. * @param uniform defines the webGL uniform location where to store the value
  11283. * @param array defines the array of int32 to store
  11284. */
  11285. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11286. /**
  11287. * Set the value of an uniform to an array of int32 (stored as vec3)
  11288. * @param uniform defines the webGL uniform location where to store the value
  11289. * @param array defines the array of int32 to store
  11290. */
  11291. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11292. /**
  11293. * Set the value of an uniform to an array of int32 (stored as vec4)
  11294. * @param uniform defines the webGL uniform location where to store the value
  11295. * @param array defines the array of int32 to store
  11296. */
  11297. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11298. /**
  11299. * Set the value of an uniform to an array of float32
  11300. * @param uniform defines the webGL uniform location where to store the value
  11301. * @param array defines the array of float32 to store
  11302. */
  11303. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11304. /**
  11305. * Set the value of an uniform to an array of float32 (stored as vec2)
  11306. * @param uniform defines the webGL uniform location where to store the value
  11307. * @param array defines the array of float32 to store
  11308. */
  11309. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11310. /**
  11311. * Set the value of an uniform to an array of float32 (stored as vec3)
  11312. * @param uniform defines the webGL uniform location where to store the value
  11313. * @param array defines the array of float32 to store
  11314. */
  11315. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11316. /**
  11317. * Set the value of an uniform to an array of float32 (stored as vec4)
  11318. * @param uniform defines the webGL uniform location where to store the value
  11319. * @param array defines the array of float32 to store
  11320. */
  11321. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11322. /**
  11323. * Set the value of an uniform to an array of number
  11324. * @param uniform defines the webGL uniform location where to store the value
  11325. * @param array defines the array of number to store
  11326. */
  11327. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11328. /**
  11329. * Set the value of an uniform to an array of number (stored as vec2)
  11330. * @param uniform defines the webGL uniform location where to store the value
  11331. * @param array defines the array of number to store
  11332. */
  11333. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11334. /**
  11335. * Set the value of an uniform to an array of number (stored as vec3)
  11336. * @param uniform defines the webGL uniform location where to store the value
  11337. * @param array defines the array of number to store
  11338. */
  11339. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11340. /**
  11341. * Set the value of an uniform to an array of number (stored as vec4)
  11342. * @param uniform defines the webGL uniform location where to store the value
  11343. * @param array defines the array of number to store
  11344. */
  11345. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11346. /**
  11347. * Set the value of an uniform to an array of float32 (stored as matrices)
  11348. * @param uniform defines the webGL uniform location where to store the value
  11349. * @param matrices defines the array of float32 to store
  11350. */
  11351. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11352. /**
  11353. * Set the value of an uniform to a matrix
  11354. * @param uniform defines the webGL uniform location where to store the value
  11355. * @param matrix defines the matrix to store
  11356. */
  11357. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11358. /**
  11359. * Set the value of an uniform to a matrix (3x3)
  11360. * @param uniform defines the webGL uniform location where to store the value
  11361. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11362. */
  11363. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11364. /**
  11365. * Set the value of an uniform to a matrix (2x2)
  11366. * @param uniform defines the webGL uniform location where to store the value
  11367. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11368. */
  11369. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11370. /**
  11371. * Set the value of an uniform to a number (int)
  11372. * @param uniform defines the webGL uniform location where to store the value
  11373. * @param value defines the int number to store
  11374. */
  11375. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11376. /**
  11377. * Set the value of an uniform to a number (float)
  11378. * @param uniform defines the webGL uniform location where to store the value
  11379. * @param value defines the float number to store
  11380. */
  11381. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11382. /**
  11383. * Set the value of an uniform to a vec2
  11384. * @param uniform defines the webGL uniform location where to store the value
  11385. * @param x defines the 1st component of the value
  11386. * @param y defines the 2nd component of the value
  11387. */
  11388. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11389. /**
  11390. * Set the value of an uniform to a vec3
  11391. * @param uniform defines the webGL uniform location where to store the value
  11392. * @param x defines the 1st component of the value
  11393. * @param y defines the 2nd component of the value
  11394. * @param z defines the 3rd component of the value
  11395. */
  11396. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11397. /**
  11398. * Set the value of an uniform to a boolean
  11399. * @param uniform defines the webGL uniform location where to store the value
  11400. * @param bool defines the boolean to store
  11401. */
  11402. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11403. /**
  11404. * Set the value of an uniform to a vec4
  11405. * @param uniform defines the webGL uniform location where to store the value
  11406. * @param x defines the 1st component of the value
  11407. * @param y defines the 2nd component of the value
  11408. * @param z defines the 3rd component of the value
  11409. * @param w defines the 4th component of the value
  11410. */
  11411. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11412. /**
  11413. * Set the value of an uniform to a Color3
  11414. * @param uniform defines the webGL uniform location where to store the value
  11415. * @param color3 defines the color to store
  11416. */
  11417. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11418. /**
  11419. * Set the value of an uniform to a Color3 and an alpha value
  11420. * @param uniform defines the webGL uniform location where to store the value
  11421. * @param color3 defines the color to store
  11422. * @param alpha defines the alpha component to store
  11423. */
  11424. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11425. /**
  11426. * Sets a Color4 on a uniform variable
  11427. * @param uniform defines the uniform location
  11428. * @param color4 defines the value to be set
  11429. */
  11430. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11431. /**
  11432. * Set various states to the webGL context
  11433. * @param culling defines backface culling state
  11434. * @param zOffset defines the value to apply to zOffset (0 by default)
  11435. * @param force defines if states must be applied even if cache is up to date
  11436. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11437. */
  11438. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11439. /**
  11440. * Set the z offset to apply to current rendering
  11441. * @param value defines the offset to apply
  11442. */
  11443. setZOffset(value: number): void;
  11444. /**
  11445. * Gets the current value of the zOffset
  11446. * @returns the current zOffset state
  11447. */
  11448. getZOffset(): number;
  11449. /**
  11450. * Enable or disable depth buffering
  11451. * @param enable defines the state to set
  11452. */
  11453. setDepthBuffer(enable: boolean): void;
  11454. /**
  11455. * Gets a boolean indicating if depth writing is enabled
  11456. * @returns the current depth writing state
  11457. */
  11458. getDepthWrite(): boolean;
  11459. /**
  11460. * Enable or disable depth writing
  11461. * @param enable defines the state to set
  11462. */
  11463. setDepthWrite(enable: boolean): void;
  11464. /**
  11465. * Enable or disable color writing
  11466. * @param enable defines the state to set
  11467. */
  11468. setColorWrite(enable: boolean): void;
  11469. /**
  11470. * Gets a boolean indicating if color writing is enabled
  11471. * @returns the current color writing state
  11472. */
  11473. getColorWrite(): boolean;
  11474. /**
  11475. * Sets alpha constants used by some alpha blending modes
  11476. * @param r defines the red component
  11477. * @param g defines the green component
  11478. * @param b defines the blue component
  11479. * @param a defines the alpha component
  11480. */
  11481. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11482. /**
  11483. * Sets the current alpha mode
  11484. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11485. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11486. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11487. */
  11488. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11489. /**
  11490. * Gets the current alpha mode
  11491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11492. * @returns the current alpha mode
  11493. */
  11494. getAlphaMode(): number;
  11495. /**
  11496. * Clears the list of texture accessible through engine.
  11497. * This can help preventing texture load conflict due to name collision.
  11498. */
  11499. clearInternalTexturesCache(): void;
  11500. /**
  11501. * Force the entire cache to be cleared
  11502. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11503. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11504. */
  11505. wipeCaches(bruteForce?: boolean): void;
  11506. /**
  11507. * Set the compressed texture format to use, based on the formats you have, and the formats
  11508. * supported by the hardware / browser.
  11509. *
  11510. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11511. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11512. * to API arguments needed to compressed textures. This puts the burden on the container
  11513. * generator to house the arcane code for determining these for current & future formats.
  11514. *
  11515. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11516. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11517. *
  11518. * Note: The result of this call is not taken into account when a texture is base64.
  11519. *
  11520. * @param formatsAvailable defines the list of those format families you have created
  11521. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11522. *
  11523. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11524. * @returns The extension selected.
  11525. */
  11526. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11527. private _getSamplingParameters;
  11528. private _partialLoadImg;
  11529. private _cascadeLoadImgs;
  11530. /** @hidden */
  11531. _createTexture(): WebGLTexture;
  11532. /**
  11533. * Usually called from BABYLON.Texture.ts.
  11534. * Passed information to create a WebGLTexture
  11535. * @param urlArg defines a value which contains one of the following:
  11536. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11537. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11538. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11539. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11540. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11541. * @param scene needed for loading to the correct scene
  11542. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11543. * @param onLoad optional callback to be called upon successful completion
  11544. * @param onError optional callback to be called upon failure
  11545. * @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
  11546. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11547. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11548. * @param forcedExtension defines the extension to use to pick the right loader
  11549. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11550. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11551. */
  11552. 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;
  11553. private _rescaleTexture;
  11554. /**
  11555. * Update a raw texture
  11556. * @param texture defines the texture to update
  11557. * @param data defines the data to store in the texture
  11558. * @param format defines the format of the data
  11559. * @param invertY defines if data must be stored with Y axis inverted
  11560. * @param compression defines the compression used (null by default)
  11561. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11562. */
  11563. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11564. /**
  11565. * Creates a raw texture
  11566. * @param data defines the data to store in the texture
  11567. * @param width defines the width of the texture
  11568. * @param height defines the height of the texture
  11569. * @param format defines the format of the data
  11570. * @param generateMipMaps defines if the engine should generate the mip levels
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11573. * @param compression defines the compression used (null by default)
  11574. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11575. * @returns the raw texture inside an InternalTexture
  11576. */
  11577. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11578. private _unpackFlipYCached;
  11579. /**
  11580. * In case you are sharing the context with other applications, it might
  11581. * be interested to not cache the unpack flip y state to ensure a consistent
  11582. * value would be set.
  11583. */
  11584. enableUnpackFlipYCached: boolean;
  11585. /** @hidden */
  11586. _unpackFlipY(value: boolean): void;
  11587. /** @hidden */
  11588. _getUnpackAlignement(): number;
  11589. /**
  11590. * Creates a dynamic texture
  11591. * @param width defines the width of the texture
  11592. * @param height defines the height of the texture
  11593. * @param generateMipMaps defines if the engine should generate the mip levels
  11594. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11595. * @returns the dynamic texture inside an InternalTexture
  11596. */
  11597. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11598. /**
  11599. * Update the sampling mode of a given texture
  11600. * @param samplingMode defines the required sampling mode
  11601. * @param texture defines the texture to update
  11602. */
  11603. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11604. /**
  11605. * Update the content of a dynamic texture
  11606. * @param texture defines the texture to update
  11607. * @param canvas defines the canvas containing the source
  11608. * @param invertY defines if data must be stored with Y axis inverted
  11609. * @param premulAlpha defines if alpha is stored as premultiplied
  11610. * @param format defines the format of the data
  11611. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11612. */
  11613. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11614. /**
  11615. * Update a video texture
  11616. * @param texture defines the texture to update
  11617. * @param video defines the video element to use
  11618. * @param invertY defines if data must be stored with Y axis inverted
  11619. */
  11620. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11621. /**
  11622. * Updates a depth texture Comparison Mode and Function.
  11623. * If the comparison Function is equal to 0, the mode will be set to none.
  11624. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11625. * @param texture The texture to set the comparison function for
  11626. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11627. */
  11628. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11629. private _setupDepthStencilTexture;
  11630. /**
  11631. * Creates a depth stencil texture.
  11632. * This is only available in WebGL 2 or with the depth texture extension available.
  11633. * @param size The size of face edge in the texture.
  11634. * @param options The options defining the texture.
  11635. * @returns The texture
  11636. */
  11637. createDepthStencilTexture(size: number | {
  11638. width: number;
  11639. height: number;
  11640. }, options: DepthTextureCreationOptions): InternalTexture;
  11641. /**
  11642. * Creates a depth stencil texture.
  11643. * This is only available in WebGL 2 or with the depth texture extension available.
  11644. * @param size The size of face edge in the texture.
  11645. * @param options The options defining the texture.
  11646. * @returns The texture
  11647. */
  11648. private _createDepthStencilTexture;
  11649. /**
  11650. * Creates a depth stencil cube texture.
  11651. * This is only available in WebGL 2.
  11652. * @param size The size of face edge in the cube texture.
  11653. * @param options The options defining the cube texture.
  11654. * @returns The cube texture
  11655. */
  11656. private _createDepthStencilCubeTexture;
  11657. /**
  11658. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11659. * @param renderTarget The render target to set the frame buffer for
  11660. */
  11661. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11662. /**
  11663. * Creates a new render target texture
  11664. * @param size defines the size of the texture
  11665. * @param options defines the options used to create the texture
  11666. * @returns a new render target texture stored in an InternalTexture
  11667. */
  11668. createRenderTargetTexture(size: number | {
  11669. width: number;
  11670. height: number;
  11671. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11672. /**
  11673. * Create a multi render target texture
  11674. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11675. * @param size defines the size of the texture
  11676. * @param options defines the creation options
  11677. * @returns the cube texture as an InternalTexture
  11678. */
  11679. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11680. private _setupFramebufferDepthAttachments;
  11681. /**
  11682. * Updates the sample count of a render target texture
  11683. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11684. * @param texture defines the texture to update
  11685. * @param samples defines the sample count to set
  11686. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11687. */
  11688. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11689. /**
  11690. * Update the sample count for a given multiple render target texture
  11691. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11692. * @param textures defines the textures to update
  11693. * @param samples defines the sample count to set
  11694. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11695. */
  11696. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11697. /** @hidden */
  11698. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11699. /** @hidden */
  11700. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11701. /** @hidden */
  11702. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11703. /** @hidden */
  11704. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11705. /**
  11706. * Creates a new render target cube texture
  11707. * @param size defines the size of the texture
  11708. * @param options defines the options used to create the texture
  11709. * @returns a new render target cube texture stored in an InternalTexture
  11710. */
  11711. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11712. /**
  11713. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11714. * @param rootUrl defines the url where the file to load is located
  11715. * @param scene defines the current scene
  11716. * @param lodScale defines scale to apply to the mip map selection
  11717. * @param lodOffset defines offset to apply to the mip map selection
  11718. * @param onLoad defines an optional callback raised when the texture is loaded
  11719. * @param onError defines an optional callback raised if there is an issue to load the texture
  11720. * @param format defines the format of the data
  11721. * @param forcedExtension defines the extension to use to pick the right loader
  11722. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11723. * @returns the cube texture as an InternalTexture
  11724. */
  11725. 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;
  11726. /**
  11727. * Creates a cube texture
  11728. * @param rootUrl defines the url where the files to load is located
  11729. * @param scene defines the current scene
  11730. * @param files defines the list of files to load (1 per face)
  11731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11732. * @param onLoad defines an optional callback raised when the texture is loaded
  11733. * @param onError defines an optional callback raised if there is an issue to load the texture
  11734. * @param format defines the format of the data
  11735. * @param forcedExtension defines the extension to use to pick the right loader
  11736. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11737. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11738. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11739. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11740. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11741. * @returns the cube texture as an InternalTexture
  11742. */
  11743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  11744. /**
  11745. * @hidden
  11746. */
  11747. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11748. /**
  11749. * Update a raw cube texture
  11750. * @param texture defines the texture to udpdate
  11751. * @param data defines the data to store
  11752. * @param format defines the data format
  11753. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11754. * @param invertY defines if data must be stored with Y axis inverted
  11755. * @param compression defines the compression used (null by default)
  11756. * @param level defines which level of the texture to update
  11757. */
  11758. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11759. /**
  11760. * Creates a new raw cube texture
  11761. * @param data defines the array of data to use to create each face
  11762. * @param size defines the size of the textures
  11763. * @param format defines the format of the data
  11764. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11765. * @param generateMipMaps defines if the engine should generate the mip levels
  11766. * @param invertY defines if data must be stored with Y axis inverted
  11767. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11768. * @param compression defines the compression used (null by default)
  11769. * @returns the cube texture as an InternalTexture
  11770. */
  11771. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11772. /**
  11773. * Creates a new raw cube texture from a specified url
  11774. * @param url defines the url where the data is located
  11775. * @param scene defines the current scene
  11776. * @param size defines the size of the textures
  11777. * @param format defines the format of the data
  11778. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11779. * @param noMipmap defines if the engine should avoid generating the mip levels
  11780. * @param callback defines a callback used to extract texture data from loaded data
  11781. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11782. * @param onLoad defines a callback called when texture is loaded
  11783. * @param onError defines a callback called if there is an error
  11784. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11785. * @param invertY defines if data must be stored with Y axis inverted
  11786. * @returns the cube texture as an InternalTexture
  11787. */
  11788. 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;
  11789. /**
  11790. * Update a raw 3D texture
  11791. * @param texture defines the texture to update
  11792. * @param data defines the data to store
  11793. * @param format defines the data format
  11794. * @param invertY defines if data must be stored with Y axis inverted
  11795. * @param compression defines the used compression (can be null)
  11796. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11797. */
  11798. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11799. /**
  11800. * Creates a new raw 3D texture
  11801. * @param data defines the data used to create the texture
  11802. * @param width defines the width of the texture
  11803. * @param height defines the height of the texture
  11804. * @param depth defines the depth of the texture
  11805. * @param format defines the format of the texture
  11806. * @param generateMipMaps defines if the engine must generate mip levels
  11807. * @param invertY defines if data must be stored with Y axis inverted
  11808. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11809. * @param compression defines the compressed used (can be null)
  11810. * @param textureType defines the compressed used (can be null)
  11811. * @returns a new raw 3D texture (stored in an InternalTexture)
  11812. */
  11813. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11814. private _prepareWebGLTextureContinuation;
  11815. private _prepareWebGLTexture;
  11816. private _convertRGBtoRGBATextureData;
  11817. /** @hidden */
  11818. _releaseFramebufferObjects(texture: InternalTexture): void;
  11819. /** @hidden */
  11820. _releaseTexture(texture: InternalTexture): void;
  11821. private setProgram;
  11822. private _boundUniforms;
  11823. /**
  11824. * Binds an effect to the webGL context
  11825. * @param effect defines the effect to bind
  11826. */
  11827. bindSamplers(effect: Effect): void;
  11828. private _moveBoundTextureOnTop;
  11829. private _getCorrectTextureChannel;
  11830. private _linkTrackers;
  11831. private _removeDesignatedSlot;
  11832. private _activateCurrentTexture;
  11833. /** @hidden */
  11834. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11835. /** @hidden */
  11836. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11837. /**
  11838. * Sets a texture to the webGL context from a postprocess
  11839. * @param channel defines the channel to use
  11840. * @param postProcess defines the source postprocess
  11841. */
  11842. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11843. /**
  11844. * Binds the output of the passed in post process to the texture channel specified
  11845. * @param channel The channel the texture should be bound to
  11846. * @param postProcess The post process which's output should be bound
  11847. */
  11848. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11849. /**
  11850. * Unbind all textures from the webGL context
  11851. */
  11852. unbindAllTextures(): void;
  11853. /**
  11854. * Sets a texture to the according uniform.
  11855. * @param channel The texture channel
  11856. * @param uniform The uniform to set
  11857. * @param texture The texture to apply
  11858. */
  11859. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11860. /**
  11861. * Sets a depth stencil texture from a render target to the according uniform.
  11862. * @param channel The texture channel
  11863. * @param uniform The uniform to set
  11864. * @param texture The render target texture containing the depth stencil texture to apply
  11865. */
  11866. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11867. private _bindSamplerUniformToChannel;
  11868. private _getTextureWrapMode;
  11869. private _setTexture;
  11870. /**
  11871. * Sets an array of texture to the webGL context
  11872. * @param channel defines the channel where the texture array must be set
  11873. * @param uniform defines the associated uniform location
  11874. * @param textures defines the array of textures to bind
  11875. */
  11876. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11877. /** @hidden */
  11878. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11879. private _setTextureParameterFloat;
  11880. private _setTextureParameterInteger;
  11881. /**
  11882. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11883. * @param x defines the x coordinate of the rectangle where pixels must be read
  11884. * @param y defines the y coordinate of the rectangle where pixels must be read
  11885. * @param width defines the width of the rectangle where pixels must be read
  11886. * @param height defines the height of the rectangle where pixels must be read
  11887. * @returns a Uint8Array containing RGBA colors
  11888. */
  11889. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11890. /**
  11891. * Add an externaly attached data from its key.
  11892. * This method call will fail and return false, if such key already exists.
  11893. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11894. * @param key the unique key that identifies the data
  11895. * @param data the data object to associate to the key for this Engine instance
  11896. * @return true if no such key were already present and the data was added successfully, false otherwise
  11897. */
  11898. addExternalData<T>(key: string, data: T): boolean;
  11899. /**
  11900. * Get an externaly attached data from its key
  11901. * @param key the unique key that identifies the data
  11902. * @return the associated data, if present (can be null), or undefined if not present
  11903. */
  11904. getExternalData<T>(key: string): T;
  11905. /**
  11906. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11907. * @param key the unique key that identifies the data
  11908. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11909. * @return the associated data, can be null if the factory returned null.
  11910. */
  11911. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11912. /**
  11913. * Remove an externaly attached data from the Engine instance
  11914. * @param key the unique key that identifies the data
  11915. * @return true if the data was successfully removed, false if it doesn't exist
  11916. */
  11917. removeExternalData(key: string): boolean;
  11918. /**
  11919. * Unbind all vertex attributes from the webGL context
  11920. */
  11921. unbindAllAttributes(): void;
  11922. /**
  11923. * 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
  11924. */
  11925. releaseEffects(): void;
  11926. /**
  11927. * Dispose and release all associated resources
  11928. */
  11929. dispose(): void;
  11930. /**
  11931. * Display the loading screen
  11932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11933. */
  11934. displayLoadingUI(): void;
  11935. /**
  11936. * Hide the loading screen
  11937. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11938. */
  11939. hideLoadingUI(): void;
  11940. /**
  11941. * Gets the current loading screen object
  11942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11943. */
  11944. /**
  11945. * Sets the current loading screen object
  11946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11947. */
  11948. loadingScreen: ILoadingScreen;
  11949. /**
  11950. * Sets the current loading screen text
  11951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11952. */
  11953. loadingUIText: string;
  11954. /**
  11955. * Sets the current loading screen background color
  11956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11957. */
  11958. loadingUIBackgroundColor: string;
  11959. /**
  11960. * Attach a new callback raised when context lost event is fired
  11961. * @param callback defines the callback to call
  11962. */
  11963. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11964. /**
  11965. * Attach a new callback raised when context restored event is fired
  11966. * @param callback defines the callback to call
  11967. */
  11968. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11969. /**
  11970. * Gets the source code of the vertex shader associated with a specific webGL program
  11971. * @param program defines the program to use
  11972. * @returns a string containing the source code of the vertex shader associated with the program
  11973. */
  11974. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11975. /**
  11976. * Gets the source code of the fragment shader associated with a specific webGL program
  11977. * @param program defines the program to use
  11978. * @returns a string containing the source code of the fragment shader associated with the program
  11979. */
  11980. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11981. /**
  11982. * Get the current error code of the webGL context
  11983. * @returns the error code
  11984. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11985. */
  11986. getError(): number;
  11987. /**
  11988. * Gets the current framerate
  11989. * @returns a number representing the framerate
  11990. */
  11991. getFps(): number;
  11992. /**
  11993. * Gets the time spent between current and previous frame
  11994. * @returns a number representing the delta time in ms
  11995. */
  11996. getDeltaTime(): number;
  11997. private _measureFps;
  11998. /** @hidden */
  11999. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12000. private _canRenderToFloatFramebuffer;
  12001. private _canRenderToHalfFloatFramebuffer;
  12002. private _canRenderToFramebuffer;
  12003. /** @hidden */
  12004. _getWebGLTextureType(type: number): number;
  12005. private _getInternalFormat;
  12006. /** @hidden */
  12007. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12008. /** @hidden */
  12009. _getRGBAMultiSampleBufferFormat(type: number): number;
  12010. /** @hidden */
  12011. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  12012. /** @hidden */
  12013. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12014. private _partialLoadFile;
  12015. private _cascadeLoadFiles;
  12016. /**
  12017. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12018. * @returns true if the engine can be created
  12019. * @ignorenaming
  12020. */
  12021. static isSupported(): boolean;
  12022. }
  12023. }
  12024. declare module BABYLON {
  12025. /**
  12026. * Options to create the null engine
  12027. */
  12028. class NullEngineOptions {
  12029. /**
  12030. * Render width (Default: 512)
  12031. */
  12032. renderWidth: number;
  12033. /**
  12034. * Render height (Default: 256)
  12035. */
  12036. renderHeight: number;
  12037. /**
  12038. * Texture size (Default: 512)
  12039. */
  12040. textureSize: number;
  12041. /**
  12042. * If delta time between frames should be constant
  12043. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12044. */
  12045. deterministicLockstep: boolean;
  12046. /**
  12047. * Maximum about of steps between frames (Default: 4)
  12048. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12049. */
  12050. lockstepMaxSteps: number;
  12051. }
  12052. /**
  12053. * The null engine class provides support for headless version of babylon.js.
  12054. * This can be used in server side scenario or for testing purposes
  12055. */
  12056. class NullEngine extends Engine {
  12057. private _options;
  12058. /**
  12059. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12060. */
  12061. isDeterministicLockStep(): boolean;
  12062. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12063. getLockstepMaxSteps(): number;
  12064. /**
  12065. * Sets hardware scaling, used to save performance if needed
  12066. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12067. */
  12068. getHardwareScalingLevel(): number;
  12069. constructor(options?: NullEngineOptions);
  12070. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12071. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12072. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12073. getRenderWidth(useScreen?: boolean): number;
  12074. getRenderHeight(useScreen?: boolean): number;
  12075. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12076. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12077. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12078. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12079. bindSamplers(effect: Effect): void;
  12080. enableEffect(effect: Effect): void;
  12081. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12082. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12083. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12084. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12085. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12086. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12087. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12088. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12089. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12090. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12091. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12092. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12093. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12094. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12095. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12096. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12097. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12098. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12099. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12100. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12101. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12102. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12103. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12104. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12105. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12106. bindBuffers(vertexBuffers: {
  12107. [key: string]: VertexBuffer;
  12108. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12109. wipeCaches(bruteForce?: boolean): void;
  12110. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12111. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12112. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12113. /** @hidden */
  12114. _createTexture(): WebGLTexture;
  12115. /** @hidden */
  12116. _releaseTexture(texture: InternalTexture): void;
  12117. 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;
  12118. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12119. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12120. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12121. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12122. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12123. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12124. areAllEffectsReady(): boolean;
  12125. /**
  12126. * @hidden
  12127. * Get the current error code of the webGL context
  12128. * @returns the error code
  12129. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12130. */
  12131. getError(): number;
  12132. /** @hidden */
  12133. _getUnpackAlignement(): number;
  12134. /** @hidden */
  12135. _unpackFlipY(value: boolean): void;
  12136. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12137. /**
  12138. * Updates a dynamic vertex buffer.
  12139. * @param vertexBuffer the vertex buffer to update
  12140. * @param data the data used to update the vertex buffer
  12141. * @param byteOffset the byte offset of the data (optional)
  12142. * @param byteLength the byte length of the data (optional)
  12143. */
  12144. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12145. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12146. /** @hidden */
  12147. _bindTexture(channel: number, texture: InternalTexture): void;
  12148. /** @hidden */
  12149. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12150. releaseEffects(): void;
  12151. displayLoadingUI(): void;
  12152. hideLoadingUI(): void;
  12153. /** @hidden */
  12154. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12155. /** @hidden */
  12156. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12157. /** @hidden */
  12158. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12159. /** @hidden */
  12160. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12161. }
  12162. }
  12163. interface WebGLRenderingContext {
  12164. readonly RASTERIZER_DISCARD: number;
  12165. readonly DEPTH_COMPONENT24: number;
  12166. readonly TEXTURE_3D: number;
  12167. readonly TEXTURE_2D_ARRAY: number;
  12168. readonly TEXTURE_COMPARE_FUNC: number;
  12169. readonly TEXTURE_COMPARE_MODE: number;
  12170. readonly COMPARE_REF_TO_TEXTURE: number;
  12171. readonly TEXTURE_WRAP_R: number;
  12172. readonly HALF_FLOAT: number;
  12173. readonly RGB8: number;
  12174. readonly RED_INTEGER: number;
  12175. readonly RG_INTEGER: number;
  12176. readonly RGB_INTEGER: number;
  12177. readonly RGBA_INTEGER: number;
  12178. readonly R8_SNORM: number;
  12179. readonly RG8_SNORM: number;
  12180. readonly RGB8_SNORM: number;
  12181. readonly RGBA8_SNORM: number;
  12182. readonly R8I: number;
  12183. readonly RG8I: number;
  12184. readonly RGB8I: number;
  12185. readonly RGBA8I: number;
  12186. readonly R8UI: number;
  12187. readonly RG8UI: number;
  12188. readonly RGB8UI: number;
  12189. readonly RGBA8UI: number;
  12190. readonly R16I: number;
  12191. readonly RG16I: number;
  12192. readonly RGB16I: number;
  12193. readonly RGBA16I: number;
  12194. readonly R16UI: number;
  12195. readonly RG16UI: number;
  12196. readonly RGB16UI: number;
  12197. readonly RGBA16UI: number;
  12198. readonly R32I: number;
  12199. readonly RG32I: number;
  12200. readonly RGB32I: number;
  12201. readonly RGBA32I: number;
  12202. readonly R32UI: number;
  12203. readonly RG32UI: number;
  12204. readonly RGB32UI: number;
  12205. readonly RGBA32UI: number;
  12206. readonly RGB10_A2UI: number;
  12207. readonly R11F_G11F_B10F: number;
  12208. readonly RGB9_E5: number;
  12209. readonly RGB10_A2: number;
  12210. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12211. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12212. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12213. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12214. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12215. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12216. 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;
  12217. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12218. readonly TRANSFORM_FEEDBACK: number;
  12219. readonly INTERLEAVED_ATTRIBS: number;
  12220. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12221. createTransformFeedback(): WebGLTransformFeedback;
  12222. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12223. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12224. beginTransformFeedback(primitiveMode: number): void;
  12225. endTransformFeedback(): void;
  12226. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12227. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12228. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12229. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12230. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12231. }
  12232. interface ImageBitmap {
  12233. readonly width: number;
  12234. readonly height: number;
  12235. close(): void;
  12236. }
  12237. interface WebGLQuery extends WebGLObject {
  12238. }
  12239. declare var WebGLQuery: {
  12240. prototype: WebGLQuery;
  12241. new (): WebGLQuery;
  12242. };
  12243. interface WebGLSampler extends WebGLObject {
  12244. }
  12245. declare var WebGLSampler: {
  12246. prototype: WebGLSampler;
  12247. new (): WebGLSampler;
  12248. };
  12249. interface WebGLSync extends WebGLObject {
  12250. }
  12251. declare var WebGLSync: {
  12252. prototype: WebGLSync;
  12253. new (): WebGLSync;
  12254. };
  12255. interface WebGLTransformFeedback extends WebGLObject {
  12256. }
  12257. declare var WebGLTransformFeedback: {
  12258. prototype: WebGLTransformFeedback;
  12259. new (): WebGLTransformFeedback;
  12260. };
  12261. interface WebGLVertexArrayObject extends WebGLObject {
  12262. }
  12263. declare var WebGLVertexArrayObject: {
  12264. prototype: WebGLVertexArrayObject;
  12265. new (): WebGLVertexArrayObject;
  12266. };
  12267. declare module BABYLON {
  12268. /**
  12269. * Gather the list of clipboard event types as constants.
  12270. */
  12271. class ClipboardEventTypes {
  12272. /**
  12273. * The clipboard event is fired when a copy command is active (pressed).
  12274. */
  12275. static readonly COPY: number;
  12276. /**
  12277. * The clipboard event is fired when a cut command is active (pressed).
  12278. */
  12279. static readonly CUT: number;
  12280. /**
  12281. * The clipboard event is fired when a paste command is active (pressed).
  12282. */
  12283. static readonly PASTE: number;
  12284. }
  12285. /**
  12286. * This class is used to store clipboard related info for the onClipboardObservable event.
  12287. */
  12288. class ClipboardInfo {
  12289. /**
  12290. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12291. */
  12292. type: number;
  12293. /**
  12294. * Defines the related dom event
  12295. */
  12296. event: ClipboardEvent;
  12297. /**
  12298. *Creates an instance of ClipboardInfo.
  12299. * @param {number} type
  12300. * @param {ClipboardEvent} event
  12301. */
  12302. constructor(
  12303. /**
  12304. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12305. */
  12306. type: number,
  12307. /**
  12308. * Defines the related dom event
  12309. */
  12310. event: ClipboardEvent);
  12311. /**
  12312. * Get the clipboard event's type from the keycode.
  12313. * @param keyCode Defines the keyCode for the current keyboard event.
  12314. * @return {number}
  12315. */
  12316. static GetTypeFromCharacter(keyCode: number): number;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Gather the list of keyboard event types as constants.
  12322. */
  12323. class KeyboardEventTypes {
  12324. /**
  12325. * The keydown event is fired when a key becomes active (pressed).
  12326. */
  12327. static readonly KEYDOWN: number;
  12328. /**
  12329. * The keyup event is fired when a key has been released.
  12330. */
  12331. static readonly KEYUP: number;
  12332. }
  12333. /**
  12334. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12335. */
  12336. class KeyboardInfo {
  12337. /**
  12338. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12339. */
  12340. type: number;
  12341. /**
  12342. * Defines the related dom event
  12343. */
  12344. event: KeyboardEvent;
  12345. /**
  12346. * Instantiates a new keyboard info.
  12347. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12348. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12349. * @param event Defines the related dom event
  12350. */
  12351. constructor(
  12352. /**
  12353. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12354. */
  12355. type: number,
  12356. /**
  12357. * Defines the related dom event
  12358. */
  12359. event: KeyboardEvent);
  12360. }
  12361. /**
  12362. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12363. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12364. */
  12365. class KeyboardInfoPre extends KeyboardInfo {
  12366. /**
  12367. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12368. */
  12369. type: number;
  12370. /**
  12371. * Defines the related dom event
  12372. */
  12373. event: KeyboardEvent;
  12374. /**
  12375. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12376. */
  12377. skipOnPointerObservable: boolean;
  12378. /**
  12379. * Instantiates a new keyboard pre info.
  12380. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12381. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12382. * @param event Defines the related dom event
  12383. */
  12384. constructor(
  12385. /**
  12386. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12387. */
  12388. type: number,
  12389. /**
  12390. * Defines the related dom event
  12391. */
  12392. event: KeyboardEvent);
  12393. }
  12394. }
  12395. declare module BABYLON {
  12396. /**
  12397. * Gather the list of pointer event types as constants.
  12398. */
  12399. class PointerEventTypes {
  12400. /**
  12401. * 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.
  12402. */
  12403. static readonly POINTERDOWN: number;
  12404. /**
  12405. * The pointerup event is fired when a pointer is no longer active.
  12406. */
  12407. static readonly POINTERUP: number;
  12408. /**
  12409. * The pointermove event is fired when a pointer changes coordinates.
  12410. */
  12411. static readonly POINTERMOVE: number;
  12412. /**
  12413. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12414. */
  12415. static readonly POINTERWHEEL: number;
  12416. /**
  12417. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12418. */
  12419. static readonly POINTERPICK: number;
  12420. /**
  12421. * The pointertap event is fired when a the object has been touched and released without drag.
  12422. */
  12423. static readonly POINTERTAP: number;
  12424. /**
  12425. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12426. */
  12427. static readonly POINTERDOUBLETAP: number;
  12428. }
  12429. /**
  12430. * Base class of pointer info types.
  12431. */
  12432. class PointerInfoBase {
  12433. /**
  12434. * Defines the type of event (BABYLON.PointerEventTypes)
  12435. */
  12436. type: number;
  12437. /**
  12438. * Defines the related dom event
  12439. */
  12440. event: PointerEvent | MouseWheelEvent;
  12441. /**
  12442. * Instantiates the base class of pointers info.
  12443. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12444. * @param event Defines the related dom event
  12445. */
  12446. constructor(
  12447. /**
  12448. * Defines the type of event (BABYLON.PointerEventTypes)
  12449. */
  12450. type: number,
  12451. /**
  12452. * Defines the related dom event
  12453. */
  12454. event: PointerEvent | MouseWheelEvent);
  12455. }
  12456. /**
  12457. * This class is used to store pointer related info for the onPrePointerObservable event.
  12458. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12459. */
  12460. class PointerInfoPre extends PointerInfoBase {
  12461. /**
  12462. * Ray from a pointer if availible (eg. 6dof controller)
  12463. */
  12464. ray: Nullable<Ray>;
  12465. /**
  12466. * Defines the local position of the pointer on the canvas.
  12467. */
  12468. localPosition: Vector2;
  12469. /**
  12470. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12471. */
  12472. skipOnPointerObservable: boolean;
  12473. /**
  12474. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12475. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12476. * @param event Defines the related dom event
  12477. * @param localX Defines the local x coordinates of the pointer when the event occured
  12478. * @param localY Defines the local y coordinates of the pointer when the event occured
  12479. */
  12480. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12481. }
  12482. /**
  12483. * This type contains all the data related to a pointer event in Babylon.js.
  12484. * 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.
  12485. */
  12486. class PointerInfo extends PointerInfoBase {
  12487. /**
  12488. * Defines the picking info associated to the info (if any)\
  12489. */
  12490. pickInfo: Nullable<PickingInfo>;
  12491. /**
  12492. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12493. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12494. * @param event Defines the related dom event
  12495. * @param pickInfo Defines the picking info associated to the info (if any)\
  12496. */
  12497. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12498. /**
  12499. * Defines the picking info associated to the info (if any)\
  12500. */
  12501. pickInfo: Nullable<PickingInfo>);
  12502. }
  12503. }
  12504. declare module BABYLON {
  12505. /**
  12506. * Represents a gamepad control stick position
  12507. */
  12508. class StickValues {
  12509. /**
  12510. * The x component of the control stick
  12511. */
  12512. x: number;
  12513. /**
  12514. * The y component of the control stick
  12515. */
  12516. y: number;
  12517. /**
  12518. * Initializes the gamepad x and y control stick values
  12519. * @param x The x component of the gamepad control stick value
  12520. * @param y The y component of the gamepad control stick value
  12521. */
  12522. constructor(
  12523. /**
  12524. * The x component of the control stick
  12525. */
  12526. x: number,
  12527. /**
  12528. * The y component of the control stick
  12529. */
  12530. y: number);
  12531. }
  12532. /**
  12533. * An interface which manages callbacks for gamepad button changes
  12534. */
  12535. interface GamepadButtonChanges {
  12536. /**
  12537. * Called when a gamepad has been changed
  12538. */
  12539. changed: boolean;
  12540. /**
  12541. * Called when a gamepad press event has been triggered
  12542. */
  12543. pressChanged: boolean;
  12544. /**
  12545. * Called when a touch event has been triggered
  12546. */
  12547. touchChanged: boolean;
  12548. /**
  12549. * Called when a value has changed
  12550. */
  12551. valueChanged: boolean;
  12552. }
  12553. /**
  12554. * Represents a gamepad
  12555. */
  12556. class Gamepad {
  12557. /**
  12558. * The id of the gamepad
  12559. */
  12560. id: string;
  12561. /**
  12562. * The index of the gamepad
  12563. */
  12564. index: number;
  12565. /**
  12566. * The browser gamepad
  12567. */
  12568. browserGamepad: any;
  12569. /**
  12570. * Specifies what type of gamepad this represents
  12571. */
  12572. type: number;
  12573. private _leftStick;
  12574. private _rightStick;
  12575. /** @hidden */
  12576. _isConnected: boolean;
  12577. private _leftStickAxisX;
  12578. private _leftStickAxisY;
  12579. private _rightStickAxisX;
  12580. private _rightStickAxisY;
  12581. /**
  12582. * Triggered when the left control stick has been changed
  12583. */
  12584. private _onleftstickchanged;
  12585. /**
  12586. * Triggered when the right control stick has been changed
  12587. */
  12588. private _onrightstickchanged;
  12589. /**
  12590. * Represents a gamepad controller
  12591. */
  12592. static GAMEPAD: number;
  12593. /**
  12594. * Represents a generic controller
  12595. */
  12596. static GENERIC: number;
  12597. /**
  12598. * Represents an XBox controller
  12599. */
  12600. static XBOX: number;
  12601. /**
  12602. * Represents a pose-enabled controller
  12603. */
  12604. static POSE_ENABLED: number;
  12605. /**
  12606. * Specifies whether the left control stick should be Y-inverted
  12607. */
  12608. protected _invertLeftStickY: boolean;
  12609. /**
  12610. * Specifies if the gamepad has been connected
  12611. */
  12612. readonly isConnected: boolean;
  12613. /**
  12614. * Initializes the gamepad
  12615. * @param id The id of the gamepad
  12616. * @param index The index of the gamepad
  12617. * @param browserGamepad The browser gamepad
  12618. * @param leftStickX The x component of the left joystick
  12619. * @param leftStickY The y component of the left joystick
  12620. * @param rightStickX The x component of the right joystick
  12621. * @param rightStickY The y component of the right joystick
  12622. */
  12623. constructor(
  12624. /**
  12625. * The id of the gamepad
  12626. */
  12627. id: string,
  12628. /**
  12629. * The index of the gamepad
  12630. */
  12631. index: number,
  12632. /**
  12633. * The browser gamepad
  12634. */
  12635. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12636. /**
  12637. * Callback triggered when the left joystick has changed
  12638. * @param callback
  12639. */
  12640. onleftstickchanged(callback: (values: StickValues) => void): void;
  12641. /**
  12642. * Callback triggered when the right joystick has changed
  12643. * @param callback
  12644. */
  12645. onrightstickchanged(callback: (values: StickValues) => void): void;
  12646. /**
  12647. * Gets the left joystick
  12648. */
  12649. /**
  12650. * Sets the left joystick values
  12651. */
  12652. leftStick: StickValues;
  12653. /**
  12654. * Gets the right joystick
  12655. */
  12656. /**
  12657. * Sets the right joystick value
  12658. */
  12659. rightStick: StickValues;
  12660. /**
  12661. * Updates the gamepad joystick positions
  12662. */
  12663. update(): void;
  12664. /**
  12665. * Disposes the gamepad
  12666. */
  12667. dispose(): void;
  12668. }
  12669. /**
  12670. * Represents a generic gamepad
  12671. */
  12672. class GenericPad extends Gamepad {
  12673. private _buttons;
  12674. private _onbuttondown;
  12675. private _onbuttonup;
  12676. /**
  12677. * Observable triggered when a button has been pressed
  12678. */
  12679. onButtonDownObservable: Observable<number>;
  12680. /**
  12681. * Observable triggered when a button has been released
  12682. */
  12683. onButtonUpObservable: Observable<number>;
  12684. /**
  12685. * Callback triggered when a button has been pressed
  12686. * @param callback Called when a button has been pressed
  12687. */
  12688. onbuttondown(callback: (buttonPressed: number) => void): void;
  12689. /**
  12690. * Callback triggered when a button has been released
  12691. * @param callback Called when a button has been released
  12692. */
  12693. onbuttonup(callback: (buttonReleased: number) => void): void;
  12694. /**
  12695. * Initializes the generic gamepad
  12696. * @param id The id of the generic gamepad
  12697. * @param index The index of the generic gamepad
  12698. * @param browserGamepad The browser gamepad
  12699. */
  12700. constructor(id: string, index: number, browserGamepad: any);
  12701. private _setButtonValue;
  12702. /**
  12703. * Updates the generic gamepad
  12704. */
  12705. update(): void;
  12706. /**
  12707. * Disposes the generic gamepad
  12708. */
  12709. dispose(): void;
  12710. }
  12711. }
  12712. declare module BABYLON {
  12713. /**
  12714. * Manager for handling gamepads
  12715. */
  12716. class GamepadManager {
  12717. private _scene?;
  12718. private _babylonGamepads;
  12719. private _oneGamepadConnected;
  12720. /** @hidden */
  12721. _isMonitoring: boolean;
  12722. private _gamepadEventSupported;
  12723. private _gamepadSupport;
  12724. /**
  12725. * observable to be triggered when the gamepad controller has been connected
  12726. */
  12727. onGamepadConnectedObservable: Observable<Gamepad>;
  12728. /**
  12729. * observable to be triggered when the gamepad controller has been disconnected
  12730. */
  12731. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12732. private _onGamepadConnectedEvent;
  12733. private _onGamepadDisconnectedEvent;
  12734. /**
  12735. * Initializes the gamepad manager
  12736. * @param _scene BabylonJS scene
  12737. */
  12738. constructor(_scene?: Scene | undefined);
  12739. /**
  12740. * The gamepads in the game pad manager
  12741. */
  12742. readonly gamepads: Gamepad[];
  12743. /**
  12744. * Get the gamepad controllers based on type
  12745. * @param type The type of gamepad controller
  12746. * @returns Nullable gamepad
  12747. */
  12748. getGamepadByType(type?: number): Nullable<Gamepad>;
  12749. /**
  12750. * Disposes the gamepad manager
  12751. */
  12752. dispose(): void;
  12753. private _addNewGamepad;
  12754. private _startMonitoringGamepads;
  12755. private _stopMonitoringGamepads;
  12756. /** @hidden */
  12757. _checkGamepadsStatus(): void;
  12758. private _updateGamepadObjects;
  12759. }
  12760. }
  12761. declare module BABYLON {
  12762. interface Scene {
  12763. /** @hidden */
  12764. _gamepadManager: Nullable<GamepadManager>;
  12765. /**
  12766. * Gets the gamepad manager associated with the scene
  12767. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12768. */
  12769. gamepadManager: GamepadManager;
  12770. }
  12771. /**
  12772. * Interface representing a free camera inputs manager
  12773. */
  12774. interface FreeCameraInputsManager {
  12775. /**
  12776. * Adds gamepad input support to the FreeCameraInputsManager.
  12777. * @returns the FreeCameraInputsManager
  12778. */
  12779. addGamepad(): FreeCameraInputsManager;
  12780. }
  12781. /**
  12782. * Interface representing an arc rotate camera inputs manager
  12783. */
  12784. interface ArcRotateCameraInputsManager {
  12785. /**
  12786. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12787. * @returns the camera inputs manager
  12788. */
  12789. addGamepad(): ArcRotateCameraInputsManager;
  12790. }
  12791. /**
  12792. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12793. */
  12794. class GamepadSystemSceneComponent implements ISceneComponent {
  12795. /**
  12796. * The component name helpfull to identify the component in the list of scene components.
  12797. */
  12798. readonly name: string;
  12799. /**
  12800. * The scene the component belongs to.
  12801. */
  12802. scene: Scene;
  12803. /**
  12804. * Creates a new instance of the component for the given scene
  12805. * @param scene Defines the scene to register the component in
  12806. */
  12807. constructor(scene: Scene);
  12808. /**
  12809. * Registers the component in a given scene
  12810. */
  12811. register(): void;
  12812. /**
  12813. * Rebuilds the elements related to this component in case of
  12814. * context lost for instance.
  12815. */
  12816. rebuild(): void;
  12817. /**
  12818. * Disposes the component and the associated ressources
  12819. */
  12820. dispose(): void;
  12821. private _beforeCameraUpdate;
  12822. }
  12823. }
  12824. declare module BABYLON {
  12825. /**
  12826. * Defines supported buttons for XBox360 compatible gamepads
  12827. */
  12828. enum Xbox360Button {
  12829. /** A */
  12830. A = 0,
  12831. /** B */
  12832. B = 1,
  12833. /** X */
  12834. X = 2,
  12835. /** Y */
  12836. Y = 3,
  12837. /** Start */
  12838. Start = 4,
  12839. /** Back */
  12840. Back = 5,
  12841. /** Left button */
  12842. LB = 6,
  12843. /** Right button */
  12844. RB = 7,
  12845. /** Left stick */
  12846. LeftStick = 8,
  12847. /** Right stick */
  12848. RightStick = 9
  12849. }
  12850. /** Defines values for XBox360 DPad */
  12851. enum Xbox360Dpad {
  12852. /** Up */
  12853. Up = 0,
  12854. /** Down */
  12855. Down = 1,
  12856. /** Left */
  12857. Left = 2,
  12858. /** Right */
  12859. Right = 3
  12860. }
  12861. /**
  12862. * Defines a XBox360 gamepad
  12863. */
  12864. class Xbox360Pad extends Gamepad {
  12865. private _leftTrigger;
  12866. private _rightTrigger;
  12867. private _onlefttriggerchanged;
  12868. private _onrighttriggerchanged;
  12869. private _onbuttondown;
  12870. private _onbuttonup;
  12871. private _ondpaddown;
  12872. private _ondpadup;
  12873. /** Observable raised when a button is pressed */
  12874. onButtonDownObservable: Observable<Xbox360Button>;
  12875. /** Observable raised when a button is released */
  12876. onButtonUpObservable: Observable<Xbox360Button>;
  12877. /** Observable raised when a pad is pressed */
  12878. onPadDownObservable: Observable<Xbox360Dpad>;
  12879. /** Observable raised when a pad is released */
  12880. onPadUpObservable: Observable<Xbox360Dpad>;
  12881. private _buttonA;
  12882. private _buttonB;
  12883. private _buttonX;
  12884. private _buttonY;
  12885. private _buttonBack;
  12886. private _buttonStart;
  12887. private _buttonLB;
  12888. private _buttonRB;
  12889. private _buttonLeftStick;
  12890. private _buttonRightStick;
  12891. private _dPadUp;
  12892. private _dPadDown;
  12893. private _dPadLeft;
  12894. private _dPadRight;
  12895. private _isXboxOnePad;
  12896. /**
  12897. * Creates a new XBox360 gamepad object
  12898. * @param id defines the id of this gamepad
  12899. * @param index defines its index
  12900. * @param gamepad defines the internal HTML gamepad object
  12901. * @param xboxOne defines if it is a XBox One gamepad
  12902. */
  12903. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12904. /**
  12905. * Defines the callback to call when left trigger is pressed
  12906. * @param callback defines the callback to use
  12907. */
  12908. onlefttriggerchanged(callback: (value: number) => void): void;
  12909. /**
  12910. * Defines the callback to call when right trigger is pressed
  12911. * @param callback defines the callback to use
  12912. */
  12913. onrighttriggerchanged(callback: (value: number) => void): void;
  12914. /**
  12915. * Gets the left trigger value
  12916. */
  12917. /**
  12918. * Sets the left trigger value
  12919. */
  12920. leftTrigger: number;
  12921. /**
  12922. * Gets the right trigger value
  12923. */
  12924. /**
  12925. * Sets the right trigger value
  12926. */
  12927. rightTrigger: number;
  12928. /**
  12929. * Defines the callback to call when a button is pressed
  12930. * @param callback defines the callback to use
  12931. */
  12932. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12933. /**
  12934. * Defines the callback to call when a button is released
  12935. * @param callback defines the callback to use
  12936. */
  12937. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12938. /**
  12939. * Defines the callback to call when a pad is pressed
  12940. * @param callback defines the callback to use
  12941. */
  12942. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12943. /**
  12944. * Defines the callback to call when a pad is released
  12945. * @param callback defines the callback to use
  12946. */
  12947. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12948. private _setButtonValue;
  12949. private _setDPadValue;
  12950. /**
  12951. * Gets the value of the `A` button
  12952. */
  12953. /**
  12954. * Sets the value of the `A` button
  12955. */
  12956. buttonA: number;
  12957. /**
  12958. * Gets the value of the `B` button
  12959. */
  12960. /**
  12961. * Sets the value of the `B` button
  12962. */
  12963. buttonB: number;
  12964. /**
  12965. * Gets the value of the `X` button
  12966. */
  12967. /**
  12968. * Sets the value of the `X` button
  12969. */
  12970. buttonX: number;
  12971. /**
  12972. * Gets the value of the `Y` button
  12973. */
  12974. /**
  12975. * Sets the value of the `Y` button
  12976. */
  12977. buttonY: number;
  12978. /**
  12979. * Gets the value of the `Start` button
  12980. */
  12981. /**
  12982. * Sets the value of the `Start` button
  12983. */
  12984. buttonStart: number;
  12985. /**
  12986. * Gets the value of the `Back` button
  12987. */
  12988. /**
  12989. * Sets the value of the `Back` button
  12990. */
  12991. buttonBack: number;
  12992. /**
  12993. * Gets the value of the `Left` button
  12994. */
  12995. /**
  12996. * Sets the value of the `Left` button
  12997. */
  12998. buttonLB: number;
  12999. /**
  13000. * Gets the value of the `Right` button
  13001. */
  13002. /**
  13003. * Sets the value of the `Right` button
  13004. */
  13005. buttonRB: number;
  13006. /**
  13007. * Gets the value of the Left joystick
  13008. */
  13009. /**
  13010. * Sets the value of the Left joystick
  13011. */
  13012. buttonLeftStick: number;
  13013. /**
  13014. * Gets the value of the Right joystick
  13015. */
  13016. /**
  13017. * Sets the value of the Right joystick
  13018. */
  13019. buttonRightStick: number;
  13020. /**
  13021. * Gets the value of D-pad up
  13022. */
  13023. /**
  13024. * Sets the value of D-pad up
  13025. */
  13026. dPadUp: number;
  13027. /**
  13028. * Gets the value of D-pad down
  13029. */
  13030. /**
  13031. * Sets the value of D-pad down
  13032. */
  13033. dPadDown: number;
  13034. /**
  13035. * Gets the value of D-pad left
  13036. */
  13037. /**
  13038. * Sets the value of D-pad left
  13039. */
  13040. dPadLeft: number;
  13041. /**
  13042. * Gets the value of D-pad right
  13043. */
  13044. /**
  13045. * Sets the value of D-pad right
  13046. */
  13047. dPadRight: number;
  13048. /**
  13049. * Force the gamepad to synchronize with device values
  13050. */
  13051. update(): void;
  13052. /**
  13053. * Disposes the gamepad
  13054. */
  13055. dispose(): void;
  13056. }
  13057. }
  13058. declare module BABYLON {
  13059. /**
  13060. * Single axis drag gizmo
  13061. */
  13062. class AxisDragGizmo extends Gizmo {
  13063. /**
  13064. * Drag behavior responsible for the gizmos dragging interactions
  13065. */
  13066. dragBehavior: PointerDragBehavior;
  13067. private _pointerObserver;
  13068. /**
  13069. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13070. */
  13071. snapDistance: number;
  13072. /**
  13073. * Event that fires each time the gizmo snaps to a new location.
  13074. * * snapDistance is the the change in distance
  13075. */
  13076. onSnapObservable: Observable<{
  13077. snapDistance: number;
  13078. }>;
  13079. /**
  13080. * Creates an AxisDragGizmo
  13081. * @param gizmoLayer The utility layer the gizmo will be added to
  13082. * @param dragAxis The axis which the gizmo will be able to drag on
  13083. * @param color The color of the gizmo
  13084. */
  13085. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13086. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13087. /**
  13088. * Disposes of the gizmo
  13089. */
  13090. dispose(): void;
  13091. }
  13092. }
  13093. declare module BABYLON {
  13094. /**
  13095. * Single axis scale gizmo
  13096. */
  13097. class AxisScaleGizmo extends Gizmo {
  13098. private _coloredMaterial;
  13099. /**
  13100. * Drag behavior responsible for the gizmos dragging interactions
  13101. */
  13102. dragBehavior: PointerDragBehavior;
  13103. private _pointerObserver;
  13104. /**
  13105. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13106. */
  13107. snapDistance: number;
  13108. /**
  13109. * Event that fires each time the gizmo snaps to a new location.
  13110. * * snapDistance is the the change in distance
  13111. */
  13112. onSnapObservable: Observable<{
  13113. snapDistance: number;
  13114. }>;
  13115. /**
  13116. * If the scaling operation should be done on all axis (default: false)
  13117. */
  13118. uniformScaling: boolean;
  13119. /**
  13120. * Creates an AxisScaleGizmo
  13121. * @param gizmoLayer The utility layer the gizmo will be added to
  13122. * @param dragAxis The axis which the gizmo will be able to scale on
  13123. * @param color The color of the gizmo
  13124. */
  13125. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13126. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13127. /**
  13128. * Disposes of the gizmo
  13129. */
  13130. dispose(): void;
  13131. /**
  13132. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13133. * @param mesh The mesh to replace the default mesh of the gizmo
  13134. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13135. */
  13136. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13137. }
  13138. }
  13139. declare module BABYLON {
  13140. /**
  13141. * Bounding box gizmo
  13142. */
  13143. class BoundingBoxGizmo extends Gizmo {
  13144. private _lineBoundingBox;
  13145. private _rotateSpheresParent;
  13146. private _scaleBoxesParent;
  13147. private _boundingDimensions;
  13148. private _renderObserver;
  13149. private _pointerObserver;
  13150. private _scaleDragSpeed;
  13151. private _tmpQuaternion;
  13152. private _tmpVector;
  13153. private _tmpRotationMatrix;
  13154. /**
  13155. * 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)
  13156. */
  13157. ignoreChildren: boolean;
  13158. /**
  13159. * 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)
  13160. */
  13161. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13162. /**
  13163. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13164. */
  13165. rotationSphereSize: number;
  13166. /**
  13167. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13168. */
  13169. scaleBoxSize: number;
  13170. /**
  13171. * 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)
  13172. */
  13173. fixedDragMeshScreenSize: boolean;
  13174. /**
  13175. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13176. */
  13177. fixedDragMeshScreenSizeDistanceFactor: number;
  13178. /**
  13179. * Fired when a rotation sphere or scale box is dragged
  13180. */
  13181. onDragStartObservable: Observable<{}>;
  13182. /**
  13183. * Fired when a scale box is dragged
  13184. */
  13185. onScaleBoxDragObservable: Observable<{}>;
  13186. /**
  13187. * Fired when a scale box drag is ended
  13188. */
  13189. onScaleBoxDragEndObservable: Observable<{}>;
  13190. /**
  13191. * Fired when a rotation sphere is dragged
  13192. */
  13193. onRotationSphereDragObservable: Observable<{}>;
  13194. /**
  13195. * Fired when a rotation sphere drag is ended
  13196. */
  13197. onRotationSphereDragEndObservable: Observable<{}>;
  13198. /**
  13199. * 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)
  13200. */
  13201. scalePivot: Nullable<Vector3>;
  13202. private _anchorMesh;
  13203. private _existingMeshScale;
  13204. private static _PivotCached;
  13205. private static _OldPivotPoint;
  13206. private static _PivotTranslation;
  13207. private static _PivotTmpVector;
  13208. /** @hidden */
  13209. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13210. /** @hidden */
  13211. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13212. /**
  13213. * Creates an BoundingBoxGizmo
  13214. * @param gizmoLayer The utility layer the gizmo will be added to
  13215. * @param color The color of the gizmo
  13216. */
  13217. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13218. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13219. private _selectNode;
  13220. /**
  13221. * Updates the bounding box information for the Gizmo
  13222. */
  13223. updateBoundingBox(): void;
  13224. private _updateRotationSpheres;
  13225. private _updateScaleBoxes;
  13226. /**
  13227. * Enables rotation on the specified axis and disables rotation on the others
  13228. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13229. */
  13230. setEnabledRotationAxis(axis: string): void;
  13231. /**
  13232. * Disposes of the gizmo
  13233. */
  13234. dispose(): void;
  13235. /**
  13236. * 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)
  13237. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13238. * @returns the bounding box mesh with the passed in mesh as a child
  13239. */
  13240. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13241. /**
  13242. * CustomMeshes are not supported by this gizmo
  13243. * @param mesh The mesh to replace the default mesh of the gizmo
  13244. */
  13245. setCustomMesh(mesh: Mesh): void;
  13246. }
  13247. }
  13248. declare module BABYLON {
  13249. /**
  13250. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13251. */
  13252. class Gizmo implements IDisposable {
  13253. /** The utility layer the gizmo will be added to */
  13254. gizmoLayer: UtilityLayerRenderer;
  13255. /**
  13256. * The root mesh of the gizmo
  13257. */
  13258. protected _rootMesh: Mesh;
  13259. private _attachedMesh;
  13260. /**
  13261. * Ratio for the scale of the gizmo (Default: 1)
  13262. */
  13263. scaleRatio: number;
  13264. private _tmpMatrix;
  13265. /**
  13266. * If a custom mesh has been set (Default: false)
  13267. */
  13268. protected _customMeshSet: boolean;
  13269. /**
  13270. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13271. * * When set, interactions will be enabled
  13272. */
  13273. attachedMesh: Nullable<AbstractMesh>;
  13274. /**
  13275. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13276. * @param mesh The mesh to replace the default mesh of the gizmo
  13277. */
  13278. setCustomMesh(mesh: Mesh): void;
  13279. /**
  13280. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13281. */
  13282. updateGizmoRotationToMatchAttachedMesh: boolean;
  13283. /**
  13284. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13285. */
  13286. updateGizmoPositionToMatchAttachedMesh: boolean;
  13287. /**
  13288. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13289. */
  13290. protected _updateScale: boolean;
  13291. protected _interactionsEnabled: boolean;
  13292. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13293. private _beforeRenderObserver;
  13294. /**
  13295. * Creates a gizmo
  13296. * @param gizmoLayer The utility layer the gizmo will be added to
  13297. */
  13298. constructor(
  13299. /** The utility layer the gizmo will be added to */
  13300. gizmoLayer?: UtilityLayerRenderer);
  13301. private _tempVector;
  13302. /**
  13303. * @hidden
  13304. * Updates the gizmo to match the attached mesh's position/rotation
  13305. */
  13306. protected _update(): void;
  13307. /**
  13308. * Disposes of the gizmo
  13309. */
  13310. dispose(): void;
  13311. }
  13312. }
  13313. declare module BABYLON {
  13314. /**
  13315. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13316. */
  13317. class GizmoManager implements IDisposable {
  13318. private scene;
  13319. /**
  13320. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13321. */
  13322. gizmos: {
  13323. positionGizmo: Nullable<PositionGizmo>;
  13324. rotationGizmo: Nullable<RotationGizmo>;
  13325. scaleGizmo: Nullable<ScaleGizmo>;
  13326. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13327. };
  13328. private _gizmosEnabled;
  13329. private _pointerObserver;
  13330. private _attachedMesh;
  13331. private _boundingBoxColor;
  13332. private _defaultUtilityLayer;
  13333. private _defaultKeepDepthUtilityLayer;
  13334. /**
  13335. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13336. */
  13337. boundingBoxDragBehavior: SixDofDragBehavior;
  13338. /**
  13339. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13340. */
  13341. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13342. /**
  13343. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13344. */
  13345. usePointerToAttachGizmos: boolean;
  13346. /**
  13347. * Instatiates a gizmo manager
  13348. * @param scene the scene to overlay the gizmos on top of
  13349. */
  13350. constructor(scene: Scene);
  13351. /**
  13352. * Attaches a set of gizmos to the specified mesh
  13353. * @param mesh The mesh the gizmo's should be attached to
  13354. */
  13355. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13356. /**
  13357. * If the position gizmo is enabled
  13358. */
  13359. positionGizmoEnabled: boolean;
  13360. /**
  13361. * If the rotation gizmo is enabled
  13362. */
  13363. rotationGizmoEnabled: boolean;
  13364. /**
  13365. * If the scale gizmo is enabled
  13366. */
  13367. scaleGizmoEnabled: boolean;
  13368. /**
  13369. * If the boundingBox gizmo is enabled
  13370. */
  13371. boundingBoxGizmoEnabled: boolean;
  13372. /**
  13373. * Disposes of the gizmo manager
  13374. */
  13375. dispose(): void;
  13376. }
  13377. }
  13378. declare module BABYLON {
  13379. /**
  13380. * Single plane rotation gizmo
  13381. */
  13382. class PlaneRotationGizmo extends Gizmo {
  13383. /**
  13384. * Drag behavior responsible for the gizmos dragging interactions
  13385. */
  13386. dragBehavior: PointerDragBehavior;
  13387. private _pointerObserver;
  13388. /**
  13389. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13390. */
  13391. snapDistance: number;
  13392. /**
  13393. * Event that fires each time the gizmo snaps to a new location.
  13394. * * snapDistance is the the change in distance
  13395. */
  13396. onSnapObservable: Observable<{
  13397. snapDistance: number;
  13398. }>;
  13399. /**
  13400. * Creates a PlaneRotationGizmo
  13401. * @param gizmoLayer The utility layer the gizmo will be added to
  13402. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13403. * @param color The color of the gizmo
  13404. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13405. */
  13406. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13408. /**
  13409. * Disposes of the gizmo
  13410. */
  13411. dispose(): void;
  13412. }
  13413. }
  13414. declare module BABYLON {
  13415. /**
  13416. * Gizmo that enables dragging a mesh along 3 axis
  13417. */
  13418. class PositionGizmo extends Gizmo {
  13419. /**
  13420. * Internal gizmo used for interactions on the x axis
  13421. */
  13422. xGizmo: AxisDragGizmo;
  13423. /**
  13424. * Internal gizmo used for interactions on the y axis
  13425. */
  13426. yGizmo: AxisDragGizmo;
  13427. /**
  13428. * Internal gizmo used for interactions on the z axis
  13429. */
  13430. zGizmo: AxisDragGizmo;
  13431. /** Fires an event when any of it's sub gizmos are dragged */
  13432. onDragStartObservable: Observable<{}>;
  13433. /** Fires an event when any of it's sub gizmos are released from dragging */
  13434. onDragEndObservable: Observable<{}>;
  13435. attachedMesh: Nullable<AbstractMesh>;
  13436. /**
  13437. * Creates a PositionGizmo
  13438. * @param gizmoLayer The utility layer the gizmo will be added to
  13439. */
  13440. constructor(gizmoLayer?: UtilityLayerRenderer);
  13441. updateGizmoRotationToMatchAttachedMesh: boolean;
  13442. /**
  13443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13444. */
  13445. snapDistance: number;
  13446. /**
  13447. * Ratio for the scale of the gizmo (Default: 1)
  13448. */
  13449. scaleRatio: number;
  13450. /**
  13451. * Disposes of the gizmo
  13452. */
  13453. dispose(): void;
  13454. /**
  13455. * CustomMeshes are not supported by this gizmo
  13456. * @param mesh The mesh to replace the default mesh of the gizmo
  13457. */
  13458. setCustomMesh(mesh: Mesh): void;
  13459. }
  13460. }
  13461. declare module BABYLON {
  13462. /**
  13463. * Gizmo that enables rotating a mesh along 3 axis
  13464. */
  13465. class RotationGizmo extends Gizmo {
  13466. /**
  13467. * Internal gizmo used for interactions on the x axis
  13468. */
  13469. xGizmo: PlaneRotationGizmo;
  13470. /**
  13471. * Internal gizmo used for interactions on the y axis
  13472. */
  13473. yGizmo: PlaneRotationGizmo;
  13474. /**
  13475. * Internal gizmo used for interactions on the z axis
  13476. */
  13477. zGizmo: PlaneRotationGizmo;
  13478. /** Fires an event when any of it's sub gizmos are dragged */
  13479. onDragStartObservable: Observable<{}>;
  13480. /** Fires an event when any of it's sub gizmos are released from dragging */
  13481. onDragEndObservable: Observable<{}>;
  13482. attachedMesh: Nullable<AbstractMesh>;
  13483. /**
  13484. * Creates a RotationGizmo
  13485. * @param gizmoLayer The utility layer the gizmo will be added to
  13486. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13487. */
  13488. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13489. updateGizmoRotationToMatchAttachedMesh: boolean;
  13490. /**
  13491. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13492. */
  13493. snapDistance: number;
  13494. /**
  13495. * Ratio for the scale of the gizmo (Default: 1)
  13496. */
  13497. scaleRatio: number;
  13498. /**
  13499. * Disposes of the gizmo
  13500. */
  13501. dispose(): void;
  13502. /**
  13503. * CustomMeshes are not supported by this gizmo
  13504. * @param mesh The mesh to replace the default mesh of the gizmo
  13505. */
  13506. setCustomMesh(mesh: Mesh): void;
  13507. }
  13508. }
  13509. declare module BABYLON {
  13510. /**
  13511. * Gizmo that enables scaling a mesh along 3 axis
  13512. */
  13513. class ScaleGizmo extends Gizmo {
  13514. /**
  13515. * Internal gizmo used for interactions on the x axis
  13516. */
  13517. xGizmo: AxisScaleGizmo;
  13518. /**
  13519. * Internal gizmo used for interactions on the y axis
  13520. */
  13521. yGizmo: AxisScaleGizmo;
  13522. /**
  13523. * Internal gizmo used for interactions on the z axis
  13524. */
  13525. zGizmo: AxisScaleGizmo;
  13526. /**
  13527. * Internal gizmo used to scale all axis equally
  13528. */
  13529. uniformScaleGizmo: AxisScaleGizmo;
  13530. /** Fires an event when any of it's sub gizmos are dragged */
  13531. onDragStartObservable: Observable<{}>;
  13532. /** Fires an event when any of it's sub gizmos are released from dragging */
  13533. onDragEndObservable: Observable<{}>;
  13534. attachedMesh: Nullable<AbstractMesh>;
  13535. /**
  13536. * Creates a ScaleGizmo
  13537. * @param gizmoLayer The utility layer the gizmo will be added to
  13538. */
  13539. constructor(gizmoLayer?: UtilityLayerRenderer);
  13540. updateGizmoRotationToMatchAttachedMesh: boolean;
  13541. /**
  13542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13543. */
  13544. snapDistance: number;
  13545. /**
  13546. * Ratio for the scale of the gizmo (Default: 1)
  13547. */
  13548. scaleRatio: number;
  13549. /**
  13550. * Disposes of the gizmo
  13551. */
  13552. dispose(): void;
  13553. }
  13554. }
  13555. declare module BABYLON {
  13556. /**
  13557. * Represents the different options available during the creation of
  13558. * a Environment helper.
  13559. *
  13560. * This can control the default ground, skybox and image processing setup of your scene.
  13561. */
  13562. interface IEnvironmentHelperOptions {
  13563. /**
  13564. * Specifies wether or not to create a ground.
  13565. * True by default.
  13566. */
  13567. createGround: boolean;
  13568. /**
  13569. * Specifies the ground size.
  13570. * 15 by default.
  13571. */
  13572. groundSize: number;
  13573. /**
  13574. * The texture used on the ground for the main color.
  13575. * Comes from the BabylonJS CDN by default.
  13576. *
  13577. * Remarks: Can be either a texture or a url.
  13578. */
  13579. groundTexture: string | BaseTexture;
  13580. /**
  13581. * The color mixed in the ground texture by default.
  13582. * BabylonJS clearColor by default.
  13583. */
  13584. groundColor: Color3;
  13585. /**
  13586. * Specifies the ground opacity.
  13587. * 1 by default.
  13588. */
  13589. groundOpacity: number;
  13590. /**
  13591. * Enables the ground to receive shadows.
  13592. * True by default.
  13593. */
  13594. enableGroundShadow: boolean;
  13595. /**
  13596. * Helps preventing the shadow to be fully black on the ground.
  13597. * 0.5 by default.
  13598. */
  13599. groundShadowLevel: number;
  13600. /**
  13601. * Creates a mirror texture attach to the ground.
  13602. * false by default.
  13603. */
  13604. enableGroundMirror: boolean;
  13605. /**
  13606. * Specifies the ground mirror size ratio.
  13607. * 0.3 by default as the default kernel is 64.
  13608. */
  13609. groundMirrorSizeRatio: number;
  13610. /**
  13611. * Specifies the ground mirror blur kernel size.
  13612. * 64 by default.
  13613. */
  13614. groundMirrorBlurKernel: number;
  13615. /**
  13616. * Specifies the ground mirror visibility amount.
  13617. * 1 by default
  13618. */
  13619. groundMirrorAmount: number;
  13620. /**
  13621. * Specifies the ground mirror reflectance weight.
  13622. * This uses the standard weight of the background material to setup the fresnel effect
  13623. * of the mirror.
  13624. * 1 by default.
  13625. */
  13626. groundMirrorFresnelWeight: number;
  13627. /**
  13628. * Specifies the ground mirror Falloff distance.
  13629. * This can helps reducing the size of the reflection.
  13630. * 0 by Default.
  13631. */
  13632. groundMirrorFallOffDistance: number;
  13633. /**
  13634. * Specifies the ground mirror texture type.
  13635. * Unsigned Int by Default.
  13636. */
  13637. groundMirrorTextureType: number;
  13638. /**
  13639. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13640. * the shown objects.
  13641. */
  13642. groundYBias: number;
  13643. /**
  13644. * Specifies wether or not to create a skybox.
  13645. * True by default.
  13646. */
  13647. createSkybox: boolean;
  13648. /**
  13649. * Specifies the skybox size.
  13650. * 20 by default.
  13651. */
  13652. skyboxSize: number;
  13653. /**
  13654. * The texture used on the skybox for the main color.
  13655. * Comes from the BabylonJS CDN by default.
  13656. *
  13657. * Remarks: Can be either a texture or a url.
  13658. */
  13659. skyboxTexture: string | BaseTexture;
  13660. /**
  13661. * The color mixed in the skybox texture by default.
  13662. * BabylonJS clearColor by default.
  13663. */
  13664. skyboxColor: Color3;
  13665. /**
  13666. * The background rotation around the Y axis of the scene.
  13667. * This helps aligning the key lights of your scene with the background.
  13668. * 0 by default.
  13669. */
  13670. backgroundYRotation: number;
  13671. /**
  13672. * Compute automatically the size of the elements to best fit with the scene.
  13673. */
  13674. sizeAuto: boolean;
  13675. /**
  13676. * Default position of the rootMesh if autoSize is not true.
  13677. */
  13678. rootPosition: Vector3;
  13679. /**
  13680. * Sets up the image processing in the scene.
  13681. * true by default.
  13682. */
  13683. setupImageProcessing: boolean;
  13684. /**
  13685. * The texture used as your environment texture in the scene.
  13686. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13687. *
  13688. * Remarks: Can be either a texture or a url.
  13689. */
  13690. environmentTexture: string | BaseTexture;
  13691. /**
  13692. * The value of the exposure to apply to the scene.
  13693. * 0.6 by default if setupImageProcessing is true.
  13694. */
  13695. cameraExposure: number;
  13696. /**
  13697. * The value of the contrast to apply to the scene.
  13698. * 1.6 by default if setupImageProcessing is true.
  13699. */
  13700. cameraContrast: number;
  13701. /**
  13702. * Specifies wether or not tonemapping should be enabled in the scene.
  13703. * true by default if setupImageProcessing is true.
  13704. */
  13705. toneMappingEnabled: boolean;
  13706. }
  13707. /**
  13708. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13709. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13710. * It also helps with the default setup of your imageProcessing configuration.
  13711. */
  13712. class EnvironmentHelper {
  13713. /**
  13714. * Default ground texture URL.
  13715. */
  13716. private static _groundTextureCDNUrl;
  13717. /**
  13718. * Default skybox texture URL.
  13719. */
  13720. private static _skyboxTextureCDNUrl;
  13721. /**
  13722. * Default environment texture URL.
  13723. */
  13724. private static _environmentTextureCDNUrl;
  13725. /**
  13726. * Creates the default options for the helper.
  13727. */
  13728. private static _getDefaultOptions;
  13729. private _rootMesh;
  13730. /**
  13731. * Gets the root mesh created by the helper.
  13732. */
  13733. readonly rootMesh: Mesh;
  13734. private _skybox;
  13735. /**
  13736. * Gets the skybox created by the helper.
  13737. */
  13738. readonly skybox: Nullable<Mesh>;
  13739. private _skyboxTexture;
  13740. /**
  13741. * Gets the skybox texture created by the helper.
  13742. */
  13743. readonly skyboxTexture: Nullable<BaseTexture>;
  13744. private _skyboxMaterial;
  13745. /**
  13746. * Gets the skybox material created by the helper.
  13747. */
  13748. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13749. private _ground;
  13750. /**
  13751. * Gets the ground mesh created by the helper.
  13752. */
  13753. readonly ground: Nullable<Mesh>;
  13754. private _groundTexture;
  13755. /**
  13756. * Gets the ground texture created by the helper.
  13757. */
  13758. readonly groundTexture: Nullable<BaseTexture>;
  13759. private _groundMirror;
  13760. /**
  13761. * Gets the ground mirror created by the helper.
  13762. */
  13763. readonly groundMirror: Nullable<MirrorTexture>;
  13764. /**
  13765. * Gets the ground mirror render list to helps pushing the meshes
  13766. * you wish in the ground reflection.
  13767. */
  13768. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13769. private _groundMaterial;
  13770. /**
  13771. * Gets the ground material created by the helper.
  13772. */
  13773. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13774. /**
  13775. * Stores the creation options.
  13776. */
  13777. private readonly _scene;
  13778. private _options;
  13779. /**
  13780. * This observable will be notified with any error during the creation of the environment,
  13781. * mainly texture creation errors.
  13782. */
  13783. onErrorObservable: Observable<{
  13784. message?: string;
  13785. exception?: any;
  13786. }>;
  13787. /**
  13788. * constructor
  13789. * @param options
  13790. * @param scene The scene to add the material to
  13791. */
  13792. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13793. /**
  13794. * Updates the background according to the new options
  13795. * @param options
  13796. */
  13797. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13798. /**
  13799. * Sets the primary color of all the available elements.
  13800. * @param color the main color to affect to the ground and the background
  13801. */
  13802. setMainColor(color: Color3): void;
  13803. /**
  13804. * Setup the image processing according to the specified options.
  13805. */
  13806. private _setupImageProcessing;
  13807. /**
  13808. * Setup the environment texture according to the specified options.
  13809. */
  13810. private _setupEnvironmentTexture;
  13811. /**
  13812. * Setup the background according to the specified options.
  13813. */
  13814. private _setupBackground;
  13815. /**
  13816. * Get the scene sizes according to the setup.
  13817. */
  13818. private _getSceneSize;
  13819. /**
  13820. * Setup the ground according to the specified options.
  13821. */
  13822. private _setupGround;
  13823. /**
  13824. * Setup the ground material according to the specified options.
  13825. */
  13826. private _setupGroundMaterial;
  13827. /**
  13828. * Setup the ground diffuse texture according to the specified options.
  13829. */
  13830. private _setupGroundDiffuseTexture;
  13831. /**
  13832. * Setup the ground mirror texture according to the specified options.
  13833. */
  13834. private _setupGroundMirrorTexture;
  13835. /**
  13836. * Setup the ground to receive the mirror texture.
  13837. */
  13838. private _setupMirrorInGroundMaterial;
  13839. /**
  13840. * Setup the skybox according to the specified options.
  13841. */
  13842. private _setupSkybox;
  13843. /**
  13844. * Setup the skybox material according to the specified options.
  13845. */
  13846. private _setupSkyboxMaterial;
  13847. /**
  13848. * Setup the skybox reflection texture according to the specified options.
  13849. */
  13850. private _setupSkyboxReflectionTexture;
  13851. private _errorHandler;
  13852. /**
  13853. * Dispose all the elements created by the Helper.
  13854. */
  13855. dispose(): void;
  13856. }
  13857. }
  13858. declare module BABYLON {
  13859. /**
  13860. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13861. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13862. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13863. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13864. */
  13865. class PhotoDome extends TransformNode {
  13866. private _useDirectMapping;
  13867. /**
  13868. * The texture being displayed on the sphere
  13869. */
  13870. protected _photoTexture: Texture;
  13871. /**
  13872. * Gets or sets the texture being displayed on the sphere
  13873. */
  13874. photoTexture: Texture;
  13875. /**
  13876. * Observable raised when an error occured while loading the 360 image
  13877. */
  13878. onLoadErrorObservable: Observable<string>;
  13879. /**
  13880. * The skybox material
  13881. */
  13882. protected _material: BackgroundMaterial;
  13883. /**
  13884. * The surface used for the skybox
  13885. */
  13886. protected _mesh: Mesh;
  13887. /**
  13888. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13889. * Also see the options.resolution property.
  13890. */
  13891. fovMultiplier: number;
  13892. /**
  13893. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13894. * @param name Element's name, child elements will append suffixes for their own names.
  13895. * @param urlsOfPhoto defines the url of the photo to display
  13896. * @param options defines an object containing optional or exposed sub element properties
  13897. * @param onError defines a callback called when an error occured while loading the texture
  13898. */
  13899. constructor(name: string, urlOfPhoto: string, options: {
  13900. resolution?: number;
  13901. size?: number;
  13902. useDirectMapping?: boolean;
  13903. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13904. /**
  13905. * Releases resources associated with this node.
  13906. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13907. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13908. */
  13909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13910. }
  13911. }
  13912. declare module BABYLON {
  13913. interface Scene {
  13914. /**
  13915. * Creates a default light for the scene.
  13916. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13917. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13918. */
  13919. createDefaultLight(replace?: boolean): void;
  13920. /**
  13921. * Creates a default camera for the scene.
  13922. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13923. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13924. * @param replace has default false, when true replaces the active camera in the scene
  13925. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13926. */
  13927. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13928. /**
  13929. * Creates a default camera and a default light.
  13930. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13931. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13932. * @param replace has the default false, when true replaces the active camera/light in the scene
  13933. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13934. */
  13935. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13936. /**
  13937. * Creates a new sky box
  13938. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13939. * @param environmentTexture defines the texture to use as environment texture
  13940. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13941. * @param scale defines the overall scale of the skybox
  13942. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13943. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13944. * @returns a new mesh holding the sky box
  13945. */
  13946. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13947. /**
  13948. * Creates a new environment
  13949. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13950. * @param options defines the options you can use to configure the environment
  13951. * @returns the new EnvironmentHelper
  13952. */
  13953. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13954. /**
  13955. * Creates a new VREXperienceHelper
  13956. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13957. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13958. * @returns a new VREXperienceHelper
  13959. */
  13960. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13961. /**
  13962. * Creates a new XREXperienceHelper
  13963. * @see http://doc.babylonjs.com/how_to/webxr
  13964. * @returns a promise for a new XREXperienceHelper
  13965. */
  13966. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13967. }
  13968. }
  13969. declare module BABYLON {
  13970. /**
  13971. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13972. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13973. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13974. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13975. */
  13976. class VideoDome extends TransformNode {
  13977. private _useDirectMapping;
  13978. /**
  13979. * The video texture being displayed on the sphere
  13980. */
  13981. protected _videoTexture: VideoTexture;
  13982. /**
  13983. * Gets the video texture being displayed on the sphere
  13984. */
  13985. readonly videoTexture: VideoTexture;
  13986. /**
  13987. * The skybox material
  13988. */
  13989. protected _material: BackgroundMaterial;
  13990. /**
  13991. * The surface used for the skybox
  13992. */
  13993. protected _mesh: Mesh;
  13994. /**
  13995. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13996. * Also see the options.resolution property.
  13997. */
  13998. fovMultiplier: number;
  13999. /**
  14000. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14001. * @param name Element's name, child elements will append suffixes for their own names.
  14002. * @param urlsOrVideo defines the url(s) or the video element to use
  14003. * @param options An object containing optional or exposed sub element properties
  14004. */
  14005. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14006. resolution?: number;
  14007. clickToPlay?: boolean;
  14008. autoPlay?: boolean;
  14009. loop?: boolean;
  14010. size?: number;
  14011. poster?: string;
  14012. useDirectMapping?: boolean;
  14013. }, scene: Scene);
  14014. /**
  14015. * Releases resources associated with this node.
  14016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14018. */
  14019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14020. }
  14021. }
  14022. declare module BABYLON {
  14023. /**
  14024. * This class can be used to get instrumentation data from a Babylon engine
  14025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14026. */
  14027. class EngineInstrumentation implements IDisposable {
  14028. /**
  14029. * Define the instrumented engine.
  14030. */
  14031. engine: Engine;
  14032. private _captureGPUFrameTime;
  14033. private _gpuFrameTimeToken;
  14034. private _gpuFrameTime;
  14035. private _captureShaderCompilationTime;
  14036. private _shaderCompilationTime;
  14037. private _onBeginFrameObserver;
  14038. private _onEndFrameObserver;
  14039. private _onBeforeShaderCompilationObserver;
  14040. private _onAfterShaderCompilationObserver;
  14041. /**
  14042. * Gets the perf counter used for GPU frame time
  14043. */
  14044. readonly gpuFrameTimeCounter: PerfCounter;
  14045. /**
  14046. * Gets the GPU frame time capture status
  14047. */
  14048. /**
  14049. * Enable or disable the GPU frame time capture
  14050. */
  14051. captureGPUFrameTime: boolean;
  14052. /**
  14053. * Gets the perf counter used for shader compilation time
  14054. */
  14055. readonly shaderCompilationTimeCounter: PerfCounter;
  14056. /**
  14057. * Gets the shader compilation time capture status
  14058. */
  14059. /**
  14060. * Enable or disable the shader compilation time capture
  14061. */
  14062. captureShaderCompilationTime: boolean;
  14063. /**
  14064. * Instantiates a new engine instrumentation.
  14065. * This class can be used to get instrumentation data from a Babylon engine
  14066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14067. * @param engine Defines the engine to instrument
  14068. */
  14069. constructor(
  14070. /**
  14071. * Define the instrumented engine.
  14072. */
  14073. engine: Engine);
  14074. /**
  14075. * Dispose and release associated resources.
  14076. */
  14077. dispose(): void;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * This class can be used to get instrumentation data from a Babylon engine
  14083. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14084. */
  14085. class SceneInstrumentation implements IDisposable {
  14086. /**
  14087. * Defines the scene to instrument
  14088. */
  14089. scene: Scene;
  14090. private _captureActiveMeshesEvaluationTime;
  14091. private _activeMeshesEvaluationTime;
  14092. private _captureRenderTargetsRenderTime;
  14093. private _renderTargetsRenderTime;
  14094. private _captureFrameTime;
  14095. private _frameTime;
  14096. private _captureRenderTime;
  14097. private _renderTime;
  14098. private _captureInterFrameTime;
  14099. private _interFrameTime;
  14100. private _captureParticlesRenderTime;
  14101. private _particlesRenderTime;
  14102. private _captureSpritesRenderTime;
  14103. private _spritesRenderTime;
  14104. private _capturePhysicsTime;
  14105. private _physicsTime;
  14106. private _captureAnimationsTime;
  14107. private _animationsTime;
  14108. private _captureCameraRenderTime;
  14109. private _cameraRenderTime;
  14110. private _onBeforeActiveMeshesEvaluationObserver;
  14111. private _onAfterActiveMeshesEvaluationObserver;
  14112. private _onBeforeRenderTargetsRenderObserver;
  14113. private _onAfterRenderTargetsRenderObserver;
  14114. private _onAfterRenderObserver;
  14115. private _onBeforeDrawPhaseObserver;
  14116. private _onAfterDrawPhaseObserver;
  14117. private _onBeforeAnimationsObserver;
  14118. private _onBeforeParticlesRenderingObserver;
  14119. private _onAfterParticlesRenderingObserver;
  14120. private _onBeforeSpritesRenderingObserver;
  14121. private _onAfterSpritesRenderingObserver;
  14122. private _onBeforePhysicsObserver;
  14123. private _onAfterPhysicsObserver;
  14124. private _onAfterAnimationsObserver;
  14125. private _onBeforeCameraRenderObserver;
  14126. private _onAfterCameraRenderObserver;
  14127. /**
  14128. * Gets the perf counter used for active meshes evaluation time
  14129. */
  14130. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14131. /**
  14132. * Gets the active meshes evaluation time capture status
  14133. */
  14134. /**
  14135. * Enable or disable the active meshes evaluation time capture
  14136. */
  14137. captureActiveMeshesEvaluationTime: boolean;
  14138. /**
  14139. * Gets the perf counter used for render targets render time
  14140. */
  14141. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14142. /**
  14143. * Gets the render targets render time capture status
  14144. */
  14145. /**
  14146. * Enable or disable the render targets render time capture
  14147. */
  14148. captureRenderTargetsRenderTime: boolean;
  14149. /**
  14150. * Gets the perf counter used for particles render time
  14151. */
  14152. readonly particlesRenderTimeCounter: PerfCounter;
  14153. /**
  14154. * Gets the particles render time capture status
  14155. */
  14156. /**
  14157. * Enable or disable the particles render time capture
  14158. */
  14159. captureParticlesRenderTime: boolean;
  14160. /**
  14161. * Gets the perf counter used for sprites render time
  14162. */
  14163. readonly spritesRenderTimeCounter: PerfCounter;
  14164. /**
  14165. * Gets the sprites render time capture status
  14166. */
  14167. /**
  14168. * Enable or disable the sprites render time capture
  14169. */
  14170. captureSpritesRenderTime: boolean;
  14171. /**
  14172. * Gets the perf counter used for physics time
  14173. */
  14174. readonly physicsTimeCounter: PerfCounter;
  14175. /**
  14176. * Gets the physics time capture status
  14177. */
  14178. /**
  14179. * Enable or disable the physics time capture
  14180. */
  14181. capturePhysicsTime: boolean;
  14182. /**
  14183. * Gets the perf counter used for animations time
  14184. */
  14185. readonly animationsTimeCounter: PerfCounter;
  14186. /**
  14187. * Gets the animations time capture status
  14188. */
  14189. /**
  14190. * Enable or disable the animations time capture
  14191. */
  14192. captureAnimationsTime: boolean;
  14193. /**
  14194. * Gets the perf counter used for frame time capture
  14195. */
  14196. readonly frameTimeCounter: PerfCounter;
  14197. /**
  14198. * Gets the frame time capture status
  14199. */
  14200. /**
  14201. * Enable or disable the frame time capture
  14202. */
  14203. captureFrameTime: boolean;
  14204. /**
  14205. * Gets the perf counter used for inter-frames time capture
  14206. */
  14207. readonly interFrameTimeCounter: PerfCounter;
  14208. /**
  14209. * Gets the inter-frames time capture status
  14210. */
  14211. /**
  14212. * Enable or disable the inter-frames time capture
  14213. */
  14214. captureInterFrameTime: boolean;
  14215. /**
  14216. * Gets the perf counter used for render time capture
  14217. */
  14218. readonly renderTimeCounter: PerfCounter;
  14219. /**
  14220. * Gets the render time capture status
  14221. */
  14222. /**
  14223. * Enable or disable the render time capture
  14224. */
  14225. captureRenderTime: boolean;
  14226. /**
  14227. * Gets the perf counter used for camera render time capture
  14228. */
  14229. readonly cameraRenderTimeCounter: PerfCounter;
  14230. /**
  14231. * Gets the camera render time capture status
  14232. */
  14233. /**
  14234. * Enable or disable the camera render time capture
  14235. */
  14236. captureCameraRenderTime: boolean;
  14237. /**
  14238. * Gets the perf counter used for draw calls
  14239. */
  14240. readonly drawCallsCounter: PerfCounter;
  14241. /**
  14242. * Gets the perf counter used for texture collisions
  14243. */
  14244. readonly textureCollisionsCounter: PerfCounter;
  14245. /**
  14246. * Instantiates a new scene instrumentation.
  14247. * This class can be used to get instrumentation data from a Babylon engine
  14248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14249. * @param scene Defines the scene to instrument
  14250. */
  14251. constructor(
  14252. /**
  14253. * Defines the scene to instrument
  14254. */
  14255. scene: Scene);
  14256. /**
  14257. * Dispose and release associated resources.
  14258. */
  14259. dispose(): void;
  14260. }
  14261. }
  14262. declare module BABYLON {
  14263. /**
  14264. * @hidden
  14265. **/
  14266. class _TimeToken {
  14267. _startTimeQuery: Nullable<WebGLQuery>;
  14268. _endTimeQuery: Nullable<WebGLQuery>;
  14269. _timeElapsedQuery: Nullable<WebGLQuery>;
  14270. _timeElapsedQueryEnded: boolean;
  14271. }
  14272. }
  14273. declare module BABYLON {
  14274. /**
  14275. * Effect layer options. This helps customizing the behaviour
  14276. * of the effect layer.
  14277. */
  14278. interface IEffectLayerOptions {
  14279. /**
  14280. * Multiplication factor apply to the canvas size to compute the render target size
  14281. * used to generated the objects (the smaller the faster).
  14282. */
  14283. mainTextureRatio: number;
  14284. /**
  14285. * Enforces a fixed size texture to ensure effect stability across devices.
  14286. */
  14287. mainTextureFixedSize?: number;
  14288. /**
  14289. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14290. */
  14291. alphaBlendingMode: number;
  14292. /**
  14293. * The camera attached to the layer.
  14294. */
  14295. camera: Nullable<Camera>;
  14296. /**
  14297. * The rendering group to draw the layer in.
  14298. */
  14299. renderingGroupId: number;
  14300. }
  14301. /**
  14302. * The effect layer Helps adding post process effect blended with the main pass.
  14303. *
  14304. * This can be for instance use to generate glow or higlight effects on the scene.
  14305. *
  14306. * The effect layer class can not be used directly and is intented to inherited from to be
  14307. * customized per effects.
  14308. */
  14309. abstract class EffectLayer {
  14310. private _vertexBuffers;
  14311. private _indexBuffer;
  14312. private _cachedDefines;
  14313. private _effectLayerMapGenerationEffect;
  14314. private _effectLayerOptions;
  14315. private _mergeEffect;
  14316. protected _scene: Scene;
  14317. protected _engine: Engine;
  14318. protected _maxSize: number;
  14319. protected _mainTextureDesiredSize: ISize;
  14320. protected _mainTexture: RenderTargetTexture;
  14321. protected _shouldRender: boolean;
  14322. protected _postProcesses: PostProcess[];
  14323. protected _textures: BaseTexture[];
  14324. protected _emissiveTextureAndColor: {
  14325. texture: Nullable<BaseTexture>;
  14326. color: Color4;
  14327. };
  14328. /**
  14329. * The name of the layer
  14330. */
  14331. name: string;
  14332. /**
  14333. * The clear color of the texture used to generate the glow map.
  14334. */
  14335. neutralColor: Color4;
  14336. /**
  14337. * Specifies wether the highlight layer is enabled or not.
  14338. */
  14339. isEnabled: boolean;
  14340. /**
  14341. * Gets the camera attached to the layer.
  14342. */
  14343. readonly camera: Nullable<Camera>;
  14344. /**
  14345. * Gets the rendering group id the layer should render in.
  14346. */
  14347. readonly renderingGroupId: number;
  14348. /**
  14349. * An event triggered when the effect layer has been disposed.
  14350. */
  14351. onDisposeObservable: Observable<EffectLayer>;
  14352. /**
  14353. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14354. */
  14355. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14356. /**
  14357. * An event triggered when the generated texture is being merged in the scene.
  14358. */
  14359. onBeforeComposeObservable: Observable<EffectLayer>;
  14360. /**
  14361. * An event triggered when the generated texture has been merged in the scene.
  14362. */
  14363. onAfterComposeObservable: Observable<EffectLayer>;
  14364. /**
  14365. * An event triggered when the efffect layer changes its size.
  14366. */
  14367. onSizeChangedObservable: Observable<EffectLayer>;
  14368. /**
  14369. * Instantiates a new effect Layer and references it in the scene.
  14370. * @param name The name of the layer
  14371. * @param scene The scene to use the layer in
  14372. */
  14373. constructor(
  14374. /** The Friendly of the effect in the scene */
  14375. name: string, scene: Scene);
  14376. /**
  14377. * Get the effect name of the layer.
  14378. * @return The effect name
  14379. */
  14380. abstract getEffectName(): string;
  14381. /**
  14382. * Checks for the readiness of the element composing the layer.
  14383. * @param subMesh the mesh to check for
  14384. * @param useInstances specify wether or not to use instances to render the mesh
  14385. * @return true if ready otherwise, false
  14386. */
  14387. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14388. /**
  14389. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14390. * @returns true if the effect requires stencil during the main canvas render pass.
  14391. */
  14392. abstract needStencil(): boolean;
  14393. /**
  14394. * Create the merge effect. This is the shader use to blit the information back
  14395. * to the main canvas at the end of the scene rendering.
  14396. * @returns The effect containing the shader used to merge the effect on the main canvas
  14397. */
  14398. protected abstract _createMergeEffect(): Effect;
  14399. /**
  14400. * Creates the render target textures and post processes used in the effect layer.
  14401. */
  14402. protected abstract _createTextureAndPostProcesses(): void;
  14403. /**
  14404. * Implementation specific of rendering the generating effect on the main canvas.
  14405. * @param effect The effect used to render through
  14406. */
  14407. protected abstract _internalRender(effect: Effect): void;
  14408. /**
  14409. * Sets the required values for both the emissive texture and and the main color.
  14410. */
  14411. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14412. /**
  14413. * Free any resources and references associated to a mesh.
  14414. * Internal use
  14415. * @param mesh The mesh to free.
  14416. */
  14417. abstract _disposeMesh(mesh: Mesh): void;
  14418. /**
  14419. * Serializes this layer (Glow or Highlight for example)
  14420. * @returns a serialized layer object
  14421. */
  14422. abstract serialize?(): any;
  14423. /**
  14424. * Initializes the effect layer with the required options.
  14425. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14426. */
  14427. protected _init(options: Partial<IEffectLayerOptions>): void;
  14428. /**
  14429. * Generates the index buffer of the full screen quad blending to the main canvas.
  14430. */
  14431. private _generateIndexBuffer;
  14432. /**
  14433. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14434. */
  14435. private _genrateVertexBuffer;
  14436. /**
  14437. * Sets the main texture desired size which is the closest power of two
  14438. * of the engine canvas size.
  14439. */
  14440. private _setMainTextureSize;
  14441. /**
  14442. * Creates the main texture for the effect layer.
  14443. */
  14444. protected _createMainTexture(): void;
  14445. /**
  14446. * Checks for the readiness of the element composing the layer.
  14447. * @param subMesh the mesh to check for
  14448. * @param useInstances specify wether or not to use instances to render the mesh
  14449. * @param emissiveTexture the associated emissive texture used to generate the glow
  14450. * @return true if ready otherwise, false
  14451. */
  14452. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14453. /**
  14454. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14455. */
  14456. render(): void;
  14457. /**
  14458. * Determine if a given mesh will be used in the current effect.
  14459. * @param mesh mesh to test
  14460. * @returns true if the mesh will be used
  14461. */
  14462. hasMesh(mesh: AbstractMesh): boolean;
  14463. /**
  14464. * Returns true if the layer contains information to display, otherwise false.
  14465. * @returns true if the glow layer should be rendered
  14466. */
  14467. shouldRender(): boolean;
  14468. /**
  14469. * Returns true if the mesh should render, otherwise false.
  14470. * @param mesh The mesh to render
  14471. * @returns true if it should render otherwise false
  14472. */
  14473. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14474. /**
  14475. * Returns true if the mesh should render, otherwise false.
  14476. * @param mesh The mesh to render
  14477. * @returns true if it should render otherwise false
  14478. */
  14479. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14480. /**
  14481. * Renders the submesh passed in parameter to the generation map.
  14482. */
  14483. protected _renderSubMesh(subMesh: SubMesh): void;
  14484. /**
  14485. * Rebuild the required buffers.
  14486. * @hidden Internal use only.
  14487. */
  14488. _rebuild(): void;
  14489. /**
  14490. * Dispose only the render target textures and post process.
  14491. */
  14492. private _disposeTextureAndPostProcesses;
  14493. /**
  14494. * Dispose the highlight layer and free resources.
  14495. */
  14496. dispose(): void;
  14497. /**
  14498. * Gets the class name of the effect layer
  14499. * @returns the string with the class name of the effect layer
  14500. */
  14501. getClassName(): string;
  14502. /**
  14503. * Creates an effect layer from parsed effect layer data
  14504. * @param parsedEffectLayer defines effect layer data
  14505. * @param scene defines the current scene
  14506. * @param rootUrl defines the root URL containing the effect layer information
  14507. * @returns a parsed effect Layer
  14508. */
  14509. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14510. }
  14511. }
  14512. declare module BABYLON {
  14513. interface AbstractScene {
  14514. /**
  14515. * The list of effect layers (highlights/glow) added to the scene
  14516. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14517. * @see http://doc.babylonjs.com/how_to/glow_layer
  14518. */
  14519. effectLayers: Array<EffectLayer>;
  14520. /**
  14521. * Removes the given effect layer from this scene.
  14522. * @param toRemove defines the effect layer to remove
  14523. * @returns the index of the removed effect layer
  14524. */
  14525. removeEffectLayer(toRemove: EffectLayer): number;
  14526. /**
  14527. * Adds the given effect layer to this scene
  14528. * @param newEffectLayer defines the effect layer to add
  14529. */
  14530. addEffectLayer(newEffectLayer: EffectLayer): void;
  14531. }
  14532. /**
  14533. * Defines the layer scene component responsible to manage any effect layers
  14534. * in a given scene.
  14535. */
  14536. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14537. /**
  14538. * The component name helpfull to identify the component in the list of scene components.
  14539. */
  14540. readonly name: string;
  14541. /**
  14542. * The scene the component belongs to.
  14543. */
  14544. scene: Scene;
  14545. private _engine;
  14546. private _renderEffects;
  14547. private _needStencil;
  14548. private _previousStencilState;
  14549. /**
  14550. * Creates a new instance of the component for the given scene
  14551. * @param scene Defines the scene to register the component in
  14552. */
  14553. constructor(scene: Scene);
  14554. /**
  14555. * Registers the component in a given scene
  14556. */
  14557. register(): void;
  14558. /**
  14559. * Rebuilds the elements related to this component in case of
  14560. * context lost for instance.
  14561. */
  14562. rebuild(): void;
  14563. /**
  14564. * Serializes the component data to the specified json object
  14565. * @param serializationObject The object to serialize to
  14566. */
  14567. serialize(serializationObject: any): void;
  14568. /**
  14569. * Adds all the element from the container to the scene
  14570. * @param container the container holding the elements
  14571. */
  14572. addFromContainer(container: AbstractScene): void;
  14573. /**
  14574. * Removes all the elements in the container from the scene
  14575. * @param container contains the elements to remove
  14576. */
  14577. removeFromContainer(container: AbstractScene): void;
  14578. /**
  14579. * Disposes the component and the associated ressources.
  14580. */
  14581. dispose(): void;
  14582. private _isReadyForMesh;
  14583. private _renderMainTexture;
  14584. private _setStencil;
  14585. private _setStencilBack;
  14586. private _draw;
  14587. private _drawCamera;
  14588. private _drawRenderingGroup;
  14589. }
  14590. }
  14591. declare module BABYLON {
  14592. interface AbstractScene {
  14593. /**
  14594. * Return a the first highlight layer of the scene with a given name.
  14595. * @param name The name of the highlight layer to look for.
  14596. * @return The highlight layer if found otherwise null.
  14597. */
  14598. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14599. }
  14600. /**
  14601. * Glow layer options. This helps customizing the behaviour
  14602. * of the glow layer.
  14603. */
  14604. interface IGlowLayerOptions {
  14605. /**
  14606. * Multiplication factor apply to the canvas size to compute the render target size
  14607. * used to generated the glowing objects (the smaller the faster).
  14608. */
  14609. mainTextureRatio: number;
  14610. /**
  14611. * Enforces a fixed size texture to ensure resize independant blur.
  14612. */
  14613. mainTextureFixedSize?: number;
  14614. /**
  14615. * How big is the kernel of the blur texture.
  14616. */
  14617. blurKernelSize: number;
  14618. /**
  14619. * The camera attached to the layer.
  14620. */
  14621. camera: Nullable<Camera>;
  14622. /**
  14623. * Enable MSAA by chosing the number of samples.
  14624. */
  14625. mainTextureSamples?: number;
  14626. /**
  14627. * The rendering group to draw the layer in.
  14628. */
  14629. renderingGroupId: number;
  14630. }
  14631. /**
  14632. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14633. *
  14634. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14635. * glowy meshes to your scene.
  14636. *
  14637. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14638. */
  14639. class GlowLayer extends EffectLayer {
  14640. /**
  14641. * Effect Name of the layer.
  14642. */
  14643. static readonly EffectName: string;
  14644. /**
  14645. * The default blur kernel size used for the glow.
  14646. */
  14647. static DefaultBlurKernelSize: number;
  14648. /**
  14649. * The default texture size ratio used for the glow.
  14650. */
  14651. static DefaultTextureRatio: number;
  14652. /**
  14653. * Sets the kernel size of the blur.
  14654. */
  14655. /**
  14656. * Gets the kernel size of the blur.
  14657. */
  14658. blurKernelSize: number;
  14659. /**
  14660. * Sets the glow intensity.
  14661. */
  14662. /**
  14663. * Gets the glow intensity.
  14664. */
  14665. intensity: number;
  14666. private _options;
  14667. private _intensity;
  14668. private _horizontalBlurPostprocess1;
  14669. private _verticalBlurPostprocess1;
  14670. private _horizontalBlurPostprocess2;
  14671. private _verticalBlurPostprocess2;
  14672. private _blurTexture1;
  14673. private _blurTexture2;
  14674. private _postProcesses1;
  14675. private _postProcesses2;
  14676. private _includedOnlyMeshes;
  14677. private _excludedMeshes;
  14678. /**
  14679. * Callback used to let the user override the color selection on a per mesh basis
  14680. */
  14681. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14682. /**
  14683. * Callback used to let the user override the texture selection on a per mesh basis
  14684. */
  14685. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14686. /**
  14687. * Instantiates a new glow Layer and references it to the scene.
  14688. * @param name The name of the layer
  14689. * @param scene The scene to use the layer in
  14690. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14691. */
  14692. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14693. /**
  14694. * Get the effect name of the layer.
  14695. * @return The effect name
  14696. */
  14697. getEffectName(): string;
  14698. /**
  14699. * Create the merge effect. This is the shader use to blit the information back
  14700. * to the main canvas at the end of the scene rendering.
  14701. */
  14702. protected _createMergeEffect(): Effect;
  14703. /**
  14704. * Creates the render target textures and post processes used in the glow layer.
  14705. */
  14706. protected _createTextureAndPostProcesses(): void;
  14707. /**
  14708. * Checks for the readiness of the element composing the layer.
  14709. * @param subMesh the mesh to check for
  14710. * @param useInstances specify wether or not to use instances to render the mesh
  14711. * @param emissiveTexture the associated emissive texture used to generate the glow
  14712. * @return true if ready otherwise, false
  14713. */
  14714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14715. /**
  14716. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14717. */
  14718. needStencil(): boolean;
  14719. /**
  14720. * Implementation specific of rendering the generating effect on the main canvas.
  14721. * @param effect The effect used to render through
  14722. */
  14723. protected _internalRender(effect: Effect): void;
  14724. /**
  14725. * Sets the required values for both the emissive texture and and the main color.
  14726. */
  14727. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14728. /**
  14729. * Returns true if the mesh should render, otherwise false.
  14730. * @param mesh The mesh to render
  14731. * @returns true if it should render otherwise false
  14732. */
  14733. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14734. /**
  14735. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14736. * @param mesh The mesh to exclude from the glow layer
  14737. */
  14738. addExcludedMesh(mesh: Mesh): void;
  14739. /**
  14740. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14741. * @param mesh The mesh to remove
  14742. */
  14743. removeExcludedMesh(mesh: Mesh): void;
  14744. /**
  14745. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14746. * @param mesh The mesh to include in the glow layer
  14747. */
  14748. addIncludedOnlyMesh(mesh: Mesh): void;
  14749. /**
  14750. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14751. * @param mesh The mesh to remove
  14752. */
  14753. removeIncludedOnlyMesh(mesh: Mesh): void;
  14754. /**
  14755. * Determine if a given mesh will be used in the glow layer
  14756. * @param mesh The mesh to test
  14757. * @returns true if the mesh will be highlighted by the current glow layer
  14758. */
  14759. hasMesh(mesh: AbstractMesh): boolean;
  14760. /**
  14761. * Free any resources and references associated to a mesh.
  14762. * Internal use
  14763. * @param mesh The mesh to free.
  14764. * @hidden
  14765. */
  14766. _disposeMesh(mesh: Mesh): void;
  14767. /**
  14768. * Gets the class name of the effect layer
  14769. * @returns the string with the class name of the effect layer
  14770. */
  14771. getClassName(): string;
  14772. /**
  14773. * Serializes this glow layer
  14774. * @returns a serialized glow layer object
  14775. */
  14776. serialize(): any;
  14777. /**
  14778. * Creates a Glow Layer from parsed glow layer data
  14779. * @param parsedGlowLayer defines glow layer data
  14780. * @param scene defines the current scene
  14781. * @param rootUrl defines the root URL containing the glow layer information
  14782. * @returns a parsed Glow Layer
  14783. */
  14784. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14785. }
  14786. }
  14787. declare module BABYLON {
  14788. interface AbstractScene {
  14789. /**
  14790. * Return a the first highlight layer of the scene with a given name.
  14791. * @param name The name of the highlight layer to look for.
  14792. * @return The highlight layer if found otherwise null.
  14793. */
  14794. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14795. }
  14796. /**
  14797. * Highlight layer options. This helps customizing the behaviour
  14798. * of the highlight layer.
  14799. */
  14800. interface IHighlightLayerOptions {
  14801. /**
  14802. * Multiplication factor apply to the canvas size to compute the render target size
  14803. * used to generated the glowing objects (the smaller the faster).
  14804. */
  14805. mainTextureRatio: number;
  14806. /**
  14807. * Enforces a fixed size texture to ensure resize independant blur.
  14808. */
  14809. mainTextureFixedSize?: number;
  14810. /**
  14811. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14812. * of the picture to blur (the smaller the faster).
  14813. */
  14814. blurTextureSizeRatio: number;
  14815. /**
  14816. * How big in texel of the blur texture is the vertical blur.
  14817. */
  14818. blurVerticalSize: number;
  14819. /**
  14820. * How big in texel of the blur texture is the horizontal blur.
  14821. */
  14822. blurHorizontalSize: number;
  14823. /**
  14824. * Alpha blending mode used to apply the blur. Default is combine.
  14825. */
  14826. alphaBlendingMode: number;
  14827. /**
  14828. * The camera attached to the layer.
  14829. */
  14830. camera: Nullable<Camera>;
  14831. /**
  14832. * Should we display highlight as a solid stroke?
  14833. */
  14834. isStroke?: boolean;
  14835. /**
  14836. * The rendering group to draw the layer in.
  14837. */
  14838. renderingGroupId: number;
  14839. }
  14840. /**
  14841. * The highlight layer Helps adding a glow effect around a mesh.
  14842. *
  14843. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14844. * glowy meshes to your scene.
  14845. *
  14846. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14847. */
  14848. class HighlightLayer extends EffectLayer {
  14849. name: string;
  14850. /**
  14851. * Effect Name of the highlight layer.
  14852. */
  14853. static readonly EffectName: string;
  14854. /**
  14855. * The neutral color used during the preparation of the glow effect.
  14856. * This is black by default as the blend operation is a blend operation.
  14857. */
  14858. static NeutralColor: Color4;
  14859. /**
  14860. * Stencil value used for glowing meshes.
  14861. */
  14862. static GlowingMeshStencilReference: number;
  14863. /**
  14864. * Stencil value used for the other meshes in the scene.
  14865. */
  14866. static NormalMeshStencilReference: number;
  14867. /**
  14868. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14869. */
  14870. innerGlow: boolean;
  14871. /**
  14872. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14873. */
  14874. outerGlow: boolean;
  14875. /**
  14876. * Specifies the horizontal size of the blur.
  14877. */
  14878. /**
  14879. * Gets the horizontal size of the blur.
  14880. */
  14881. blurHorizontalSize: number;
  14882. /**
  14883. * Specifies the vertical size of the blur.
  14884. */
  14885. /**
  14886. * Gets the vertical size of the blur.
  14887. */
  14888. blurVerticalSize: number;
  14889. /**
  14890. * An event triggered when the highlight layer is being blurred.
  14891. */
  14892. onBeforeBlurObservable: Observable<HighlightLayer>;
  14893. /**
  14894. * An event triggered when the highlight layer has been blurred.
  14895. */
  14896. onAfterBlurObservable: Observable<HighlightLayer>;
  14897. private _instanceGlowingMeshStencilReference;
  14898. private _options;
  14899. private _downSamplePostprocess;
  14900. private _horizontalBlurPostprocess;
  14901. private _verticalBlurPostprocess;
  14902. private _blurTexture;
  14903. private _meshes;
  14904. private _excludedMeshes;
  14905. /**
  14906. * Instantiates a new highlight Layer and references it to the scene..
  14907. * @param name The name of the layer
  14908. * @param scene The scene to use the layer in
  14909. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14910. */
  14911. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14912. /**
  14913. * Get the effect name of the layer.
  14914. * @return The effect name
  14915. */
  14916. getEffectName(): string;
  14917. /**
  14918. * Create the merge effect. This is the shader use to blit the information back
  14919. * to the main canvas at the end of the scene rendering.
  14920. */
  14921. protected _createMergeEffect(): Effect;
  14922. /**
  14923. * Creates the render target textures and post processes used in the highlight layer.
  14924. */
  14925. protected _createTextureAndPostProcesses(): void;
  14926. /**
  14927. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14928. */
  14929. needStencil(): boolean;
  14930. /**
  14931. * Checks for the readiness of the element composing the layer.
  14932. * @param subMesh the mesh to check for
  14933. * @param useInstances specify wether or not to use instances to render the mesh
  14934. * @param emissiveTexture the associated emissive texture used to generate the glow
  14935. * @return true if ready otherwise, false
  14936. */
  14937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14938. /**
  14939. * Implementation specific of rendering the generating effect on the main canvas.
  14940. * @param effect The effect used to render through
  14941. */
  14942. protected _internalRender(effect: Effect): void;
  14943. /**
  14944. * Returns true if the layer contains information to display, otherwise false.
  14945. */
  14946. shouldRender(): boolean;
  14947. /**
  14948. * Returns true if the mesh should render, otherwise false.
  14949. * @param mesh The mesh to render
  14950. * @returns true if it should render otherwise false
  14951. */
  14952. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14953. /**
  14954. * Sets the required values for both the emissive texture and and the main color.
  14955. */
  14956. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14957. /**
  14958. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14959. * @param mesh The mesh to exclude from the highlight layer
  14960. */
  14961. addExcludedMesh(mesh: Mesh): void;
  14962. /**
  14963. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14964. * @param mesh The mesh to highlight
  14965. */
  14966. removeExcludedMesh(mesh: Mesh): void;
  14967. /**
  14968. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14969. * @param mesh mesh to test
  14970. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14971. */
  14972. hasMesh(mesh: AbstractMesh): boolean;
  14973. /**
  14974. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14975. * @param mesh The mesh to highlight
  14976. * @param color The color of the highlight
  14977. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14978. */
  14979. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14980. /**
  14981. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14982. * @param mesh The mesh to highlight
  14983. */
  14984. removeMesh(mesh: Mesh): void;
  14985. /**
  14986. * Force the stencil to the normal expected value for none glowing parts
  14987. */
  14988. private _defaultStencilReference;
  14989. /**
  14990. * Free any resources and references associated to a mesh.
  14991. * Internal use
  14992. * @param mesh The mesh to free.
  14993. * @hidden
  14994. */
  14995. _disposeMesh(mesh: Mesh): void;
  14996. /**
  14997. * Dispose the highlight layer and free resources.
  14998. */
  14999. dispose(): void;
  15000. /**
  15001. * Gets the class name of the effect layer
  15002. * @returns the string with the class name of the effect layer
  15003. */
  15004. getClassName(): string;
  15005. /**
  15006. * Serializes this Highlight layer
  15007. * @returns a serialized Highlight layer object
  15008. */
  15009. serialize(): any;
  15010. /**
  15011. * Creates a Highlight layer from parsed Highlight layer data
  15012. * @param parsedHightlightLayer defines the Highlight layer data
  15013. * @param scene defines the current scene
  15014. * @param rootUrl defines the root URL containing the Highlight layer information
  15015. * @returns a parsed Highlight layer
  15016. */
  15017. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15018. }
  15019. }
  15020. declare module BABYLON {
  15021. /**
  15022. * This represents a full screen 2d layer.
  15023. * This can be useful to display a picture in the background of your scene for instance.
  15024. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15025. */
  15026. class Layer {
  15027. /**
  15028. * Define the name of the layer.
  15029. */
  15030. name: string;
  15031. /**
  15032. * Define the texture the layer should display.
  15033. */
  15034. texture: Nullable<Texture>;
  15035. /**
  15036. * Is the layer in background or foreground.
  15037. */
  15038. isBackground: boolean;
  15039. /**
  15040. * Define the color of the layer (instead of texture).
  15041. */
  15042. color: Color4;
  15043. /**
  15044. * Define the scale of the layer in order to zoom in out of the texture.
  15045. */
  15046. scale: Vector2;
  15047. /**
  15048. * Define an offset for the layer in order to shift the texture.
  15049. */
  15050. offset: Vector2;
  15051. /**
  15052. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15053. */
  15054. alphaBlendingMode: number;
  15055. /**
  15056. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15057. * Alpha test will not mix with the background color in case of transparency.
  15058. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15059. */
  15060. alphaTest: boolean;
  15061. /**
  15062. * Define a mask to restrict the layer to only some of the scene cameras.
  15063. */
  15064. layerMask: number;
  15065. /**
  15066. * Define the list of render target the layer is visible into.
  15067. */
  15068. renderTargetTextures: RenderTargetTexture[];
  15069. /**
  15070. * Define if the layer is only used in renderTarget or if it also
  15071. * renders in the main frame buffer of the canvas.
  15072. */
  15073. renderOnlyInRenderTargetTextures: boolean;
  15074. private _scene;
  15075. private _vertexBuffers;
  15076. private _indexBuffer;
  15077. private _effect;
  15078. private _alphaTestEffect;
  15079. /**
  15080. * An event triggered when the layer is disposed.
  15081. */
  15082. onDisposeObservable: Observable<Layer>;
  15083. private _onDisposeObserver;
  15084. /**
  15085. * Back compatibility with callback before the onDisposeObservable existed.
  15086. * The set callback will be triggered when the layer has been disposed.
  15087. */
  15088. onDispose: () => void;
  15089. /**
  15090. * An event triggered before rendering the scene
  15091. */
  15092. onBeforeRenderObservable: Observable<Layer>;
  15093. private _onBeforeRenderObserver;
  15094. /**
  15095. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15096. * The set callback will be triggered just before rendering the layer.
  15097. */
  15098. onBeforeRender: () => void;
  15099. /**
  15100. * An event triggered after rendering the scene
  15101. */
  15102. onAfterRenderObservable: Observable<Layer>;
  15103. private _onAfterRenderObserver;
  15104. /**
  15105. * Back compatibility with callback before the onAfterRenderObservable existed.
  15106. * The set callback will be triggered just after rendering the layer.
  15107. */
  15108. onAfterRender: () => void;
  15109. /**
  15110. * Instantiates a new layer.
  15111. * This represents a full screen 2d layer.
  15112. * This can be useful to display a picture in the background of your scene for instance.
  15113. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15114. * @param name Define the name of the layer in the scene
  15115. * @param imgUrl Define the url of the texture to display in the layer
  15116. * @param scene Define the scene the layer belongs to
  15117. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15118. * @param color Defines a color for the layer
  15119. */
  15120. constructor(
  15121. /**
  15122. * Define the name of the layer.
  15123. */
  15124. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15125. private _createIndexBuffer;
  15126. /** @hidden */
  15127. _rebuild(): void;
  15128. /**
  15129. * Renders the layer in the scene.
  15130. */
  15131. render(): void;
  15132. /**
  15133. * Disposes and releases the associated ressources.
  15134. */
  15135. dispose(): void;
  15136. }
  15137. }
  15138. declare module BABYLON {
  15139. interface AbstractScene {
  15140. /**
  15141. * The list of layers (background and foreground) of the scene
  15142. */
  15143. layers: Array<Layer>;
  15144. }
  15145. /**
  15146. * Defines the layer scene component responsible to manage any layers
  15147. * in a given scene.
  15148. */
  15149. class LayerSceneComponent implements ISceneComponent {
  15150. /**
  15151. * The component name helpfull to identify the component in the list of scene components.
  15152. */
  15153. readonly name: string;
  15154. /**
  15155. * The scene the component belongs to.
  15156. */
  15157. scene: Scene;
  15158. private _engine;
  15159. /**
  15160. * Creates a new instance of the component for the given scene
  15161. * @param scene Defines the scene to register the component in
  15162. */
  15163. constructor(scene: Scene);
  15164. /**
  15165. * Registers the component in a given scene
  15166. */
  15167. register(): void;
  15168. /**
  15169. * Rebuilds the elements related to this component in case of
  15170. * context lost for instance.
  15171. */
  15172. rebuild(): void;
  15173. /**
  15174. * Disposes the component and the associated ressources.
  15175. */
  15176. dispose(): void;
  15177. private _draw;
  15178. private _drawCameraPredicate;
  15179. private _drawCameraBackground;
  15180. private _drawCameraForeground;
  15181. private _drawRenderTargetPredicate;
  15182. private _drawRenderTargetBackground;
  15183. private _drawRenderTargetForeground;
  15184. }
  15185. }
  15186. declare module BABYLON {
  15187. /**
  15188. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15189. * It controls one of the indiviual texture used in the effect.
  15190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15191. */
  15192. class LensFlare {
  15193. /**
  15194. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15195. */
  15196. size: number;
  15197. /**
  15198. * 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.
  15199. */
  15200. position: number;
  15201. /**
  15202. * Define the lens color.
  15203. */
  15204. color: Color3;
  15205. /**
  15206. * Define the lens texture.
  15207. */
  15208. texture: Nullable<Texture>;
  15209. /**
  15210. * Define the alpha mode to render this particular lens.
  15211. */
  15212. alphaMode: number;
  15213. private _system;
  15214. /**
  15215. * Creates a new Lens Flare.
  15216. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15217. * It controls one of the indiviual texture used in the effect.
  15218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15219. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15220. * @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.
  15221. * @param color Define the lens color
  15222. * @param imgUrl Define the lens texture url
  15223. * @param system Define the `lensFlareSystem` this flare is part of
  15224. * @returns The newly created Lens Flare
  15225. */
  15226. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15227. /**
  15228. * Instantiates a new Lens Flare.
  15229. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15230. * It controls one of the indiviual texture used in the effect.
  15231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15232. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15233. * @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.
  15234. * @param color Define the lens color
  15235. * @param imgUrl Define the lens texture url
  15236. * @param system Define the `lensFlareSystem` this flare is part of
  15237. */
  15238. constructor(
  15239. /**
  15240. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15241. */
  15242. size: number,
  15243. /**
  15244. * 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.
  15245. */
  15246. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15247. /**
  15248. * Dispose and release the lens flare with its associated resources.
  15249. */
  15250. dispose(): void;
  15251. }
  15252. }
  15253. declare module BABYLON {
  15254. /**
  15255. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15256. * It is usually composed of several `BABYLON.lensFlare`.
  15257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15258. */
  15259. class LensFlareSystem {
  15260. /**
  15261. * Define the name of the lens flare system
  15262. */
  15263. name: string;
  15264. /**
  15265. * List of lens flares used in this system.
  15266. */
  15267. lensFlares: LensFlare[];
  15268. /**
  15269. * Define a limit from the border the lens flare can be visible.
  15270. */
  15271. borderLimit: number;
  15272. /**
  15273. * Define a viewport border we do not want to see the lens flare in.
  15274. */
  15275. viewportBorder: number;
  15276. /**
  15277. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15278. */
  15279. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15280. /**
  15281. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15282. */
  15283. layerMask: number;
  15284. /**
  15285. * Define the id of the lens flare system in the scene.
  15286. * (equal to name by default)
  15287. */
  15288. id: string;
  15289. private _scene;
  15290. private _emitter;
  15291. private _vertexBuffers;
  15292. private _indexBuffer;
  15293. private _effect;
  15294. private _positionX;
  15295. private _positionY;
  15296. private _isEnabled;
  15297. /**
  15298. * Instantiates a lens flare system.
  15299. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15300. * It is usually composed of several `BABYLON.lensFlare`.
  15301. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15302. * @param name Define the name of the lens flare system in the scene
  15303. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15304. * @param scene Define the scene the lens flare system belongs to
  15305. */
  15306. constructor(
  15307. /**
  15308. * Define the name of the lens flare system
  15309. */
  15310. name: string, emitter: any, scene: Scene);
  15311. /**
  15312. * Define if the lens flare system is enabled.
  15313. */
  15314. isEnabled: boolean;
  15315. /**
  15316. * Get the scene the effects belongs to.
  15317. * @returns the scene holding the lens flare system
  15318. */
  15319. getScene(): Scene;
  15320. /**
  15321. * Get the emitter of the lens flare system.
  15322. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15323. * @returns the emitter of the lens flare system
  15324. */
  15325. getEmitter(): any;
  15326. /**
  15327. * Set the emitter of the lens flare system.
  15328. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15329. * @param newEmitter Define the new emitter of the system
  15330. */
  15331. setEmitter(newEmitter: any): void;
  15332. /**
  15333. * Get the lens flare system emitter position.
  15334. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15335. * @returns the position
  15336. */
  15337. getEmitterPosition(): Vector3;
  15338. /**
  15339. * @hidden
  15340. */
  15341. computeEffectivePosition(globalViewport: Viewport): boolean;
  15342. /** @hidden */
  15343. _isVisible(): boolean;
  15344. /**
  15345. * @hidden
  15346. */
  15347. render(): boolean;
  15348. /**
  15349. * Dispose and release the lens flare with its associated resources.
  15350. */
  15351. dispose(): void;
  15352. /**
  15353. * Parse a lens flare system from a JSON repressentation
  15354. * @param parsedLensFlareSystem Define the JSON to parse
  15355. * @param scene Define the scene the parsed system should be instantiated in
  15356. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15357. * @returns the parsed system
  15358. */
  15359. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15360. /**
  15361. * Serialize the current Lens Flare System into a JSON representation.
  15362. * @returns the serialized JSON
  15363. */
  15364. serialize(): any;
  15365. }
  15366. }
  15367. declare module BABYLON {
  15368. interface AbstractScene {
  15369. /**
  15370. * The list of lens flare system added to the scene
  15371. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15372. */
  15373. lensFlareSystems: Array<LensFlareSystem>;
  15374. /**
  15375. * Removes the given lens flare system from this scene.
  15376. * @param toRemove The lens flare system to remove
  15377. * @returns The index of the removed lens flare system
  15378. */
  15379. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15380. /**
  15381. * Adds the given lens flare system to this scene
  15382. * @param newLensFlareSystem The lens flare system to add
  15383. */
  15384. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15385. /**
  15386. * Gets a lens flare system using its name
  15387. * @param name defines the name to look for
  15388. * @returns the lens flare system or null if not found
  15389. */
  15390. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15391. /**
  15392. * Gets a lens flare system using its id
  15393. * @param id defines the id to look for
  15394. * @returns the lens flare system or null if not found
  15395. */
  15396. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15397. }
  15398. /**
  15399. * Defines the lens flare scene component responsible to manage any lens flares
  15400. * in a given scene.
  15401. */
  15402. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15403. /**
  15404. * The component name helpfull to identify the component in the list of scene components.
  15405. */
  15406. readonly name: string;
  15407. /**
  15408. * The scene the component belongs to.
  15409. */
  15410. scene: Scene;
  15411. /**
  15412. * Creates a new instance of the component for the given scene
  15413. * @param scene Defines the scene to register the component in
  15414. */
  15415. constructor(scene: Scene);
  15416. /**
  15417. * Registers the component in a given scene
  15418. */
  15419. register(): void;
  15420. /**
  15421. * Rebuilds the elements related to this component in case of
  15422. * context lost for instance.
  15423. */
  15424. rebuild(): void;
  15425. /**
  15426. * Adds all the element from the container to the scene
  15427. * @param container the container holding the elements
  15428. */
  15429. addFromContainer(container: AbstractScene): void;
  15430. /**
  15431. * Removes all the elements in the container from the scene
  15432. * @param container contains the elements to remove
  15433. */
  15434. removeFromContainer(container: AbstractScene): void;
  15435. /**
  15436. * Serializes the component data to the specified json object
  15437. * @param serializationObject The object to serialize to
  15438. */
  15439. serialize(serializationObject: any): void;
  15440. /**
  15441. * Disposes the component and the associated ressources.
  15442. */
  15443. dispose(): void;
  15444. private _draw;
  15445. }
  15446. }
  15447. declare module BABYLON {
  15448. /**
  15449. * A directional light is defined by a direction (what a surprise!).
  15450. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15451. * 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.
  15452. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15453. */
  15454. class DirectionalLight extends ShadowLight {
  15455. private _shadowFrustumSize;
  15456. /**
  15457. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15458. */
  15459. /**
  15460. * Specifies a fix frustum size for the shadow generation.
  15461. */
  15462. shadowFrustumSize: number;
  15463. private _shadowOrthoScale;
  15464. /**
  15465. * Gets the shadow projection scale against the optimal computed one.
  15466. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15467. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15468. */
  15469. /**
  15470. * Sets the shadow projection scale against the optimal computed one.
  15471. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15472. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15473. */
  15474. shadowOrthoScale: number;
  15475. /**
  15476. * Automatically compute the projection matrix to best fit (including all the casters)
  15477. * on each frame.
  15478. */
  15479. autoUpdateExtends: boolean;
  15480. private _orthoLeft;
  15481. private _orthoRight;
  15482. private _orthoTop;
  15483. private _orthoBottom;
  15484. /**
  15485. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15486. * The directional light is emitted from everywhere in the given direction.
  15487. * It can cast shadows.
  15488. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15489. * @param name The friendly name of the light
  15490. * @param direction The direction of the light
  15491. * @param scene The scene the light belongs to
  15492. */
  15493. constructor(name: string, direction: Vector3, scene: Scene);
  15494. /**
  15495. * Returns the string "DirectionalLight".
  15496. * @return The class name
  15497. */
  15498. getClassName(): string;
  15499. /**
  15500. * Returns the integer 1.
  15501. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15502. */
  15503. getTypeID(): number;
  15504. /**
  15505. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15506. * Returns the DirectionalLight Shadow projection matrix.
  15507. */
  15508. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15509. /**
  15510. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15511. * Returns the DirectionalLight Shadow projection matrix.
  15512. */
  15513. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15514. /**
  15515. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15516. * Returns the DirectionalLight Shadow projection matrix.
  15517. */
  15518. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15519. protected _buildUniformLayout(): void;
  15520. /**
  15521. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15522. * @param effect The effect to update
  15523. * @param lightIndex The index of the light in the effect to update
  15524. * @returns The directional light
  15525. */
  15526. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15527. /**
  15528. * Gets the minZ used for shadow according to both the scene and the light.
  15529. *
  15530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15532. * @param activeCamera The camera we are returning the min for
  15533. * @returns the depth min z
  15534. */
  15535. getDepthMinZ(activeCamera: Camera): number;
  15536. /**
  15537. * Gets the maxZ used for shadow according to both the scene and the light.
  15538. *
  15539. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15540. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15541. * @param activeCamera The camera we are returning the max for
  15542. * @returns the depth max z
  15543. */
  15544. getDepthMaxZ(activeCamera: Camera): number;
  15545. /**
  15546. * Prepares the list of defines specific to the light type.
  15547. * @param defines the list of defines
  15548. * @param lightIndex defines the index of the light for the effect
  15549. */
  15550. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15551. }
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * The HemisphericLight simulates the ambient environment light,
  15556. * so the passed direction is the light reflection direction, not the incoming direction.
  15557. */
  15558. class HemisphericLight extends Light {
  15559. /**
  15560. * The groundColor is the light in the opposite direction to the one specified during creation.
  15561. * 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.
  15562. */
  15563. groundColor: Color3;
  15564. /**
  15565. * The light reflection direction, not the incoming direction.
  15566. */
  15567. direction: Vector3;
  15568. /**
  15569. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15570. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15571. * The HemisphericLight can't cast shadows.
  15572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15573. * @param name The friendly name of the light
  15574. * @param direction The direction of the light reflection
  15575. * @param scene The scene the light belongs to
  15576. */
  15577. constructor(name: string, direction: Vector3, scene: Scene);
  15578. protected _buildUniformLayout(): void;
  15579. /**
  15580. * Returns the string "HemisphericLight".
  15581. * @return The class name
  15582. */
  15583. getClassName(): string;
  15584. /**
  15585. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15586. * Returns the updated direction.
  15587. * @param target The target the direction should point to
  15588. * @return The computed direction
  15589. */
  15590. setDirectionToTarget(target: Vector3): Vector3;
  15591. /**
  15592. * Returns the shadow generator associated to the light.
  15593. * @returns Always null for hemispheric lights because it does not support shadows.
  15594. */
  15595. getShadowGenerator(): Nullable<IShadowGenerator>;
  15596. /**
  15597. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15598. * @param effect The effect to update
  15599. * @param lightIndex The index of the light in the effect to update
  15600. * @returns The hemispheric light
  15601. */
  15602. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15603. /**
  15604. * Computes the world matrix of the node
  15605. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15606. * @param useWasUpdatedFlag defines a reserved property
  15607. * @returns the world matrix
  15608. */
  15609. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15610. /**
  15611. * Returns the integer 3.
  15612. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15613. */
  15614. getTypeID(): number;
  15615. /**
  15616. * Prepares the list of defines specific to the light type.
  15617. * @param defines the list of defines
  15618. * @param lightIndex defines the index of the light for the effect
  15619. */
  15620. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. /**
  15625. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15626. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15627. * 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.
  15628. */
  15629. abstract class Light extends Node {
  15630. /**
  15631. * Falloff Default: light is falling off following the material specification:
  15632. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15633. */
  15634. static readonly FALLOFF_DEFAULT: number;
  15635. /**
  15636. * Falloff Physical: light is falling off following the inverse squared distance law.
  15637. */
  15638. static readonly FALLOFF_PHYSICAL: number;
  15639. /**
  15640. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15641. * to enhance interoperability with other engines.
  15642. */
  15643. static readonly FALLOFF_GLTF: number;
  15644. /**
  15645. * Falloff Standard: light is falling off like in the standard material
  15646. * to enhance interoperability with other materials.
  15647. */
  15648. static readonly FALLOFF_STANDARD: number;
  15649. /**
  15650. * If every light affecting the material is in this lightmapMode,
  15651. * material.lightmapTexture adds or multiplies
  15652. * (depends on material.useLightmapAsShadowmap)
  15653. * after every other light calculations.
  15654. */
  15655. static readonly LIGHTMAP_DEFAULT: number;
  15656. /**
  15657. * material.lightmapTexture as only diffuse lighting from this light
  15658. * adds only specular lighting from this light
  15659. * adds dynamic shadows
  15660. */
  15661. static readonly LIGHTMAP_SPECULAR: number;
  15662. /**
  15663. * material.lightmapTexture as only lighting
  15664. * no light calculation from this light
  15665. * only adds dynamic shadows from this light
  15666. */
  15667. static readonly LIGHTMAP_SHADOWSONLY: number;
  15668. /**
  15669. * Each light type uses the default quantity according to its type:
  15670. * point/spot lights use luminous intensity
  15671. * directional lights use illuminance
  15672. */
  15673. static readonly INTENSITYMODE_AUTOMATIC: number;
  15674. /**
  15675. * lumen (lm)
  15676. */
  15677. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15678. /**
  15679. * candela (lm/sr)
  15680. */
  15681. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15682. /**
  15683. * lux (lm/m^2)
  15684. */
  15685. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15686. /**
  15687. * nit (cd/m^2)
  15688. */
  15689. static readonly INTENSITYMODE_LUMINANCE: number;
  15690. /**
  15691. * Light type const id of the point light.
  15692. */
  15693. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15694. /**
  15695. * Light type const id of the directional light.
  15696. */
  15697. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15698. /**
  15699. * Light type const id of the spot light.
  15700. */
  15701. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15702. /**
  15703. * Light type const id of the hemispheric light.
  15704. */
  15705. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15706. /**
  15707. * Diffuse gives the basic color to an object.
  15708. */
  15709. diffuse: Color3;
  15710. /**
  15711. * Specular produces a highlight color on an object.
  15712. * Note: This is note affecting PBR materials.
  15713. */
  15714. specular: Color3;
  15715. /**
  15716. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15717. * falling off base on range or angle.
  15718. * This can be set to any values in Light.FALLOFF_x.
  15719. *
  15720. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15721. * other types of materials.
  15722. */
  15723. falloffType: number;
  15724. /**
  15725. * Strength of the light.
  15726. * Note: By default it is define in the framework own unit.
  15727. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15728. */
  15729. intensity: number;
  15730. private _range;
  15731. protected _inverseSquaredRange: number;
  15732. /**
  15733. * Defines how far from the source the light is impacting in scene units.
  15734. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15735. */
  15736. /**
  15737. * Defines how far from the source the light is impacting in scene units.
  15738. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15739. */
  15740. range: number;
  15741. /**
  15742. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15743. * of light.
  15744. */
  15745. private _photometricScale;
  15746. private _intensityMode;
  15747. /**
  15748. * Gets the photometric scale used to interpret the intensity.
  15749. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15750. */
  15751. /**
  15752. * Sets the photometric scale used to interpret the intensity.
  15753. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15754. */
  15755. intensityMode: number;
  15756. private _radius;
  15757. /**
  15758. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15759. */
  15760. /**
  15761. * sets the light radius used by PBR Materials to simulate soft area lights.
  15762. */
  15763. radius: number;
  15764. private _renderPriority;
  15765. /**
  15766. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15767. * exceeding the number allowed of the materials.
  15768. */
  15769. renderPriority: number;
  15770. private _shadowEnabled;
  15771. /**
  15772. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15773. * the current shadow generator.
  15774. */
  15775. /**
  15776. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15777. * the current shadow generator.
  15778. */
  15779. shadowEnabled: boolean;
  15780. private _includedOnlyMeshes;
  15781. /**
  15782. * Gets the only meshes impacted by this light.
  15783. */
  15784. /**
  15785. * Sets the only meshes impacted by this light.
  15786. */
  15787. includedOnlyMeshes: AbstractMesh[];
  15788. private _excludedMeshes;
  15789. /**
  15790. * Gets the meshes not impacted by this light.
  15791. */
  15792. /**
  15793. * Sets the meshes not impacted by this light.
  15794. */
  15795. excludedMeshes: AbstractMesh[];
  15796. private _excludeWithLayerMask;
  15797. /**
  15798. * Gets the layer id use to find what meshes are not impacted by the light.
  15799. * Inactive if 0
  15800. */
  15801. /**
  15802. * Sets the layer id use to find what meshes are not impacted by the light.
  15803. * Inactive if 0
  15804. */
  15805. excludeWithLayerMask: number;
  15806. private _includeOnlyWithLayerMask;
  15807. /**
  15808. * Gets the layer id use to find what meshes are impacted by the light.
  15809. * Inactive if 0
  15810. */
  15811. /**
  15812. * Sets the layer id use to find what meshes are impacted by the light.
  15813. * Inactive if 0
  15814. */
  15815. includeOnlyWithLayerMask: number;
  15816. private _lightmapMode;
  15817. /**
  15818. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15819. */
  15820. /**
  15821. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15822. */
  15823. lightmapMode: number;
  15824. /**
  15825. * Shadow generator associted to the light.
  15826. * @hidden Internal use only.
  15827. */
  15828. _shadowGenerator: Nullable<IShadowGenerator>;
  15829. /**
  15830. * @hidden Internal use only.
  15831. */
  15832. _excludedMeshesIds: string[];
  15833. /**
  15834. * @hidden Internal use only.
  15835. */
  15836. _includedOnlyMeshesIds: string[];
  15837. /**
  15838. * The current light unifom buffer.
  15839. * @hidden Internal use only.
  15840. */
  15841. _uniformBuffer: UniformBuffer;
  15842. /**
  15843. * Creates a Light object in the scene.
  15844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15845. * @param name The firendly name of the light
  15846. * @param scene The scene the light belongs too
  15847. */
  15848. constructor(name: string, scene: Scene);
  15849. protected abstract _buildUniformLayout(): void;
  15850. /**
  15851. * Sets the passed Effect "effect" with the Light information.
  15852. * @param effect The effect to update
  15853. * @param lightIndex The index of the light in the effect to update
  15854. * @returns The light
  15855. */
  15856. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15857. /**
  15858. * Returns the string "Light".
  15859. * @returns the class name
  15860. */
  15861. getClassName(): string;
  15862. /**
  15863. * Converts the light information to a readable string for debug purpose.
  15864. * @param fullDetails Supports for multiple levels of logging within scene loading
  15865. * @returns the human readable light info
  15866. */
  15867. toString(fullDetails?: boolean): string;
  15868. /** @hidden */
  15869. protected _syncParentEnabledState(): void;
  15870. /**
  15871. * Set the enabled state of this node.
  15872. * @param value - the new enabled state
  15873. */
  15874. setEnabled(value: boolean): void;
  15875. /**
  15876. * Returns the Light associated shadow generator if any.
  15877. * @return the associated shadow generator.
  15878. */
  15879. getShadowGenerator(): Nullable<IShadowGenerator>;
  15880. /**
  15881. * Returns a Vector3, the absolute light position in the World.
  15882. * @returns the world space position of the light
  15883. */
  15884. getAbsolutePosition(): Vector3;
  15885. /**
  15886. * Specifies if the light will affect the passed mesh.
  15887. * @param mesh The mesh to test against the light
  15888. * @return true the mesh is affected otherwise, false.
  15889. */
  15890. canAffectMesh(mesh: AbstractMesh): boolean;
  15891. /**
  15892. * Sort function to order lights for rendering.
  15893. * @param a First Light object to compare to second.
  15894. * @param b Second Light object to compare first.
  15895. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15896. */
  15897. static CompareLightsPriority(a: Light, b: Light): number;
  15898. /**
  15899. * Releases resources associated with this node.
  15900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15902. */
  15903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15904. /**
  15905. * Returns the light type ID (integer).
  15906. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15907. */
  15908. getTypeID(): number;
  15909. /**
  15910. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15911. * @returns the scaled intensity in intensity mode unit
  15912. */
  15913. getScaledIntensity(): number;
  15914. /**
  15915. * Returns a new Light object, named "name", from the current one.
  15916. * @param name The name of the cloned light
  15917. * @returns the new created light
  15918. */
  15919. clone(name: string): Nullable<Light>;
  15920. /**
  15921. * Serializes the current light into a Serialization object.
  15922. * @returns the serialized object.
  15923. */
  15924. serialize(): any;
  15925. /**
  15926. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15927. * This new light is named "name" and added to the passed scene.
  15928. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15929. * @param name The friendly name of the light
  15930. * @param scene The scene the new light will belong to
  15931. * @returns the constructor function
  15932. */
  15933. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15934. /**
  15935. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15936. * @param parsedLight The JSON representation of the light
  15937. * @param scene The scene to create the parsed light in
  15938. * @returns the created light after parsing
  15939. */
  15940. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15941. private _hookArrayForExcluded;
  15942. private _hookArrayForIncludedOnly;
  15943. private _resyncMeshes;
  15944. /**
  15945. * Forces the meshes to update their light related information in their rendering used effects
  15946. * @hidden Internal Use Only
  15947. */
  15948. _markMeshesAsLightDirty(): void;
  15949. /**
  15950. * Recomputes the cached photometric scale if needed.
  15951. */
  15952. private _computePhotometricScale;
  15953. /**
  15954. * Returns the Photometric Scale according to the light type and intensity mode.
  15955. */
  15956. private _getPhotometricScale;
  15957. /**
  15958. * Reorder the light in the scene according to their defined priority.
  15959. * @hidden Internal Use Only
  15960. */
  15961. _reorderLightsInScene(): void;
  15962. /**
  15963. * Prepares the list of defines specific to the light type.
  15964. * @param defines the list of defines
  15965. * @param lightIndex defines the index of the light for the effect
  15966. */
  15967. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15968. }
  15969. }
  15970. declare module BABYLON {
  15971. /**
  15972. * A point light is a light defined by an unique point in world space.
  15973. * The light is emitted in every direction from this point.
  15974. * A good example of a point light is a standard light bulb.
  15975. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15976. */
  15977. class PointLight extends ShadowLight {
  15978. private _shadowAngle;
  15979. /**
  15980. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15981. * This specifies what angle the shadow will use to be created.
  15982. *
  15983. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15984. */
  15985. /**
  15986. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15987. * This specifies what angle the shadow will use to be created.
  15988. *
  15989. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15990. */
  15991. shadowAngle: number;
  15992. /**
  15993. * Gets the direction if it has been set.
  15994. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15995. */
  15996. /**
  15997. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15998. */
  15999. direction: Vector3;
  16000. /**
  16001. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16002. * A PointLight emits the light in every direction.
  16003. * It can cast shadows.
  16004. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16005. * ```javascript
  16006. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16007. * ```
  16008. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16009. * @param name The light friendly name
  16010. * @param position The position of the point light in the scene
  16011. * @param scene The scene the lights belongs to
  16012. */
  16013. constructor(name: string, position: Vector3, scene: Scene);
  16014. /**
  16015. * Returns the string "PointLight"
  16016. * @returns the class name
  16017. */
  16018. getClassName(): string;
  16019. /**
  16020. * Returns the integer 0.
  16021. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16022. */
  16023. getTypeID(): number;
  16024. /**
  16025. * Specifies wether or not the shadowmap should be a cube texture.
  16026. * @returns true if the shadowmap needs to be a cube texture.
  16027. */
  16028. needCube(): boolean;
  16029. /**
  16030. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16033. */
  16034. getShadowDirection(faceIndex?: number): Vector3;
  16035. /**
  16036. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16037. * - fov = PI / 2
  16038. * - aspect ratio : 1.0
  16039. * - z-near and far equal to the active camera minZ and maxZ.
  16040. * Returns the PointLight.
  16041. */
  16042. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16043. protected _buildUniformLayout(): void;
  16044. /**
  16045. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16046. * @param effect The effect to update
  16047. * @param lightIndex The index of the light in the effect to update
  16048. * @returns The point light
  16049. */
  16050. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16051. /**
  16052. * Prepares the list of defines specific to the light type.
  16053. * @param defines the list of defines
  16054. * @param lightIndex defines the index of the light for the effect
  16055. */
  16056. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16057. }
  16058. }
  16059. declare module BABYLON {
  16060. /**
  16061. * Interface describing all the common properties and methods a shadow light needs to implement.
  16062. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16063. * as well as binding the different shadow properties to the effects.
  16064. */
  16065. interface IShadowLight extends Light {
  16066. /**
  16067. * The light id in the scene (used in scene.findLighById for instance)
  16068. */
  16069. id: string;
  16070. /**
  16071. * The position the shdow will be casted from.
  16072. */
  16073. position: Vector3;
  16074. /**
  16075. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16076. */
  16077. direction: Vector3;
  16078. /**
  16079. * The transformed position. Position of the light in world space taking parenting in account.
  16080. */
  16081. transformedPosition: Vector3;
  16082. /**
  16083. * The transformed direction. Direction of the light in world space taking parenting in account.
  16084. */
  16085. transformedDirection: Vector3;
  16086. /**
  16087. * The friendly name of the light in the scene.
  16088. */
  16089. name: string;
  16090. /**
  16091. * Defines the shadow projection clipping minimum z value.
  16092. */
  16093. shadowMinZ: number;
  16094. /**
  16095. * Defines the shadow projection clipping maximum z value.
  16096. */
  16097. shadowMaxZ: number;
  16098. /**
  16099. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16100. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16101. */
  16102. computeTransformedInformation(): boolean;
  16103. /**
  16104. * Gets the scene the light belongs to.
  16105. * @returns The scene
  16106. */
  16107. getScene(): Scene;
  16108. /**
  16109. * Callback defining a custom Projection Matrix Builder.
  16110. * This can be used to override the default projection matrix computation.
  16111. */
  16112. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16113. /**
  16114. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16115. * @param matrix The materix to updated with the projection information
  16116. * @param viewMatrix The transform matrix of the light
  16117. * @param renderList The list of mesh to render in the map
  16118. * @returns The current light
  16119. */
  16120. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16121. /**
  16122. * Gets the current depth scale used in ESM.
  16123. * @returns The scale
  16124. */
  16125. getDepthScale(): number;
  16126. /**
  16127. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16128. * @returns true if a cube texture needs to be use
  16129. */
  16130. needCube(): boolean;
  16131. /**
  16132. * Detects if the projection matrix requires to be recomputed this frame.
  16133. * @returns true if it requires to be recomputed otherwise, false.
  16134. */
  16135. needProjectionMatrixCompute(): boolean;
  16136. /**
  16137. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16138. */
  16139. forceProjectionMatrixCompute(): void;
  16140. /**
  16141. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16142. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16143. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16144. */
  16145. getShadowDirection(faceIndex?: number): Vector3;
  16146. /**
  16147. * Gets the minZ used for shadow according to both the scene and the light.
  16148. * @param activeCamera The camera we are returning the min for
  16149. * @returns the depth min z
  16150. */
  16151. getDepthMinZ(activeCamera: Camera): number;
  16152. /**
  16153. * Gets the maxZ used for shadow according to both the scene and the light.
  16154. * @param activeCamera The camera we are returning the max for
  16155. * @returns the depth max z
  16156. */
  16157. getDepthMaxZ(activeCamera: Camera): number;
  16158. }
  16159. /**
  16160. * Base implementation IShadowLight
  16161. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16162. */
  16163. abstract class ShadowLight extends Light implements IShadowLight {
  16164. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16165. protected _position: Vector3;
  16166. protected _setPosition(value: Vector3): void;
  16167. /**
  16168. * Sets the position the shadow will be casted from. Also use as the light position for both
  16169. * point and spot lights.
  16170. */
  16171. /**
  16172. * Sets the position the shadow will be casted from. Also use as the light position for both
  16173. * point and spot lights.
  16174. */
  16175. position: Vector3;
  16176. protected _direction: Vector3;
  16177. protected _setDirection(value: Vector3): void;
  16178. /**
  16179. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16180. * Also use as the light direction on spot and directional lights.
  16181. */
  16182. /**
  16183. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16184. * Also use as the light direction on spot and directional lights.
  16185. */
  16186. direction: Vector3;
  16187. private _shadowMinZ;
  16188. /**
  16189. * Gets the shadow projection clipping minimum z value.
  16190. */
  16191. /**
  16192. * Sets the shadow projection clipping minimum z value.
  16193. */
  16194. shadowMinZ: number;
  16195. private _shadowMaxZ;
  16196. /**
  16197. * Sets the shadow projection clipping maximum z value.
  16198. */
  16199. /**
  16200. * Gets the shadow projection clipping maximum z value.
  16201. */
  16202. shadowMaxZ: number;
  16203. /**
  16204. * Callback defining a custom Projection Matrix Builder.
  16205. * This can be used to override the default projection matrix computation.
  16206. */
  16207. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16208. /**
  16209. * The transformed position. Position of the light in world space taking parenting in account.
  16210. */
  16211. transformedPosition: Vector3;
  16212. /**
  16213. * The transformed direction. Direction of the light in world space taking parenting in account.
  16214. */
  16215. transformedDirection: Vector3;
  16216. private _needProjectionMatrixCompute;
  16217. /**
  16218. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16219. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16220. */
  16221. computeTransformedInformation(): boolean;
  16222. /**
  16223. * Return the depth scale used for the shadow map.
  16224. * @returns the depth scale.
  16225. */
  16226. getDepthScale(): number;
  16227. /**
  16228. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16229. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16230. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16231. */
  16232. getShadowDirection(faceIndex?: number): Vector3;
  16233. /**
  16234. * Returns the ShadowLight absolute position in the World.
  16235. * @returns the position vector in world space
  16236. */
  16237. getAbsolutePosition(): Vector3;
  16238. /**
  16239. * Sets the ShadowLight direction toward the passed target.
  16240. * @param target The point tot target in local space
  16241. * @returns the updated ShadowLight direction
  16242. */
  16243. setDirectionToTarget(target: Vector3): Vector3;
  16244. /**
  16245. * Returns the light rotation in euler definition.
  16246. * @returns the x y z rotation in local space.
  16247. */
  16248. getRotation(): Vector3;
  16249. /**
  16250. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16251. * @returns true if a cube texture needs to be use
  16252. */
  16253. needCube(): boolean;
  16254. /**
  16255. * Detects if the projection matrix requires to be recomputed this frame.
  16256. * @returns true if it requires to be recomputed otherwise, false.
  16257. */
  16258. needProjectionMatrixCompute(): boolean;
  16259. /**
  16260. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16261. */
  16262. forceProjectionMatrixCompute(): void;
  16263. /** @hidden */
  16264. _initCache(): void;
  16265. /** @hidden */
  16266. _isSynchronized(): boolean;
  16267. /**
  16268. * Computes the world matrix of the node
  16269. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16270. * @returns the world matrix
  16271. */
  16272. computeWorldMatrix(force?: boolean): Matrix;
  16273. /**
  16274. * Gets the minZ used for shadow according to both the scene and the light.
  16275. * @param activeCamera The camera we are returning the min for
  16276. * @returns the depth min z
  16277. */
  16278. getDepthMinZ(activeCamera: Camera): number;
  16279. /**
  16280. * Gets the maxZ used for shadow according to both the scene and the light.
  16281. * @param activeCamera The camera we are returning the max for
  16282. * @returns the depth max z
  16283. */
  16284. getDepthMaxZ(activeCamera: Camera): number;
  16285. /**
  16286. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16287. * @param matrix The materix to updated with the projection information
  16288. * @param viewMatrix The transform matrix of the light
  16289. * @param renderList The list of mesh to render in the map
  16290. * @returns The current light
  16291. */
  16292. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16293. }
  16294. }
  16295. declare module BABYLON {
  16296. /**
  16297. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16298. * These values define a cone of light starting from the position, emitting toward the direction.
  16299. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16300. * and the exponent defines the speed of the decay of the light with distance (reach).
  16301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16302. */
  16303. class SpotLight extends ShadowLight {
  16304. private _angle;
  16305. private _innerAngle;
  16306. private _cosHalfAngle;
  16307. private _lightAngleScale;
  16308. private _lightAngleOffset;
  16309. /**
  16310. * Gets the cone angle of the spot light in Radians.
  16311. */
  16312. /**
  16313. * Sets the cone angle of the spot light in Radians.
  16314. */
  16315. angle: number;
  16316. /**
  16317. * Only used in gltf falloff mode, this defines the angle where
  16318. * the directional falloff will start before cutting at angle which could be seen
  16319. * as outer angle.
  16320. */
  16321. /**
  16322. * Only used in gltf falloff mode, this defines the angle where
  16323. * the directional falloff will start before cutting at angle which could be seen
  16324. * as outer angle.
  16325. */
  16326. innerAngle: number;
  16327. private _shadowAngleScale;
  16328. /**
  16329. * Allows scaling the angle of the light for shadow generation only.
  16330. */
  16331. /**
  16332. * Allows scaling the angle of the light for shadow generation only.
  16333. */
  16334. shadowAngleScale: number;
  16335. /**
  16336. * The light decay speed with the distance from the emission spot.
  16337. */
  16338. exponent: number;
  16339. private _projectionTextureMatrix;
  16340. /**
  16341. * Allows reading the projecton texture
  16342. */
  16343. readonly projectionTextureMatrix: Matrix;
  16344. protected _projectionTextureLightNear: number;
  16345. /**
  16346. * Gets the near clip of the Spotlight for texture projection.
  16347. */
  16348. /**
  16349. * Sets the near clip of the Spotlight for texture projection.
  16350. */
  16351. projectionTextureLightNear: number;
  16352. protected _projectionTextureLightFar: number;
  16353. /**
  16354. * Gets the far clip of the Spotlight for texture projection.
  16355. */
  16356. /**
  16357. * Sets the far clip of the Spotlight for texture projection.
  16358. */
  16359. projectionTextureLightFar: number;
  16360. protected _projectionTextureUpDirection: Vector3;
  16361. /**
  16362. * Gets the Up vector of the Spotlight for texture projection.
  16363. */
  16364. /**
  16365. * Sets the Up vector of the Spotlight for texture projection.
  16366. */
  16367. projectionTextureUpDirection: Vector3;
  16368. private _projectionTexture;
  16369. /**
  16370. * Gets the projection texture of the light.
  16371. */
  16372. /**
  16373. * Sets the projection texture of the light.
  16374. */
  16375. projectionTexture: Nullable<BaseTexture>;
  16376. private _projectionTextureViewLightDirty;
  16377. private _projectionTextureProjectionLightDirty;
  16378. private _projectionTextureDirty;
  16379. private _projectionTextureViewTargetVector;
  16380. private _projectionTextureViewLightMatrix;
  16381. private _projectionTextureProjectionLightMatrix;
  16382. private _projectionTextureScalingMatrix;
  16383. /**
  16384. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16385. * It can cast shadows.
  16386. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16387. * @param name The light friendly name
  16388. * @param position The position of the spot light in the scene
  16389. * @param direction The direction of the light in the scene
  16390. * @param angle The cone angle of the light in Radians
  16391. * @param exponent The light decay speed with the distance from the emission spot
  16392. * @param scene The scene the lights belongs to
  16393. */
  16394. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16395. /**
  16396. * Returns the string "SpotLight".
  16397. * @returns the class name
  16398. */
  16399. getClassName(): string;
  16400. /**
  16401. * Returns the integer 2.
  16402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16403. */
  16404. getTypeID(): number;
  16405. /**
  16406. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16407. */
  16408. protected _setDirection(value: Vector3): void;
  16409. /**
  16410. * Overrides the position setter to recompute the projection texture view light Matrix.
  16411. */
  16412. protected _setPosition(value: Vector3): void;
  16413. /**
  16414. * 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.
  16415. * Returns the SpotLight.
  16416. */
  16417. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16418. protected _computeProjectionTextureViewLightMatrix(): void;
  16419. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16420. /**
  16421. * Main function for light texture projection matrix computing.
  16422. */
  16423. protected _computeProjectionTextureMatrix(): void;
  16424. protected _buildUniformLayout(): void;
  16425. private _computeAngleValues;
  16426. /**
  16427. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16428. * @param effect The effect to update
  16429. * @param lightIndex The index of the light in the effect to update
  16430. * @returns The spot light
  16431. */
  16432. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16433. /**
  16434. * Disposes the light and the associated resources.
  16435. */
  16436. dispose(): void;
  16437. /**
  16438. * Prepares the list of defines specific to the light type.
  16439. * @param defines the list of defines
  16440. * @param lightIndex defines the index of the light for the effect
  16441. */
  16442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16443. }
  16444. }
  16445. declare module BABYLON {
  16446. /**
  16447. * Interface used to present a loading screen while loading a scene
  16448. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16449. */
  16450. interface ILoadingScreen {
  16451. /**
  16452. * Function called to display the loading screen
  16453. */
  16454. displayLoadingUI: () => void;
  16455. /**
  16456. * Function called to hide the loading screen
  16457. */
  16458. hideLoadingUI: () => void;
  16459. /**
  16460. * Gets or sets the color to use for the background
  16461. */
  16462. loadingUIBackgroundColor: string;
  16463. /**
  16464. * Gets or sets the text to display while loading
  16465. */
  16466. loadingUIText: string;
  16467. }
  16468. /**
  16469. * Class used for the default loading screen
  16470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16471. */
  16472. class DefaultLoadingScreen implements ILoadingScreen {
  16473. private _renderingCanvas;
  16474. private _loadingText;
  16475. private _loadingDivBackgroundColor;
  16476. private _loadingDiv;
  16477. private _loadingTextDiv;
  16478. /**
  16479. * Creates a new default loading screen
  16480. * @param _renderingCanvas defines the canvas used to render the scene
  16481. * @param _loadingText defines the default text to display
  16482. * @param _loadingDivBackgroundColor defines the default background color
  16483. */
  16484. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16485. /**
  16486. * Function called to display the loading screen
  16487. */
  16488. displayLoadingUI(): void;
  16489. /**
  16490. * Function called to hide the loading screen
  16491. */
  16492. hideLoadingUI(): void;
  16493. /**
  16494. * Gets or sets the text to display while loading
  16495. */
  16496. loadingUIText: string;
  16497. /**
  16498. * Gets or sets the color to use for the background
  16499. */
  16500. loadingUIBackgroundColor: string;
  16501. private _resizeLoadingUI;
  16502. }
  16503. }
  16504. declare module BABYLON {
  16505. /**
  16506. * Class used to represent data loading progression
  16507. */
  16508. class SceneLoaderProgressEvent {
  16509. /** defines if data length to load can be evaluated */
  16510. readonly lengthComputable: boolean;
  16511. /** defines the loaded data length */
  16512. readonly loaded: number;
  16513. /** defines the data length to load */
  16514. readonly total: number;
  16515. /**
  16516. * Create a new progress event
  16517. * @param lengthComputable defines if data length to load can be evaluated
  16518. * @param loaded defines the loaded data length
  16519. * @param total defines the data length to load
  16520. */
  16521. constructor(
  16522. /** defines if data length to load can be evaluated */
  16523. lengthComputable: boolean,
  16524. /** defines the loaded data length */
  16525. loaded: number,
  16526. /** defines the data length to load */
  16527. total: number);
  16528. /**
  16529. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16530. * @param event defines the source event
  16531. * @returns a new SceneLoaderProgressEvent
  16532. */
  16533. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16534. }
  16535. /**
  16536. * Interface used by SceneLoader plugins to define supported file extensions
  16537. */
  16538. interface ISceneLoaderPluginExtensions {
  16539. /**
  16540. * Defines the list of supported extensions
  16541. */
  16542. [extension: string]: {
  16543. isBinary: boolean;
  16544. };
  16545. }
  16546. /**
  16547. * Interface used by SceneLoader plugin factory
  16548. */
  16549. interface ISceneLoaderPluginFactory {
  16550. /**
  16551. * Defines the name of the factory
  16552. */
  16553. name: string;
  16554. /**
  16555. * Function called to create a new plugin
  16556. * @return the new plugin
  16557. */
  16558. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16559. /**
  16560. * Boolean indicating if the plugin can direct load specific data
  16561. */
  16562. canDirectLoad?: (data: string) => boolean;
  16563. }
  16564. /**
  16565. * Interface used to define a SceneLoader plugin
  16566. */
  16567. interface ISceneLoaderPlugin {
  16568. /**
  16569. * The friendly name of this plugin.
  16570. */
  16571. name: string;
  16572. /**
  16573. * The file extensions supported by this plugin.
  16574. */
  16575. extensions: string | ISceneLoaderPluginExtensions;
  16576. /**
  16577. * Import meshes into a scene.
  16578. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16579. * @param scene The scene to import into
  16580. * @param data The data to import
  16581. * @param rootUrl The root url for scene and resources
  16582. * @param meshes The meshes array to import into
  16583. * @param particleSystems The particle systems array to import into
  16584. * @param skeletons The skeletons array to import into
  16585. * @param onError The callback when import fails
  16586. * @returns True if successful or false otherwise
  16587. */
  16588. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16589. /**
  16590. * Load into a scene.
  16591. * @param scene The scene to load into
  16592. * @param data The data to import
  16593. * @param rootUrl The root url for scene and resources
  16594. * @param onError The callback when import fails
  16595. * @returns true if successful or false otherwise
  16596. */
  16597. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16598. /**
  16599. * The callback that returns true if the data can be directly loaded.
  16600. */
  16601. canDirectLoad?: (data: string) => boolean;
  16602. /**
  16603. * The callback that allows custom handling of the root url based on the response url.
  16604. */
  16605. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16606. /**
  16607. * Load into an asset container.
  16608. * @param scene The scene to load into
  16609. * @param data The data to import
  16610. * @param rootUrl The root url for scene and resources
  16611. * @param onError The callback when import fails
  16612. * @returns The loaded asset container
  16613. */
  16614. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16615. }
  16616. /**
  16617. * Interface used to define an async SceneLoader plugin
  16618. */
  16619. interface ISceneLoaderPluginAsync {
  16620. /**
  16621. * The friendly name of this plugin.
  16622. */
  16623. name: string;
  16624. /**
  16625. * The file extensions supported by this plugin.
  16626. */
  16627. extensions: string | ISceneLoaderPluginExtensions;
  16628. /**
  16629. * Import meshes into a scene.
  16630. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16631. * @param scene The scene to import into
  16632. * @param data The data to import
  16633. * @param rootUrl The root url for scene and resources
  16634. * @param onProgress The callback when the load progresses
  16635. * @param fileName Defines the name of the file to load
  16636. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16637. */
  16638. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16639. meshes: AbstractMesh[];
  16640. particleSystems: IParticleSystem[];
  16641. skeletons: Skeleton[];
  16642. animationGroups: AnimationGroup[];
  16643. }>;
  16644. /**
  16645. * Load into a scene.
  16646. * @param scene The scene to load into
  16647. * @param data The data to import
  16648. * @param rootUrl The root url for scene and resources
  16649. * @param onProgress The callback when the load progresses
  16650. * @param fileName Defines the name of the file to load
  16651. * @returns Nothing
  16652. */
  16653. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16654. /**
  16655. * The callback that returns true if the data can be directly loaded.
  16656. */
  16657. canDirectLoad?: (data: string) => boolean;
  16658. /**
  16659. * The callback that allows custom handling of the root url based on the response url.
  16660. */
  16661. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16662. /**
  16663. * Load into an asset container.
  16664. * @param scene The scene to load into
  16665. * @param data The data to import
  16666. * @param rootUrl The root url for scene and resources
  16667. * @param onProgress The callback when the load progresses
  16668. * @param fileName Defines the name of the file to load
  16669. * @returns The loaded asset container
  16670. */
  16671. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16672. }
  16673. /**
  16674. * Class used to load scene from various file formats using registered plugins
  16675. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16676. */
  16677. class SceneLoader {
  16678. private static _ForceFullSceneLoadingForIncremental;
  16679. private static _ShowLoadingScreen;
  16680. private static _CleanBoneMatrixWeights;
  16681. /**
  16682. * No logging while loading
  16683. */
  16684. static readonly NO_LOGGING: number;
  16685. /**
  16686. * Minimal logging while loading
  16687. */
  16688. static readonly MINIMAL_LOGGING: number;
  16689. /**
  16690. * Summary logging while loading
  16691. */
  16692. static readonly SUMMARY_LOGGING: number;
  16693. /**
  16694. * Detailled logging while loading
  16695. */
  16696. static readonly DETAILED_LOGGING: number;
  16697. private static _loggingLevel;
  16698. /**
  16699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16700. */
  16701. static ForceFullSceneLoadingForIncremental: boolean;
  16702. /**
  16703. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16704. */
  16705. static ShowLoadingScreen: boolean;
  16706. /**
  16707. * Defines the current logging level (while loading the scene)
  16708. * @ignorenaming
  16709. */
  16710. static loggingLevel: number;
  16711. /**
  16712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16713. */
  16714. static CleanBoneMatrixWeights: boolean;
  16715. /**
  16716. * Event raised when a plugin is used to load a scene
  16717. */
  16718. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16719. private static _registeredPlugins;
  16720. private static _getDefaultPlugin;
  16721. private static _getPluginForExtension;
  16722. private static _getPluginForDirectLoad;
  16723. private static _getPluginForFilename;
  16724. private static _getDirectLoad;
  16725. private static _loadData;
  16726. private static _getFileInfo;
  16727. /**
  16728. * Gets a plugin that can load the given extension
  16729. * @param extension defines the extension to load
  16730. * @returns a plugin or null if none works
  16731. */
  16732. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16733. /**
  16734. * Gets a boolean indicating that the given extension can be loaded
  16735. * @param extension defines the extension to load
  16736. * @returns true if the extension is supported
  16737. */
  16738. static IsPluginForExtensionAvailable(extension: string): boolean;
  16739. /**
  16740. * Adds a new plugin to the list of registered plugins
  16741. * @param plugin defines the plugin to add
  16742. */
  16743. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16744. /**
  16745. * Import meshes into a scene
  16746. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16747. * @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)
  16748. * @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)
  16749. * @param scene the instance of BABYLON.Scene to append to
  16750. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16751. * @param onProgress a callback with a progress event for each file being loaded
  16752. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16753. * @param pluginExtension the extension used to determine the plugin
  16754. * @returns The loaded plugin
  16755. */
  16756. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, 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>;
  16757. /**
  16758. * Import meshes into a scene
  16759. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16760. * @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)
  16761. * @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)
  16762. * @param scene the instance of BABYLON.Scene to append to
  16763. * @param onProgress a callback with a progress event for each file being loaded
  16764. * @param pluginExtension the extension used to determine the plugin
  16765. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16766. */
  16767. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16768. meshes: AbstractMesh[];
  16769. particleSystems: IParticleSystem[];
  16770. skeletons: Skeleton[];
  16771. animationGroups: AnimationGroup[];
  16772. }>;
  16773. /**
  16774. * Load a scene
  16775. * @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)
  16776. * @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)
  16777. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16778. * @param onSuccess a callback with the scene when import succeeds
  16779. * @param onProgress a callback with a progress event for each file being loaded
  16780. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16781. * @param pluginExtension the extension used to determine the plugin
  16782. * @returns The loaded plugin
  16783. */
  16784. static Load(rootUrl: string, sceneFilename: string, engine: 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>;
  16785. /**
  16786. * Load a scene
  16787. * @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)
  16788. * @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)
  16789. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16790. * @param onProgress a callback with a progress event for each file being loaded
  16791. * @param pluginExtension the extension used to determine the plugin
  16792. * @returns The loaded scene
  16793. */
  16794. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16795. /**
  16796. * Append a scene
  16797. * @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)
  16798. * @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)
  16799. * @param scene is the instance of BABYLON.Scene to append to
  16800. * @param onSuccess a callback with the scene when import succeeds
  16801. * @param onProgress a callback with a progress event for each file being loaded
  16802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16803. * @param pluginExtension the extension used to determine the plugin
  16804. * @returns The loaded plugin
  16805. */
  16806. static Append(rootUrl: string, sceneFilename?: string, 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>;
  16807. /**
  16808. * Append a scene
  16809. * @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)
  16810. * @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)
  16811. * @param scene is the instance of BABYLON.Scene to append to
  16812. * @param onProgress a callback with a progress event for each file being loaded
  16813. * @param pluginExtension the extension used to determine the plugin
  16814. * @returns The given scene
  16815. */
  16816. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16817. /**
  16818. * Load a scene into an asset container
  16819. * @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)
  16820. * @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)
  16821. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16822. * @param onSuccess a callback with the scene when import succeeds
  16823. * @param onProgress a callback with a progress event for each file being loaded
  16824. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16825. * @param pluginExtension the extension used to determine the plugin
  16826. * @returns The loaded plugin
  16827. */
  16828. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, 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>;
  16829. /**
  16830. * Load a scene into an asset container
  16831. * @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)
  16832. * @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)
  16833. * @param scene is the instance of BABYLON.Scene to append to
  16834. * @param onProgress a callback with a progress event for each file being loaded
  16835. * @param pluginExtension the extension used to determine the plugin
  16836. * @returns The loaded asset container
  16837. */
  16838. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16839. }
  16840. }
  16841. declare module BABYLON {
  16842. /**
  16843. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16845. * 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;
  16846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16847. */
  16848. class ColorCurves {
  16849. private _dirty;
  16850. private _tempColor;
  16851. private _globalCurve;
  16852. private _highlightsCurve;
  16853. private _midtonesCurve;
  16854. private _shadowsCurve;
  16855. private _positiveCurve;
  16856. private _negativeCurve;
  16857. private _globalHue;
  16858. private _globalDensity;
  16859. private _globalSaturation;
  16860. private _globalExposure;
  16861. /**
  16862. * Gets the global Hue value.
  16863. * 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).
  16864. */
  16865. /**
  16866. * Sets the global Hue value.
  16867. * 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).
  16868. */
  16869. globalHue: number;
  16870. /**
  16871. * Gets the global Density value.
  16872. * 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.
  16873. * Values less than zero provide a filter of opposite hue.
  16874. */
  16875. /**
  16876. * Sets the global Density value.
  16877. * 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.
  16878. * Values less than zero provide a filter of opposite hue.
  16879. */
  16880. globalDensity: number;
  16881. /**
  16882. * Gets the global Saturation value.
  16883. * 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.
  16884. */
  16885. /**
  16886. * Sets the global Saturation value.
  16887. * 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.
  16888. */
  16889. globalSaturation: number;
  16890. /**
  16891. * Gets the global Exposure value.
  16892. * 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.
  16893. */
  16894. /**
  16895. * Sets the global Exposure value.
  16896. * 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.
  16897. */
  16898. globalExposure: number;
  16899. private _highlightsHue;
  16900. private _highlightsDensity;
  16901. private _highlightsSaturation;
  16902. private _highlightsExposure;
  16903. /**
  16904. * Gets the highlights Hue value.
  16905. * 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).
  16906. */
  16907. /**
  16908. * Sets the highlights Hue value.
  16909. * 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).
  16910. */
  16911. highlightsHue: number;
  16912. /**
  16913. * Gets the highlights Density value.
  16914. * 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.
  16915. * Values less than zero provide a filter of opposite hue.
  16916. */
  16917. /**
  16918. * Sets the highlights Density value.
  16919. * 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.
  16920. * Values less than zero provide a filter of opposite hue.
  16921. */
  16922. highlightsDensity: number;
  16923. /**
  16924. * Gets the highlights Saturation value.
  16925. * 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.
  16926. */
  16927. /**
  16928. * Sets the highlights Saturation value.
  16929. * 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.
  16930. */
  16931. highlightsSaturation: number;
  16932. /**
  16933. * Gets the highlights Exposure value.
  16934. * 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.
  16935. */
  16936. /**
  16937. * Sets the highlights Exposure value.
  16938. * 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.
  16939. */
  16940. highlightsExposure: number;
  16941. private _midtonesHue;
  16942. private _midtonesDensity;
  16943. private _midtonesSaturation;
  16944. private _midtonesExposure;
  16945. /**
  16946. * Gets the midtones Hue value.
  16947. * 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).
  16948. */
  16949. /**
  16950. * Sets the midtones Hue value.
  16951. * 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).
  16952. */
  16953. midtonesHue: number;
  16954. /**
  16955. * Gets the midtones Density value.
  16956. * 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.
  16957. * Values less than zero provide a filter of opposite hue.
  16958. */
  16959. /**
  16960. * Sets the midtones Density value.
  16961. * 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.
  16962. * Values less than zero provide a filter of opposite hue.
  16963. */
  16964. midtonesDensity: number;
  16965. /**
  16966. * Gets the midtones Saturation value.
  16967. * 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.
  16968. */
  16969. /**
  16970. * Sets the midtones Saturation value.
  16971. * 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.
  16972. */
  16973. midtonesSaturation: number;
  16974. /**
  16975. * Gets the midtones Exposure value.
  16976. * 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.
  16977. */
  16978. /**
  16979. * Sets the midtones Exposure value.
  16980. * 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.
  16981. */
  16982. midtonesExposure: number;
  16983. private _shadowsHue;
  16984. private _shadowsDensity;
  16985. private _shadowsSaturation;
  16986. private _shadowsExposure;
  16987. /**
  16988. * Gets the shadows Hue value.
  16989. * 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).
  16990. */
  16991. /**
  16992. * Sets the shadows Hue value.
  16993. * 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).
  16994. */
  16995. shadowsHue: number;
  16996. /**
  16997. * Gets the shadows Density value.
  16998. * 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.
  16999. * Values less than zero provide a filter of opposite hue.
  17000. */
  17001. /**
  17002. * Sets the shadows Density value.
  17003. * 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.
  17004. * Values less than zero provide a filter of opposite hue.
  17005. */
  17006. shadowsDensity: number;
  17007. /**
  17008. * Gets the shadows Saturation value.
  17009. * 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.
  17010. */
  17011. /**
  17012. * Sets the shadows Saturation value.
  17013. * 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.
  17014. */
  17015. shadowsSaturation: number;
  17016. /**
  17017. * Gets the shadows Exposure value.
  17018. * 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.
  17019. */
  17020. /**
  17021. * Sets the shadows Exposure value.
  17022. * 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.
  17023. */
  17024. shadowsExposure: number;
  17025. /**
  17026. * Returns the class name
  17027. * @returns The class name
  17028. */
  17029. getClassName(): string;
  17030. /**
  17031. * Binds the color curves to the shader.
  17032. * @param colorCurves The color curve to bind
  17033. * @param effect The effect to bind to
  17034. * @param positiveUniform The positive uniform shader parameter
  17035. * @param neutralUniform The neutral uniform shader parameter
  17036. * @param negativeUniform The negative uniform shader parameter
  17037. */
  17038. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17039. /**
  17040. * Prepare the list of uniforms associated with the ColorCurves effects.
  17041. * @param uniformsList The list of uniforms used in the effect
  17042. */
  17043. static PrepareUniforms(uniformsList: string[]): void;
  17044. /**
  17045. * Returns color grading data based on a hue, density, saturation and exposure value.
  17046. * @param filterHue The hue of the color filter.
  17047. * @param filterDensity The density of the color filter.
  17048. * @param saturation The saturation.
  17049. * @param exposure The exposure.
  17050. * @param result The result data container.
  17051. */
  17052. private getColorGradingDataToRef;
  17053. /**
  17054. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17055. * @param value The input slider value in range [-100,100].
  17056. * @returns Adjusted value.
  17057. */
  17058. private static applyColorGradingSliderNonlinear;
  17059. /**
  17060. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17061. * @param hue The hue (H) input.
  17062. * @param saturation The saturation (S) input.
  17063. * @param brightness The brightness (B) input.
  17064. * @result An RGBA color represented as Vector4.
  17065. */
  17066. private static fromHSBToRef;
  17067. /**
  17068. * Returns a value clamped between min and max
  17069. * @param value The value to clamp
  17070. * @param min The minimum of value
  17071. * @param max The maximum of value
  17072. * @returns The clamped value.
  17073. */
  17074. private static clamp;
  17075. /**
  17076. * Clones the current color curve instance.
  17077. * @return The cloned curves
  17078. */
  17079. clone(): ColorCurves;
  17080. /**
  17081. * Serializes the current color curve instance to a json representation.
  17082. * @return a JSON representation
  17083. */
  17084. serialize(): any;
  17085. /**
  17086. * Parses the color curve from a json representation.
  17087. * @param source the JSON source to parse
  17088. * @return The parsed curves
  17089. */
  17090. static Parse(source: any): ColorCurves;
  17091. }
  17092. }
  17093. declare module BABYLON {
  17094. /**
  17095. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17096. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17097. */
  17098. class EffectFallbacks {
  17099. private _defines;
  17100. private _currentRank;
  17101. private _maxRank;
  17102. private _mesh;
  17103. /**
  17104. * Removes the fallback from the bound mesh.
  17105. */
  17106. unBindMesh(): void;
  17107. /**
  17108. * Adds a fallback on the specified property.
  17109. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17110. * @param define The name of the define in the shader
  17111. */
  17112. addFallback(rank: number, define: string): void;
  17113. /**
  17114. * Sets the mesh to use CPU skinning when needing to fallback.
  17115. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17116. * @param mesh The mesh to use the fallbacks.
  17117. */
  17118. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17119. /**
  17120. * Checks to see if more fallbacks are still availible.
  17121. */
  17122. readonly isMoreFallbacks: boolean;
  17123. /**
  17124. * Removes the defines that shoould be removed when falling back.
  17125. * @param currentDefines defines the current define statements for the shader.
  17126. * @param effect defines the current effect we try to compile
  17127. * @returns The resulting defines with defines of the current rank removed.
  17128. */
  17129. reduce(currentDefines: string, effect: Effect): string;
  17130. }
  17131. /**
  17132. * Options to be used when creating an effect.
  17133. */
  17134. class EffectCreationOptions {
  17135. /**
  17136. * Atrributes that will be used in the shader.
  17137. */
  17138. attributes: string[];
  17139. /**
  17140. * Uniform varible names that will be set in the shader.
  17141. */
  17142. uniformsNames: string[];
  17143. /**
  17144. * Uniform buffer varible names that will be set in the shader.
  17145. */
  17146. uniformBuffersNames: string[];
  17147. /**
  17148. * Sampler texture variable names that will be set in the shader.
  17149. */
  17150. samplers: string[];
  17151. /**
  17152. * Define statements that will be set in the shader.
  17153. */
  17154. defines: any;
  17155. /**
  17156. * Possible fallbacks for this effect to improve performance when needed.
  17157. */
  17158. fallbacks: Nullable<EffectFallbacks>;
  17159. /**
  17160. * Callback that will be called when the shader is compiled.
  17161. */
  17162. onCompiled: Nullable<(effect: Effect) => void>;
  17163. /**
  17164. * Callback that will be called if an error occurs during shader compilation.
  17165. */
  17166. onError: Nullable<(effect: Effect, errors: string) => void>;
  17167. /**
  17168. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17169. */
  17170. indexParameters: any;
  17171. /**
  17172. * Max number of lights that can be used in the shader.
  17173. */
  17174. maxSimultaneousLights: number;
  17175. /**
  17176. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17177. */
  17178. transformFeedbackVaryings: Nullable<string[]>;
  17179. }
  17180. /**
  17181. * Effect containing vertex and fragment shader that can be executed on an object.
  17182. */
  17183. class Effect {
  17184. /**
  17185. * Name of the effect.
  17186. */
  17187. name: any;
  17188. /**
  17189. * String container all the define statements that should be set on the shader.
  17190. */
  17191. defines: string;
  17192. /**
  17193. * Callback that will be called when the shader is compiled.
  17194. */
  17195. onCompiled: Nullable<(effect: Effect) => void>;
  17196. /**
  17197. * Callback that will be called if an error occurs during shader compilation.
  17198. */
  17199. onError: Nullable<(effect: Effect, errors: string) => void>;
  17200. /**
  17201. * Callback that will be called when effect is bound.
  17202. */
  17203. onBind: Nullable<(effect: Effect) => void>;
  17204. /**
  17205. * Unique ID of the effect.
  17206. */
  17207. uniqueId: number;
  17208. /**
  17209. * Observable that will be called when the shader is compiled.
  17210. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17211. */
  17212. onCompileObservable: Observable<Effect>;
  17213. /**
  17214. * Observable that will be called if an error occurs during shader compilation.
  17215. */
  17216. onErrorObservable: Observable<Effect>;
  17217. /** @hidden */
  17218. _onBindObservable: Nullable<Observable<Effect>>;
  17219. /**
  17220. * Observable that will be called when effect is bound.
  17221. */
  17222. readonly onBindObservable: Observable<Effect>;
  17223. /** @hidden */
  17224. _bonesComputationForcedToCPU: boolean;
  17225. private static _uniqueIdSeed;
  17226. private _engine;
  17227. private _uniformBuffersNames;
  17228. private _uniformsNames;
  17229. private _samplers;
  17230. private _isReady;
  17231. private _compilationError;
  17232. private _attributesNames;
  17233. private _attributes;
  17234. private _uniforms;
  17235. /**
  17236. * Key for the effect.
  17237. * @hidden
  17238. */
  17239. _key: string;
  17240. private _indexParameters;
  17241. private _fallbacks;
  17242. private _vertexSourceCode;
  17243. private _fragmentSourceCode;
  17244. private _vertexSourceCodeOverride;
  17245. private _fragmentSourceCodeOverride;
  17246. private _transformFeedbackVaryings;
  17247. /**
  17248. * Compiled shader to webGL program.
  17249. * @hidden
  17250. */
  17251. _program: WebGLProgram;
  17252. private _valueCache;
  17253. private static _baseCache;
  17254. /**
  17255. * Instantiates an effect.
  17256. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17257. * @param baseName Name of the effect.
  17258. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17259. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17260. * @param samplers List of sampler variables that will be passed to the shader.
  17261. * @param engine Engine to be used to render the effect
  17262. * @param defines Define statements to be added to the shader.
  17263. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17264. * @param onCompiled Callback that will be called when the shader is compiled.
  17265. * @param onError Callback that will be called if an error occurs during shader compilation.
  17266. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17267. */
  17268. 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);
  17269. /**
  17270. * Unique key for this effect
  17271. */
  17272. readonly key: string;
  17273. /**
  17274. * If the effect has been compiled and prepared.
  17275. * @returns if the effect is compiled and prepared.
  17276. */
  17277. isReady(): boolean;
  17278. /**
  17279. * The engine the effect was initialized with.
  17280. * @returns the engine.
  17281. */
  17282. getEngine(): Engine;
  17283. /**
  17284. * The compiled webGL program for the effect
  17285. * @returns the webGL program.
  17286. */
  17287. getProgram(): WebGLProgram;
  17288. /**
  17289. * The set of names of attribute variables for the shader.
  17290. * @returns An array of attribute names.
  17291. */
  17292. getAttributesNames(): string[];
  17293. /**
  17294. * Returns the attribute at the given index.
  17295. * @param index The index of the attribute.
  17296. * @returns The location of the attribute.
  17297. */
  17298. getAttributeLocation(index: number): number;
  17299. /**
  17300. * Returns the attribute based on the name of the variable.
  17301. * @param name of the attribute to look up.
  17302. * @returns the attribute location.
  17303. */
  17304. getAttributeLocationByName(name: string): number;
  17305. /**
  17306. * The number of attributes.
  17307. * @returns the numnber of attributes.
  17308. */
  17309. getAttributesCount(): number;
  17310. /**
  17311. * Gets the index of a uniform variable.
  17312. * @param uniformName of the uniform to look up.
  17313. * @returns the index.
  17314. */
  17315. getUniformIndex(uniformName: string): number;
  17316. /**
  17317. * Returns the attribute based on the name of the variable.
  17318. * @param uniformName of the uniform to look up.
  17319. * @returns the location of the uniform.
  17320. */
  17321. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17322. /**
  17323. * Returns an array of sampler variable names
  17324. * @returns The array of sampler variable neames.
  17325. */
  17326. getSamplers(): string[];
  17327. /**
  17328. * The error from the last compilation.
  17329. * @returns the error string.
  17330. */
  17331. getCompilationError(): string;
  17332. /**
  17333. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17334. * @param func The callback to be used.
  17335. */
  17336. executeWhenCompiled(func: (effect: Effect) => void): void;
  17337. private _checkIsReady;
  17338. /** @hidden */
  17339. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17340. /** @hidden */
  17341. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17342. /** @hidden */
  17343. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17344. private _processShaderConversion;
  17345. private _processIncludes;
  17346. private _processPrecision;
  17347. /**
  17348. * Recompiles the webGL program
  17349. * @param vertexSourceCode The source code for the vertex shader.
  17350. * @param fragmentSourceCode The source code for the fragment shader.
  17351. * @param onCompiled Callback called when completed.
  17352. * @param onError Callback called on error.
  17353. * @hidden
  17354. */
  17355. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17356. /**
  17357. * Gets the uniform locations of the the specified variable names
  17358. * @param names THe names of the variables to lookup.
  17359. * @returns Array of locations in the same order as variable names.
  17360. */
  17361. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17362. /**
  17363. * Prepares the effect
  17364. * @hidden
  17365. */
  17366. _prepareEffect(): void;
  17367. /**
  17368. * Checks if the effect is supported. (Must be called after compilation)
  17369. */
  17370. readonly isSupported: boolean;
  17371. /**
  17372. * Binds a texture to the engine to be used as output of the shader.
  17373. * @param channel Name of the output variable.
  17374. * @param texture Texture to bind.
  17375. * @hidden
  17376. */
  17377. _bindTexture(channel: string, texture: InternalTexture): void;
  17378. /**
  17379. * Sets a texture on the engine to be used in the shader.
  17380. * @param channel Name of the sampler variable.
  17381. * @param texture Texture to set.
  17382. */
  17383. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17384. /**
  17385. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17386. * @param channel Name of the sampler variable.
  17387. * @param texture Texture to set.
  17388. */
  17389. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17390. /**
  17391. * Sets an array of textures on the engine to be used in the shader.
  17392. * @param channel Name of the variable.
  17393. * @param textures Textures to set.
  17394. */
  17395. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17396. /**
  17397. * 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)
  17398. * @param channel Name of the sampler variable.
  17399. * @param postProcess Post process to get the input texture from.
  17400. */
  17401. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17402. /**
  17403. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17404. * 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)
  17405. * @param channel Name of the sampler variable.
  17406. * @param postProcess Post process to get the output texture from.
  17407. */
  17408. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17409. /** @hidden */
  17410. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17411. /** @hidden */
  17412. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17413. /** @hidden */
  17414. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17415. /** @hidden */
  17416. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17417. /**
  17418. * Binds a buffer to a uniform.
  17419. * @param buffer Buffer to bind.
  17420. * @param name Name of the uniform variable to bind to.
  17421. */
  17422. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17423. /**
  17424. * Binds block to a uniform.
  17425. * @param blockName Name of the block to bind.
  17426. * @param index Index to bind.
  17427. */
  17428. bindUniformBlock(blockName: string, index: number): void;
  17429. /**
  17430. * Sets an interger value on a uniform variable.
  17431. * @param uniformName Name of the variable.
  17432. * @param value Value to be set.
  17433. * @returns this effect.
  17434. */
  17435. setInt(uniformName: string, value: number): Effect;
  17436. /**
  17437. * Sets an int array on a uniform variable.
  17438. * @param uniformName Name of the variable.
  17439. * @param array array to be set.
  17440. * @returns this effect.
  17441. */
  17442. setIntArray(uniformName: string, array: Int32Array): Effect;
  17443. /**
  17444. * 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)
  17445. * @param uniformName Name of the variable.
  17446. * @param array array to be set.
  17447. * @returns this effect.
  17448. */
  17449. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17450. /**
  17451. * 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)
  17452. * @param uniformName Name of the variable.
  17453. * @param array array to be set.
  17454. * @returns this effect.
  17455. */
  17456. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17457. /**
  17458. * 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)
  17459. * @param uniformName Name of the variable.
  17460. * @param array array to be set.
  17461. * @returns this effect.
  17462. */
  17463. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17464. /**
  17465. * Sets an float array on a uniform variable.
  17466. * @param uniformName Name of the variable.
  17467. * @param array array to be set.
  17468. * @returns this effect.
  17469. */
  17470. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17471. /**
  17472. * 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)
  17473. * @param uniformName Name of the variable.
  17474. * @param array array to be set.
  17475. * @returns this effect.
  17476. */
  17477. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17478. /**
  17479. * 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)
  17480. * @param uniformName Name of the variable.
  17481. * @param array array to be set.
  17482. * @returns this effect.
  17483. */
  17484. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17485. /**
  17486. * 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)
  17487. * @param uniformName Name of the variable.
  17488. * @param array array to be set.
  17489. * @returns this effect.
  17490. */
  17491. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17492. /**
  17493. * Sets an array on a uniform variable.
  17494. * @param uniformName Name of the variable.
  17495. * @param array array to be set.
  17496. * @returns this effect.
  17497. */
  17498. setArray(uniformName: string, array: number[]): Effect;
  17499. /**
  17500. * 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)
  17501. * @param uniformName Name of the variable.
  17502. * @param array array to be set.
  17503. * @returns this effect.
  17504. */
  17505. setArray2(uniformName: string, array: number[]): Effect;
  17506. /**
  17507. * 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)
  17508. * @param uniformName Name of the variable.
  17509. * @param array array to be set.
  17510. * @returns this effect.
  17511. */
  17512. setArray3(uniformName: string, array: number[]): Effect;
  17513. /**
  17514. * 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)
  17515. * @param uniformName Name of the variable.
  17516. * @param array array to be set.
  17517. * @returns this effect.
  17518. */
  17519. setArray4(uniformName: string, array: number[]): Effect;
  17520. /**
  17521. * Sets matrices on a uniform variable.
  17522. * @param uniformName Name of the variable.
  17523. * @param matrices matrices to be set.
  17524. * @returns this effect.
  17525. */
  17526. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17527. /**
  17528. * Sets matrix on a uniform variable.
  17529. * @param uniformName Name of the variable.
  17530. * @param matrix matrix to be set.
  17531. * @returns this effect.
  17532. */
  17533. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17534. /**
  17535. * 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)
  17536. * @param uniformName Name of the variable.
  17537. * @param matrix matrix to be set.
  17538. * @returns this effect.
  17539. */
  17540. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17541. /**
  17542. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17543. * @param uniformName Name of the variable.
  17544. * @param matrix matrix to be set.
  17545. * @returns this effect.
  17546. */
  17547. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17548. /**
  17549. * Sets a float on a uniform variable.
  17550. * @param uniformName Name of the variable.
  17551. * @param value value to be set.
  17552. * @returns this effect.
  17553. */
  17554. setFloat(uniformName: string, value: number): Effect;
  17555. /**
  17556. * Sets a boolean on a uniform variable.
  17557. * @param uniformName Name of the variable.
  17558. * @param bool value to be set.
  17559. * @returns this effect.
  17560. */
  17561. setBool(uniformName: string, bool: boolean): Effect;
  17562. /**
  17563. * Sets a Vector2 on a uniform variable.
  17564. * @param uniformName Name of the variable.
  17565. * @param vector2 vector2 to be set.
  17566. * @returns this effect.
  17567. */
  17568. setVector2(uniformName: string, vector2: Vector2): Effect;
  17569. /**
  17570. * Sets a float2 on a uniform variable.
  17571. * @param uniformName Name of the variable.
  17572. * @param x First float in float2.
  17573. * @param y Second float in float2.
  17574. * @returns this effect.
  17575. */
  17576. setFloat2(uniformName: string, x: number, y: number): Effect;
  17577. /**
  17578. * Sets a Vector3 on a uniform variable.
  17579. * @param uniformName Name of the variable.
  17580. * @param vector3 Value to be set.
  17581. * @returns this effect.
  17582. */
  17583. setVector3(uniformName: string, vector3: Vector3): Effect;
  17584. /**
  17585. * Sets a float3 on a uniform variable.
  17586. * @param uniformName Name of the variable.
  17587. * @param x First float in float3.
  17588. * @param y Second float in float3.
  17589. * @param z Third float in float3.
  17590. * @returns this effect.
  17591. */
  17592. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17593. /**
  17594. * Sets a Vector4 on a uniform variable.
  17595. * @param uniformName Name of the variable.
  17596. * @param vector4 Value to be set.
  17597. * @returns this effect.
  17598. */
  17599. setVector4(uniformName: string, vector4: Vector4): Effect;
  17600. /**
  17601. * Sets a float4 on a uniform variable.
  17602. * @param uniformName Name of the variable.
  17603. * @param x First float in float4.
  17604. * @param y Second float in float4.
  17605. * @param z Third float in float4.
  17606. * @param w Fourth float in float4.
  17607. * @returns this effect.
  17608. */
  17609. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17610. /**
  17611. * Sets a Color3 on a uniform variable.
  17612. * @param uniformName Name of the variable.
  17613. * @param color3 Value to be set.
  17614. * @returns this effect.
  17615. */
  17616. setColor3(uniformName: string, color3: Color3): Effect;
  17617. /**
  17618. * Sets a Color4 on a uniform variable.
  17619. * @param uniformName Name of the variable.
  17620. * @param color3 Value to be set.
  17621. * @param alpha Alpha value to be set.
  17622. * @returns this effect.
  17623. */
  17624. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17625. /**
  17626. * Sets a Color4 on a uniform variable
  17627. * @param uniformName defines the name of the variable
  17628. * @param color4 defines the value to be set
  17629. * @returns this effect.
  17630. */
  17631. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17632. /**
  17633. * This function will add a new shader to the shader store
  17634. * @param name the name of the shader
  17635. * @param pixelShader optional pixel shader content
  17636. * @param vertexShader optional vertex shader content
  17637. */
  17638. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17639. /**
  17640. * Store of each shader (The can be looked up using effect.key)
  17641. */
  17642. static ShadersStore: {
  17643. [key: string]: string;
  17644. };
  17645. /**
  17646. * Store of each included file for a shader (The can be looked up using effect.key)
  17647. */
  17648. static IncludesShadersStore: {
  17649. [key: string]: string;
  17650. };
  17651. /**
  17652. * Resets the cache of effects.
  17653. */
  17654. static ResetCache(): void;
  17655. }
  17656. }
  17657. declare module BABYLON {
  17658. /**
  17659. * This represents all the required information to add a fresnel effect on a material:
  17660. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17661. */
  17662. class FresnelParameters {
  17663. private _isEnabled;
  17664. /**
  17665. * Define if the fresnel effect is enable or not.
  17666. */
  17667. isEnabled: boolean;
  17668. /**
  17669. * Define the color used on edges (grazing angle)
  17670. */
  17671. leftColor: Color3;
  17672. /**
  17673. * Define the color used on center
  17674. */
  17675. rightColor: Color3;
  17676. /**
  17677. * Define bias applied to computed fresnel term
  17678. */
  17679. bias: number;
  17680. /**
  17681. * Defined the power exponent applied to fresnel term
  17682. */
  17683. power: number;
  17684. /**
  17685. * Clones the current fresnel and its valuues
  17686. * @returns a clone fresnel configuration
  17687. */
  17688. clone(): FresnelParameters;
  17689. /**
  17690. * Serializes the current fresnel parameters to a JSON representation.
  17691. * @return the JSON serialization
  17692. */
  17693. serialize(): any;
  17694. /**
  17695. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17696. * @param parsedFresnelParameters Define the JSON representation
  17697. * @returns the parsed parameters
  17698. */
  17699. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17700. }
  17701. }
  17702. declare module BABYLON {
  17703. /**
  17704. * Interface to follow in your material defines to integrate easily the
  17705. * Image proccessing functions.
  17706. * @hidden
  17707. */
  17708. interface IImageProcessingConfigurationDefines {
  17709. IMAGEPROCESSING: boolean;
  17710. VIGNETTE: boolean;
  17711. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17712. VIGNETTEBLENDMODEOPAQUE: boolean;
  17713. TONEMAPPING: boolean;
  17714. TONEMAPPING_ACES: boolean;
  17715. CONTRAST: boolean;
  17716. EXPOSURE: boolean;
  17717. COLORCURVES: boolean;
  17718. COLORGRADING: boolean;
  17719. COLORGRADING3D: boolean;
  17720. SAMPLER3DGREENDEPTH: boolean;
  17721. SAMPLER3DBGRMAP: boolean;
  17722. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17723. }
  17724. /**
  17725. * @hidden
  17726. */
  17727. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17728. IMAGEPROCESSING: boolean;
  17729. VIGNETTE: boolean;
  17730. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17731. VIGNETTEBLENDMODEOPAQUE: boolean;
  17732. TONEMAPPING: boolean;
  17733. TONEMAPPING_ACES: boolean;
  17734. CONTRAST: boolean;
  17735. COLORCURVES: boolean;
  17736. COLORGRADING: boolean;
  17737. COLORGRADING3D: boolean;
  17738. SAMPLER3DGREENDEPTH: boolean;
  17739. SAMPLER3DBGRMAP: boolean;
  17740. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17741. EXPOSURE: boolean;
  17742. constructor();
  17743. }
  17744. /**
  17745. * This groups together the common properties used for image processing either in direct forward pass
  17746. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17747. * or not.
  17748. */
  17749. class ImageProcessingConfiguration {
  17750. /**
  17751. * Default tone mapping applied in BabylonJS.
  17752. */
  17753. static readonly TONEMAPPING_STANDARD: number;
  17754. /**
  17755. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17756. * to other engines rendering to increase portability.
  17757. */
  17758. static readonly TONEMAPPING_ACES: number;
  17759. /**
  17760. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17761. */
  17762. colorCurves: Nullable<ColorCurves>;
  17763. private _colorCurvesEnabled;
  17764. /**
  17765. * Gets wether the color curves effect is enabled.
  17766. */
  17767. /**
  17768. * Sets wether the color curves effect is enabled.
  17769. */
  17770. colorCurvesEnabled: boolean;
  17771. private _colorGradingTexture;
  17772. /**
  17773. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17774. */
  17775. /**
  17776. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17777. */
  17778. colorGradingTexture: Nullable<BaseTexture>;
  17779. private _colorGradingEnabled;
  17780. /**
  17781. * Gets wether the color grading effect is enabled.
  17782. */
  17783. /**
  17784. * Sets wether the color grading effect is enabled.
  17785. */
  17786. colorGradingEnabled: boolean;
  17787. private _colorGradingWithGreenDepth;
  17788. /**
  17789. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17790. */
  17791. /**
  17792. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17793. */
  17794. colorGradingWithGreenDepth: boolean;
  17795. private _colorGradingBGR;
  17796. /**
  17797. * Gets wether the color grading texture contains BGR values.
  17798. */
  17799. /**
  17800. * Sets wether the color grading texture contains BGR values.
  17801. */
  17802. colorGradingBGR: boolean;
  17803. /** @hidden */
  17804. _exposure: number;
  17805. /**
  17806. * Gets the Exposure used in the effect.
  17807. */
  17808. /**
  17809. * Sets the Exposure used in the effect.
  17810. */
  17811. exposure: number;
  17812. private _toneMappingEnabled;
  17813. /**
  17814. * Gets wether the tone mapping effect is enabled.
  17815. */
  17816. /**
  17817. * Sets wether the tone mapping effect is enabled.
  17818. */
  17819. toneMappingEnabled: boolean;
  17820. private _toneMappingType;
  17821. /**
  17822. * Gets the type of tone mapping effect.
  17823. */
  17824. /**
  17825. * Sets the type of tone mapping effect used in BabylonJS.
  17826. */
  17827. toneMappingType: number;
  17828. protected _contrast: number;
  17829. /**
  17830. * Gets the contrast used in the effect.
  17831. */
  17832. /**
  17833. * Sets the contrast used in the effect.
  17834. */
  17835. contrast: number;
  17836. /**
  17837. * Vignette stretch size.
  17838. */
  17839. vignetteStretch: number;
  17840. /**
  17841. * Vignette centre X Offset.
  17842. */
  17843. vignetteCentreX: number;
  17844. /**
  17845. * Vignette centre Y Offset.
  17846. */
  17847. vignetteCentreY: number;
  17848. /**
  17849. * Vignette weight or intensity of the vignette effect.
  17850. */
  17851. vignetteWeight: number;
  17852. /**
  17853. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17854. * if vignetteEnabled is set to true.
  17855. */
  17856. vignetteColor: Color4;
  17857. /**
  17858. * Camera field of view used by the Vignette effect.
  17859. */
  17860. vignetteCameraFov: number;
  17861. private _vignetteBlendMode;
  17862. /**
  17863. * Gets the vignette blend mode allowing different kind of effect.
  17864. */
  17865. /**
  17866. * Sets the vignette blend mode allowing different kind of effect.
  17867. */
  17868. vignetteBlendMode: number;
  17869. private _vignetteEnabled;
  17870. /**
  17871. * Gets wether the vignette effect is enabled.
  17872. */
  17873. /**
  17874. * Sets wether the vignette effect is enabled.
  17875. */
  17876. vignetteEnabled: boolean;
  17877. private _applyByPostProcess;
  17878. /**
  17879. * Gets wether the image processing is applied through a post process or not.
  17880. */
  17881. /**
  17882. * Sets wether the image processing is applied through a post process or not.
  17883. */
  17884. applyByPostProcess: boolean;
  17885. private _isEnabled;
  17886. /**
  17887. * Gets wether the image processing is enabled or not.
  17888. */
  17889. /**
  17890. * Sets wether the image processing is enabled or not.
  17891. */
  17892. isEnabled: boolean;
  17893. /**
  17894. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17895. */
  17896. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17897. /**
  17898. * Method called each time the image processing information changes requires to recompile the effect.
  17899. */
  17900. protected _updateParameters(): void;
  17901. /**
  17902. * Gets the current class name.
  17903. * @return "ImageProcessingConfiguration"
  17904. */
  17905. getClassName(): string;
  17906. /**
  17907. * Prepare the list of uniforms associated with the Image Processing effects.
  17908. * @param uniforms The list of uniforms used in the effect
  17909. * @param defines the list of defines currently in use
  17910. */
  17911. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17912. /**
  17913. * Prepare the list of samplers associated with the Image Processing effects.
  17914. * @param samplersList The list of uniforms used in the effect
  17915. * @param defines the list of defines currently in use
  17916. */
  17917. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17918. /**
  17919. * Prepare the list of defines associated to the shader.
  17920. * @param defines the list of defines to complete
  17921. * @param forPostProcess Define if we are currently in post process mode or not
  17922. */
  17923. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17924. /**
  17925. * Returns true if all the image processing information are ready.
  17926. * @returns True if ready, otherwise, false
  17927. */
  17928. isReady(): boolean;
  17929. /**
  17930. * Binds the image processing to the shader.
  17931. * @param effect The effect to bind to
  17932. * @param aspectRatio Define the current aspect ratio of the effect
  17933. */
  17934. bind(effect: Effect, aspectRatio?: number): void;
  17935. /**
  17936. * Clones the current image processing instance.
  17937. * @return The cloned image processing
  17938. */
  17939. clone(): ImageProcessingConfiguration;
  17940. /**
  17941. * Serializes the current image processing instance to a json representation.
  17942. * @return a JSON representation
  17943. */
  17944. serialize(): any;
  17945. /**
  17946. * Parses the image processing from a json representation.
  17947. * @param source the JSON source to parse
  17948. * @return The parsed image processing
  17949. */
  17950. static Parse(source: any): ImageProcessingConfiguration;
  17951. private static _VIGNETTEMODE_MULTIPLY;
  17952. private static _VIGNETTEMODE_OPAQUE;
  17953. /**
  17954. * Used to apply the vignette as a mix with the pixel color.
  17955. */
  17956. static readonly VIGNETTEMODE_MULTIPLY: number;
  17957. /**
  17958. * Used to apply the vignette as a replacement of the pixel color.
  17959. */
  17960. static readonly VIGNETTEMODE_OPAQUE: number;
  17961. }
  17962. }
  17963. declare module BABYLON {
  17964. /**
  17965. * Manages the defines for the Material
  17966. */
  17967. class MaterialDefines {
  17968. private _keys;
  17969. private _isDirty;
  17970. /** @hidden */
  17971. _renderId: number;
  17972. /** @hidden */
  17973. _areLightsDirty: boolean;
  17974. /** @hidden */
  17975. _areAttributesDirty: boolean;
  17976. /** @hidden */
  17977. _areTexturesDirty: boolean;
  17978. /** @hidden */
  17979. _areFresnelDirty: boolean;
  17980. /** @hidden */
  17981. _areMiscDirty: boolean;
  17982. /** @hidden */
  17983. _areImageProcessingDirty: boolean;
  17984. /** @hidden */
  17985. _normals: boolean;
  17986. /** @hidden */
  17987. _uvs: boolean;
  17988. /** @hidden */
  17989. _needNormals: boolean;
  17990. /** @hidden */
  17991. _needUVs: boolean;
  17992. /**
  17993. * Specifies if the material needs to be re-calculated
  17994. */
  17995. readonly isDirty: boolean;
  17996. /**
  17997. * Marks the material to indicate that it has been re-calculated
  17998. */
  17999. markAsProcessed(): void;
  18000. /**
  18001. * Marks the material to indicate that it needs to be re-calculated
  18002. */
  18003. markAsUnprocessed(): void;
  18004. /**
  18005. * Marks the material to indicate all of its defines need to be re-calculated
  18006. */
  18007. markAllAsDirty(): void;
  18008. /**
  18009. * Marks the material to indicate that image processing needs to be re-calculated
  18010. */
  18011. markAsImageProcessingDirty(): void;
  18012. /**
  18013. * Marks the material to indicate the lights need to be re-calculated
  18014. */
  18015. markAsLightDirty(): void;
  18016. /**
  18017. * Marks the attribute state as changed
  18018. */
  18019. markAsAttributesDirty(): void;
  18020. /**
  18021. * Marks the texture state as changed
  18022. */
  18023. markAsTexturesDirty(): void;
  18024. /**
  18025. * Marks the fresnel state as changed
  18026. */
  18027. markAsFresnelDirty(): void;
  18028. /**
  18029. * Marks the misc state as changed
  18030. */
  18031. markAsMiscDirty(): void;
  18032. /**
  18033. * Rebuilds the material defines
  18034. */
  18035. rebuild(): void;
  18036. /**
  18037. * Specifies if two material defines are equal
  18038. * @param other - A material define instance to compare to
  18039. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18040. */
  18041. isEqual(other: MaterialDefines): boolean;
  18042. /**
  18043. * Clones this instance's defines to another instance
  18044. * @param other - material defines to clone values to
  18045. */
  18046. cloneTo(other: MaterialDefines): void;
  18047. /**
  18048. * Resets the material define values
  18049. */
  18050. reset(): void;
  18051. /**
  18052. * Converts the material define values to a string
  18053. * @returns - String of material define information
  18054. */
  18055. toString(): string;
  18056. }
  18057. /**
  18058. * Base class for the main features of a material in Babylon.js
  18059. */
  18060. class Material implements IAnimatable {
  18061. private static _TriangleFillMode;
  18062. private static _WireFrameFillMode;
  18063. private static _PointFillMode;
  18064. private static _PointListDrawMode;
  18065. private static _LineListDrawMode;
  18066. private static _LineLoopDrawMode;
  18067. private static _LineStripDrawMode;
  18068. private static _TriangleStripDrawMode;
  18069. private static _TriangleFanDrawMode;
  18070. /**
  18071. * Returns the triangle fill mode
  18072. */
  18073. static readonly TriangleFillMode: number;
  18074. /**
  18075. * Returns the wireframe mode
  18076. */
  18077. static readonly WireFrameFillMode: number;
  18078. /**
  18079. * Returns the point fill mode
  18080. */
  18081. static readonly PointFillMode: number;
  18082. /**
  18083. * Returns the point list draw mode
  18084. */
  18085. static readonly PointListDrawMode: number;
  18086. /**
  18087. * Returns the line list draw mode
  18088. */
  18089. static readonly LineListDrawMode: number;
  18090. /**
  18091. * Returns the line loop draw mode
  18092. */
  18093. static readonly LineLoopDrawMode: number;
  18094. /**
  18095. * Returns the line strip draw mode
  18096. */
  18097. static readonly LineStripDrawMode: number;
  18098. /**
  18099. * Returns the triangle strip draw mode
  18100. */
  18101. static readonly TriangleStripDrawMode: number;
  18102. /**
  18103. * Returns the triangle fan draw mode
  18104. */
  18105. static readonly TriangleFanDrawMode: number;
  18106. /**
  18107. * Stores the clock-wise side orientation
  18108. */
  18109. private static _ClockWiseSideOrientation;
  18110. /**
  18111. * Stores the counter clock-wise side orientation
  18112. */
  18113. private static _CounterClockWiseSideOrientation;
  18114. /**
  18115. * Returns the clock-wise side orientation
  18116. */
  18117. static readonly ClockWiseSideOrientation: number;
  18118. /**
  18119. * Returns the counter clock-wise side orientation
  18120. */
  18121. static readonly CounterClockWiseSideOrientation: number;
  18122. /**
  18123. * The dirty texture flag value
  18124. */
  18125. static readonly TextureDirtyFlag: number;
  18126. /**
  18127. * The dirty light flag value
  18128. */
  18129. static readonly LightDirtyFlag: number;
  18130. /**
  18131. * The dirty fresnel flag value
  18132. */
  18133. static readonly FresnelDirtyFlag: number;
  18134. /**
  18135. * The dirty attribute flag value
  18136. */
  18137. static readonly AttributesDirtyFlag: number;
  18138. /**
  18139. * The dirty misc flag value
  18140. */
  18141. static readonly MiscDirtyFlag: number;
  18142. /**
  18143. * The all dirty flag value
  18144. */
  18145. static readonly AllDirtyFlag: number;
  18146. /**
  18147. * The ID of the material
  18148. */
  18149. id: string;
  18150. /**
  18151. * Gets or sets the unique id of the material
  18152. */
  18153. uniqueId: number;
  18154. /**
  18155. * The name of the material
  18156. */
  18157. name: string;
  18158. /**
  18159. * Gets or sets user defined metadata
  18160. */
  18161. metadata: any;
  18162. /**
  18163. * Specifies if the ready state should be checked on each call
  18164. */
  18165. checkReadyOnEveryCall: boolean;
  18166. /**
  18167. * Specifies if the ready state should be checked once
  18168. */
  18169. checkReadyOnlyOnce: boolean;
  18170. /**
  18171. * The state of the material
  18172. */
  18173. state: string;
  18174. /**
  18175. * The alpha value of the material
  18176. */
  18177. protected _alpha: number;
  18178. /**
  18179. * Sets the alpha value of the material
  18180. */
  18181. /**
  18182. * Gets the alpha value of the material
  18183. */
  18184. alpha: number;
  18185. /**
  18186. * Specifies if back face culling is enabled
  18187. */
  18188. protected _backFaceCulling: boolean;
  18189. /**
  18190. * Sets the back-face culling state
  18191. */
  18192. /**
  18193. * Gets the back-face culling state
  18194. */
  18195. backFaceCulling: boolean;
  18196. /**
  18197. * Stores the value for side orientation
  18198. */
  18199. sideOrientation: number;
  18200. /**
  18201. * Callback triggered when the material is compiled
  18202. */
  18203. onCompiled: (effect: Effect) => void;
  18204. /**
  18205. * Callback triggered when an error occurs
  18206. */
  18207. onError: (effect: Effect, errors: string) => void;
  18208. /**
  18209. * Callback triggered to get the render target textures
  18210. */
  18211. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18212. /**
  18213. * Gets a boolean indicating that current material needs to register RTT
  18214. */
  18215. readonly hasRenderTargetTextures: boolean;
  18216. /**
  18217. * Specifies if the material should be serialized
  18218. */
  18219. doNotSerialize: boolean;
  18220. /**
  18221. * @hidden
  18222. */
  18223. _storeEffectOnSubMeshes: boolean;
  18224. /**
  18225. * Stores the animations for the material
  18226. */
  18227. animations: Array<Animation>;
  18228. /**
  18229. * An event triggered when the material is disposed
  18230. */
  18231. onDisposeObservable: Observable<Material>;
  18232. /**
  18233. * An observer which watches for dispose events
  18234. */
  18235. private _onDisposeObserver;
  18236. private _onUnBindObservable;
  18237. /**
  18238. * Called during a dispose event
  18239. */
  18240. onDispose: () => void;
  18241. private _onBindObservable;
  18242. /**
  18243. * An event triggered when the material is bound
  18244. */
  18245. readonly onBindObservable: Observable<AbstractMesh>;
  18246. /**
  18247. * An observer which watches for bind events
  18248. */
  18249. private _onBindObserver;
  18250. /**
  18251. * Called during a bind event
  18252. */
  18253. onBind: (Mesh: AbstractMesh) => void;
  18254. /**
  18255. * An event triggered when the material is unbound
  18256. */
  18257. readonly onUnBindObservable: Observable<Material>;
  18258. /**
  18259. * Stores the value of the alpha mode
  18260. */
  18261. private _alphaMode;
  18262. /**
  18263. * Sets the value of the alpha mode.
  18264. *
  18265. * | Value | Type | Description |
  18266. * | --- | --- | --- |
  18267. * | 0 | ALPHA_DISABLE | |
  18268. * | 1 | ALPHA_ADD | |
  18269. * | 2 | ALPHA_COMBINE | |
  18270. * | 3 | ALPHA_SUBTRACT | |
  18271. * | 4 | ALPHA_MULTIPLY | |
  18272. * | 5 | ALPHA_MAXIMIZED | |
  18273. * | 6 | ALPHA_ONEONE | |
  18274. * | 7 | ALPHA_PREMULTIPLIED | |
  18275. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18276. * | 9 | ALPHA_INTERPOLATE | |
  18277. * | 10 | ALPHA_SCREENMODE | |
  18278. *
  18279. */
  18280. /**
  18281. * Gets the value of the alpha mode
  18282. */
  18283. alphaMode: number;
  18284. /**
  18285. * Stores the state of the need depth pre-pass value
  18286. */
  18287. private _needDepthPrePass;
  18288. /**
  18289. * Sets the need depth pre-pass value
  18290. */
  18291. /**
  18292. * Gets the depth pre-pass value
  18293. */
  18294. needDepthPrePass: boolean;
  18295. /**
  18296. * Specifies if depth writing should be disabled
  18297. */
  18298. disableDepthWrite: boolean;
  18299. /**
  18300. * Specifies if depth writing should be forced
  18301. */
  18302. forceDepthWrite: boolean;
  18303. /**
  18304. * Specifies if there should be a separate pass for culling
  18305. */
  18306. separateCullingPass: boolean;
  18307. /**
  18308. * Stores the state specifing if fog should be enabled
  18309. */
  18310. private _fogEnabled;
  18311. /**
  18312. * Sets the state for enabling fog
  18313. */
  18314. /**
  18315. * Gets the value of the fog enabled state
  18316. */
  18317. fogEnabled: boolean;
  18318. /**
  18319. * Stores the size of points
  18320. */
  18321. pointSize: number;
  18322. /**
  18323. * Stores the z offset value
  18324. */
  18325. zOffset: number;
  18326. /**
  18327. * Gets a value specifying if wireframe mode is enabled
  18328. */
  18329. /**
  18330. * Sets the state of wireframe mode
  18331. */
  18332. wireframe: boolean;
  18333. /**
  18334. * Gets the value specifying if point clouds are enabled
  18335. */
  18336. /**
  18337. * Sets the state of point cloud mode
  18338. */
  18339. pointsCloud: boolean;
  18340. /**
  18341. * Gets the material fill mode
  18342. */
  18343. /**
  18344. * Sets the material fill mode
  18345. */
  18346. fillMode: number;
  18347. /**
  18348. * @hidden
  18349. * Stores the effects for the material
  18350. */
  18351. _effect: Nullable<Effect>;
  18352. /**
  18353. * @hidden
  18354. * Specifies if the material was previously ready
  18355. */
  18356. _wasPreviouslyReady: boolean;
  18357. /**
  18358. * Specifies if uniform buffers should be used
  18359. */
  18360. private _useUBO;
  18361. /**
  18362. * Stores a reference to the scene
  18363. */
  18364. private _scene;
  18365. /**
  18366. * Stores the fill mode state
  18367. */
  18368. private _fillMode;
  18369. /**
  18370. * Specifies if the depth write state should be cached
  18371. */
  18372. private _cachedDepthWriteState;
  18373. /**
  18374. * Stores the uniform buffer
  18375. */
  18376. protected _uniformBuffer: UniformBuffer;
  18377. /** @hidden */
  18378. _indexInSceneMaterialArray: number;
  18379. /** @hidden */
  18380. meshMap: Nullable<{
  18381. [id: string]: AbstractMesh | undefined;
  18382. }>;
  18383. /**
  18384. * Creates a material instance
  18385. * @param name defines the name of the material
  18386. * @param scene defines the scene to reference
  18387. * @param doNotAdd specifies if the material should be added to the scene
  18388. */
  18389. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18390. /**
  18391. * Returns a string representation of the current material
  18392. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18393. * @returns a string with material information
  18394. */
  18395. toString(fullDetails?: boolean): string;
  18396. /**
  18397. * Gets the class name of the material
  18398. * @returns a string with the class name of the material
  18399. */
  18400. getClassName(): string;
  18401. /**
  18402. * Specifies if updates for the material been locked
  18403. */
  18404. readonly isFrozen: boolean;
  18405. /**
  18406. * Locks updates for the material
  18407. */
  18408. freeze(): void;
  18409. /**
  18410. * Unlocks updates for the material
  18411. */
  18412. unfreeze(): void;
  18413. /**
  18414. * Specifies if the material is ready to be used
  18415. * @param mesh defines the mesh to check
  18416. * @param useInstances specifies if instances should be used
  18417. * @returns a boolean indicating if the material is ready to be used
  18418. */
  18419. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18420. /**
  18421. * Specifies that the submesh is ready to be used
  18422. * @param mesh defines the mesh to check
  18423. * @param subMesh defines which submesh to check
  18424. * @param useInstances specifies that instances should be used
  18425. * @returns a boolean indicating that the submesh is ready or not
  18426. */
  18427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18428. /**
  18429. * Returns the material effect
  18430. * @returns the effect associated with the material
  18431. */
  18432. getEffect(): Nullable<Effect>;
  18433. /**
  18434. * Returns the current scene
  18435. * @returns a Scene
  18436. */
  18437. getScene(): Scene;
  18438. /**
  18439. * Specifies if the material will require alpha blending
  18440. * @returns a boolean specifying if alpha blending is needed
  18441. */
  18442. needAlphaBlending(): boolean;
  18443. /**
  18444. * Specifies if the mesh will require alpha blending
  18445. * @param mesh defines the mesh to check
  18446. * @returns a boolean specifying if alpha blending is needed for the mesh
  18447. */
  18448. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18449. /**
  18450. * Specifies if this material should be rendered in alpha test mode
  18451. * @returns a boolean specifying if an alpha test is needed.
  18452. */
  18453. needAlphaTesting(): boolean;
  18454. /**
  18455. * Gets the texture used for the alpha test
  18456. * @returns the texture to use for alpha testing
  18457. */
  18458. getAlphaTestTexture(): Nullable<BaseTexture>;
  18459. /**
  18460. * Marks the material to indicate that it needs to be re-calculated
  18461. */
  18462. markDirty(): void;
  18463. /** @hidden */
  18464. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18465. /**
  18466. * Binds the material to the mesh
  18467. * @param world defines the world transformation matrix
  18468. * @param mesh defines the mesh to bind the material to
  18469. */
  18470. bind(world: Matrix, mesh?: Mesh): void;
  18471. /**
  18472. * Binds the submesh to the material
  18473. * @param world defines the world transformation matrix
  18474. * @param mesh defines the mesh containing the submesh
  18475. * @param subMesh defines the submesh to bind the material to
  18476. */
  18477. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18478. /**
  18479. * Binds the world matrix to the material
  18480. * @param world defines the world transformation matrix
  18481. */
  18482. bindOnlyWorldMatrix(world: Matrix): void;
  18483. /**
  18484. * Binds the scene's uniform buffer to the effect.
  18485. * @param effect defines the effect to bind to the scene uniform buffer
  18486. * @param sceneUbo defines the uniform buffer storing scene data
  18487. */
  18488. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18489. /**
  18490. * Binds the view matrix to the effect
  18491. * @param effect defines the effect to bind the view matrix to
  18492. */
  18493. bindView(effect: Effect): void;
  18494. /**
  18495. * Binds the view projection matrix to the effect
  18496. * @param effect defines the effect to bind the view projection matrix to
  18497. */
  18498. bindViewProjection(effect: Effect): void;
  18499. /**
  18500. * Specifies if material alpha testing should be turned on for the mesh
  18501. * @param mesh defines the mesh to check
  18502. */
  18503. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18504. /**
  18505. * Processes to execute after binding the material to a mesh
  18506. * @param mesh defines the rendered mesh
  18507. */
  18508. protected _afterBind(mesh?: Mesh): void;
  18509. /**
  18510. * Unbinds the material from the mesh
  18511. */
  18512. unbind(): void;
  18513. /**
  18514. * Gets the active textures from the material
  18515. * @returns an array of textures
  18516. */
  18517. getActiveTextures(): BaseTexture[];
  18518. /**
  18519. * Specifies if the material uses a texture
  18520. * @param texture defines the texture to check against the material
  18521. * @returns a boolean specifying if the material uses the texture
  18522. */
  18523. hasTexture(texture: BaseTexture): boolean;
  18524. /**
  18525. * Makes a duplicate of the material, and gives it a new name
  18526. * @param name defines the new name for the duplicated material
  18527. * @returns the cloned material
  18528. */
  18529. clone(name: string): Nullable<Material>;
  18530. /**
  18531. * Gets the meshes bound to the material
  18532. * @returns an array of meshes bound to the material
  18533. */
  18534. getBindedMeshes(): AbstractMesh[];
  18535. /**
  18536. * Force shader compilation
  18537. * @param mesh defines the mesh associated with this material
  18538. * @param onCompiled defines a function to execute once the material is compiled
  18539. * @param options defines the options to configure the compilation
  18540. */
  18541. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18542. clipPlane: boolean;
  18543. }>): void;
  18544. /**
  18545. * Force shader compilation
  18546. * @param mesh defines the mesh that will use this material
  18547. * @param options defines additional options for compiling the shaders
  18548. * @returns a promise that resolves when the compilation completes
  18549. */
  18550. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18551. clipPlane: boolean;
  18552. }>): Promise<void>;
  18553. private static readonly _ImageProcessingDirtyCallBack;
  18554. private static readonly _TextureDirtyCallBack;
  18555. private static readonly _FresnelDirtyCallBack;
  18556. private static readonly _MiscDirtyCallBack;
  18557. private static readonly _LightsDirtyCallBack;
  18558. private static readonly _AttributeDirtyCallBack;
  18559. private static _FresnelAndMiscDirtyCallBack;
  18560. private static _TextureAndMiscDirtyCallBack;
  18561. private static readonly _DirtyCallbackArray;
  18562. private static readonly _RunDirtyCallBacks;
  18563. /**
  18564. * Marks a define in the material to indicate that it needs to be re-computed
  18565. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18566. */
  18567. markAsDirty(flag: number): void;
  18568. /**
  18569. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18570. * @param func defines a function which checks material defines against the submeshes
  18571. */
  18572. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18573. /**
  18574. * Indicates that image processing needs to be re-calculated for all submeshes
  18575. */
  18576. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18577. /**
  18578. * Indicates that textures need to be re-calculated for all submeshes
  18579. */
  18580. protected _markAllSubMeshesAsTexturesDirty(): void;
  18581. /**
  18582. * Indicates that fresnel needs to be re-calculated for all submeshes
  18583. */
  18584. protected _markAllSubMeshesAsFresnelDirty(): void;
  18585. /**
  18586. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18587. */
  18588. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18589. /**
  18590. * Indicates that lights need to be re-calculated for all submeshes
  18591. */
  18592. protected _markAllSubMeshesAsLightsDirty(): void;
  18593. /**
  18594. * Indicates that attributes need to be re-calculated for all submeshes
  18595. */
  18596. protected _markAllSubMeshesAsAttributesDirty(): void;
  18597. /**
  18598. * Indicates that misc needs to be re-calculated for all submeshes
  18599. */
  18600. protected _markAllSubMeshesAsMiscDirty(): void;
  18601. /**
  18602. * Indicates that textures and misc need to be re-calculated for all submeshes
  18603. */
  18604. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18605. /**
  18606. * Disposes the material
  18607. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18608. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18609. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18610. */
  18611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18612. /** @hidden */
  18613. private releaseVertexArrayObject;
  18614. /**
  18615. * Serializes this material
  18616. * @returns the serialized material object
  18617. */
  18618. serialize(): any;
  18619. /**
  18620. * Creates a MultiMaterial from parsed MultiMaterial data.
  18621. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18622. * @param scene defines the hosting scene
  18623. * @returns a new MultiMaterial
  18624. */
  18625. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18626. /**
  18627. * Creates a material from parsed material data
  18628. * @param parsedMaterial defines parsed material data
  18629. * @param scene defines the hosting scene
  18630. * @param rootUrl defines the root URL to use to load textures
  18631. * @returns a new material
  18632. */
  18633. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18634. }
  18635. }
  18636. declare module BABYLON {
  18637. /**
  18638. * "Static Class" containing the most commonly used helper while dealing with material for
  18639. * rendering purpose.
  18640. *
  18641. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18642. *
  18643. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18644. */
  18645. class MaterialHelper {
  18646. /**
  18647. * Bind the current view position to an effect.
  18648. * @param effect The effect to be bound
  18649. * @param scene The scene the eyes position is used from
  18650. */
  18651. static BindEyePosition(effect: Effect, scene: Scene): void;
  18652. /**
  18653. * Helps preparing the defines values about the UVs in used in the effect.
  18654. * UVs are shared as much as we can accross channels in the shaders.
  18655. * @param texture The texture we are preparing the UVs for
  18656. * @param defines The defines to update
  18657. * @param key The channel key "diffuse", "specular"... used in the shader
  18658. */
  18659. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18660. /**
  18661. * Binds a texture matrix value to its corrsponding uniform
  18662. * @param texture The texture to bind the matrix for
  18663. * @param uniformBuffer The uniform buffer receivin the data
  18664. * @param key The channel key "diffuse", "specular"... used in the shader
  18665. */
  18666. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18667. /**
  18668. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18669. * @param mesh defines the current mesh
  18670. * @param scene defines the current scene
  18671. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18672. * @param pointsCloud defines if point cloud rendering has to be turned on
  18673. * @param fogEnabled defines if fog has to be turned on
  18674. * @param alphaTest defines if alpha testing has to be turned on
  18675. * @param defines defines the current list of defines
  18676. */
  18677. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18678. /**
  18679. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18680. * @param scene defines the current scene
  18681. * @param engine defines the current engine
  18682. * @param defines specifies the list of active defines
  18683. * @param useInstances defines if instances have to be turned on
  18684. * @param useClipPlane defines if clip plane have to be turned on
  18685. */
  18686. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18687. /**
  18688. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18689. * @param mesh The mesh containing the geometry data we will draw
  18690. * @param defines The defines to update
  18691. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18692. * @param useBones Precise whether bones should be used or not (override mesh info)
  18693. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18694. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18695. * @returns false if defines are considered not dirty and have not been checked
  18696. */
  18697. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18698. /**
  18699. * Prepares the defines related to the light information passed in parameter
  18700. * @param scene The scene we are intending to draw
  18701. * @param mesh The mesh the effect is compiling for
  18702. * @param defines The defines to update
  18703. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18704. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18705. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18706. * @returns true if normals will be required for the rest of the effect
  18707. */
  18708. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18709. /**
  18710. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18711. * that won t be acctive due to defines being turned off.
  18712. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18713. * @param samplersList The samplers list
  18714. * @param defines The defines helping in the list generation
  18715. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18716. */
  18717. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18718. /**
  18719. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18720. * @param defines The defines to update while falling back
  18721. * @param fallbacks The authorized effect fallbacks
  18722. * @param maxSimultaneousLights The maximum number of lights allowed
  18723. * @param rank the current rank of the Effect
  18724. * @returns The newly affected rank
  18725. */
  18726. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18727. /**
  18728. * Prepares the list of attributes required for morph targets according to the effect defines.
  18729. * @param attribs The current list of supported attribs
  18730. * @param mesh The mesh to prepare the morph targets attributes for
  18731. * @param defines The current Defines of the effect
  18732. */
  18733. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18734. /**
  18735. * Prepares the list of attributes required for bones according to the effect defines.
  18736. * @param attribs The current list of supported attribs
  18737. * @param mesh The mesh to prepare the bones attributes for
  18738. * @param defines The current Defines of the effect
  18739. * @param fallbacks The current efffect fallback strategy
  18740. */
  18741. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18742. /**
  18743. * Prepares the list of attributes required for instances according to the effect defines.
  18744. * @param attribs The current list of supported attribs
  18745. * @param defines The current Defines of the effect
  18746. */
  18747. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18748. /**
  18749. * Binds the light shadow information to the effect for the given mesh.
  18750. * @param light The light containing the generator
  18751. * @param scene The scene the lights belongs to
  18752. * @param mesh The mesh we are binding the information to render
  18753. * @param lightIndex The light index in the effect used to render the mesh
  18754. * @param effect The effect we are binding the data to
  18755. */
  18756. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18757. /**
  18758. * Binds the light information to the effect.
  18759. * @param light The light containing the generator
  18760. * @param effect The effect we are binding the data to
  18761. * @param lightIndex The light index in the effect used to render
  18762. */
  18763. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18764. /**
  18765. * Binds the lights information from the scene to the effect for the given mesh.
  18766. * @param scene The scene the lights belongs to
  18767. * @param mesh The mesh we are binding the information to render
  18768. * @param effect The effect we are binding the data to
  18769. * @param defines The generated defines for the effect
  18770. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18771. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18772. */
  18773. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18774. private static _tempFogColor;
  18775. /**
  18776. * Binds the fog information from the scene to the effect for the given mesh.
  18777. * @param scene The scene the lights belongs to
  18778. * @param mesh The mesh we are binding the information to render
  18779. * @param effect The effect we are binding the data to
  18780. * @param linearSpace Defines if the fog effect is applied in linear space
  18781. */
  18782. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18783. /**
  18784. * Binds the bones information from the mesh to the effect.
  18785. * @param mesh The mesh we are binding the information to render
  18786. * @param effect The effect we are binding the data to
  18787. */
  18788. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18789. /**
  18790. * Binds the morph targets information from the mesh to the effect.
  18791. * @param abstractMesh The mesh we are binding the information to render
  18792. * @param effect The effect we are binding the data to
  18793. */
  18794. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18795. /**
  18796. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18797. * @param defines The generated defines used in the effect
  18798. * @param effect The effect we are binding the data to
  18799. * @param scene The scene we are willing to render with logarithmic scale for
  18800. */
  18801. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18802. /**
  18803. * Binds the clip plane information from the scene to the effect.
  18804. * @param scene The scene the clip plane information are extracted from
  18805. * @param effect The effect we are binding the data to
  18806. */
  18807. static BindClipPlane(effect: Effect, scene: Scene): void;
  18808. }
  18809. }
  18810. declare module BABYLON {
  18811. /**
  18812. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18813. * separate meshes. This can be use to improve performances.
  18814. * @see http://doc.babylonjs.com/how_to/multi_materials
  18815. */
  18816. class MultiMaterial extends Material {
  18817. private _subMaterials;
  18818. /**
  18819. * Gets or Sets the list of Materials used within the multi material.
  18820. * They need to be ordered according to the submeshes order in the associated mesh
  18821. */
  18822. subMaterials: Nullable<Material>[];
  18823. /**
  18824. * Function used to align with Node.getChildren()
  18825. * @returns the list of Materials used within the multi material
  18826. */
  18827. getChildren(): Nullable<Material>[];
  18828. /**
  18829. * Instantiates a new Multi Material
  18830. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18831. * separate meshes. This can be use to improve performances.
  18832. * @see http://doc.babylonjs.com/how_to/multi_materials
  18833. * @param name Define the name in the scene
  18834. * @param scene Define the scene the material belongs to
  18835. */
  18836. constructor(name: string, scene: Scene);
  18837. private _hookArray;
  18838. /**
  18839. * Get one of the submaterial by its index in the submaterials array
  18840. * @param index The index to look the sub material at
  18841. * @returns The Material if the index has been defined
  18842. */
  18843. getSubMaterial(index: number): Nullable<Material>;
  18844. /**
  18845. * Get the list of active textures for the whole sub materials list.
  18846. * @returns All the textures that will be used during the rendering
  18847. */
  18848. getActiveTextures(): BaseTexture[];
  18849. /**
  18850. * Gets the current class name of the material e.g. "MultiMaterial"
  18851. * Mainly use in serialization.
  18852. * @returns the class name
  18853. */
  18854. getClassName(): string;
  18855. /**
  18856. * Checks if the material is ready to render the requested sub mesh
  18857. * @param mesh Define the mesh the submesh belongs to
  18858. * @param subMesh Define the sub mesh to look readyness for
  18859. * @param useInstances Define whether or not the material is used with instances
  18860. * @returns true if ready, otherwise false
  18861. */
  18862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18863. /**
  18864. * Clones the current material and its related sub materials
  18865. * @param name Define the name of the newly cloned material
  18866. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18867. * @returns the cloned material
  18868. */
  18869. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18870. /**
  18871. * Serializes the materials into a JSON representation.
  18872. * @returns the JSON representation
  18873. */
  18874. serialize(): any;
  18875. /**
  18876. * Dispose the material and release its associated resources
  18877. * @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)
  18878. * @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)
  18879. */
  18880. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18881. }
  18882. }
  18883. declare module BABYLON {
  18884. /**
  18885. * Base class of materials working in push mode in babylon JS
  18886. * @hidden
  18887. */
  18888. class PushMaterial extends Material {
  18889. protected _activeEffect: Effect;
  18890. protected _normalMatrix: Matrix;
  18891. /**
  18892. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18893. * This means that the material can keep using a previous shader while a new one is being compiled.
  18894. * This is mostly used when shader parallel compilation is supported (true by default)
  18895. */
  18896. allowShaderHotSwapping: boolean;
  18897. constructor(name: string, scene: Scene);
  18898. getEffect(): Effect;
  18899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18900. /**
  18901. * Binds the given world matrix to the active effect
  18902. *
  18903. * @param world the matrix to bind
  18904. */
  18905. bindOnlyWorldMatrix(world: Matrix): void;
  18906. /**
  18907. * Binds the given normal matrix to the active effect
  18908. *
  18909. * @param normalMatrix the matrix to bind
  18910. */
  18911. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18912. bind(world: Matrix, mesh?: Mesh): void;
  18913. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18914. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18915. }
  18916. }
  18917. declare module BABYLON {
  18918. /**
  18919. * Defines the options associated with the creation of a shader material.
  18920. */
  18921. interface IShaderMaterialOptions {
  18922. /**
  18923. * Does the material work in alpha blend mode
  18924. */
  18925. needAlphaBlending: boolean;
  18926. /**
  18927. * Does the material work in alpha test mode
  18928. */
  18929. needAlphaTesting: boolean;
  18930. /**
  18931. * The list of attribute names used in the shader
  18932. */
  18933. attributes: string[];
  18934. /**
  18935. * The list of unifrom names used in the shader
  18936. */
  18937. uniforms: string[];
  18938. /**
  18939. * The list of UBO names used in the shader
  18940. */
  18941. uniformBuffers: string[];
  18942. /**
  18943. * The list of sampler names used in the shader
  18944. */
  18945. samplers: string[];
  18946. /**
  18947. * The list of defines used in the shader
  18948. */
  18949. defines: string[];
  18950. }
  18951. /**
  18952. * 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.
  18953. *
  18954. * This returned material effects how the mesh will look based on the code in the shaders.
  18955. *
  18956. * @see http://doc.babylonjs.com/how_to/shader_material
  18957. */
  18958. class ShaderMaterial extends Material {
  18959. private _shaderPath;
  18960. private _options;
  18961. private _textures;
  18962. private _textureArrays;
  18963. private _floats;
  18964. private _ints;
  18965. private _floatsArrays;
  18966. private _colors3;
  18967. private _colors3Arrays;
  18968. private _colors4;
  18969. private _vectors2;
  18970. private _vectors3;
  18971. private _vectors4;
  18972. private _matrices;
  18973. private _matrices3x3;
  18974. private _matrices2x2;
  18975. private _vectors2Arrays;
  18976. private _vectors3Arrays;
  18977. private _cachedWorldViewMatrix;
  18978. private _renderId;
  18979. /**
  18980. * Instantiate a new shader material.
  18981. * 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.
  18982. * This returned material effects how the mesh will look based on the code in the shaders.
  18983. * @see http://doc.babylonjs.com/how_to/shader_material
  18984. * @param name Define the name of the material in the scene
  18985. * @param scene Define the scene the material belongs to
  18986. * @param shaderPath Defines the route to the shader code in one of three ways:
  18987. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18988. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18989. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18990. * @param options Define the options used to create the shader
  18991. */
  18992. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18993. /**
  18994. * Gets the current class name of the material e.g. "ShaderMaterial"
  18995. * Mainly use in serialization.
  18996. * @returns the class name
  18997. */
  18998. getClassName(): string;
  18999. /**
  19000. * Specifies if the material will require alpha blending
  19001. * @returns a boolean specifying if alpha blending is needed
  19002. */
  19003. needAlphaBlending(): boolean;
  19004. /**
  19005. * Specifies if this material should be rendered in alpha test mode
  19006. * @returns a boolean specifying if an alpha test is needed.
  19007. */
  19008. needAlphaTesting(): boolean;
  19009. private _checkUniform;
  19010. /**
  19011. * Set a texture in the shader.
  19012. * @param name Define the name of the uniform samplers as defined in the shader
  19013. * @param texture Define the texture to bind to this sampler
  19014. * @return the material itself allowing "fluent" like uniform updates
  19015. */
  19016. setTexture(name: string, texture: Texture): ShaderMaterial;
  19017. /**
  19018. * Set a texture array in the shader.
  19019. * @param name Define the name of the uniform sampler array as defined in the shader
  19020. * @param textures Define the list of textures to bind to this sampler
  19021. * @return the material itself allowing "fluent" like uniform updates
  19022. */
  19023. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19024. /**
  19025. * Set a float in the shader.
  19026. * @param name Define the name of the uniform as defined in the shader
  19027. * @param value Define the value to give to the uniform
  19028. * @return the material itself allowing "fluent" like uniform updates
  19029. */
  19030. setFloat(name: string, value: number): ShaderMaterial;
  19031. /**
  19032. * Set a int in the shader.
  19033. * @param name Define the name of the uniform as defined in the shader
  19034. * @param value Define the value to give to the uniform
  19035. * @return the material itself allowing "fluent" like uniform updates
  19036. */
  19037. setInt(name: string, value: number): ShaderMaterial;
  19038. /**
  19039. * Set an array of floats in the shader.
  19040. * @param name Define the name of the uniform as defined in the shader
  19041. * @param value Define the value to give to the uniform
  19042. * @return the material itself allowing "fluent" like uniform updates
  19043. */
  19044. setFloats(name: string, value: number[]): ShaderMaterial;
  19045. /**
  19046. * Set a vec3 in the shader from a Color3.
  19047. * @param name Define the name of the uniform as defined in the shader
  19048. * @param value Define the value to give to the uniform
  19049. * @return the material itself allowing "fluent" like uniform updates
  19050. */
  19051. setColor3(name: string, value: Color3): ShaderMaterial;
  19052. /**
  19053. * Set a vec3 array in the shader from a Color3 array.
  19054. * @param name Define the name of the uniform as defined in the shader
  19055. * @param value Define the value to give to the uniform
  19056. * @return the material itself allowing "fluent" like uniform updates
  19057. */
  19058. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19059. /**
  19060. * Set a vec4 in the shader from a Color4.
  19061. * @param name Define the name of the uniform as defined in the shader
  19062. * @param value Define the value to give to the uniform
  19063. * @return the material itself allowing "fluent" like uniform updates
  19064. */
  19065. setColor4(name: string, value: Color4): ShaderMaterial;
  19066. /**
  19067. * Set a vec2 in the shader from a Vector2.
  19068. * @param name Define the name of the uniform as defined in the shader
  19069. * @param value Define the value to give to the uniform
  19070. * @return the material itself allowing "fluent" like uniform updates
  19071. */
  19072. setVector2(name: string, value: Vector2): ShaderMaterial;
  19073. /**
  19074. * Set a vec3 in the shader from a Vector3.
  19075. * @param name Define the name of the uniform as defined in the shader
  19076. * @param value Define the value to give to the uniform
  19077. * @return the material itself allowing "fluent" like uniform updates
  19078. */
  19079. setVector3(name: string, value: Vector3): ShaderMaterial;
  19080. /**
  19081. * Set a vec4 in the shader from a Vector4.
  19082. * @param name Define the name of the uniform as defined in the shader
  19083. * @param value Define the value to give to the uniform
  19084. * @return the material itself allowing "fluent" like uniform updates
  19085. */
  19086. setVector4(name: string, value: Vector4): ShaderMaterial;
  19087. /**
  19088. * Set a mat4 in the shader from a Matrix.
  19089. * @param name Define the name of the uniform as defined in the shader
  19090. * @param value Define the value to give to the uniform
  19091. * @return the material itself allowing "fluent" like uniform updates
  19092. */
  19093. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19094. /**
  19095. * Set a mat3 in the shader from a Float32Array.
  19096. * @param name Define the name of the uniform as defined in the shader
  19097. * @param value Define the value to give to the uniform
  19098. * @return the material itself allowing "fluent" like uniform updates
  19099. */
  19100. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19101. /**
  19102. * Set a mat2 in the shader from a Float32Array.
  19103. * @param name Define the name of the uniform as defined in the shader
  19104. * @param value Define the value to give to the uniform
  19105. * @return the material itself allowing "fluent" like uniform updates
  19106. */
  19107. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19108. /**
  19109. * Set a vec2 array in the shader from a number array.
  19110. * @param name Define the name of the uniform as defined in the shader
  19111. * @param value Define the value to give to the uniform
  19112. * @return the material itself allowing "fluent" like uniform updates
  19113. */
  19114. setArray2(name: string, value: number[]): ShaderMaterial;
  19115. /**
  19116. * Set a vec3 array in the shader from a number array.
  19117. * @param name Define the name of the uniform as defined in the shader
  19118. * @param value Define the value to give to the uniform
  19119. * @return the material itself allowing "fluent" like uniform updates
  19120. */
  19121. setArray3(name: string, value: number[]): ShaderMaterial;
  19122. private _checkCache;
  19123. /**
  19124. * Checks if the material is ready to render the requested mesh
  19125. * @param mesh Define the mesh to render
  19126. * @param useInstances Define whether or not the material is used with instances
  19127. * @returns true if ready, otherwise false
  19128. */
  19129. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19130. /**
  19131. * Binds the world matrix to the material
  19132. * @param world defines the world transformation matrix
  19133. */
  19134. bindOnlyWorldMatrix(world: Matrix): void;
  19135. /**
  19136. * Binds the material to the mesh
  19137. * @param world defines the world transformation matrix
  19138. * @param mesh defines the mesh to bind the material to
  19139. */
  19140. bind(world: Matrix, mesh?: Mesh): void;
  19141. /**
  19142. * Gets the active textures from the material
  19143. * @returns an array of textures
  19144. */
  19145. getActiveTextures(): BaseTexture[];
  19146. /**
  19147. * Specifies if the material uses a texture
  19148. * @param texture defines the texture to check against the material
  19149. * @returns a boolean specifying if the material uses the texture
  19150. */
  19151. hasTexture(texture: BaseTexture): boolean;
  19152. /**
  19153. * Makes a duplicate of the material, and gives it a new name
  19154. * @param name defines the new name for the duplicated material
  19155. * @returns the cloned material
  19156. */
  19157. clone(name: string): ShaderMaterial;
  19158. /**
  19159. * Disposes the material
  19160. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19161. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19162. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19163. */
  19164. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19165. /**
  19166. * Serializes this material in a JSON representation
  19167. * @returns the serialized material object
  19168. */
  19169. serialize(): any;
  19170. /**
  19171. * Creates a shader material from parsed shader material data
  19172. * @param source defines the JSON represnetation of the material
  19173. * @param scene defines the hosting scene
  19174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19175. * @returns a new material
  19176. */
  19177. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19178. }
  19179. }
  19180. declare module BABYLON {
  19181. /** @hidden */
  19182. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19183. MAINUV1: boolean;
  19184. MAINUV2: boolean;
  19185. DIFFUSE: boolean;
  19186. DIFFUSEDIRECTUV: number;
  19187. AMBIENT: boolean;
  19188. AMBIENTDIRECTUV: number;
  19189. OPACITY: boolean;
  19190. OPACITYDIRECTUV: number;
  19191. OPACITYRGB: boolean;
  19192. REFLECTION: boolean;
  19193. EMISSIVE: boolean;
  19194. EMISSIVEDIRECTUV: number;
  19195. SPECULAR: boolean;
  19196. SPECULARDIRECTUV: number;
  19197. BUMP: boolean;
  19198. BUMPDIRECTUV: number;
  19199. PARALLAX: boolean;
  19200. PARALLAXOCCLUSION: boolean;
  19201. SPECULAROVERALPHA: boolean;
  19202. CLIPPLANE: boolean;
  19203. CLIPPLANE2: boolean;
  19204. CLIPPLANE3: boolean;
  19205. CLIPPLANE4: boolean;
  19206. ALPHATEST: boolean;
  19207. DEPTHPREPASS: boolean;
  19208. ALPHAFROMDIFFUSE: boolean;
  19209. POINTSIZE: boolean;
  19210. FOG: boolean;
  19211. SPECULARTERM: boolean;
  19212. DIFFUSEFRESNEL: boolean;
  19213. OPACITYFRESNEL: boolean;
  19214. REFLECTIONFRESNEL: boolean;
  19215. REFRACTIONFRESNEL: boolean;
  19216. EMISSIVEFRESNEL: boolean;
  19217. FRESNEL: boolean;
  19218. NORMAL: boolean;
  19219. UV1: boolean;
  19220. UV2: boolean;
  19221. VERTEXCOLOR: boolean;
  19222. VERTEXALPHA: boolean;
  19223. NUM_BONE_INFLUENCERS: number;
  19224. BonesPerMesh: number;
  19225. BONETEXTURE: boolean;
  19226. INSTANCES: boolean;
  19227. GLOSSINESS: boolean;
  19228. ROUGHNESS: boolean;
  19229. EMISSIVEASILLUMINATION: boolean;
  19230. LINKEMISSIVEWITHDIFFUSE: boolean;
  19231. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19232. LIGHTMAP: boolean;
  19233. LIGHTMAPDIRECTUV: number;
  19234. OBJECTSPACE_NORMALMAP: boolean;
  19235. USELIGHTMAPASSHADOWMAP: boolean;
  19236. REFLECTIONMAP_3D: boolean;
  19237. REFLECTIONMAP_SPHERICAL: boolean;
  19238. REFLECTIONMAP_PLANAR: boolean;
  19239. REFLECTIONMAP_CUBIC: boolean;
  19240. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19241. REFLECTIONMAP_PROJECTION: boolean;
  19242. REFLECTIONMAP_SKYBOX: boolean;
  19243. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19244. REFLECTIONMAP_EXPLICIT: boolean;
  19245. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19246. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19247. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19248. INVERTCUBICMAP: boolean;
  19249. LOGARITHMICDEPTH: boolean;
  19250. REFRACTION: boolean;
  19251. REFRACTIONMAP_3D: boolean;
  19252. REFLECTIONOVERALPHA: boolean;
  19253. TWOSIDEDLIGHTING: boolean;
  19254. SHADOWFLOAT: boolean;
  19255. MORPHTARGETS: boolean;
  19256. MORPHTARGETS_NORMAL: boolean;
  19257. MORPHTARGETS_TANGENT: boolean;
  19258. NUM_MORPH_INFLUENCERS: number;
  19259. NONUNIFORMSCALING: boolean;
  19260. PREMULTIPLYALPHA: boolean;
  19261. IMAGEPROCESSING: boolean;
  19262. VIGNETTE: boolean;
  19263. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19264. VIGNETTEBLENDMODEOPAQUE: boolean;
  19265. TONEMAPPING: boolean;
  19266. TONEMAPPING_ACES: boolean;
  19267. CONTRAST: boolean;
  19268. COLORCURVES: boolean;
  19269. COLORGRADING: boolean;
  19270. COLORGRADING3D: boolean;
  19271. SAMPLER3DGREENDEPTH: boolean;
  19272. SAMPLER3DBGRMAP: boolean;
  19273. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19274. /**
  19275. * If the reflection texture on this material is in linear color space
  19276. * @hidden
  19277. */
  19278. IS_REFLECTION_LINEAR: boolean;
  19279. /**
  19280. * If the refraction texture on this material is in linear color space
  19281. * @hidden
  19282. */
  19283. IS_REFRACTION_LINEAR: boolean;
  19284. EXPOSURE: boolean;
  19285. constructor();
  19286. setReflectionMode(modeToEnable: string): void;
  19287. }
  19288. /**
  19289. * This is the default material used in Babylon. It is the best trade off between quality
  19290. * and performances.
  19291. * @see http://doc.babylonjs.com/babylon101/materials
  19292. */
  19293. class StandardMaterial extends PushMaterial {
  19294. private _diffuseTexture;
  19295. /**
  19296. * The basic texture of the material as viewed under a light.
  19297. */
  19298. diffuseTexture: Nullable<BaseTexture>;
  19299. private _ambientTexture;
  19300. /**
  19301. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19302. */
  19303. ambientTexture: Nullable<BaseTexture>;
  19304. private _opacityTexture;
  19305. /**
  19306. * Define the transparency of the material from a texture.
  19307. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19308. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19309. */
  19310. opacityTexture: Nullable<BaseTexture>;
  19311. private _reflectionTexture;
  19312. /**
  19313. * Define the texture used to display the reflection.
  19314. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19315. */
  19316. reflectionTexture: Nullable<BaseTexture>;
  19317. private _emissiveTexture;
  19318. /**
  19319. * Define texture of the material as if self lit.
  19320. * This will be mixed in the final result even in the absence of light.
  19321. */
  19322. emissiveTexture: Nullable<BaseTexture>;
  19323. private _specularTexture;
  19324. /**
  19325. * Define how the color and intensity of the highlight given by the light in the material.
  19326. */
  19327. specularTexture: Nullable<BaseTexture>;
  19328. private _bumpTexture;
  19329. /**
  19330. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19331. * 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.
  19332. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19333. */
  19334. bumpTexture: Nullable<BaseTexture>;
  19335. private _lightmapTexture;
  19336. /**
  19337. * Complex lighting can be computationally expensive to compute at runtime.
  19338. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19339. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19340. */
  19341. lightmapTexture: Nullable<BaseTexture>;
  19342. private _refractionTexture;
  19343. /**
  19344. * Define the texture used to display the refraction.
  19345. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19346. */
  19347. refractionTexture: Nullable<BaseTexture>;
  19348. /**
  19349. * The color of the material lit by the environmental background lighting.
  19350. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19351. */
  19352. ambientColor: Color3;
  19353. /**
  19354. * The basic color of the material as viewed under a light.
  19355. */
  19356. diffuseColor: Color3;
  19357. /**
  19358. * Define how the color and intensity of the highlight given by the light in the material.
  19359. */
  19360. specularColor: Color3;
  19361. /**
  19362. * Define the color of the material as if self lit.
  19363. * This will be mixed in the final result even in the absence of light.
  19364. */
  19365. emissiveColor: Color3;
  19366. /**
  19367. * Defines how sharp are the highlights in the material.
  19368. * The bigger the value the sharper giving a more glossy feeling to the result.
  19369. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19370. */
  19371. specularPower: number;
  19372. private _useAlphaFromDiffuseTexture;
  19373. /**
  19374. * Does the transparency come from the diffuse texture alpha channel.
  19375. */
  19376. useAlphaFromDiffuseTexture: boolean;
  19377. private _useEmissiveAsIllumination;
  19378. /**
  19379. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19380. */
  19381. useEmissiveAsIllumination: boolean;
  19382. private _linkEmissiveWithDiffuse;
  19383. /**
  19384. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19385. * the emissive level when the final color is close to one.
  19386. */
  19387. linkEmissiveWithDiffuse: boolean;
  19388. private _useSpecularOverAlpha;
  19389. /**
  19390. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19391. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19392. */
  19393. useSpecularOverAlpha: boolean;
  19394. private _useReflectionOverAlpha;
  19395. /**
  19396. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19397. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19398. */
  19399. useReflectionOverAlpha: boolean;
  19400. private _disableLighting;
  19401. /**
  19402. * Does lights from the scene impacts this material.
  19403. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19404. */
  19405. disableLighting: boolean;
  19406. private _useObjectSpaceNormalMap;
  19407. /**
  19408. * Allows using an object space normal map (instead of tangent space).
  19409. */
  19410. useObjectSpaceNormalMap: boolean;
  19411. private _useParallax;
  19412. /**
  19413. * Is parallax enabled or not.
  19414. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19415. */
  19416. useParallax: boolean;
  19417. private _useParallaxOcclusion;
  19418. /**
  19419. * Is parallax occlusion enabled or not.
  19420. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19421. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19422. */
  19423. useParallaxOcclusion: boolean;
  19424. /**
  19425. * 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.
  19426. */
  19427. parallaxScaleBias: number;
  19428. private _roughness;
  19429. /**
  19430. * Helps to define how blurry the reflections should appears in the material.
  19431. */
  19432. roughness: number;
  19433. /**
  19434. * In case of refraction, define the value of the indice of refraction.
  19435. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19436. */
  19437. indexOfRefraction: number;
  19438. /**
  19439. * Invert the refraction texture alongside the y axis.
  19440. * It can be useful with procedural textures or probe for instance.
  19441. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19442. */
  19443. invertRefractionY: boolean;
  19444. /**
  19445. * Defines the alpha limits in alpha test mode.
  19446. */
  19447. alphaCutOff: number;
  19448. private _useLightmapAsShadowmap;
  19449. /**
  19450. * In case of light mapping, define whether the map contains light or shadow informations.
  19451. */
  19452. useLightmapAsShadowmap: boolean;
  19453. private _diffuseFresnelParameters;
  19454. /**
  19455. * Define the diffuse fresnel parameters of the material.
  19456. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19457. */
  19458. diffuseFresnelParameters: FresnelParameters;
  19459. private _opacityFresnelParameters;
  19460. /**
  19461. * Define the opacity fresnel parameters of the material.
  19462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19463. */
  19464. opacityFresnelParameters: FresnelParameters;
  19465. private _reflectionFresnelParameters;
  19466. /**
  19467. * Define the reflection fresnel parameters of the material.
  19468. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19469. */
  19470. reflectionFresnelParameters: FresnelParameters;
  19471. private _refractionFresnelParameters;
  19472. /**
  19473. * Define the refraction fresnel parameters of the material.
  19474. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19475. */
  19476. refractionFresnelParameters: FresnelParameters;
  19477. private _emissiveFresnelParameters;
  19478. /**
  19479. * Define the emissive fresnel parameters of the material.
  19480. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19481. */
  19482. emissiveFresnelParameters: FresnelParameters;
  19483. private _useReflectionFresnelFromSpecular;
  19484. /**
  19485. * If true automatically deducts the fresnels values from the material specularity.
  19486. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19487. */
  19488. useReflectionFresnelFromSpecular: boolean;
  19489. private _useGlossinessFromSpecularMapAlpha;
  19490. /**
  19491. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19492. */
  19493. useGlossinessFromSpecularMapAlpha: boolean;
  19494. private _maxSimultaneousLights;
  19495. /**
  19496. * Defines the maximum number of lights that can be used in the material
  19497. */
  19498. maxSimultaneousLights: number;
  19499. private _invertNormalMapX;
  19500. /**
  19501. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19502. */
  19503. invertNormalMapX: boolean;
  19504. private _invertNormalMapY;
  19505. /**
  19506. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19507. */
  19508. invertNormalMapY: boolean;
  19509. private _twoSidedLighting;
  19510. /**
  19511. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19512. */
  19513. twoSidedLighting: boolean;
  19514. /**
  19515. * Default configuration related to image processing available in the standard Material.
  19516. */
  19517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19518. /**
  19519. * Gets the image processing configuration used either in this material.
  19520. */
  19521. /**
  19522. * Sets the Default image processing configuration used either in the this material.
  19523. *
  19524. * If sets to null, the scene one is in use.
  19525. */
  19526. imageProcessingConfiguration: ImageProcessingConfiguration;
  19527. /**
  19528. * Keep track of the image processing observer to allow dispose and replace.
  19529. */
  19530. private _imageProcessingObserver;
  19531. /**
  19532. * Attaches a new image processing configuration to the Standard Material.
  19533. * @param configuration
  19534. */
  19535. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19536. /**
  19537. * Gets wether the color curves effect is enabled.
  19538. */
  19539. /**
  19540. * Sets wether the color curves effect is enabled.
  19541. */
  19542. cameraColorCurvesEnabled: boolean;
  19543. /**
  19544. * Gets wether the color grading effect is enabled.
  19545. */
  19546. /**
  19547. * Gets wether the color grading effect is enabled.
  19548. */
  19549. cameraColorGradingEnabled: boolean;
  19550. /**
  19551. * Gets wether tonemapping is enabled or not.
  19552. */
  19553. /**
  19554. * Sets wether tonemapping is enabled or not
  19555. */
  19556. cameraToneMappingEnabled: boolean;
  19557. /**
  19558. * The camera exposure used on this material.
  19559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19560. * This corresponds to a photographic exposure.
  19561. */
  19562. /**
  19563. * The camera exposure used on this material.
  19564. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19565. * This corresponds to a photographic exposure.
  19566. */
  19567. cameraExposure: number;
  19568. /**
  19569. * Gets The camera contrast used on this material.
  19570. */
  19571. /**
  19572. * Sets The camera contrast used on this material.
  19573. */
  19574. cameraContrast: number;
  19575. /**
  19576. * Gets the Color Grading 2D Lookup Texture.
  19577. */
  19578. /**
  19579. * Sets the Color Grading 2D Lookup Texture.
  19580. */
  19581. cameraColorGradingTexture: Nullable<BaseTexture>;
  19582. /**
  19583. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19584. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19585. * 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;
  19586. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19587. */
  19588. /**
  19589. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19590. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19591. * 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;
  19592. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19593. */
  19594. cameraColorCurves: Nullable<ColorCurves>;
  19595. /**
  19596. * Custom callback helping to override the default shader used in the material.
  19597. */
  19598. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19599. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19600. protected _worldViewProjectionMatrix: Matrix;
  19601. protected _globalAmbientColor: Color3;
  19602. protected _useLogarithmicDepth: boolean;
  19603. /**
  19604. * Instantiates a new standard material.
  19605. * This is the default material used in Babylon. It is the best trade off between quality
  19606. * and performances.
  19607. * @see http://doc.babylonjs.com/babylon101/materials
  19608. * @param name Define the name of the material in the scene
  19609. * @param scene Define the scene the material belong to
  19610. */
  19611. constructor(name: string, scene: Scene);
  19612. /**
  19613. * Gets a boolean indicating that current material needs to register RTT
  19614. */
  19615. readonly hasRenderTargetTextures: boolean;
  19616. /**
  19617. * Gets the current class name of the material e.g. "StandardMaterial"
  19618. * Mainly use in serialization.
  19619. * @returns the class name
  19620. */
  19621. getClassName(): string;
  19622. /**
  19623. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19624. * You can try switching to logarithmic depth.
  19625. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19626. */
  19627. useLogarithmicDepth: boolean;
  19628. /**
  19629. * Specifies if the material will require alpha blending
  19630. * @returns a boolean specifying if alpha blending is needed
  19631. */
  19632. needAlphaBlending(): boolean;
  19633. /**
  19634. * Specifies if this material should be rendered in alpha test mode
  19635. * @returns a boolean specifying if an alpha test is needed.
  19636. */
  19637. needAlphaTesting(): boolean;
  19638. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19639. /**
  19640. * Get the texture used for alpha test purpose.
  19641. * @returns the diffuse texture in case of the standard material.
  19642. */
  19643. getAlphaTestTexture(): Nullable<BaseTexture>;
  19644. /**
  19645. * Get if the submesh is ready to be used and all its information available.
  19646. * Child classes can use it to update shaders
  19647. * @param mesh defines the mesh to check
  19648. * @param subMesh defines which submesh to check
  19649. * @param useInstances specifies that instances should be used
  19650. * @returns a boolean indicating that the submesh is ready or not
  19651. */
  19652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19653. /**
  19654. * Builds the material UBO layouts.
  19655. * Used internally during the effect preparation.
  19656. */
  19657. buildUniformLayout(): void;
  19658. /**
  19659. * Unbinds the material from the mesh
  19660. */
  19661. unbind(): void;
  19662. /**
  19663. * Binds the submesh to this material by preparing the effect and shader to draw
  19664. * @param world defines the world transformation matrix
  19665. * @param mesh defines the mesh containing the submesh
  19666. * @param subMesh defines the submesh to bind the material to
  19667. */
  19668. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19669. /**
  19670. * Get the list of animatables in the material.
  19671. * @returns the list of animatables object used in the material
  19672. */
  19673. getAnimatables(): IAnimatable[];
  19674. /**
  19675. * Gets the active textures from the material
  19676. * @returns an array of textures
  19677. */
  19678. getActiveTextures(): BaseTexture[];
  19679. /**
  19680. * Specifies if the material uses a texture
  19681. * @param texture defines the texture to check against the material
  19682. * @returns a boolean specifying if the material uses the texture
  19683. */
  19684. hasTexture(texture: BaseTexture): boolean;
  19685. /**
  19686. * Disposes the material
  19687. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19688. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19689. */
  19690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19691. /**
  19692. * Makes a duplicate of the material, and gives it a new name
  19693. * @param name defines the new name for the duplicated material
  19694. * @returns the cloned material
  19695. */
  19696. clone(name: string): StandardMaterial;
  19697. /**
  19698. * Serializes this material in a JSON representation
  19699. * @returns the serialized material object
  19700. */
  19701. serialize(): any;
  19702. /**
  19703. * Creates a standard material from parsed material data
  19704. * @param source defines the JSON represnetation of the material
  19705. * @param scene defines the hosting scene
  19706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19707. * @returns a new material
  19708. */
  19709. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19710. private static _DiffuseTextureEnabled;
  19711. /**
  19712. * Are diffuse textures enabled in the application.
  19713. */
  19714. static DiffuseTextureEnabled: boolean;
  19715. private static _AmbientTextureEnabled;
  19716. /**
  19717. * Are ambient textures enabled in the application.
  19718. */
  19719. static AmbientTextureEnabled: boolean;
  19720. private static _OpacityTextureEnabled;
  19721. /**
  19722. * Are opacity textures enabled in the application.
  19723. */
  19724. static OpacityTextureEnabled: boolean;
  19725. private static _ReflectionTextureEnabled;
  19726. /**
  19727. * Are reflection textures enabled in the application.
  19728. */
  19729. static ReflectionTextureEnabled: boolean;
  19730. private static _EmissiveTextureEnabled;
  19731. /**
  19732. * Are emissive textures enabled in the application.
  19733. */
  19734. static EmissiveTextureEnabled: boolean;
  19735. private static _SpecularTextureEnabled;
  19736. /**
  19737. * Are specular textures enabled in the application.
  19738. */
  19739. static SpecularTextureEnabled: boolean;
  19740. private static _BumpTextureEnabled;
  19741. /**
  19742. * Are bump textures enabled in the application.
  19743. */
  19744. static BumpTextureEnabled: boolean;
  19745. private static _LightmapTextureEnabled;
  19746. /**
  19747. * Are lightmap textures enabled in the application.
  19748. */
  19749. static LightmapTextureEnabled: boolean;
  19750. private static _RefractionTextureEnabled;
  19751. /**
  19752. * Are refraction textures enabled in the application.
  19753. */
  19754. static RefractionTextureEnabled: boolean;
  19755. private static _ColorGradingTextureEnabled;
  19756. /**
  19757. * Are color grading textures enabled in the application.
  19758. */
  19759. static ColorGradingTextureEnabled: boolean;
  19760. private static _FresnelEnabled;
  19761. /**
  19762. * Are fresnels enabled in the application.
  19763. */
  19764. static FresnelEnabled: boolean;
  19765. }
  19766. }
  19767. declare module BABYLON {
  19768. /**
  19769. * Uniform buffer objects.
  19770. *
  19771. * Handles blocks of uniform on the GPU.
  19772. *
  19773. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19774. *
  19775. * For more information, please refer to :
  19776. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19777. */
  19778. class UniformBuffer {
  19779. private _engine;
  19780. private _buffer;
  19781. private _data;
  19782. private _bufferData;
  19783. private _dynamic?;
  19784. private _uniformLocations;
  19785. private _uniformSizes;
  19786. private _uniformLocationPointer;
  19787. private _needSync;
  19788. private _noUBO;
  19789. private _currentEffect;
  19790. private static _MAX_UNIFORM_SIZE;
  19791. private static _tempBuffer;
  19792. /**
  19793. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19794. * This is dynamic to allow compat with webgl 1 and 2.
  19795. * You will need to pass the name of the uniform as well as the value.
  19796. */
  19797. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19798. /**
  19799. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19800. * This is dynamic to allow compat with webgl 1 and 2.
  19801. * You will need to pass the name of the uniform as well as the value.
  19802. */
  19803. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19804. /**
  19805. * Lambda to Update a single float in a uniform buffer.
  19806. * This is dynamic to allow compat with webgl 1 and 2.
  19807. * You will need to pass the name of the uniform as well as the value.
  19808. */
  19809. updateFloat: (name: string, x: number) => void;
  19810. /**
  19811. * Lambda to Update a vec2 of float in a uniform buffer.
  19812. * This is dynamic to allow compat with webgl 1 and 2.
  19813. * You will need to pass the name of the uniform as well as the value.
  19814. */
  19815. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19816. /**
  19817. * Lambda to Update a vec3 of float in a uniform buffer.
  19818. * This is dynamic to allow compat with webgl 1 and 2.
  19819. * You will need to pass the name of the uniform as well as the value.
  19820. */
  19821. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19822. /**
  19823. * Lambda to Update a vec4 of float in a uniform buffer.
  19824. * This is dynamic to allow compat with webgl 1 and 2.
  19825. * You will need to pass the name of the uniform as well as the value.
  19826. */
  19827. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19828. /**
  19829. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19830. * This is dynamic to allow compat with webgl 1 and 2.
  19831. * You will need to pass the name of the uniform as well as the value.
  19832. */
  19833. updateMatrix: (name: string, mat: Matrix) => void;
  19834. /**
  19835. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19836. * This is dynamic to allow compat with webgl 1 and 2.
  19837. * You will need to pass the name of the uniform as well as the value.
  19838. */
  19839. updateVector3: (name: string, vector: Vector3) => void;
  19840. /**
  19841. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19842. * This is dynamic to allow compat with webgl 1 and 2.
  19843. * You will need to pass the name of the uniform as well as the value.
  19844. */
  19845. updateVector4: (name: string, vector: Vector4) => void;
  19846. /**
  19847. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19848. * This is dynamic to allow compat with webgl 1 and 2.
  19849. * You will need to pass the name of the uniform as well as the value.
  19850. */
  19851. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19852. /**
  19853. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19854. * This is dynamic to allow compat with webgl 1 and 2.
  19855. * You will need to pass the name of the uniform as well as the value.
  19856. */
  19857. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19858. /**
  19859. * Instantiates a new Uniform buffer objects.
  19860. *
  19861. * Handles blocks of uniform on the GPU.
  19862. *
  19863. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19864. *
  19865. * For more information, please refer to :
  19866. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19867. * @param engine Define the engine the buffer is associated with
  19868. * @param data Define the data contained in the buffer
  19869. * @param dynamic Define if the buffer is updatable
  19870. */
  19871. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19872. /**
  19873. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19874. * or just falling back on setUniformXXX calls.
  19875. */
  19876. readonly useUbo: boolean;
  19877. /**
  19878. * Indicates if the WebGL underlying uniform buffer is in sync
  19879. * with the javascript cache data.
  19880. */
  19881. readonly isSync: boolean;
  19882. /**
  19883. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19884. * Also, a dynamic UniformBuffer will disable cache verification and always
  19885. * update the underlying WebGL uniform buffer to the GPU.
  19886. * @returns if Dynamic, otherwise false
  19887. */
  19888. isDynamic(): boolean;
  19889. /**
  19890. * The data cache on JS side.
  19891. * @returns the underlying data as a float array
  19892. */
  19893. getData(): Float32Array;
  19894. /**
  19895. * The underlying WebGL Uniform buffer.
  19896. * @returns the webgl buffer
  19897. */
  19898. getBuffer(): Nullable<WebGLBuffer>;
  19899. /**
  19900. * std140 layout specifies how to align data within an UBO structure.
  19901. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19902. * for specs.
  19903. */
  19904. private _fillAlignment;
  19905. /**
  19906. * Adds an uniform in the buffer.
  19907. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19908. * for the layout to be correct !
  19909. * @param name Name of the uniform, as used in the uniform block in the shader.
  19910. * @param size Data size, or data directly.
  19911. */
  19912. addUniform(name: string, size: number | number[]): void;
  19913. /**
  19914. * Adds a Matrix 4x4 to the uniform buffer.
  19915. * @param name Name of the uniform, as used in the uniform block in the shader.
  19916. * @param mat A 4x4 matrix.
  19917. */
  19918. addMatrix(name: string, mat: Matrix): void;
  19919. /**
  19920. * Adds a vec2 to the uniform buffer.
  19921. * @param name Name of the uniform, as used in the uniform block in the shader.
  19922. * @param x Define the x component value of the vec2
  19923. * @param y Define the y component value of the vec2
  19924. */
  19925. addFloat2(name: string, x: number, y: number): void;
  19926. /**
  19927. * Adds a vec3 to the uniform buffer.
  19928. * @param name Name of the uniform, as used in the uniform block in the shader.
  19929. * @param x Define the x component value of the vec3
  19930. * @param y Define the y component value of the vec3
  19931. * @param z Define the z component value of the vec3
  19932. */
  19933. addFloat3(name: string, x: number, y: number, z: number): void;
  19934. /**
  19935. * Adds a vec3 to the uniform buffer.
  19936. * @param name Name of the uniform, as used in the uniform block in the shader.
  19937. * @param color Define the vec3 from a Color
  19938. */
  19939. addColor3(name: string, color: Color3): void;
  19940. /**
  19941. * Adds a vec4 to the uniform buffer.
  19942. * @param name Name of the uniform, as used in the uniform block in the shader.
  19943. * @param color Define the rgb components from a Color
  19944. * @param alpha Define the a component of the vec4
  19945. */
  19946. addColor4(name: string, color: Color3, alpha: number): void;
  19947. /**
  19948. * Adds a vec3 to the uniform buffer.
  19949. * @param name Name of the uniform, as used in the uniform block in the shader.
  19950. * @param vector Define the vec3 components from a Vector
  19951. */
  19952. addVector3(name: string, vector: Vector3): void;
  19953. /**
  19954. * Adds a Matrix 3x3 to the uniform buffer.
  19955. * @param name Name of the uniform, as used in the uniform block in the shader.
  19956. */
  19957. addMatrix3x3(name: string): void;
  19958. /**
  19959. * Adds a Matrix 2x2 to the uniform buffer.
  19960. * @param name Name of the uniform, as used in the uniform block in the shader.
  19961. */
  19962. addMatrix2x2(name: string): void;
  19963. /**
  19964. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19965. */
  19966. create(): void;
  19967. /** @hidden */
  19968. _rebuild(): void;
  19969. /**
  19970. * Updates the WebGL Uniform Buffer on the GPU.
  19971. * If the `dynamic` flag is set to true, no cache comparison is done.
  19972. * Otherwise, the buffer will be updated only if the cache differs.
  19973. */
  19974. update(): void;
  19975. /**
  19976. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19977. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19978. * @param data Define the flattened data
  19979. * @param size Define the size of the data.
  19980. */
  19981. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19982. private _updateMatrix3x3ForUniform;
  19983. private _updateMatrix3x3ForEffect;
  19984. private _updateMatrix2x2ForEffect;
  19985. private _updateMatrix2x2ForUniform;
  19986. private _updateFloatForEffect;
  19987. private _updateFloatForUniform;
  19988. private _updateFloat2ForEffect;
  19989. private _updateFloat2ForUniform;
  19990. private _updateFloat3ForEffect;
  19991. private _updateFloat3ForUniform;
  19992. private _updateFloat4ForEffect;
  19993. private _updateFloat4ForUniform;
  19994. private _updateMatrixForEffect;
  19995. private _updateMatrixForUniform;
  19996. private _updateVector3ForEffect;
  19997. private _updateVector3ForUniform;
  19998. private _updateVector4ForEffect;
  19999. private _updateVector4ForUniform;
  20000. private _updateColor3ForEffect;
  20001. private _updateColor3ForUniform;
  20002. private _updateColor4ForEffect;
  20003. private _updateColor4ForUniform;
  20004. /**
  20005. * Sets a sampler uniform on the effect.
  20006. * @param name Define the name of the sampler.
  20007. * @param texture Define the texture to set in the sampler
  20008. */
  20009. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20010. /**
  20011. * Directly updates the value of the uniform in the cache AND on the GPU.
  20012. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20013. * @param data Define the flattened data
  20014. */
  20015. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20016. /**
  20017. * Binds this uniform buffer to an effect.
  20018. * @param effect Define the effect to bind the buffer to
  20019. * @param name Name of the uniform block in the shader.
  20020. */
  20021. bindToEffect(effect: Effect, name: string): void;
  20022. /**
  20023. * Disposes the uniform buffer.
  20024. */
  20025. dispose(): void;
  20026. }
  20027. }
  20028. declare module BABYLON {
  20029. /**
  20030. * Scalar computation library
  20031. */
  20032. class Scalar {
  20033. /**
  20034. * Two pi constants convenient for computation.
  20035. */
  20036. static TwoPi: number;
  20037. /**
  20038. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20039. * @param a number
  20040. * @param b number
  20041. * @param epsilon (default = 1.401298E-45)
  20042. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20043. */
  20044. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20045. /**
  20046. * Returns a string : the upper case translation of the number i to hexadecimal.
  20047. * @param i number
  20048. * @returns the upper case translation of the number i to hexadecimal.
  20049. */
  20050. static ToHex(i: number): string;
  20051. /**
  20052. * Returns -1 if value is negative and +1 is value is positive.
  20053. * @param value the value
  20054. * @returns the value itself if it's equal to zero.
  20055. */
  20056. static Sign(value: number): number;
  20057. /**
  20058. * Returns the value itself if it's between min and max.
  20059. * Returns min if the value is lower than min.
  20060. * Returns max if the value is greater than max.
  20061. * @param value the value to clmap
  20062. * @param min the min value to clamp to (default: 0)
  20063. * @param max the max value to clamp to (default: 1)
  20064. * @returns the clamped value
  20065. */
  20066. static Clamp(value: number, min?: number, max?: number): number;
  20067. /**
  20068. * the log2 of value.
  20069. * @param value the value to compute log2 of
  20070. * @returns the log2 of value.
  20071. */
  20072. static Log2(value: number): number;
  20073. /**
  20074. * Loops the value, so that it is never larger than length and never smaller than 0.
  20075. *
  20076. * This is similar to the modulo operator but it works with floating point numbers.
  20077. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20078. * With t = 5 and length = 2.5, the result would be 0.0.
  20079. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20080. * @param value the value
  20081. * @param length the length
  20082. * @returns the looped value
  20083. */
  20084. static Repeat(value: number, length: number): number;
  20085. /**
  20086. * Normalize the value between 0.0 and 1.0 using min and max values
  20087. * @param value value to normalize
  20088. * @param min max to normalize between
  20089. * @param max min to normalize between
  20090. * @returns the normalized value
  20091. */
  20092. static Normalize(value: number, min: number, max: number): number;
  20093. /**
  20094. * Denormalize the value from 0.0 and 1.0 using min and max values
  20095. * @param normalized value to denormalize
  20096. * @param min max to denormalize between
  20097. * @param max min to denormalize between
  20098. * @returns the denormalized value
  20099. */
  20100. static Denormalize(normalized: number, min: number, max: number): number;
  20101. /**
  20102. * Calculates the shortest difference between two given angles given in degrees.
  20103. * @param current current angle in degrees
  20104. * @param target target angle in degrees
  20105. * @returns the delta
  20106. */
  20107. static DeltaAngle(current: number, target: number): number;
  20108. /**
  20109. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20110. * @param tx value
  20111. * @param length length
  20112. * @returns The returned value will move back and forth between 0 and length
  20113. */
  20114. static PingPong(tx: number, length: number): number;
  20115. /**
  20116. * Interpolates between min and max with smoothing at the limits.
  20117. *
  20118. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20119. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20120. * @param from from
  20121. * @param to to
  20122. * @param tx value
  20123. * @returns the smooth stepped value
  20124. */
  20125. static SmoothStep(from: number, to: number, tx: number): number;
  20126. /**
  20127. * Moves a value current towards target.
  20128. *
  20129. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20130. * Negative values of maxDelta pushes the value away from target.
  20131. * @param current current value
  20132. * @param target target value
  20133. * @param maxDelta max distance to move
  20134. * @returns resulting value
  20135. */
  20136. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20137. /**
  20138. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20139. *
  20140. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20141. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20142. * @param current current value
  20143. * @param target target value
  20144. * @param maxDelta max distance to move
  20145. * @returns resulting angle
  20146. */
  20147. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20148. /**
  20149. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20150. * @param start start value
  20151. * @param end target value
  20152. * @param amount amount to lerp between
  20153. * @returns the lerped value
  20154. */
  20155. static Lerp(start: number, end: number, amount: number): number;
  20156. /**
  20157. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20158. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20159. * @param start start value
  20160. * @param end target value
  20161. * @param amount amount to lerp between
  20162. * @returns the lerped value
  20163. */
  20164. static LerpAngle(start: number, end: number, amount: number): number;
  20165. /**
  20166. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20167. * @param a start value
  20168. * @param b target value
  20169. * @param value value between a and b
  20170. * @returns the inverseLerp value
  20171. */
  20172. static InverseLerp(a: number, b: number, value: number): number;
  20173. /**
  20174. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20175. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20176. * @param value1 spline value
  20177. * @param tangent1 spline value
  20178. * @param value2 spline value
  20179. * @param tangent2 spline value
  20180. * @param amount input value
  20181. * @returns hermite result
  20182. */
  20183. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20184. /**
  20185. * Returns a random float number between and min and max values
  20186. * @param min min value of random
  20187. * @param max max value of random
  20188. * @returns random value
  20189. */
  20190. static RandomRange(min: number, max: number): number;
  20191. /**
  20192. * This function returns percentage of a number in a given range.
  20193. *
  20194. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20195. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20196. * @param number to convert to percentage
  20197. * @param min min range
  20198. * @param max max range
  20199. * @returns the percentage
  20200. */
  20201. static RangeToPercent(number: number, min: number, max: number): number;
  20202. /**
  20203. * This function returns number that corresponds to the percentage in a given range.
  20204. *
  20205. * PercentToRange(0.34,0,100) will return 34.
  20206. * @param percent to convert to number
  20207. * @param min min range
  20208. * @param max max range
  20209. * @returns the number
  20210. */
  20211. static PercentToRange(percent: number, min: number, max: number): number;
  20212. /**
  20213. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20214. * @param angle The angle to normalize in radian.
  20215. * @return The converted angle.
  20216. */
  20217. static NormalizeRadians(angle: number): number;
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * Constant used to convert a value to gamma space
  20223. * @ignorenaming
  20224. */
  20225. const ToGammaSpace: number;
  20226. /**
  20227. * Constant used to convert a value to linear space
  20228. * @ignorenaming
  20229. */
  20230. const ToLinearSpace = 2.2;
  20231. /**
  20232. * Constant used to define the minimal number value in Babylon.js
  20233. * @ignorenaming
  20234. */
  20235. const Epsilon = 0.001;
  20236. /**
  20237. * Class used to hold a RBG color
  20238. */
  20239. class Color3 {
  20240. /**
  20241. * Defines the red component (between 0 and 1, default is 0)
  20242. */
  20243. r: number;
  20244. /**
  20245. * Defines the green component (between 0 and 1, default is 0)
  20246. */
  20247. g: number;
  20248. /**
  20249. * Defines the blue component (between 0 and 1, default is 0)
  20250. */
  20251. b: number;
  20252. /**
  20253. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20254. * @param r defines the red component (between 0 and 1, default is 0)
  20255. * @param g defines the green component (between 0 and 1, default is 0)
  20256. * @param b defines the blue component (between 0 and 1, default is 0)
  20257. */
  20258. constructor(
  20259. /**
  20260. * Defines the red component (between 0 and 1, default is 0)
  20261. */
  20262. r?: number,
  20263. /**
  20264. * Defines the green component (between 0 and 1, default is 0)
  20265. */
  20266. g?: number,
  20267. /**
  20268. * Defines the blue component (between 0 and 1, default is 0)
  20269. */
  20270. b?: number);
  20271. /**
  20272. * Creates a string with the Color3 current values
  20273. * @returns the string representation of the Color3 object
  20274. */
  20275. toString(): string;
  20276. /**
  20277. * Returns the string "Color3"
  20278. * @returns "Color3"
  20279. */
  20280. getClassName(): string;
  20281. /**
  20282. * Compute the Color3 hash code
  20283. * @returns an unique number that can be used to hash Color3 objects
  20284. */
  20285. getHashCode(): number;
  20286. /**
  20287. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20288. * @param array defines the array where to store the r,g,b components
  20289. * @param index defines an optional index in the target array to define where to start storing values
  20290. * @returns the current Color3 object
  20291. */
  20292. toArray(array: FloatArray, index?: number): Color3;
  20293. /**
  20294. * Returns a new Color4 object from the current Color3 and the given alpha
  20295. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20296. * @returns a new Color4 object
  20297. */
  20298. toColor4(alpha?: number): Color4;
  20299. /**
  20300. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20301. * @returns the new array
  20302. */
  20303. asArray(): number[];
  20304. /**
  20305. * Returns the luminance value
  20306. * @returns a float value
  20307. */
  20308. toLuminance(): number;
  20309. /**
  20310. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20311. * @param otherColor defines the second operand
  20312. * @returns the new Color3 object
  20313. */
  20314. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20315. /**
  20316. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20317. * @param otherColor defines the second operand
  20318. * @param result defines the Color3 object where to store the result
  20319. * @returns the current Color3
  20320. */
  20321. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20322. /**
  20323. * Determines equality between Color3 objects
  20324. * @param otherColor defines the second operand
  20325. * @returns true if the rgb values are equal to the given ones
  20326. */
  20327. equals(otherColor: DeepImmutable<Color3>): boolean;
  20328. /**
  20329. * Determines equality between the current Color3 object and a set of r,b,g values
  20330. * @param r defines the red component to check
  20331. * @param g defines the green component to check
  20332. * @param b defines the blue component to check
  20333. * @returns true if the rgb values are equal to the given ones
  20334. */
  20335. equalsFloats(r: number, g: number, b: number): boolean;
  20336. /**
  20337. * Multiplies in place each rgb value by scale
  20338. * @param scale defines the scaling factor
  20339. * @returns the updated Color3
  20340. */
  20341. scale(scale: number): Color3;
  20342. /**
  20343. * Multiplies the rgb values by scale and stores the result into "result"
  20344. * @param scale defines the scaling factor
  20345. * @param result defines the Color3 object where to store the result
  20346. * @returns the unmodified current Color3
  20347. */
  20348. scaleToRef(scale: number, result: Color3): Color3;
  20349. /**
  20350. * Scale the current Color3 values by a factor and add the result to a given Color3
  20351. * @param scale defines the scale factor
  20352. * @param result defines color to store the result into
  20353. * @returns the unmodified current Color3
  20354. */
  20355. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20356. /**
  20357. * Clamps the rgb values by the min and max values and stores the result into "result"
  20358. * @param min defines minimum clamping value (default is 0)
  20359. * @param max defines maximum clamping value (default is 1)
  20360. * @param result defines color to store the result into
  20361. * @returns the original Color3
  20362. */
  20363. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20364. /**
  20365. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20366. * @param otherColor defines the second operand
  20367. * @returns the new Color3
  20368. */
  20369. add(otherColor: DeepImmutable<Color3>): Color3;
  20370. /**
  20371. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20372. * @param otherColor defines the second operand
  20373. * @param result defines Color3 object to store the result into
  20374. * @returns the unmodified current Color3
  20375. */
  20376. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20377. /**
  20378. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20379. * @param otherColor defines the second operand
  20380. * @returns the new Color3
  20381. */
  20382. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20383. /**
  20384. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20385. * @param otherColor defines the second operand
  20386. * @param result defines Color3 object to store the result into
  20387. * @returns the unmodified current Color3
  20388. */
  20389. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20390. /**
  20391. * Copy the current object
  20392. * @returns a new Color3 copied the current one
  20393. */
  20394. clone(): Color3;
  20395. /**
  20396. * Copies the rgb values from the source in the current Color3
  20397. * @param source defines the source Color3 object
  20398. * @returns the updated Color3 object
  20399. */
  20400. copyFrom(source: DeepImmutable<Color3>): Color3;
  20401. /**
  20402. * Updates the Color3 rgb values from the given floats
  20403. * @param r defines the red component to read from
  20404. * @param g defines the green component to read from
  20405. * @param b defines the blue component to read from
  20406. * @returns the current Color3 object
  20407. */
  20408. copyFromFloats(r: number, g: number, b: number): Color3;
  20409. /**
  20410. * Updates the Color3 rgb values from the given floats
  20411. * @param r defines the red component to read from
  20412. * @param g defines the green component to read from
  20413. * @param b defines the blue component to read from
  20414. * @returns the current Color3 object
  20415. */
  20416. set(r: number, g: number, b: number): Color3;
  20417. /**
  20418. * Compute the Color3 hexadecimal code as a string
  20419. * @returns a string containing the hexadecimal representation of the Color3 object
  20420. */
  20421. toHexString(): string;
  20422. /**
  20423. * Computes a new Color3 converted from the current one to linear space
  20424. * @returns a new Color3 object
  20425. */
  20426. toLinearSpace(): Color3;
  20427. /**
  20428. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20429. * @param convertedColor defines the Color3 object where to store the linear space version
  20430. * @returns the unmodified Color3
  20431. */
  20432. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20433. /**
  20434. * Computes a new Color3 converted from the current one to gamma space
  20435. * @returns a new Color3 object
  20436. */
  20437. toGammaSpace(): Color3;
  20438. /**
  20439. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20440. * @param convertedColor defines the Color3 object where to store the gamma space version
  20441. * @returns the unmodified Color3
  20442. */
  20443. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20444. /**
  20445. * Creates a new Color3 from the string containing valid hexadecimal values
  20446. * @param hex defines a string containing valid hexadecimal values
  20447. * @returns a new Color3 object
  20448. */
  20449. static FromHexString(hex: string): Color3;
  20450. /**
  20451. * Creates a new Vector3 from the starting index of the given array
  20452. * @param array defines the source array
  20453. * @param offset defines an offset in the source array
  20454. * @returns a new Color3 object
  20455. */
  20456. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20457. /**
  20458. * Creates a new Color3 from integer values (< 256)
  20459. * @param r defines the red component to read from (value between 0 and 255)
  20460. * @param g defines the green component to read from (value between 0 and 255)
  20461. * @param b defines the blue component to read from (value between 0 and 255)
  20462. * @returns a new Color3 object
  20463. */
  20464. static FromInts(r: number, g: number, b: number): Color3;
  20465. /**
  20466. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20467. * @param start defines the start Color3 value
  20468. * @param end defines the end Color3 value
  20469. * @param amount defines the gradient value between start and end
  20470. * @returns a new Color3 object
  20471. */
  20472. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20473. /**
  20474. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20475. * @param left defines the start value
  20476. * @param right defines the end value
  20477. * @param amount defines the gradient factor
  20478. * @param result defines the Color3 object where to store the result
  20479. */
  20480. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20481. /**
  20482. * Returns a Color3 value containing a red color
  20483. * @returns a new Color3 object
  20484. */
  20485. static Red(): Color3;
  20486. /**
  20487. * Returns a Color3 value containing a green color
  20488. * @returns a new Color3 object
  20489. */
  20490. static Green(): Color3;
  20491. /**
  20492. * Returns a Color3 value containing a blue color
  20493. * @returns a new Color3 object
  20494. */
  20495. static Blue(): Color3;
  20496. /**
  20497. * Returns a Color3 value containing a black color
  20498. * @returns a new Color3 object
  20499. */
  20500. static Black(): Color3;
  20501. /**
  20502. * Returns a Color3 value containing a white color
  20503. * @returns a new Color3 object
  20504. */
  20505. static White(): Color3;
  20506. /**
  20507. * Returns a Color3 value containing a purple color
  20508. * @returns a new Color3 object
  20509. */
  20510. static Purple(): Color3;
  20511. /**
  20512. * Returns a Color3 value containing a magenta color
  20513. * @returns a new Color3 object
  20514. */
  20515. static Magenta(): Color3;
  20516. /**
  20517. * Returns a Color3 value containing a yellow color
  20518. * @returns a new Color3 object
  20519. */
  20520. static Yellow(): Color3;
  20521. /**
  20522. * Returns a Color3 value containing a gray color
  20523. * @returns a new Color3 object
  20524. */
  20525. static Gray(): Color3;
  20526. /**
  20527. * Returns a Color3 value containing a teal color
  20528. * @returns a new Color3 object
  20529. */
  20530. static Teal(): Color3;
  20531. /**
  20532. * Returns a Color3 value containing a random color
  20533. * @returns a new Color3 object
  20534. */
  20535. static Random(): Color3;
  20536. }
  20537. /**
  20538. * Class used to hold a RBGA color
  20539. */
  20540. class Color4 {
  20541. /**
  20542. * Defines the red component (between 0 and 1, default is 0)
  20543. */
  20544. r: number;
  20545. /**
  20546. * Defines the green component (between 0 and 1, default is 0)
  20547. */
  20548. g: number;
  20549. /**
  20550. * Defines the blue component (between 0 and 1, default is 0)
  20551. */
  20552. b: number;
  20553. /**
  20554. * Defines the alpha component (between 0 and 1, default is 1)
  20555. */
  20556. a: number;
  20557. /**
  20558. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20559. * @param r defines the red component (between 0 and 1, default is 0)
  20560. * @param g defines the green component (between 0 and 1, default is 0)
  20561. * @param b defines the blue component (between 0 and 1, default is 0)
  20562. * @param a defines the alpha component (between 0 and 1, default is 1)
  20563. */
  20564. constructor(
  20565. /**
  20566. * Defines the red component (between 0 and 1, default is 0)
  20567. */
  20568. r?: number,
  20569. /**
  20570. * Defines the green component (between 0 and 1, default is 0)
  20571. */
  20572. g?: number,
  20573. /**
  20574. * Defines the blue component (between 0 and 1, default is 0)
  20575. */
  20576. b?: number,
  20577. /**
  20578. * Defines the alpha component (between 0 and 1, default is 1)
  20579. */
  20580. a?: number);
  20581. /**
  20582. * Adds in place the given Color4 values to the current Color4 object
  20583. * @param right defines the second operand
  20584. * @returns the current updated Color4 object
  20585. */
  20586. addInPlace(right: DeepImmutable<Color4>): Color4;
  20587. /**
  20588. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20589. * @returns the new array
  20590. */
  20591. asArray(): number[];
  20592. /**
  20593. * Stores from the starting index in the given array the Color4 successive values
  20594. * @param array defines the array where to store the r,g,b components
  20595. * @param index defines an optional index in the target array to define where to start storing values
  20596. * @returns the current Color4 object
  20597. */
  20598. toArray(array: number[], index?: number): Color4;
  20599. /**
  20600. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20601. * @param right defines the second operand
  20602. * @returns a new Color4 object
  20603. */
  20604. add(right: DeepImmutable<Color4>): Color4;
  20605. /**
  20606. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20607. * @param right defines the second operand
  20608. * @returns a new Color4 object
  20609. */
  20610. subtract(right: DeepImmutable<Color4>): Color4;
  20611. /**
  20612. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20613. * @param right defines the second operand
  20614. * @param result defines the Color4 object where to store the result
  20615. * @returns the current Color4 object
  20616. */
  20617. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20618. /**
  20619. * Creates a new Color4 with the current Color4 values multiplied by scale
  20620. * @param scale defines the scaling factor to apply
  20621. * @returns a new Color4 object
  20622. */
  20623. scale(scale: number): Color4;
  20624. /**
  20625. * Multiplies the current Color4 values by scale and stores the result in "result"
  20626. * @param scale defines the scaling factor to apply
  20627. * @param result defines the Color4 object where to store the result
  20628. * @returns the current unmodified Color4
  20629. */
  20630. scaleToRef(scale: number, result: Color4): Color4;
  20631. /**
  20632. * Scale the current Color4 values by a factor and add the result to a given Color4
  20633. * @param scale defines the scale factor
  20634. * @param result defines the Color4 object where to store the result
  20635. * @returns the unmodified current Color4
  20636. */
  20637. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20638. /**
  20639. * Clamps the rgb values by the min and max values and stores the result into "result"
  20640. * @param min defines minimum clamping value (default is 0)
  20641. * @param max defines maximum clamping value (default is 1)
  20642. * @param result defines color to store the result into.
  20643. * @returns the cuurent Color4
  20644. */
  20645. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20646. /**
  20647. * Multipy an Color4 value by another and return a new Color4 object
  20648. * @param color defines the Color4 value to multiply by
  20649. * @returns a new Color4 object
  20650. */
  20651. multiply(color: Color4): Color4;
  20652. /**
  20653. * Multipy a Color4 value by another and push the result in a reference value
  20654. * @param color defines the Color4 value to multiply by
  20655. * @param result defines the Color4 to fill the result in
  20656. * @returns the result Color4
  20657. */
  20658. multiplyToRef(color: Color4, result: Color4): Color4;
  20659. /**
  20660. * Creates a string with the Color4 current values
  20661. * @returns the string representation of the Color4 object
  20662. */
  20663. toString(): string;
  20664. /**
  20665. * Returns the string "Color4"
  20666. * @returns "Color4"
  20667. */
  20668. getClassName(): string;
  20669. /**
  20670. * Compute the Color4 hash code
  20671. * @returns an unique number that can be used to hash Color4 objects
  20672. */
  20673. getHashCode(): number;
  20674. /**
  20675. * Creates a new Color4 copied from the current one
  20676. * @returns a new Color4 object
  20677. */
  20678. clone(): Color4;
  20679. /**
  20680. * Copies the given Color4 values into the current one
  20681. * @param source defines the source Color4 object
  20682. * @returns the current updated Color4 object
  20683. */
  20684. copyFrom(source: Color4): Color4;
  20685. /**
  20686. * Copies the given float values into the current one
  20687. * @param r defines the red component to read from
  20688. * @param g defines the green component to read from
  20689. * @param b defines the blue component to read from
  20690. * @param a defines the alpha component to read from
  20691. * @returns the current updated Color4 object
  20692. */
  20693. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20694. /**
  20695. * Copies the given float values into the current one
  20696. * @param r defines the red component to read from
  20697. * @param g defines the green component to read from
  20698. * @param b defines the blue component to read from
  20699. * @param a defines the alpha component to read from
  20700. * @returns the current updated Color4 object
  20701. */
  20702. set(r: number, g: number, b: number, a: number): Color4;
  20703. /**
  20704. * Compute the Color4 hexadecimal code as a string
  20705. * @returns a string containing the hexadecimal representation of the Color4 object
  20706. */
  20707. toHexString(): string;
  20708. /**
  20709. * Computes a new Color4 converted from the current one to linear space
  20710. * @returns a new Color4 object
  20711. */
  20712. toLinearSpace(): Color4;
  20713. /**
  20714. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20715. * @param convertedColor defines the Color4 object where to store the linear space version
  20716. * @returns the unmodified Color4
  20717. */
  20718. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20719. /**
  20720. * Computes a new Color4 converted from the current one to gamma space
  20721. * @returns a new Color4 object
  20722. */
  20723. toGammaSpace(): Color4;
  20724. /**
  20725. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20726. * @param convertedColor defines the Color4 object where to store the gamma space version
  20727. * @returns the unmodified Color4
  20728. */
  20729. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20730. /**
  20731. * Creates a new Color4 from the string containing valid hexadecimal values
  20732. * @param hex defines a string containing valid hexadecimal values
  20733. * @returns a new Color4 object
  20734. */
  20735. static FromHexString(hex: string): Color4;
  20736. /**
  20737. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20738. * @param left defines the start value
  20739. * @param right defines the end value
  20740. * @param amount defines the gradient factor
  20741. * @returns a new Color4 object
  20742. */
  20743. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20744. /**
  20745. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20746. * @param left defines the start value
  20747. * @param right defines the end value
  20748. * @param amount defines the gradient factor
  20749. * @param result defines the Color4 object where to store data
  20750. */
  20751. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20752. /**
  20753. * Creates a new Color4 from a Color3 and an alpha value
  20754. * @param color3 defines the source Color3 to read from
  20755. * @param alpha defines the alpha component (1.0 by default)
  20756. * @returns a new Color4 object
  20757. */
  20758. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20759. /**
  20760. * Creates a new Color4 from the starting index element of the given array
  20761. * @param array defines the source array to read from
  20762. * @param offset defines the offset in the source array
  20763. * @returns a new Color4 object
  20764. */
  20765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20766. /**
  20767. * Creates a new Color3 from integer values (< 256)
  20768. * @param r defines the red component to read from (value between 0 and 255)
  20769. * @param g defines the green component to read from (value between 0 and 255)
  20770. * @param b defines the blue component to read from (value between 0 and 255)
  20771. * @param a defines the alpha component to read from (value between 0 and 255)
  20772. * @returns a new Color3 object
  20773. */
  20774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20775. /**
  20776. * Check the content of a given array and convert it to an array containing RGBA data
  20777. * If the original array was already containing count * 4 values then it is returned directly
  20778. * @param colors defines the array to check
  20779. * @param count defines the number of RGBA data to expect
  20780. * @returns an array containing count * 4 values (RGBA)
  20781. */
  20782. static CheckColors4(colors: number[], count: number): number[];
  20783. }
  20784. /**
  20785. * Class representing a vector containing 2 coordinates
  20786. */
  20787. class Vector2 {
  20788. /** defines the first coordinate */
  20789. x: number;
  20790. /** defines the second coordinate */
  20791. y: number;
  20792. /**
  20793. * Creates a new Vector2 from the given x and y coordinates
  20794. * @param x defines the first coordinate
  20795. * @param y defines the second coordinate
  20796. */
  20797. constructor(
  20798. /** defines the first coordinate */
  20799. x?: number,
  20800. /** defines the second coordinate */
  20801. y?: number);
  20802. /**
  20803. * Gets a string with the Vector2 coordinates
  20804. * @returns a string with the Vector2 coordinates
  20805. */
  20806. toString(): string;
  20807. /**
  20808. * Gets class name
  20809. * @returns the string "Vector2"
  20810. */
  20811. getClassName(): string;
  20812. /**
  20813. * Gets current vector hash code
  20814. * @returns the Vector2 hash code as a number
  20815. */
  20816. getHashCode(): number;
  20817. /**
  20818. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20819. * @param array defines the source array
  20820. * @param index defines the offset in source array
  20821. * @returns the current Vector2
  20822. */
  20823. toArray(array: FloatArray, index?: number): Vector2;
  20824. /**
  20825. * Copy the current vector to an array
  20826. * @returns a new array with 2 elements: the Vector2 coordinates.
  20827. */
  20828. asArray(): number[];
  20829. /**
  20830. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20831. * @param source defines the source Vector2
  20832. * @returns the current updated Vector2
  20833. */
  20834. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20835. /**
  20836. * Sets the Vector2 coordinates with the given floats
  20837. * @param x defines the first coordinate
  20838. * @param y defines the second coordinate
  20839. * @returns the current updated Vector2
  20840. */
  20841. copyFromFloats(x: number, y: number): Vector2;
  20842. /**
  20843. * Sets the Vector2 coordinates with the given floats
  20844. * @param x defines the first coordinate
  20845. * @param y defines the second coordinate
  20846. * @returns the current updated Vector2
  20847. */
  20848. set(x: number, y: number): Vector2;
  20849. /**
  20850. * Add another vector with the current one
  20851. * @param otherVector defines the other vector
  20852. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20853. */
  20854. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20855. /**
  20856. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20857. * @param otherVector defines the other vector
  20858. * @param result defines the target vector
  20859. * @returns the unmodified current Vector2
  20860. */
  20861. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20862. /**
  20863. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20864. * @param otherVector defines the other vector
  20865. * @returns the current updated Vector2
  20866. */
  20867. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20868. /**
  20869. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20870. * @param otherVector defines the other vector
  20871. * @returns a new Vector2
  20872. */
  20873. addVector3(otherVector: Vector3): Vector2;
  20874. /**
  20875. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20876. * @param otherVector defines the other vector
  20877. * @returns a new Vector2
  20878. */
  20879. subtract(otherVector: Vector2): Vector2;
  20880. /**
  20881. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20882. * @param otherVector defines the other vector
  20883. * @param result defines the target vector
  20884. * @returns the unmodified current Vector2
  20885. */
  20886. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20887. /**
  20888. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20889. * @param otherVector defines the other vector
  20890. * @returns the current updated Vector2
  20891. */
  20892. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20893. /**
  20894. * Multiplies in place the current Vector2 coordinates by the given ones
  20895. * @param otherVector defines the other vector
  20896. * @returns the current updated Vector2
  20897. */
  20898. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20899. /**
  20900. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20901. * @param otherVector defines the other vector
  20902. * @returns a new Vector2
  20903. */
  20904. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20905. /**
  20906. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20907. * @param otherVector defines the other vector
  20908. * @param result defines the target vector
  20909. * @returns the unmodified current Vector2
  20910. */
  20911. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20912. /**
  20913. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20914. * @param x defines the first coordinate
  20915. * @param y defines the second coordinate
  20916. * @returns a new Vector2
  20917. */
  20918. multiplyByFloats(x: number, y: number): Vector2;
  20919. /**
  20920. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20921. * @param otherVector defines the other vector
  20922. * @returns a new Vector2
  20923. */
  20924. divide(otherVector: Vector2): Vector2;
  20925. /**
  20926. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20927. * @param otherVector defines the other vector
  20928. * @param result defines the target vector
  20929. * @returns the unmodified current Vector2
  20930. */
  20931. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20932. /**
  20933. * Divides the current Vector2 coordinates by the given ones
  20934. * @param otherVector defines the other vector
  20935. * @returns the current updated Vector2
  20936. */
  20937. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20938. /**
  20939. * Gets a new Vector2 with current Vector2 negated coordinates
  20940. * @returns a new Vector2
  20941. */
  20942. negate(): Vector2;
  20943. /**
  20944. * Multiply the Vector2 coordinates by scale
  20945. * @param scale defines the scaling factor
  20946. * @returns the current updated Vector2
  20947. */
  20948. scaleInPlace(scale: number): Vector2;
  20949. /**
  20950. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20951. * @param scale defines the scaling factor
  20952. * @returns a new Vector2
  20953. */
  20954. scale(scale: number): Vector2;
  20955. /**
  20956. * Scale the current Vector2 values by a factor to a given Vector2
  20957. * @param scale defines the scale factor
  20958. * @param result defines the Vector2 object where to store the result
  20959. * @returns the unmodified current Vector2
  20960. */
  20961. scaleToRef(scale: number, result: Vector2): Vector2;
  20962. /**
  20963. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20964. * @param scale defines the scale factor
  20965. * @param result defines the Vector2 object where to store the result
  20966. * @returns the unmodified current Vector2
  20967. */
  20968. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20969. /**
  20970. * Gets a boolean if two vectors are equals
  20971. * @param otherVector defines the other vector
  20972. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20973. */
  20974. equals(otherVector: DeepImmutable<Vector2>): boolean;
  20975. /**
  20976. * Gets a boolean if two vectors are equals (using an epsilon value)
  20977. * @param otherVector defines the other vector
  20978. * @param epsilon defines the minimal distance to consider equality
  20979. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20980. */
  20981. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  20982. /**
  20983. * Gets a new Vector2 from current Vector2 floored values
  20984. * @returns a new Vector2
  20985. */
  20986. floor(): Vector2;
  20987. /**
  20988. * Gets a new Vector2 from current Vector2 floored values
  20989. * @returns a new Vector2
  20990. */
  20991. fract(): Vector2;
  20992. /**
  20993. * Gets the length of the vector
  20994. * @returns the vector length (float)
  20995. */
  20996. length(): number;
  20997. /**
  20998. * Gets the vector squared length
  20999. * @returns the vector squared length (float)
  21000. */
  21001. lengthSquared(): number;
  21002. /**
  21003. * Normalize the vector
  21004. * @returns the current updated Vector2
  21005. */
  21006. normalize(): Vector2;
  21007. /**
  21008. * Gets a new Vector2 copied from the Vector2
  21009. * @returns a new Vector2
  21010. */
  21011. clone(): Vector2;
  21012. /**
  21013. * Gets a new Vector2(0, 0)
  21014. * @returns a new Vector2
  21015. */
  21016. static Zero(): Vector2;
  21017. /**
  21018. * Gets a new Vector2(1, 1)
  21019. * @returns a new Vector2
  21020. */
  21021. static One(): Vector2;
  21022. /**
  21023. * Gets a new Vector2 set from the given index element of the given array
  21024. * @param array defines the data source
  21025. * @param offset defines the offset in the data source
  21026. * @returns a new Vector2
  21027. */
  21028. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21029. /**
  21030. * Sets "result" from the given index element of the given array
  21031. * @param array defines the data source
  21032. * @param offset defines the offset in the data source
  21033. * @param result defines the target vector
  21034. */
  21035. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21036. /**
  21037. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21038. * @param value1 defines 1st point of control
  21039. * @param value2 defines 2nd point of control
  21040. * @param value3 defines 3rd point of control
  21041. * @param value4 defines 4th point of control
  21042. * @param amount defines the interpolation factor
  21043. * @returns a new Vector2
  21044. */
  21045. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21046. /**
  21047. * 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".
  21048. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21049. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21050. * @param value defines the value to clamp
  21051. * @param min defines the lower limit
  21052. * @param max defines the upper limit
  21053. * @returns a new Vector2
  21054. */
  21055. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21056. /**
  21057. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21058. * @param value1 defines the 1st control point
  21059. * @param tangent1 defines the outgoing tangent
  21060. * @param value2 defines the 2nd control point
  21061. * @param tangent2 defines the incoming tangent
  21062. * @param amount defines the interpolation factor
  21063. * @returns a new Vector2
  21064. */
  21065. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21066. /**
  21067. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21068. * @param start defines the start vector
  21069. * @param end defines the end vector
  21070. * @param amount defines the interpolation factor
  21071. * @returns a new Vector2
  21072. */
  21073. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21074. /**
  21075. * Gets the dot product of the vector "left" and the vector "right"
  21076. * @param left defines first vector
  21077. * @param right defines second vector
  21078. * @returns the dot product (float)
  21079. */
  21080. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21081. /**
  21082. * Returns a new Vector2 equal to the normalized given vector
  21083. * @param vector defines the vector to normalize
  21084. * @returns a new Vector2
  21085. */
  21086. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21087. /**
  21088. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21089. * @param left defines 1st vector
  21090. * @param right defines 2nd vector
  21091. * @returns a new Vector2
  21092. */
  21093. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21094. /**
  21095. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21096. * @param left defines 1st vector
  21097. * @param right defines 2nd vector
  21098. * @returns a new Vector2
  21099. */
  21100. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21101. /**
  21102. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21103. * @param vector defines the vector to transform
  21104. * @param transformation defines the matrix to apply
  21105. * @returns a new Vector2
  21106. */
  21107. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21108. /**
  21109. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21110. * @param vector defines the vector to transform
  21111. * @param transformation defines the matrix to apply
  21112. * @param result defines the target vector
  21113. */
  21114. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21115. /**
  21116. * Determines if a given vector is included in a triangle
  21117. * @param p defines the vector to test
  21118. * @param p0 defines 1st triangle point
  21119. * @param p1 defines 2nd triangle point
  21120. * @param p2 defines 3rd triangle point
  21121. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21122. */
  21123. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21124. /**
  21125. * Gets the distance between the vectors "value1" and "value2"
  21126. * @param value1 defines first vector
  21127. * @param value2 defines second vector
  21128. * @returns the distance between vectors
  21129. */
  21130. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21131. /**
  21132. * Returns the squared distance between the vectors "value1" and "value2"
  21133. * @param value1 defines first vector
  21134. * @param value2 defines second vector
  21135. * @returns the squared distance between vectors
  21136. */
  21137. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21138. /**
  21139. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21140. * @param value1 defines first vector
  21141. * @param value2 defines second vector
  21142. * @returns a new Vector2
  21143. */
  21144. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21145. /**
  21146. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21147. * @param p defines the middle point
  21148. * @param segA defines one point of the segment
  21149. * @param segB defines the other point of the segment
  21150. * @returns the shortest distance
  21151. */
  21152. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21153. }
  21154. /**
  21155. * Classed used to store (x,y,z) vector representation
  21156. * A Vector3 is the main object used in 3D geometry
  21157. * It can represent etiher the coordinates of a point the space, either a direction
  21158. * Reminder: Babylon.js uses a left handed forward facing system
  21159. */
  21160. class Vector3 {
  21161. /**
  21162. * Defines the first coordinates (on X axis)
  21163. */
  21164. x: number;
  21165. /**
  21166. * Defines the second coordinates (on Y axis)
  21167. */
  21168. y: number;
  21169. /**
  21170. * Defines the third coordinates (on Z axis)
  21171. */
  21172. z: number;
  21173. /**
  21174. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21175. * @param x defines the first coordinates (on X axis)
  21176. * @param y defines the second coordinates (on Y axis)
  21177. * @param z defines the third coordinates (on Z axis)
  21178. */
  21179. constructor(
  21180. /**
  21181. * Defines the first coordinates (on X axis)
  21182. */
  21183. x?: number,
  21184. /**
  21185. * Defines the second coordinates (on Y axis)
  21186. */
  21187. y?: number,
  21188. /**
  21189. * Defines the third coordinates (on Z axis)
  21190. */
  21191. z?: number);
  21192. /**
  21193. * Creates a string representation of the Vector3
  21194. * @returns a string with the Vector3 coordinates.
  21195. */
  21196. toString(): string;
  21197. /**
  21198. * Gets the class name
  21199. * @returns the string "Vector3"
  21200. */
  21201. getClassName(): string;
  21202. /**
  21203. * Creates the Vector3 hash code
  21204. * @returns a number which tends to be unique between Vector3 instances
  21205. */
  21206. getHashCode(): number;
  21207. /**
  21208. * Creates an array containing three elements : the coordinates of the Vector3
  21209. * @returns a new array of numbers
  21210. */
  21211. asArray(): number[];
  21212. /**
  21213. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21214. * @param array defines the destination array
  21215. * @param index defines the offset in the destination array
  21216. * @returns the current Vector3
  21217. */
  21218. toArray(array: FloatArray, index?: number): Vector3;
  21219. /**
  21220. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21221. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21222. */
  21223. toQuaternion(): Quaternion;
  21224. /**
  21225. * Adds the given vector to the current Vector3
  21226. * @param otherVector defines the second operand
  21227. * @returns the current updated Vector3
  21228. */
  21229. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21230. /**
  21231. * Adds the given coordinates to the current Vector3
  21232. * @param x defines the x coordinate of the operand
  21233. * @param y defines the y coordinate of the operand
  21234. * @param z defines the z coordinate of the operand
  21235. * @returns the current updated Vector3
  21236. */
  21237. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21238. /**
  21239. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21240. * @param otherVector defines the second operand
  21241. * @returns the resulting Vector3
  21242. */
  21243. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21244. /**
  21245. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21246. * @param otherVector defines the second operand
  21247. * @param result defines the Vector3 object where to store the result
  21248. * @returns the current Vector3
  21249. */
  21250. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21251. /**
  21252. * Subtract the given vector from the current Vector3
  21253. * @param otherVector defines the second operand
  21254. * @returns the current updated Vector3
  21255. */
  21256. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21257. /**
  21258. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21259. * @param otherVector defines the second operand
  21260. * @returns the resulting Vector3
  21261. */
  21262. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21263. /**
  21264. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21265. * @param otherVector defines the second operand
  21266. * @param result defines the Vector3 object where to store the result
  21267. * @returns the current Vector3
  21268. */
  21269. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21270. /**
  21271. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21272. * @param x defines the x coordinate of the operand
  21273. * @param y defines the y coordinate of the operand
  21274. * @param z defines the z coordinate of the operand
  21275. * @returns the resulting Vector3
  21276. */
  21277. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21278. /**
  21279. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21280. * @param x defines the x coordinate of the operand
  21281. * @param y defines the y coordinate of the operand
  21282. * @param z defines the z coordinate of the operand
  21283. * @param result defines the Vector3 object where to store the result
  21284. * @returns the current Vector3
  21285. */
  21286. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21287. /**
  21288. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21289. * @returns a new Vector3
  21290. */
  21291. negate(): Vector3;
  21292. /**
  21293. * Multiplies the Vector3 coordinates by the float "scale"
  21294. * @param scale defines the multiplier factor
  21295. * @returns the current updated Vector3
  21296. */
  21297. scaleInPlace(scale: number): Vector3;
  21298. /**
  21299. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21300. * @param scale defines the multiplier factor
  21301. * @returns a new Vector3
  21302. */
  21303. scale(scale: number): Vector3;
  21304. /**
  21305. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21306. * @param scale defines the multiplier factor
  21307. * @param result defines the Vector3 object where to store the result
  21308. * @returns the current Vector3
  21309. */
  21310. scaleToRef(scale: number, result: Vector3): Vector3;
  21311. /**
  21312. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21313. * @param scale defines the scale factor
  21314. * @param result defines the Vector3 object where to store the result
  21315. * @returns the unmodified current Vector3
  21316. */
  21317. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21318. /**
  21319. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21320. * @param otherVector defines the second operand
  21321. * @returns true if both vectors are equals
  21322. */
  21323. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21324. /**
  21325. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21326. * @param otherVector defines the second operand
  21327. * @param epsilon defines the minimal distance to define values as equals
  21328. * @returns true if both vectors are distant less than epsilon
  21329. */
  21330. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21331. /**
  21332. * Returns true if the current Vector3 coordinates equals the given floats
  21333. * @param x defines the x coordinate of the operand
  21334. * @param y defines the y coordinate of the operand
  21335. * @param z defines the z coordinate of the operand
  21336. * @returns true if both vectors are equals
  21337. */
  21338. equalsToFloats(x: number, y: number, z: number): boolean;
  21339. /**
  21340. * Multiplies the current Vector3 coordinates by the given ones
  21341. * @param otherVector defines the second operand
  21342. * @returns the current updated Vector3
  21343. */
  21344. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21345. /**
  21346. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21347. * @param otherVector defines the second operand
  21348. * @returns the new Vector3
  21349. */
  21350. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21351. /**
  21352. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21353. * @param otherVector defines the second operand
  21354. * @param result defines the Vector3 object where to store the result
  21355. * @returns the current Vector3
  21356. */
  21357. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21358. /**
  21359. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21360. * @param x defines the x coordinate of the operand
  21361. * @param y defines the y coordinate of the operand
  21362. * @param z defines the z coordinate of the operand
  21363. * @returns the new Vector3
  21364. */
  21365. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21366. /**
  21367. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21368. * @param otherVector defines the second operand
  21369. * @returns the new Vector3
  21370. */
  21371. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21372. /**
  21373. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21374. * @param otherVector defines the second operand
  21375. * @param result defines the Vector3 object where to store the result
  21376. * @returns the current Vector3
  21377. */
  21378. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21379. /**
  21380. * Divides the current Vector3 coordinates by the given ones.
  21381. * @param otherVector defines the second operand
  21382. * @returns the current updated Vector3
  21383. */
  21384. divideInPlace(otherVector: Vector3): Vector3;
  21385. /**
  21386. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21387. * @param other defines the second operand
  21388. * @returns the current updated Vector3
  21389. */
  21390. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21391. /**
  21392. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21393. * @param other defines the second operand
  21394. * @returns the current updated Vector3
  21395. */
  21396. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21397. /**
  21398. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21399. * @param x defines the x coordinate of the operand
  21400. * @param y defines the y coordinate of the operand
  21401. * @param z defines the z coordinate of the operand
  21402. * @returns the current updated Vector3
  21403. */
  21404. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21405. /**
  21406. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21407. * @param x defines the x coordinate of the operand
  21408. * @param y defines the y coordinate of the operand
  21409. * @param z defines the z coordinate of the operand
  21410. * @returns the current updated Vector3
  21411. */
  21412. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21413. /**
  21414. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21415. */
  21416. readonly isNonUniform: boolean;
  21417. /**
  21418. * Gets a new Vector3 from current Vector3 floored values
  21419. * @returns a new Vector3
  21420. */
  21421. floor(): Vector3;
  21422. /**
  21423. * Gets a new Vector3 from current Vector3 floored values
  21424. * @returns a new Vector3
  21425. */
  21426. fract(): Vector3;
  21427. /**
  21428. * Gets the length of the Vector3
  21429. * @returns the length of the Vecto3
  21430. */
  21431. length(): number;
  21432. /**
  21433. * Gets the squared length of the Vector3
  21434. * @returns squared length of the Vector3
  21435. */
  21436. lengthSquared(): number;
  21437. /**
  21438. * Normalize the current Vector3.
  21439. * Please note that this is an in place operation.
  21440. * @returns the current updated Vector3
  21441. */
  21442. normalize(): Vector3;
  21443. /**
  21444. * Reorders the x y z properties of the vector in place
  21445. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21446. * @returns the current updated vector
  21447. */
  21448. reorderInPlace(order: string): this;
  21449. /**
  21450. * Rotates the vector around 0,0,0 by a quaternion
  21451. * @param quaternion the rotation quaternion
  21452. * @param result vector to store the result
  21453. * @returns the resulting vector
  21454. */
  21455. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21456. /**
  21457. * Rotates a vector around a given point
  21458. * @param quaternion the rotation quaternion
  21459. * @param point the point to rotate around
  21460. * @param result vector to store the result
  21461. * @returns the resulting vector
  21462. */
  21463. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21464. /**
  21465. * Normalize the current Vector3 with the given input length.
  21466. * Please note that this is an in place operation.
  21467. * @param len the length of the vector
  21468. * @returns the current updated Vector3
  21469. */
  21470. normalizeFromLength(len: number): Vector3;
  21471. /**
  21472. * Normalize the current Vector3 to a new vector
  21473. * @returns the new Vector3
  21474. */
  21475. normalizeToNew(): Vector3;
  21476. /**
  21477. * Normalize the current Vector3 to the reference
  21478. * @param reference define the Vector3 to update
  21479. * @returns the updated Vector3
  21480. */
  21481. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21482. /**
  21483. * Creates a new Vector3 copied from the current Vector3
  21484. * @returns the new Vector3
  21485. */
  21486. clone(): Vector3;
  21487. /**
  21488. * Copies the given vector coordinates to the current Vector3 ones
  21489. * @param source defines the source Vector3
  21490. * @returns the current updated Vector3
  21491. */
  21492. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21493. /**
  21494. * Copies the given floats to the current Vector3 coordinates
  21495. * @param x defines the x coordinate of the operand
  21496. * @param y defines the y coordinate of the operand
  21497. * @param z defines the z coordinate of the operand
  21498. * @returns the current updated Vector3
  21499. */
  21500. copyFromFloats(x: number, y: number, z: number): Vector3;
  21501. /**
  21502. * Copies the given floats to the current Vector3 coordinates
  21503. * @param x defines the x coordinate of the operand
  21504. * @param y defines the y coordinate of the operand
  21505. * @param z defines the z coordinate of the operand
  21506. * @returns the current updated Vector3
  21507. */
  21508. set(x: number, y: number, z: number): Vector3;
  21509. /**
  21510. * Copies the given float to the current Vector3 coordinates
  21511. * @param v defines the x, y and z coordinates of the operand
  21512. * @returns the current updated Vector3
  21513. */
  21514. setAll(v: number): Vector3;
  21515. /**
  21516. * Get the clip factor between two vectors
  21517. * @param vector0 defines the first operand
  21518. * @param vector1 defines the second operand
  21519. * @param axis defines the axis to use
  21520. * @param size defines the size along the axis
  21521. * @returns the clip factor
  21522. */
  21523. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21524. /**
  21525. * Get angle between two vectors
  21526. * @param vector0 angle between vector0 and vector1
  21527. * @param vector1 angle between vector0 and vector1
  21528. * @param normal direction of the normal
  21529. * @return the angle between vector0 and vector1
  21530. */
  21531. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21532. /**
  21533. * Returns a new Vector3 set from the index "offset" of the given array
  21534. * @param array defines the source array
  21535. * @param offset defines the offset in the source array
  21536. * @returns the new Vector3
  21537. */
  21538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21539. /**
  21540. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21541. * This function is deprecated. Use FromArray instead
  21542. * @param array defines the source array
  21543. * @param offset defines the offset in the source array
  21544. * @returns the new Vector3
  21545. */
  21546. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21547. /**
  21548. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21549. * @param array defines the source array
  21550. * @param offset defines the offset in the source array
  21551. * @param result defines the Vector3 where to store the result
  21552. */
  21553. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21554. /**
  21555. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21556. * This function is deprecated. Use FromArrayToRef instead.
  21557. * @param array defines the source array
  21558. * @param offset defines the offset in the source array
  21559. * @param result defines the Vector3 where to store the result
  21560. */
  21561. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21562. /**
  21563. * Sets the given vector "result" with the given floats.
  21564. * @param x defines the x coordinate of the source
  21565. * @param y defines the y coordinate of the source
  21566. * @param z defines the z coordinate of the source
  21567. * @param result defines the Vector3 where to store the result
  21568. */
  21569. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21570. /**
  21571. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21572. * @returns a new empty Vector3
  21573. */
  21574. static Zero(): Vector3;
  21575. /**
  21576. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21577. * @returns a new unit Vector3
  21578. */
  21579. static One(): Vector3;
  21580. /**
  21581. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21582. * @returns a new up Vector3
  21583. */
  21584. static Up(): Vector3;
  21585. /**
  21586. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21587. * @returns a new down Vector3
  21588. */
  21589. static Down(): Vector3;
  21590. /**
  21591. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21592. * @returns a new forward Vector3
  21593. */
  21594. static Forward(): Vector3;
  21595. /**
  21596. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21597. * @returns a new forward Vector3
  21598. */
  21599. static Backward(): Vector3;
  21600. /**
  21601. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21602. * @returns a new right Vector3
  21603. */
  21604. static Right(): Vector3;
  21605. /**
  21606. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21607. * @returns a new left Vector3
  21608. */
  21609. static Left(): Vector3;
  21610. /**
  21611. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21612. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21613. * @param vector defines the Vector3 to transform
  21614. * @param transformation defines the transformation matrix
  21615. * @returns the transformed Vector3
  21616. */
  21617. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21618. /**
  21619. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21620. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21621. * @param vector defines the Vector3 to transform
  21622. * @param transformation defines the transformation matrix
  21623. * @param result defines the Vector3 where to store the result
  21624. */
  21625. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21626. /**
  21627. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21628. * This method computes tranformed coordinates only, not transformed direction vectors
  21629. * @param x define the x coordinate of the source vector
  21630. * @param y define the y coordinate of the source vector
  21631. * @param z define the z coordinate of the source vector
  21632. * @param transformation defines the transformation matrix
  21633. * @param result defines the Vector3 where to store the result
  21634. */
  21635. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21636. /**
  21637. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21638. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21639. * @param vector defines the Vector3 to transform
  21640. * @param transformation defines the transformation matrix
  21641. * @returns the new Vector3
  21642. */
  21643. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21644. /**
  21645. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21646. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21647. * @param vector defines the Vector3 to transform
  21648. * @param transformation defines the transformation matrix
  21649. * @param result defines the Vector3 where to store the result
  21650. */
  21651. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21652. /**
  21653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21654. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21655. * @param x define the x coordinate of the source vector
  21656. * @param y define the y coordinate of the source vector
  21657. * @param z define the z coordinate of the source vector
  21658. * @param transformation defines the transformation matrix
  21659. * @param result defines the Vector3 where to store the result
  21660. */
  21661. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21662. /**
  21663. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21664. * @param value1 defines the first control point
  21665. * @param value2 defines the second control point
  21666. * @param value3 defines the third control point
  21667. * @param value4 defines the fourth control point
  21668. * @param amount defines the amount on the spline to use
  21669. * @returns the new Vector3
  21670. */
  21671. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21672. /**
  21673. * 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"
  21674. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21675. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21676. * @param value defines the current value
  21677. * @param min defines the lower range value
  21678. * @param max defines the upper range value
  21679. * @returns the new Vector3
  21680. */
  21681. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21682. /**
  21683. * 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"
  21684. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21685. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21686. * @param value defines the current value
  21687. * @param min defines the lower range value
  21688. * @param max defines the upper range value
  21689. * @param result defines the Vector3 where to store the result
  21690. */
  21691. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21692. /**
  21693. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21694. * @param value1 defines the first control point
  21695. * @param tangent1 defines the first tangent vector
  21696. * @param value2 defines the second control point
  21697. * @param tangent2 defines the second tangent vector
  21698. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21699. * @returns the new Vector3
  21700. */
  21701. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21702. /**
  21703. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21704. * @param start defines the start value
  21705. * @param end defines the end value
  21706. * @param amount max defines amount between both (between 0 and 1)
  21707. * @returns the new Vector3
  21708. */
  21709. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21710. /**
  21711. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21712. * @param start defines the start value
  21713. * @param end defines the end value
  21714. * @param amount max defines amount between both (between 0 and 1)
  21715. * @param result defines the Vector3 where to store the result
  21716. */
  21717. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21718. /**
  21719. * Returns the dot product (float) between the vectors "left" and "right"
  21720. * @param left defines the left operand
  21721. * @param right defines the right operand
  21722. * @returns the dot product
  21723. */
  21724. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21725. /**
  21726. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21727. * The cross product is then orthogonal to both "left" and "right"
  21728. * @param left defines the left operand
  21729. * @param right defines the right operand
  21730. * @returns the cross product
  21731. */
  21732. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21733. /**
  21734. * Sets the given vector "result" with the cross product of "left" and "right"
  21735. * The cross product is then orthogonal to both "left" and "right"
  21736. * @param left defines the left operand
  21737. * @param right defines the right operand
  21738. * @param result defines the Vector3 where to store the result
  21739. */
  21740. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21741. /**
  21742. * Returns a new Vector3 as the normalization of the given vector
  21743. * @param vector defines the Vector3 to normalize
  21744. * @returns the new Vector3
  21745. */
  21746. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21747. /**
  21748. * Sets the given vector "result" with the normalization of the given first vector
  21749. * @param vector defines the Vector3 to normalize
  21750. * @param result defines the Vector3 where to store the result
  21751. */
  21752. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21753. /**
  21754. * Project a Vector3 onto screen space
  21755. * @param vector defines the Vector3 to project
  21756. * @param world defines the world matrix to use
  21757. * @param transform defines the transform (view x projection) matrix to use
  21758. * @param viewport defines the screen viewport to use
  21759. * @returns the new Vector3
  21760. */
  21761. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21762. /** @hidden */
  21763. private static UnprojectFromInvertedMatrixToRef;
  21764. /**
  21765. * Unproject from screen space to object space
  21766. * @param source defines the screen space Vector3 to use
  21767. * @param viewportWidth defines the current width of the viewport
  21768. * @param viewportHeight defines the current height of the viewport
  21769. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21770. * @param transform defines the transform (view x projection) matrix to use
  21771. * @returns the new Vector3
  21772. */
  21773. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21774. /**
  21775. * Unproject from screen space to object space
  21776. * @param source defines the screen space Vector3 to use
  21777. * @param viewportWidth defines the current width of the viewport
  21778. * @param viewportHeight defines the current height of the viewport
  21779. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21780. * @param view defines the view matrix to use
  21781. * @param projection defines the projection matrix to use
  21782. * @returns the new Vector3
  21783. */
  21784. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21785. /**
  21786. * Unproject from screen space to object space
  21787. * @param source defines the screen space Vector3 to use
  21788. * @param viewportWidth defines the current width of the viewport
  21789. * @param viewportHeight defines the current height of the viewport
  21790. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21791. * @param view defines the view matrix to use
  21792. * @param projection defines the projection matrix to use
  21793. * @param result defines the Vector3 where to store the result
  21794. */
  21795. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21796. /**
  21797. * Unproject from screen space to object space
  21798. * @param sourceX defines the screen space x coordinate to use
  21799. * @param sourceY defines the screen space y coordinate to use
  21800. * @param sourceZ defines the screen space z coordinate to use
  21801. * @param viewportWidth defines the current width of the viewport
  21802. * @param viewportHeight defines the current height of the viewport
  21803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21804. * @param view defines the view matrix to use
  21805. * @param projection defines the projection matrix to use
  21806. * @param result defines the Vector3 where to store the result
  21807. */
  21808. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21809. /**
  21810. * Unproject a ray from screen space to object space
  21811. * @param sourceX defines the screen space x coordinate to use
  21812. * @param sourceY defines the screen space y coordinate to use
  21813. * @param viewportWidth defines the current width of the viewport
  21814. * @param viewportHeight defines the current height of the viewport
  21815. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21816. * @param view defines the view matrix to use
  21817. * @param projection defines the projection matrix to use
  21818. * @param ray defines the Ray where to store the result
  21819. */
  21820. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21821. /**
  21822. * Gets the minimal coordinate values between two Vector3
  21823. * @param left defines the first operand
  21824. * @param right defines the second operand
  21825. * @returns the new Vector3
  21826. */
  21827. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21828. /**
  21829. * Gets the maximal coordinate values between two Vector3
  21830. * @param left defines the first operand
  21831. * @param right defines the second operand
  21832. * @returns the new Vector3
  21833. */
  21834. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21835. /**
  21836. * Returns the distance between the vectors "value1" and "value2"
  21837. * @param value1 defines the first operand
  21838. * @param value2 defines the second operand
  21839. * @returns the distance
  21840. */
  21841. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21842. /**
  21843. * Returns the squared distance between the vectors "value1" and "value2"
  21844. * @param value1 defines the first operand
  21845. * @param value2 defines the second operand
  21846. * @returns the squared distance
  21847. */
  21848. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21849. /**
  21850. * Returns a new Vector3 located at the center between "value1" and "value2"
  21851. * @param value1 defines the first operand
  21852. * @param value2 defines the second operand
  21853. * @returns the new Vector3
  21854. */
  21855. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21856. /**
  21857. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21858. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21859. * to something in order to rotate it from its local system to the given target system
  21860. * Note: axis1, axis2 and axis3 are normalized during this operation
  21861. * @param axis1 defines the first axis
  21862. * @param axis2 defines the second axis
  21863. * @param axis3 defines the third axis
  21864. * @returns a new Vector3
  21865. */
  21866. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21867. /**
  21868. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21869. * @param axis1 defines the first axis
  21870. * @param axis2 defines the second axis
  21871. * @param axis3 defines the third axis
  21872. * @param ref defines the Vector3 where to store the result
  21873. */
  21874. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21875. }
  21876. /**
  21877. * Vector4 class created for EulerAngle class conversion to Quaternion
  21878. */
  21879. class Vector4 {
  21880. /** x value of the vector */
  21881. x: number;
  21882. /** y value of the vector */
  21883. y: number;
  21884. /** z value of the vector */
  21885. z: number;
  21886. /** w value of the vector */
  21887. w: number;
  21888. /**
  21889. * Creates a Vector4 object from the given floats.
  21890. * @param x x value of the vector
  21891. * @param y y value of the vector
  21892. * @param z z value of the vector
  21893. * @param w w value of the vector
  21894. */
  21895. constructor(
  21896. /** x value of the vector */
  21897. x: number,
  21898. /** y value of the vector */
  21899. y: number,
  21900. /** z value of the vector */
  21901. z: number,
  21902. /** w value of the vector */
  21903. w: number);
  21904. /**
  21905. * Returns the string with the Vector4 coordinates.
  21906. * @returns a string containing all the vector values
  21907. */
  21908. toString(): string;
  21909. /**
  21910. * Returns the string "Vector4".
  21911. * @returns "Vector4"
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Returns the Vector4 hash code.
  21916. * @returns a unique hash code
  21917. */
  21918. getHashCode(): number;
  21919. /**
  21920. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21921. * @returns the resulting array
  21922. */
  21923. asArray(): number[];
  21924. /**
  21925. * Populates the given array from the given index with the Vector4 coordinates.
  21926. * @param array array to populate
  21927. * @param index index of the array to start at (default: 0)
  21928. * @returns the Vector4.
  21929. */
  21930. toArray(array: FloatArray, index?: number): Vector4;
  21931. /**
  21932. * Adds the given vector to the current Vector4.
  21933. * @param otherVector the vector to add
  21934. * @returns the updated Vector4.
  21935. */
  21936. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21937. /**
  21938. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21939. * @param otherVector the vector to add
  21940. * @returns the resulting vector
  21941. */
  21942. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21943. /**
  21944. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21945. * @param otherVector the vector to add
  21946. * @param result the vector to store the result
  21947. * @returns the current Vector4.
  21948. */
  21949. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21950. /**
  21951. * Subtract in place the given vector from the current Vector4.
  21952. * @param otherVector the vector to subtract
  21953. * @returns the updated Vector4.
  21954. */
  21955. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21956. /**
  21957. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21958. * @param otherVector the vector to add
  21959. * @returns the new vector with the result
  21960. */
  21961. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  21962. /**
  21963. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21964. * @param otherVector the vector to subtract
  21965. * @param result the vector to store the result
  21966. * @returns the current Vector4.
  21967. */
  21968. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21969. /**
  21970. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21971. */
  21972. /**
  21973. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21974. * @param x value to subtract
  21975. * @param y value to subtract
  21976. * @param z value to subtract
  21977. * @param w value to subtract
  21978. * @returns new vector containing the result
  21979. */
  21980. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21981. /**
  21982. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21983. * @param x value to subtract
  21984. * @param y value to subtract
  21985. * @param z value to subtract
  21986. * @param w value to subtract
  21987. * @param result the vector to store the result in
  21988. * @returns the current Vector4.
  21989. */
  21990. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21991. /**
  21992. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21993. * @returns a new vector with the negated values
  21994. */
  21995. negate(): Vector4;
  21996. /**
  21997. * Multiplies the current Vector4 coordinates by scale (float).
  21998. * @param scale the number to scale with
  21999. * @returns the updated Vector4.
  22000. */
  22001. scaleInPlace(scale: number): Vector4;
  22002. /**
  22003. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22004. * @param scale the number to scale with
  22005. * @returns a new vector with the result
  22006. */
  22007. scale(scale: number): Vector4;
  22008. /**
  22009. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22010. * @param scale the number to scale with
  22011. * @param result a vector to store the result in
  22012. * @returns the current Vector4.
  22013. */
  22014. scaleToRef(scale: number, result: Vector4): Vector4;
  22015. /**
  22016. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22017. * @param scale defines the scale factor
  22018. * @param result defines the Vector4 object where to store the result
  22019. * @returns the unmodified current Vector4
  22020. */
  22021. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22022. /**
  22023. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22024. * @param otherVector the vector to compare against
  22025. * @returns true if they are equal
  22026. */
  22027. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22028. /**
  22029. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22030. * @param otherVector vector to compare against
  22031. * @param epsilon (Default: very small number)
  22032. * @returns true if they are equal
  22033. */
  22034. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22035. /**
  22036. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22037. * @param x x value to compare against
  22038. * @param y y value to compare against
  22039. * @param z z value to compare against
  22040. * @param w w value to compare against
  22041. * @returns true if equal
  22042. */
  22043. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22044. /**
  22045. * Multiplies in place the current Vector4 by the given one.
  22046. * @param otherVector vector to multiple with
  22047. * @returns the updated Vector4.
  22048. */
  22049. multiplyInPlace(otherVector: Vector4): Vector4;
  22050. /**
  22051. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22052. * @param otherVector vector to multiple with
  22053. * @returns resulting new vector
  22054. */
  22055. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22056. /**
  22057. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22058. * @param otherVector vector to multiple with
  22059. * @param result vector to store the result
  22060. * @returns the current Vector4.
  22061. */
  22062. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22063. /**
  22064. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22065. * @param x x value multiply with
  22066. * @param y y value multiply with
  22067. * @param z z value multiply with
  22068. * @param w w value multiply with
  22069. * @returns resulting new vector
  22070. */
  22071. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22072. /**
  22073. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22074. * @param otherVector vector to devide with
  22075. * @returns resulting new vector
  22076. */
  22077. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22078. /**
  22079. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22080. * @param otherVector vector to devide with
  22081. * @param result vector to store the result
  22082. * @returns the current Vector4.
  22083. */
  22084. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22085. /**
  22086. * Divides the current Vector3 coordinates by the given ones.
  22087. * @param otherVector vector to devide with
  22088. * @returns the updated Vector3.
  22089. */
  22090. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22091. /**
  22092. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22093. * @param other defines the second operand
  22094. * @returns the current updated Vector4
  22095. */
  22096. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22097. /**
  22098. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22099. * @param other defines the second operand
  22100. * @returns the current updated Vector4
  22101. */
  22102. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22103. /**
  22104. * Gets a new Vector4 from current Vector4 floored values
  22105. * @returns a new Vector4
  22106. */
  22107. floor(): Vector4;
  22108. /**
  22109. * Gets a new Vector4 from current Vector3 floored values
  22110. * @returns a new Vector4
  22111. */
  22112. fract(): Vector4;
  22113. /**
  22114. * Returns the Vector4 length (float).
  22115. * @returns the length
  22116. */
  22117. length(): number;
  22118. /**
  22119. * Returns the Vector4 squared length (float).
  22120. * @returns the length squared
  22121. */
  22122. lengthSquared(): number;
  22123. /**
  22124. * Normalizes in place the Vector4.
  22125. * @returns the updated Vector4.
  22126. */
  22127. normalize(): Vector4;
  22128. /**
  22129. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22130. * @returns this converted to a new vector3
  22131. */
  22132. toVector3(): Vector3;
  22133. /**
  22134. * Returns a new Vector4 copied from the current one.
  22135. * @returns the new cloned vector
  22136. */
  22137. clone(): Vector4;
  22138. /**
  22139. * Updates the current Vector4 with the given one coordinates.
  22140. * @param source the source vector to copy from
  22141. * @returns the updated Vector4.
  22142. */
  22143. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22144. /**
  22145. * Updates the current Vector4 coordinates with the given floats.
  22146. * @param x float to copy from
  22147. * @param y float to copy from
  22148. * @param z float to copy from
  22149. * @param w float to copy from
  22150. * @returns the updated Vector4.
  22151. */
  22152. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22153. /**
  22154. * Updates the current Vector4 coordinates with the given floats.
  22155. * @param x float to set from
  22156. * @param y float to set from
  22157. * @param z float to set from
  22158. * @param w float to set from
  22159. * @returns the updated Vector4.
  22160. */
  22161. set(x: number, y: number, z: number, w: number): Vector4;
  22162. /**
  22163. * Copies the given float to the current Vector3 coordinates
  22164. * @param v defines the x, y, z and w coordinates of the operand
  22165. * @returns the current updated Vector3
  22166. */
  22167. setAll(v: number): Vector4;
  22168. /**
  22169. * Returns a new Vector4 set from the starting index of the given array.
  22170. * @param array the array to pull values from
  22171. * @param offset the offset into the array to start at
  22172. * @returns the new vector
  22173. */
  22174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22175. /**
  22176. * Updates the given vector "result" from the starting index of the given array.
  22177. * @param array the array to pull values from
  22178. * @param offset the offset into the array to start at
  22179. * @param result the vector to store the result in
  22180. */
  22181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22182. /**
  22183. * Updates the given vector "result" from the starting index of the given Float32Array.
  22184. * @param array the array to pull values from
  22185. * @param offset the offset into the array to start at
  22186. * @param result the vector to store the result in
  22187. */
  22188. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22189. /**
  22190. * Updates the given vector "result" coordinates from the given floats.
  22191. * @param x float to set from
  22192. * @param y float to set from
  22193. * @param z float to set from
  22194. * @param w float to set from
  22195. * @param result the vector to the floats in
  22196. */
  22197. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22198. /**
  22199. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22200. * @returns the new vector
  22201. */
  22202. static Zero(): Vector4;
  22203. /**
  22204. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22205. * @returns the new vector
  22206. */
  22207. static One(): Vector4;
  22208. /**
  22209. * Returns a new normalized Vector4 from the given one.
  22210. * @param vector the vector to normalize
  22211. * @returns the vector
  22212. */
  22213. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22214. /**
  22215. * Updates the given vector "result" from the normalization of the given one.
  22216. * @param vector the vector to normalize
  22217. * @param result the vector to store the result in
  22218. */
  22219. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22220. /**
  22221. * Returns a vector with the minimum values from the left and right vectors
  22222. * @param left left vector to minimize
  22223. * @param right right vector to minimize
  22224. * @returns a new vector with the minimum of the left and right vector values
  22225. */
  22226. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22227. /**
  22228. * Returns a vector with the maximum values from the left and right vectors
  22229. * @param left left vector to maximize
  22230. * @param right right vector to maximize
  22231. * @returns a new vector with the maximum of the left and right vector values
  22232. */
  22233. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22234. /**
  22235. * Returns the distance (float) between the vectors "value1" and "value2".
  22236. * @param value1 value to calulate the distance between
  22237. * @param value2 value to calulate the distance between
  22238. * @return the distance between the two vectors
  22239. */
  22240. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22241. /**
  22242. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22243. * @param value1 value to calulate the distance between
  22244. * @param value2 value to calulate the distance between
  22245. * @return the distance between the two vectors squared
  22246. */
  22247. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22248. /**
  22249. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22250. * @param value1 value to calulate the center between
  22251. * @param value2 value to calulate the center between
  22252. * @return the center between the two vectors
  22253. */
  22254. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22255. /**
  22256. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22257. * This methods computes transformed normalized direction vectors only.
  22258. * @param vector the vector to transform
  22259. * @param transformation the transformation matrix to apply
  22260. * @returns the new vector
  22261. */
  22262. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22263. /**
  22264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22265. * This methods computes transformed normalized direction vectors only.
  22266. * @param vector the vector to transform
  22267. * @param transformation the transformation matrix to apply
  22268. * @param result the vector to store the result in
  22269. */
  22270. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22271. /**
  22272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22273. * This methods computes transformed normalized direction vectors only.
  22274. * @param x value to transform
  22275. * @param y value to transform
  22276. * @param z value to transform
  22277. * @param w value to transform
  22278. * @param transformation the transformation matrix to apply
  22279. * @param result the vector to store the results in
  22280. */
  22281. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22282. }
  22283. /**
  22284. * Interface for the size containing width and height
  22285. */
  22286. interface ISize {
  22287. /**
  22288. * Width
  22289. */
  22290. width: number;
  22291. /**
  22292. * Heighht
  22293. */
  22294. height: number;
  22295. }
  22296. /**
  22297. * Size containing widht and height
  22298. */
  22299. class Size implements ISize {
  22300. /**
  22301. * Width
  22302. */
  22303. width: number;
  22304. /**
  22305. * Height
  22306. */
  22307. height: number;
  22308. /**
  22309. * Creates a Size object from the given width and height (floats).
  22310. * @param width width of the new size
  22311. * @param height height of the new size
  22312. */
  22313. constructor(width: number, height: number);
  22314. /**
  22315. * Returns a string with the Size width and height
  22316. * @returns a string with the Size width and height
  22317. */
  22318. toString(): string;
  22319. /**
  22320. * "Size"
  22321. * @returns the string "Size"
  22322. */
  22323. getClassName(): string;
  22324. /**
  22325. * Returns the Size hash code.
  22326. * @returns a hash code for a unique width and height
  22327. */
  22328. getHashCode(): number;
  22329. /**
  22330. * Updates the current size from the given one.
  22331. * @param src the given size
  22332. */
  22333. copyFrom(src: Size): void;
  22334. /**
  22335. * Updates in place the current Size from the given floats.
  22336. * @param width width of the new size
  22337. * @param height height of the new size
  22338. * @returns the updated Size.
  22339. */
  22340. copyFromFloats(width: number, height: number): Size;
  22341. /**
  22342. * Updates in place the current Size from the given floats.
  22343. * @param width width to set
  22344. * @param height height to set
  22345. * @returns the updated Size.
  22346. */
  22347. set(width: number, height: number): Size;
  22348. /**
  22349. * Multiplies the width and height by numbers
  22350. * @param w factor to multiple the width by
  22351. * @param h factor to multiple the height by
  22352. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22353. */
  22354. multiplyByFloats(w: number, h: number): Size;
  22355. /**
  22356. * Clones the size
  22357. * @returns a new Size copied from the given one.
  22358. */
  22359. clone(): Size;
  22360. /**
  22361. * True if the current Size and the given one width and height are strictly equal.
  22362. * @param other the other size to compare against
  22363. * @returns True if the current Size and the given one width and height are strictly equal.
  22364. */
  22365. equals(other: Size): boolean;
  22366. /**
  22367. * The surface of the Size : width * height (float).
  22368. */
  22369. readonly surface: number;
  22370. /**
  22371. * Create a new size of zero
  22372. * @returns a new Size set to (0.0, 0.0)
  22373. */
  22374. static Zero(): Size;
  22375. /**
  22376. * Sums the width and height of two sizes
  22377. * @param otherSize size to add to this size
  22378. * @returns a new Size set as the addition result of the current Size and the given one.
  22379. */
  22380. add(otherSize: Size): Size;
  22381. /**
  22382. * Subtracts the width and height of two
  22383. * @param otherSize size to subtract to this size
  22384. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22385. */
  22386. subtract(otherSize: Size): Size;
  22387. /**
  22388. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22389. * @param start starting size to lerp between
  22390. * @param end end size to lerp between
  22391. * @param amount amount to lerp between the start and end values
  22392. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22393. */
  22394. static Lerp(start: Size, end: Size, amount: number): Size;
  22395. }
  22396. /**
  22397. * Class used to store quaternion data
  22398. * @see https://en.wikipedia.org/wiki/Quaternion
  22399. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22400. */
  22401. class Quaternion {
  22402. /** defines the first component (0 by default) */
  22403. x: number;
  22404. /** defines the second component (0 by default) */
  22405. y: number;
  22406. /** defines the third component (0 by default) */
  22407. z: number;
  22408. /** defines the fourth component (1.0 by default) */
  22409. w: number;
  22410. /**
  22411. * Creates a new Quaternion from the given floats
  22412. * @param x defines the first component (0 by default)
  22413. * @param y defines the second component (0 by default)
  22414. * @param z defines the third component (0 by default)
  22415. * @param w defines the fourth component (1.0 by default)
  22416. */
  22417. constructor(
  22418. /** defines the first component (0 by default) */
  22419. x?: number,
  22420. /** defines the second component (0 by default) */
  22421. y?: number,
  22422. /** defines the third component (0 by default) */
  22423. z?: number,
  22424. /** defines the fourth component (1.0 by default) */
  22425. w?: number);
  22426. /**
  22427. * Gets a string representation for the current quaternion
  22428. * @returns a string with the Quaternion coordinates
  22429. */
  22430. toString(): string;
  22431. /**
  22432. * Gets the class name of the quaternion
  22433. * @returns the string "Quaternion"
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Gets a hash code for this quaternion
  22438. * @returns the quaternion hash code
  22439. */
  22440. getHashCode(): number;
  22441. /**
  22442. * Copy the quaternion to an array
  22443. * @returns a new array populated with 4 elements from the quaternion coordinates
  22444. */
  22445. asArray(): number[];
  22446. /**
  22447. * Check if two quaternions are equals
  22448. * @param otherQuaternion defines the second operand
  22449. * @return true if the current quaternion and the given one coordinates are strictly equals
  22450. */
  22451. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22452. /**
  22453. * Clone the current quaternion
  22454. * @returns a new quaternion copied from the current one
  22455. */
  22456. clone(): Quaternion;
  22457. /**
  22458. * Copy a quaternion to the current one
  22459. * @param other defines the other quaternion
  22460. * @returns the updated current quaternion
  22461. */
  22462. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22463. /**
  22464. * Updates the current quaternion with the given float coordinates
  22465. * @param x defines the x coordinate
  22466. * @param y defines the y coordinate
  22467. * @param z defines the z coordinate
  22468. * @param w defines the w coordinate
  22469. * @returns the updated current quaternion
  22470. */
  22471. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22472. /**
  22473. * Updates the current quaternion from the given float coordinates
  22474. * @param x defines the x coordinate
  22475. * @param y defines the y coordinate
  22476. * @param z defines the z coordinate
  22477. * @param w defines the w coordinate
  22478. * @returns the updated current quaternion
  22479. */
  22480. set(x: number, y: number, z: number, w: number): Quaternion;
  22481. /**
  22482. * Adds two quaternions
  22483. * @param other defines the second operand
  22484. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22485. */
  22486. add(other: DeepImmutable<Quaternion>): Quaternion;
  22487. /**
  22488. * Add a quaternion to the current one
  22489. * @param other defines the quaternion to add
  22490. * @returns the current quaternion
  22491. */
  22492. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22493. /**
  22494. * Subtract two quaternions
  22495. * @param other defines the second operand
  22496. * @returns a new quaternion as the subtraction result of the given one from the current one
  22497. */
  22498. subtract(other: Quaternion): Quaternion;
  22499. /**
  22500. * Multiplies the current quaternion by a scale factor
  22501. * @param value defines the scale factor
  22502. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22503. */
  22504. scale(value: number): Quaternion;
  22505. /**
  22506. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22507. * @param scale defines the scale factor
  22508. * @param result defines the Quaternion object where to store the result
  22509. * @returns the unmodified current quaternion
  22510. */
  22511. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22512. /**
  22513. * Multiplies in place the current quaternion by a scale factor
  22514. * @param value defines the scale factor
  22515. * @returns the current modified quaternion
  22516. */
  22517. scaleInPlace(value: number): Quaternion;
  22518. /**
  22519. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22520. * @param scale defines the scale factor
  22521. * @param result defines the Quaternion object where to store the result
  22522. * @returns the unmodified current quaternion
  22523. */
  22524. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22525. /**
  22526. * Multiplies two quaternions
  22527. * @param q1 defines the second operand
  22528. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22529. */
  22530. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22531. /**
  22532. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22533. * @param q1 defines the second operand
  22534. * @param result defines the target quaternion
  22535. * @returns the current quaternion
  22536. */
  22537. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22538. /**
  22539. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22540. * @param q1 defines the second operand
  22541. * @returns the currentupdated quaternion
  22542. */
  22543. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22544. /**
  22545. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22546. * @param ref defines the target quaternion
  22547. * @returns the current quaternion
  22548. */
  22549. conjugateToRef(ref: Quaternion): Quaternion;
  22550. /**
  22551. * Conjugates in place (1-q) the current quaternion
  22552. * @returns the current updated quaternion
  22553. */
  22554. conjugateInPlace(): Quaternion;
  22555. /**
  22556. * Conjugates in place (1-q) the current quaternion
  22557. * @returns a new quaternion
  22558. */
  22559. conjugate(): Quaternion;
  22560. /**
  22561. * Gets length of current quaternion
  22562. * @returns the quaternion length (float)
  22563. */
  22564. length(): number;
  22565. /**
  22566. * Normalize in place the current quaternion
  22567. * @returns the current updated quaternion
  22568. */
  22569. normalize(): Quaternion;
  22570. /**
  22571. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22572. * @param order is a reserved parameter and is ignore for now
  22573. * @returns a new Vector3 containing the Euler angles
  22574. */
  22575. toEulerAngles(order?: string): Vector3;
  22576. /**
  22577. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22578. * @param result defines the vector which will be filled with the Euler angles
  22579. * @param order is a reserved parameter and is ignore for now
  22580. * @returns the current unchanged quaternion
  22581. */
  22582. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22583. /**
  22584. * Updates the given rotation matrix with the current quaternion values
  22585. * @param result defines the target matrix
  22586. * @returns the current unchanged quaternion
  22587. */
  22588. toRotationMatrix(result: Matrix): Quaternion;
  22589. /**
  22590. * Updates the current quaternion from the given rotation matrix values
  22591. * @param matrix defines the source matrix
  22592. * @returns the current updated quaternion
  22593. */
  22594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22595. /**
  22596. * Creates a new quaternion from a rotation matrix
  22597. * @param matrix defines the source matrix
  22598. * @returns a new quaternion created from the given rotation matrix values
  22599. */
  22600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22601. /**
  22602. * Updates the given quaternion with the given rotation matrix values
  22603. * @param matrix defines the source matrix
  22604. * @param result defines the target quaternion
  22605. */
  22606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22607. /**
  22608. * Returns the dot product (float) between the quaternions "left" and "right"
  22609. * @param left defines the left operand
  22610. * @param right defines the right operand
  22611. * @returns the dot product
  22612. */
  22613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22614. /**
  22615. * Checks if the two quaternions are close to each other
  22616. * @param quat0 defines the first quaternion to check
  22617. * @param quat1 defines the second quaternion to check
  22618. * @returns true if the two quaternions are close to each other
  22619. */
  22620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22621. /**
  22622. * Creates an empty quaternion
  22623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22624. */
  22625. static Zero(): Quaternion;
  22626. /**
  22627. * Inverse a given quaternion
  22628. * @param q defines the source quaternion
  22629. * @returns a new quaternion as the inverted current quaternion
  22630. */
  22631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22632. /**
  22633. * Inverse a given quaternion
  22634. * @param q defines the source quaternion
  22635. * @param result the quaternion the result will be stored in
  22636. * @returns the result quaternion
  22637. */
  22638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22639. /**
  22640. * Creates an identity quaternion
  22641. * @returns the identity quaternion
  22642. */
  22643. static Identity(): Quaternion;
  22644. /**
  22645. * Gets a boolean indicating if the given quaternion is identity
  22646. * @param quaternion defines the quaternion to check
  22647. * @returns true if the quaternion is identity
  22648. */
  22649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22650. /**
  22651. * Creates a quaternion from a rotation around an axis
  22652. * @param axis defines the axis to use
  22653. * @param angle defines the angle to use
  22654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22655. */
  22656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22657. /**
  22658. * Creates a rotation around an axis and stores it into the given quaternion
  22659. * @param axis defines the axis to use
  22660. * @param angle defines the angle to use
  22661. * @param result defines the target quaternion
  22662. * @returns the target quaternion
  22663. */
  22664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22665. /**
  22666. * Creates a new quaternion from data stored into an array
  22667. * @param array defines the data source
  22668. * @param offset defines the offset in the source array where the data starts
  22669. * @returns a new quaternion
  22670. */
  22671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22672. /**
  22673. * Create a quaternion from Euler rotation angles
  22674. * @param x Pitch
  22675. * @param y Yaw
  22676. * @param z Roll
  22677. * @returns the new Quaternion
  22678. */
  22679. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22680. /**
  22681. * Updates a quaternion from Euler rotation angles
  22682. * @param x Pitch
  22683. * @param y Yaw
  22684. * @param z Roll
  22685. * @param result the quaternion to store the result
  22686. * @returns the updated quaternion
  22687. */
  22688. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22689. /**
  22690. * Create a quaternion from Euler rotation vector
  22691. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22692. * @returns the new Quaternion
  22693. */
  22694. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22695. /**
  22696. * Updates a quaternion from Euler rotation vector
  22697. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22698. * @param result the quaternion to store the result
  22699. * @returns the updated quaternion
  22700. */
  22701. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22702. /**
  22703. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22704. * @param yaw defines the rotation around Y axis
  22705. * @param pitch defines the rotation around X axis
  22706. * @param roll defines the rotation around Z axis
  22707. * @returns the new quaternion
  22708. */
  22709. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22710. /**
  22711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22712. * @param yaw defines the rotation around Y axis
  22713. * @param pitch defines the rotation around X axis
  22714. * @param roll defines the rotation around Z axis
  22715. * @param result defines the target quaternion
  22716. */
  22717. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22718. /**
  22719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22720. * @param alpha defines the rotation around first axis
  22721. * @param beta defines the rotation around second axis
  22722. * @param gamma defines the rotation around third axis
  22723. * @returns the new quaternion
  22724. */
  22725. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22726. /**
  22727. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22728. * @param alpha defines the rotation around first axis
  22729. * @param beta defines the rotation around second axis
  22730. * @param gamma defines the rotation around third axis
  22731. * @param result defines the target quaternion
  22732. */
  22733. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22734. /**
  22735. * 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)
  22736. * @param axis1 defines the first axis
  22737. * @param axis2 defines the second axis
  22738. * @param axis3 defines the third axis
  22739. * @returns the new quaternion
  22740. */
  22741. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22742. /**
  22743. * 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
  22744. * @param axis1 defines the first axis
  22745. * @param axis2 defines the second axis
  22746. * @param axis3 defines the third axis
  22747. * @param ref defines the target quaternion
  22748. */
  22749. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22750. /**
  22751. * Interpolates between two quaternions
  22752. * @param left defines first quaternion
  22753. * @param right defines second quaternion
  22754. * @param amount defines the gradient to use
  22755. * @returns the new interpolated quaternion
  22756. */
  22757. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22758. /**
  22759. * Interpolates between two quaternions and stores it into a target quaternion
  22760. * @param left defines first quaternion
  22761. * @param right defines second quaternion
  22762. * @param amount defines the gradient to use
  22763. * @param result defines the target quaternion
  22764. */
  22765. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22766. /**
  22767. * Interpolate between two quaternions using Hermite interpolation
  22768. * @param value1 defines first quaternion
  22769. * @param tangent1 defines the incoming tangent
  22770. * @param value2 defines second quaternion
  22771. * @param tangent2 defines the outgoing tangent
  22772. * @param amount defines the target quaternion
  22773. * @returns the new interpolated quaternion
  22774. */
  22775. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22776. }
  22777. /**
  22778. * Class used to store matrix data (4x4)
  22779. */
  22780. class Matrix {
  22781. private static _updateFlagSeed;
  22782. private static _identityReadOnly;
  22783. private _isIdentity;
  22784. private _isIdentityDirty;
  22785. private _isIdentity3x2;
  22786. private _isIdentity3x2Dirty;
  22787. /**
  22788. * Gets the update flag of the matrix which is an unique number for the matrix.
  22789. * It will be incremented every time the matrix data change.
  22790. * You can use it to speed the comparison between two versions of the same matrix.
  22791. */
  22792. updateFlag: number;
  22793. private readonly _m;
  22794. /**
  22795. * Gets the internal data of the matrix
  22796. */
  22797. readonly m: DeepImmutable<Float32Array>;
  22798. /** @hidden */
  22799. _markAsUpdated(): void;
  22800. /** @hidden */
  22801. private _updateIdentityStatus;
  22802. /**
  22803. * Creates an empty matrix (filled with zeros)
  22804. */
  22805. constructor();
  22806. /**
  22807. * Check if the current matrix is identity
  22808. * @returns true is the matrix is the identity matrix
  22809. */
  22810. isIdentity(): boolean;
  22811. /**
  22812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22813. * @returns true is the matrix is the identity matrix
  22814. */
  22815. isIdentityAs3x2(): boolean;
  22816. /**
  22817. * Gets the determinant of the matrix
  22818. * @returns the matrix determinant
  22819. */
  22820. determinant(): number;
  22821. /**
  22822. * Returns the matrix as a Float32Array
  22823. * @returns the matrix underlying array
  22824. */
  22825. toArray(): DeepImmutable<Float32Array>;
  22826. /**
  22827. * Returns the matrix as a Float32Array
  22828. * @returns the matrix underlying array.
  22829. */
  22830. asArray(): DeepImmutable<Float32Array>;
  22831. /**
  22832. * Inverts the current matrix in place
  22833. * @returns the current inverted matrix
  22834. */
  22835. invert(): Matrix;
  22836. /**
  22837. * Sets all the matrix elements to zero
  22838. * @returns the current matrix
  22839. */
  22840. reset(): Matrix;
  22841. /**
  22842. * Adds the current matrix with a second one
  22843. * @param other defines the matrix to add
  22844. * @returns a new matrix as the addition of the current matrix and the given one
  22845. */
  22846. add(other: DeepImmutable<Matrix>): Matrix;
  22847. /**
  22848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22849. * @param other defines the matrix to add
  22850. * @param result defines the target matrix
  22851. * @returns the current matrix
  22852. */
  22853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22854. /**
  22855. * Adds in place the given matrix to the current matrix
  22856. * @param other defines the second operand
  22857. * @returns the current updated matrix
  22858. */
  22859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22860. /**
  22861. * Sets the given matrix to the current inverted Matrix
  22862. * @param other defines the target matrix
  22863. * @returns the unmodified current matrix
  22864. */
  22865. invertToRef(other: Matrix): Matrix;
  22866. /**
  22867. * add a value at the specified position in the current Matrix
  22868. * @param index the index of the value within the matrix. between 0 and 15.
  22869. * @param value the value to be added
  22870. * @returns the current updated matrix
  22871. */
  22872. addAtIndex(index: number, value: number): Matrix;
  22873. /**
  22874. * mutiply the specified position in the current Matrix by a value
  22875. * @param index the index of the value within the matrix. between 0 and 15.
  22876. * @param value the value to be added
  22877. * @returns the current updated matrix
  22878. */
  22879. multiplyAtIndex(index: number, value: number): Matrix;
  22880. /**
  22881. * Inserts the translation vector (using 3 floats) in the current matrix
  22882. * @param x defines the 1st component of the translation
  22883. * @param y defines the 2nd component of the translation
  22884. * @param z defines the 3rd component of the translation
  22885. * @returns the current updated matrix
  22886. */
  22887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22888. /**
  22889. * Inserts the translation vector in the current matrix
  22890. * @param vector3 defines the translation to insert
  22891. * @returns the current updated matrix
  22892. */
  22893. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22894. /**
  22895. * Gets the translation value of the current matrix
  22896. * @returns a new Vector3 as the extracted translation from the matrix
  22897. */
  22898. getTranslation(): Vector3;
  22899. /**
  22900. * Fill a Vector3 with the extracted translation from the matrix
  22901. * @param result defines the Vector3 where to store the translation
  22902. * @returns the current matrix
  22903. */
  22904. getTranslationToRef(result: Vector3): Matrix;
  22905. /**
  22906. * Remove rotation and scaling part from the matrix
  22907. * @returns the updated matrix
  22908. */
  22909. removeRotationAndScaling(): Matrix;
  22910. /**
  22911. * Multiply two matrices
  22912. * @param other defines the second operand
  22913. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22914. */
  22915. multiply(other: DeepImmutable<Matrix>): Matrix;
  22916. /**
  22917. * Copy the current matrix from the given one
  22918. * @param other defines the source matrix
  22919. * @returns the current updated matrix
  22920. */
  22921. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22922. /**
  22923. * Populates the given array from the starting index with the current matrix values
  22924. * @param array defines the target array
  22925. * @param offset defines the offset in the target array where to start storing values
  22926. * @returns the current matrix
  22927. */
  22928. copyToArray(array: Float32Array, offset?: number): Matrix;
  22929. /**
  22930. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22931. * @param other defines the second operand
  22932. * @param result defines the matrix where to store the multiplication
  22933. * @returns the current matrix
  22934. */
  22935. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22936. /**
  22937. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22938. * @param other defines the second operand
  22939. * @param result defines the array where to store the multiplication
  22940. * @param offset defines the offset in the target array where to start storing values
  22941. * @returns the current matrix
  22942. */
  22943. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22944. /**
  22945. * Check equality between this matrix and a second one
  22946. * @param value defines the second matrix to compare
  22947. * @returns true is the current matrix and the given one values are strictly equal
  22948. */
  22949. equals(value: DeepImmutable<Matrix>): boolean;
  22950. /**
  22951. * Clone the current matrix
  22952. * @returns a new matrix from the current matrix
  22953. */
  22954. clone(): Matrix;
  22955. /**
  22956. * Returns the name of the current matrix class
  22957. * @returns the string "Matrix"
  22958. */
  22959. getClassName(): string;
  22960. /**
  22961. * Gets the hash code of the current matrix
  22962. * @returns the hash code
  22963. */
  22964. getHashCode(): number;
  22965. /**
  22966. * Decomposes the current Matrix into a translation, rotation and scaling components
  22967. * @param scale defines the scale vector3 given as a reference to update
  22968. * @param rotation defines the rotation quaternion given as a reference to update
  22969. * @param translation defines the translation vector3 given as a reference to update
  22970. * @returns true if operation was successful
  22971. */
  22972. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22973. /**
  22974. * Gets specific row of the matrix
  22975. * @param index defines the number of the row to get
  22976. * @returns the index-th row of the current matrix as a new Vector4
  22977. */
  22978. getRow(index: number): Nullable<Vector4>;
  22979. /**
  22980. * Sets the index-th row of the current matrix to the vector4 values
  22981. * @param index defines the number of the row to set
  22982. * @param row defines the target vector4
  22983. * @returns the updated current matrix
  22984. */
  22985. setRow(index: number, row: Vector4): Matrix;
  22986. /**
  22987. * Compute the transpose of the matrix
  22988. * @returns the new transposed matrix
  22989. */
  22990. transpose(): Matrix;
  22991. /**
  22992. * Compute the transpose of the matrix and store it in a given matrix
  22993. * @param result defines the target matrix
  22994. * @returns the current matrix
  22995. */
  22996. transposeToRef(result: Matrix): Matrix;
  22997. /**
  22998. * Sets the index-th row of the current matrix with the given 4 x float values
  22999. * @param index defines the row index
  23000. * @param x defines the x component to set
  23001. * @param y defines the y component to set
  23002. * @param z defines the z component to set
  23003. * @param w defines the w component to set
  23004. * @returns the updated current matrix
  23005. */
  23006. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23007. /**
  23008. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23009. * @param scale defines the scale factor
  23010. * @returns a new matrix
  23011. */
  23012. scale(scale: number): Matrix;
  23013. /**
  23014. * Scale the current matrix values by a factor to a given result matrix
  23015. * @param scale defines the scale factor
  23016. * @param result defines the matrix to store the result
  23017. * @returns the current matrix
  23018. */
  23019. scaleToRef(scale: number, result: Matrix): Matrix;
  23020. /**
  23021. * Scale the current matrix values by a factor and add the result to a given matrix
  23022. * @param scale defines the scale factor
  23023. * @param result defines the Matrix to store the result
  23024. * @returns the current matrix
  23025. */
  23026. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23027. /**
  23028. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23029. * @param ref matrix to store the result
  23030. */
  23031. toNormalMatrix(ref: Matrix): void;
  23032. /**
  23033. * Gets only rotation part of the current matrix
  23034. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23035. */
  23036. getRotationMatrix(): Matrix;
  23037. /**
  23038. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23039. * @param result defines the target matrix to store data to
  23040. * @returns the current matrix
  23041. */
  23042. getRotationMatrixToRef(result: Matrix): Matrix;
  23043. /**
  23044. * Toggles model matrix from being right handed to left handed in place and vice versa
  23045. */
  23046. toggleModelMatrixHandInPlace(): void;
  23047. /**
  23048. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23049. */
  23050. toggleProjectionMatrixHandInPlace(): void;
  23051. /**
  23052. * Creates a matrix from an array
  23053. * @param array defines the source array
  23054. * @param offset defines an offset in the source array
  23055. * @returns a new Matrix set from the starting index of the given array
  23056. */
  23057. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23058. /**
  23059. * Copy the content of an array into a given matrix
  23060. * @param array defines the source array
  23061. * @param offset defines an offset in the source array
  23062. * @param result defines the target matrix
  23063. */
  23064. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23065. /**
  23066. * Stores an array into a matrix after having multiplied each component by a given factor
  23067. * @param array defines the source array
  23068. * @param offset defines the offset in the source array
  23069. * @param scale defines the scaling factor
  23070. * @param result defines the target matrix
  23071. */
  23072. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23073. /**
  23074. * Gets an identity matrix that must not be updated
  23075. */
  23076. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23077. /**
  23078. * Stores a list of values (16) inside a given matrix
  23079. * @param initialM11 defines 1st value of 1st row
  23080. * @param initialM12 defines 2nd value of 1st row
  23081. * @param initialM13 defines 3rd value of 1st row
  23082. * @param initialM14 defines 4th value of 1st row
  23083. * @param initialM21 defines 1st value of 2nd row
  23084. * @param initialM22 defines 2nd value of 2nd row
  23085. * @param initialM23 defines 3rd value of 2nd row
  23086. * @param initialM24 defines 4th value of 2nd row
  23087. * @param initialM31 defines 1st value of 3rd row
  23088. * @param initialM32 defines 2nd value of 3rd row
  23089. * @param initialM33 defines 3rd value of 3rd row
  23090. * @param initialM34 defines 4th value of 3rd row
  23091. * @param initialM41 defines 1st value of 4th row
  23092. * @param initialM42 defines 2nd value of 4th row
  23093. * @param initialM43 defines 3rd value of 4th row
  23094. * @param initialM44 defines 4th value of 4th row
  23095. * @param result defines the target matrix
  23096. */
  23097. 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;
  23098. /**
  23099. * Creates new matrix from a list of values (16)
  23100. * @param initialM11 defines 1st value of 1st row
  23101. * @param initialM12 defines 2nd value of 1st row
  23102. * @param initialM13 defines 3rd value of 1st row
  23103. * @param initialM14 defines 4th value of 1st row
  23104. * @param initialM21 defines 1st value of 2nd row
  23105. * @param initialM22 defines 2nd value of 2nd row
  23106. * @param initialM23 defines 3rd value of 2nd row
  23107. * @param initialM24 defines 4th value of 2nd row
  23108. * @param initialM31 defines 1st value of 3rd row
  23109. * @param initialM32 defines 2nd value of 3rd row
  23110. * @param initialM33 defines 3rd value of 3rd row
  23111. * @param initialM34 defines 4th value of 3rd row
  23112. * @param initialM41 defines 1st value of 4th row
  23113. * @param initialM42 defines 2nd value of 4th row
  23114. * @param initialM43 defines 3rd value of 4th row
  23115. * @param initialM44 defines 4th value of 4th row
  23116. * @returns the new matrix
  23117. */
  23118. 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;
  23119. /**
  23120. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23121. * @param scale defines the scale vector3
  23122. * @param rotation defines the rotation quaternion
  23123. * @param translation defines the translation vector3
  23124. * @returns a new matrix
  23125. */
  23126. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23127. /**
  23128. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23129. * @param scale defines the scale vector3
  23130. * @param rotation defines the rotation quaternion
  23131. * @param translation defines the translation vector3
  23132. * @param result defines the target matrix
  23133. */
  23134. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23135. /**
  23136. * Creates a new identity matrix
  23137. * @returns a new identity matrix
  23138. */
  23139. static Identity(): Matrix;
  23140. /**
  23141. * Creates a new identity matrix and stores the result in a given matrix
  23142. * @param result defines the target matrix
  23143. */
  23144. static IdentityToRef(result: Matrix): void;
  23145. /**
  23146. * Creates a new zero matrix
  23147. * @returns a new zero matrix
  23148. */
  23149. static Zero(): Matrix;
  23150. /**
  23151. * Creates a new rotation matrix for "angle" radians around the X axis
  23152. * @param angle defines the angle (in radians) to use
  23153. * @return the new matrix
  23154. */
  23155. static RotationX(angle: number): Matrix;
  23156. /**
  23157. * Creates a new matrix as the invert of a given matrix
  23158. * @param source defines the source matrix
  23159. * @returns the new matrix
  23160. */
  23161. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23162. /**
  23163. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23164. * @param angle defines the angle (in radians) to use
  23165. * @param result defines the target matrix
  23166. */
  23167. static RotationXToRef(angle: number, result: Matrix): void;
  23168. /**
  23169. * Creates a new rotation matrix for "angle" radians around the Y axis
  23170. * @param angle defines the angle (in radians) to use
  23171. * @return the new matrix
  23172. */
  23173. static RotationY(angle: number): Matrix;
  23174. /**
  23175. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23176. * @param angle defines the angle (in radians) to use
  23177. * @param result defines the target matrix
  23178. */
  23179. static RotationYToRef(angle: number, result: Matrix): void;
  23180. /**
  23181. * Creates a new rotation matrix for "angle" radians around the Z axis
  23182. * @param angle defines the angle (in radians) to use
  23183. * @return the new matrix
  23184. */
  23185. static RotationZ(angle: number): Matrix;
  23186. /**
  23187. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23188. * @param angle defines the angle (in radians) to use
  23189. * @param result defines the target matrix
  23190. */
  23191. static RotationZToRef(angle: number, result: Matrix): void;
  23192. /**
  23193. * Creates a new rotation matrix for "angle" radians around the given axis
  23194. * @param axis defines the axis to use
  23195. * @param angle defines the angle (in radians) to use
  23196. * @return the new matrix
  23197. */
  23198. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23199. /**
  23200. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23201. * @param axis defines the axis to use
  23202. * @param angle defines the angle (in radians) to use
  23203. * @param result defines the target matrix
  23204. */
  23205. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23206. /**
  23207. * Creates a rotation matrix
  23208. * @param yaw defines the yaw angle in radians (Y axis)
  23209. * @param pitch defines the pitch angle in radians (X axis)
  23210. * @param roll defines the roll angle in radians (X axis)
  23211. * @returns the new rotation matrix
  23212. */
  23213. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23214. /**
  23215. * Creates a rotation matrix and stores it in a given matrix
  23216. * @param yaw defines the yaw angle in radians (Y axis)
  23217. * @param pitch defines the pitch angle in radians (X axis)
  23218. * @param roll defines the roll angle in radians (X axis)
  23219. * @param result defines the target matrix
  23220. */
  23221. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23222. /**
  23223. * Creates a scaling matrix
  23224. * @param x defines the scale factor on X axis
  23225. * @param y defines the scale factor on Y axis
  23226. * @param z defines the scale factor on Z axis
  23227. * @returns the new matrix
  23228. */
  23229. static Scaling(x: number, y: number, z: number): Matrix;
  23230. /**
  23231. * Creates a scaling matrix and stores it in a given matrix
  23232. * @param x defines the scale factor on X axis
  23233. * @param y defines the scale factor on Y axis
  23234. * @param z defines the scale factor on Z axis
  23235. * @param result defines the target matrix
  23236. */
  23237. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23238. /**
  23239. * Creates a translation matrix
  23240. * @param x defines the translation on X axis
  23241. * @param y defines the translation on Y axis
  23242. * @param z defines the translationon Z axis
  23243. * @returns the new matrix
  23244. */
  23245. static Translation(x: number, y: number, z: number): Matrix;
  23246. /**
  23247. * Creates a translation matrix and stores it in a given matrix
  23248. * @param x defines the translation on X axis
  23249. * @param y defines the translation on Y axis
  23250. * @param z defines the translationon Z axis
  23251. * @param result defines the target matrix
  23252. */
  23253. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23254. /**
  23255. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23256. * @param startValue defines the start value
  23257. * @param endValue defines the end value
  23258. * @param gradient defines the gradient factor
  23259. * @returns the new matrix
  23260. */
  23261. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23262. /**
  23263. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23264. * @param startValue defines the start value
  23265. * @param endValue defines the end value
  23266. * @param gradient defines the gradient factor
  23267. * @param result defines the Matrix object where to store data
  23268. */
  23269. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23270. /**
  23271. * Builds a new matrix whose values are computed by:
  23272. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23273. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23274. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23275. * @param startValue defines the first matrix
  23276. * @param endValue defines the second matrix
  23277. * @param gradient defines the gradient between the two matrices
  23278. * @returns the new matrix
  23279. */
  23280. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23281. /**
  23282. * Update a matrix to values which are computed by:
  23283. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23284. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23285. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23286. * @param startValue defines the first matrix
  23287. * @param endValue defines the second matrix
  23288. * @param gradient defines the gradient between the two matrices
  23289. * @param result defines the target matrix
  23290. */
  23291. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23292. /**
  23293. * 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"
  23294. * This function works in left handed mode
  23295. * @param eye defines the final position of the entity
  23296. * @param target defines where the entity should look at
  23297. * @param up defines the up vector for the entity
  23298. * @returns the new matrix
  23299. */
  23300. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23301. /**
  23302. * 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".
  23303. * This function works in left handed mode
  23304. * @param eye defines the final position of the entity
  23305. * @param target defines where the entity should look at
  23306. * @param up defines the up vector for the entity
  23307. * @param result defines the target matrix
  23308. */
  23309. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23310. /**
  23311. * 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"
  23312. * This function works in right handed mode
  23313. * @param eye defines the final position of the entity
  23314. * @param target defines where the entity should look at
  23315. * @param up defines the up vector for the entity
  23316. * @returns the new matrix
  23317. */
  23318. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23319. /**
  23320. * 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".
  23321. * This function works in right handed mode
  23322. * @param eye defines the final position of the entity
  23323. * @param target defines where the entity should look at
  23324. * @param up defines the up vector for the entity
  23325. * @param result defines the target matrix
  23326. */
  23327. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23328. /**
  23329. * Create a left-handed orthographic projection matrix
  23330. * @param width defines the viewport width
  23331. * @param height defines the viewport height
  23332. * @param znear defines the near clip plane
  23333. * @param zfar defines the far clip plane
  23334. * @returns a new matrix as a left-handed orthographic projection matrix
  23335. */
  23336. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23337. /**
  23338. * Store a left-handed orthographic projection to a given matrix
  23339. * @param width defines the viewport width
  23340. * @param height defines the viewport height
  23341. * @param znear defines the near clip plane
  23342. * @param zfar defines the far clip plane
  23343. * @param result defines the target matrix
  23344. */
  23345. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23346. /**
  23347. * Create a left-handed orthographic projection matrix
  23348. * @param left defines the viewport left coordinate
  23349. * @param right defines the viewport right coordinate
  23350. * @param bottom defines the viewport bottom coordinate
  23351. * @param top defines the viewport top coordinate
  23352. * @param znear defines the near clip plane
  23353. * @param zfar defines the far clip plane
  23354. * @returns a new matrix as a left-handed orthographic projection matrix
  23355. */
  23356. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23357. /**
  23358. * Stores a left-handed orthographic projection into a given matrix
  23359. * @param left defines the viewport left coordinate
  23360. * @param right defines the viewport right coordinate
  23361. * @param bottom defines the viewport bottom coordinate
  23362. * @param top defines the viewport top coordinate
  23363. * @param znear defines the near clip plane
  23364. * @param zfar defines the far clip plane
  23365. * @param result defines the target matrix
  23366. */
  23367. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23368. /**
  23369. * Creates a right-handed orthographic projection matrix
  23370. * @param left defines the viewport left coordinate
  23371. * @param right defines the viewport right coordinate
  23372. * @param bottom defines the viewport bottom coordinate
  23373. * @param top defines the viewport top coordinate
  23374. * @param znear defines the near clip plane
  23375. * @param zfar defines the far clip plane
  23376. * @returns a new matrix as a right-handed orthographic projection matrix
  23377. */
  23378. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23379. /**
  23380. * Stores a right-handed orthographic projection into a given matrix
  23381. * @param left defines the viewport left coordinate
  23382. * @param right defines the viewport right coordinate
  23383. * @param bottom defines the viewport bottom coordinate
  23384. * @param top defines the viewport top coordinate
  23385. * @param znear defines the near clip plane
  23386. * @param zfar defines the far clip plane
  23387. * @param result defines the target matrix
  23388. */
  23389. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23390. /**
  23391. * Creates a left-handed perspective projection matrix
  23392. * @param width defines the viewport width
  23393. * @param height defines the viewport height
  23394. * @param znear defines the near clip plane
  23395. * @param zfar defines the far clip plane
  23396. * @returns a new matrix as a left-handed perspective projection matrix
  23397. */
  23398. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23399. /**
  23400. * Creates a left-handed perspective projection matrix
  23401. * @param fov defines the horizontal field of view
  23402. * @param aspect defines the aspect ratio
  23403. * @param znear defines the near clip plane
  23404. * @param zfar defines the far clip plane
  23405. * @returns a new matrix as a left-handed perspective projection matrix
  23406. */
  23407. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23408. /**
  23409. * Stores a left-handed perspective projection into a given matrix
  23410. * @param fov defines the horizontal field of view
  23411. * @param aspect defines the aspect ratio
  23412. * @param znear defines the near clip plane
  23413. * @param zfar defines the far clip plane
  23414. * @param result defines the target matrix
  23415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23416. */
  23417. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23418. /**
  23419. * Creates a right-handed perspective projection matrix
  23420. * @param fov defines the horizontal field of view
  23421. * @param aspect defines the aspect ratio
  23422. * @param znear defines the near clip plane
  23423. * @param zfar defines the far clip plane
  23424. * @returns a new matrix as a right-handed perspective projection matrix
  23425. */
  23426. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23427. /**
  23428. * Stores a right-handed perspective projection into a given matrix
  23429. * @param fov defines the horizontal field of view
  23430. * @param aspect defines the aspect ratio
  23431. * @param znear defines the near clip plane
  23432. * @param zfar defines the far clip plane
  23433. * @param result defines the target matrix
  23434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23435. */
  23436. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23437. /**
  23438. * Stores a perspective projection for WebVR info a given matrix
  23439. * @param fov defines the field of view
  23440. * @param znear defines the near clip plane
  23441. * @param zfar defines the far clip plane
  23442. * @param result defines the target matrix
  23443. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23444. */
  23445. static PerspectiveFovWebVRToRef(fov: {
  23446. upDegrees: number;
  23447. downDegrees: number;
  23448. leftDegrees: number;
  23449. rightDegrees: number;
  23450. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23451. /**
  23452. * Computes a complete transformation matrix
  23453. * @param viewport defines the viewport to use
  23454. * @param world defines the world matrix
  23455. * @param view defines the view matrix
  23456. * @param projection defines the projection matrix
  23457. * @param zmin defines the near clip plane
  23458. * @param zmax defines the far clip plane
  23459. * @returns the transformation matrix
  23460. */
  23461. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23462. /**
  23463. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23464. * @param matrix defines the matrix to use
  23465. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23466. */
  23467. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23468. /**
  23469. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23470. * @param matrix defines the matrix to use
  23471. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23472. */
  23473. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23474. /**
  23475. * Compute the transpose of a given matrix
  23476. * @param matrix defines the matrix to transpose
  23477. * @returns the new matrix
  23478. */
  23479. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23480. /**
  23481. * Compute the transpose of a matrix and store it in a target matrix
  23482. * @param matrix defines the matrix to transpose
  23483. * @param result defines the target matrix
  23484. */
  23485. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23486. /**
  23487. * Computes a reflection matrix from a plane
  23488. * @param plane defines the reflection plane
  23489. * @returns a new matrix
  23490. */
  23491. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23492. /**
  23493. * Computes a reflection matrix from a plane
  23494. * @param plane defines the reflection plane
  23495. * @param result defines the target matrix
  23496. */
  23497. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23498. /**
  23499. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23500. * @param xaxis defines the value of the 1st axis
  23501. * @param yaxis defines the value of the 2nd axis
  23502. * @param zaxis defines the value of the 3rd axis
  23503. * @param result defines the target matrix
  23504. */
  23505. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23506. /**
  23507. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23508. * @param quat defines the quaternion to use
  23509. * @param result defines the target matrix
  23510. */
  23511. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23512. }
  23513. /**
  23514. * Represens a plane by the equation ax + by + cz + d = 0
  23515. */
  23516. class Plane {
  23517. /**
  23518. * Normal of the plane (a,b,c)
  23519. */
  23520. normal: Vector3;
  23521. /**
  23522. * d component of the plane
  23523. */
  23524. d: number;
  23525. /**
  23526. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23527. * @param a a component of the plane
  23528. * @param b b component of the plane
  23529. * @param c c component of the plane
  23530. * @param d d component of the plane
  23531. */
  23532. constructor(a: number, b: number, c: number, d: number);
  23533. /**
  23534. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23535. */
  23536. asArray(): number[];
  23537. /**
  23538. * @returns a new plane copied from the current Plane.
  23539. */
  23540. clone(): Plane;
  23541. /**
  23542. * @returns the string "Plane".
  23543. */
  23544. getClassName(): string;
  23545. /**
  23546. * @returns the Plane hash code.
  23547. */
  23548. getHashCode(): number;
  23549. /**
  23550. * Normalize the current Plane in place.
  23551. * @returns the updated Plane.
  23552. */
  23553. normalize(): Plane;
  23554. /**
  23555. * Applies a transformation the plane and returns the result
  23556. * @param transformation the transformation matrix to be applied to the plane
  23557. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23558. */
  23559. transform(transformation: DeepImmutable<Matrix>): Plane;
  23560. /**
  23561. * Calcualtte the dot product between the point and the plane normal
  23562. * @param point point to calculate the dot product with
  23563. * @returns the dot product (float) of the point coordinates and the plane normal.
  23564. */
  23565. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23566. /**
  23567. * Updates the current Plane from the plane defined by the three given points.
  23568. * @param point1 one of the points used to contruct the plane
  23569. * @param point2 one of the points used to contruct the plane
  23570. * @param point3 one of the points used to contruct the plane
  23571. * @returns the updated Plane.
  23572. */
  23573. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23574. /**
  23575. * Checks if the plane is facing a given direction
  23576. * @param direction the direction to check if the plane is facing
  23577. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23578. * @returns True is the vector "direction" is the same side than the plane normal.
  23579. */
  23580. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23581. /**
  23582. * Calculates the distance to a point
  23583. * @param point point to calculate distance to
  23584. * @returns the signed distance (float) from the given point to the Plane.
  23585. */
  23586. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23587. /**
  23588. * Creates a plane from an array
  23589. * @param array the array to create a plane from
  23590. * @returns a new Plane from the given array.
  23591. */
  23592. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23593. /**
  23594. * Creates a plane from three points
  23595. * @param point1 point used to create the plane
  23596. * @param point2 point used to create the plane
  23597. * @param point3 point used to create the plane
  23598. * @returns a new Plane defined by the three given points.
  23599. */
  23600. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23601. /**
  23602. * Creates a plane from an origin point and a normal
  23603. * @param origin origin of the plane to be constructed
  23604. * @param normal normal of the plane to be constructed
  23605. * @returns a new Plane the normal vector to this plane at the given origin point.
  23606. * Note : the vector "normal" is updated because normalized.
  23607. */
  23608. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23609. /**
  23610. * Calculates the distance from a plane and a point
  23611. * @param origin origin of the plane to be constructed
  23612. * @param normal normal of the plane to be constructed
  23613. * @param point point to calculate distance to
  23614. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23615. */
  23616. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23617. }
  23618. /**
  23619. * Class used to represent a viewport on screen
  23620. */
  23621. class Viewport {
  23622. /** viewport left coordinate */
  23623. x: number;
  23624. /** viewport top coordinate */
  23625. y: number;
  23626. /**viewport width */
  23627. width: number;
  23628. /** viewport height */
  23629. height: number;
  23630. /**
  23631. * Creates a Viewport object located at (x, y) and sized (width, height)
  23632. * @param x defines viewport left coordinate
  23633. * @param y defines viewport top coordinate
  23634. * @param width defines the viewport width
  23635. * @param height defines the viewport height
  23636. */
  23637. constructor(
  23638. /** viewport left coordinate */
  23639. x: number,
  23640. /** viewport top coordinate */
  23641. y: number,
  23642. /**viewport width */
  23643. width: number,
  23644. /** viewport height */
  23645. height: number);
  23646. /**
  23647. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23648. * @param renderWidthOrEngine defines either an engine or the rendering width
  23649. * @param renderHeight defines the rendering height
  23650. * @returns a new Viewport
  23651. */
  23652. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23653. /**
  23654. * Returns a new Viewport copied from the current one
  23655. * @returns a new Viewport
  23656. */
  23657. clone(): Viewport;
  23658. }
  23659. /**
  23660. * Reprasents a camera frustum
  23661. */
  23662. class Frustum {
  23663. /**
  23664. * Gets the planes representing the frustum
  23665. * @param transform matrix to be applied to the returned planes
  23666. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23667. */
  23668. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23669. /**
  23670. * Gets the near frustum plane transformed by the transform matrix
  23671. * @param transform transformation matrix to be applied to the resulting frustum plane
  23672. * @param frustumPlane the resuling frustum plane
  23673. */
  23674. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23675. /**
  23676. * Gets the far frustum plane transformed by the transform matrix
  23677. * @param transform transformation matrix to be applied to the resulting frustum plane
  23678. * @param frustumPlane the resuling frustum plane
  23679. */
  23680. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23681. /**
  23682. * Gets the left frustum plane transformed by the transform matrix
  23683. * @param transform transformation matrix to be applied to the resulting frustum plane
  23684. * @param frustumPlane the resuling frustum plane
  23685. */
  23686. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23687. /**
  23688. * Gets the right frustum plane transformed by the transform matrix
  23689. * @param transform transformation matrix to be applied to the resulting frustum plane
  23690. * @param frustumPlane the resuling frustum plane
  23691. */
  23692. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23693. /**
  23694. * Gets the top frustum plane transformed by the transform matrix
  23695. * @param transform transformation matrix to be applied to the resulting frustum plane
  23696. * @param frustumPlane the resuling frustum plane
  23697. */
  23698. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23699. /**
  23700. * Gets the bottom frustum plane transformed by the transform matrix
  23701. * @param transform transformation matrix to be applied to the resulting frustum plane
  23702. * @param frustumPlane the resuling frustum plane
  23703. */
  23704. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23705. /**
  23706. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23707. * @param transform transformation matrix to be applied to the resulting frustum planes
  23708. * @param frustumPlanes the resuling frustum planes
  23709. */
  23710. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23711. }
  23712. /** Defines supported spaces */
  23713. enum Space {
  23714. /** Local (object) space */
  23715. LOCAL = 0,
  23716. /** World space */
  23717. WORLD = 1,
  23718. /** Bone space */
  23719. BONE = 2
  23720. }
  23721. /** Defines the 3 main axes */
  23722. class Axis {
  23723. /** X axis */
  23724. static X: Vector3;
  23725. /** Y axis */
  23726. static Y: Vector3;
  23727. /** Z axis */
  23728. static Z: Vector3;
  23729. }
  23730. /** Class used to represent a Bezier curve */
  23731. class BezierCurve {
  23732. /**
  23733. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23734. * @param t defines the time
  23735. * @param x1 defines the left coordinate on X axis
  23736. * @param y1 defines the left coordinate on Y axis
  23737. * @param x2 defines the right coordinate on X axis
  23738. * @param y2 defines the right coordinate on Y axis
  23739. * @returns the interpolated value
  23740. */
  23741. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23742. }
  23743. /**
  23744. * Defines potential orientation for back face culling
  23745. */
  23746. enum Orientation {
  23747. /**
  23748. * Clockwise
  23749. */
  23750. CW = 0,
  23751. /** Counter clockwise */
  23752. CCW = 1
  23753. }
  23754. /**
  23755. * Defines angle representation
  23756. */
  23757. class Angle {
  23758. private _radians;
  23759. /**
  23760. * Creates an Angle object of "radians" radians (float).
  23761. */
  23762. constructor(radians: number);
  23763. /**
  23764. * Get value in degrees
  23765. * @returns the Angle value in degrees (float)
  23766. */
  23767. degrees(): number;
  23768. /**
  23769. * Get value in radians
  23770. * @returns the Angle value in radians (float)
  23771. */
  23772. radians(): number;
  23773. /**
  23774. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23775. * @param a defines first vector
  23776. * @param b defines second vector
  23777. * @returns a new Angle
  23778. */
  23779. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23780. /**
  23781. * Gets a new Angle object from the given float in radians
  23782. * @param radians defines the angle value in radians
  23783. * @returns a new Angle
  23784. */
  23785. static FromRadians(radians: number): Angle;
  23786. /**
  23787. * Gets a new Angle object from the given float in degrees
  23788. * @param degrees defines the angle value in degrees
  23789. * @returns a new Angle
  23790. */
  23791. static FromDegrees(degrees: number): Angle;
  23792. }
  23793. /**
  23794. * This represents an arc in a 2d space.
  23795. */
  23796. class Arc2 {
  23797. /** Defines the start point of the arc */
  23798. startPoint: Vector2;
  23799. /** Defines the mid point of the arc */
  23800. midPoint: Vector2;
  23801. /** Defines the end point of the arc */
  23802. endPoint: Vector2;
  23803. /**
  23804. * Defines the center point of the arc.
  23805. */
  23806. centerPoint: Vector2;
  23807. /**
  23808. * Defines the radius of the arc.
  23809. */
  23810. radius: number;
  23811. /**
  23812. * Defines the angle of the arc (from mid point to end point).
  23813. */
  23814. angle: Angle;
  23815. /**
  23816. * Defines the start angle of the arc (from start point to middle point).
  23817. */
  23818. startAngle: Angle;
  23819. /**
  23820. * Defines the orientation of the arc (clock wise/counter clock wise).
  23821. */
  23822. orientation: Orientation;
  23823. /**
  23824. * Creates an Arc object from the three given points : start, middle and end.
  23825. * @param startPoint Defines the start point of the arc
  23826. * @param midPoint Defines the midlle point of the arc
  23827. * @param endPoint Defines the end point of the arc
  23828. */
  23829. constructor(
  23830. /** Defines the start point of the arc */
  23831. startPoint: Vector2,
  23832. /** Defines the mid point of the arc */
  23833. midPoint: Vector2,
  23834. /** Defines the end point of the arc */
  23835. endPoint: Vector2);
  23836. }
  23837. /**
  23838. * Represents a 2D path made up of multiple 2D points
  23839. */
  23840. class Path2 {
  23841. private _points;
  23842. private _length;
  23843. /**
  23844. * If the path start and end point are the same
  23845. */
  23846. closed: boolean;
  23847. /**
  23848. * Creates a Path2 object from the starting 2D coordinates x and y.
  23849. * @param x the starting points x value
  23850. * @param y the starting points y value
  23851. */
  23852. constructor(x: number, y: number);
  23853. /**
  23854. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23855. * @param x the added points x value
  23856. * @param y the added points y value
  23857. * @returns the updated Path2.
  23858. */
  23859. addLineTo(x: number, y: number): Path2;
  23860. /**
  23861. * 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.
  23862. * @param midX middle point x value
  23863. * @param midY middle point y value
  23864. * @param endX end point x value
  23865. * @param endY end point y value
  23866. * @param numberOfSegments (default: 36)
  23867. * @returns the updated Path2.
  23868. */
  23869. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23870. /**
  23871. * Closes the Path2.
  23872. * @returns the Path2.
  23873. */
  23874. close(): Path2;
  23875. /**
  23876. * Gets the sum of the distance between each sequential point in the path
  23877. * @returns the Path2 total length (float).
  23878. */
  23879. length(): number;
  23880. /**
  23881. * Gets the points which construct the path
  23882. * @returns the Path2 internal array of points.
  23883. */
  23884. getPoints(): Vector2[];
  23885. /**
  23886. * Retreives the point at the distance aways from the starting point
  23887. * @param normalizedLengthPosition the length along the path to retreive the point from
  23888. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23889. */
  23890. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23891. /**
  23892. * Creates a new path starting from an x and y position
  23893. * @param x starting x value
  23894. * @param y starting y value
  23895. * @returns a new Path2 starting at the coordinates (x, y).
  23896. */
  23897. static StartingAt(x: number, y: number): Path2;
  23898. }
  23899. /**
  23900. * Represents a 3D path made up of multiple 3D points
  23901. */
  23902. class Path3D {
  23903. /**
  23904. * an array of Vector3, the curve axis of the Path3D
  23905. */
  23906. path: Vector3[];
  23907. private _curve;
  23908. private _distances;
  23909. private _tangents;
  23910. private _normals;
  23911. private _binormals;
  23912. private _raw;
  23913. /**
  23914. * new Path3D(path, normal, raw)
  23915. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23916. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23917. * @param path an array of Vector3, the curve axis of the Path3D
  23918. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23919. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23920. */
  23921. constructor(
  23922. /**
  23923. * an array of Vector3, the curve axis of the Path3D
  23924. */
  23925. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23926. /**
  23927. * Returns the Path3D array of successive Vector3 designing its curve.
  23928. * @returns the Path3D array of successive Vector3 designing its curve.
  23929. */
  23930. getCurve(): Vector3[];
  23931. /**
  23932. * Returns an array populated with tangent vectors on each Path3D curve point.
  23933. * @returns an array populated with tangent vectors on each Path3D curve point.
  23934. */
  23935. getTangents(): Vector3[];
  23936. /**
  23937. * Returns an array populated with normal vectors on each Path3D curve point.
  23938. * @returns an array populated with normal vectors on each Path3D curve point.
  23939. */
  23940. getNormals(): Vector3[];
  23941. /**
  23942. * Returns an array populated with binormal vectors on each Path3D curve point.
  23943. * @returns an array populated with binormal vectors on each Path3D curve point.
  23944. */
  23945. getBinormals(): Vector3[];
  23946. /**
  23947. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23948. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23949. */
  23950. getDistances(): number[];
  23951. /**
  23952. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23953. * @param path path which all values are copied into the curves points
  23954. * @param firstNormal which should be projected onto the curve
  23955. * @returns the same object updated.
  23956. */
  23957. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23958. private _compute;
  23959. private _getFirstNonNullVector;
  23960. private _getLastNonNullVector;
  23961. private _normalVector;
  23962. }
  23963. /**
  23964. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23965. * A Curve3 is designed from a series of successive Vector3.
  23966. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23967. */
  23968. class Curve3 {
  23969. private _points;
  23970. private _length;
  23971. /**
  23972. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  23973. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23974. * @param v1 (Vector3) the control point
  23975. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23976. * @param nbPoints (integer) the wanted number of points in the curve
  23977. * @returns the created Curve3
  23978. */
  23979. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23980. /**
  23981. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  23982. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23983. * @param v1 (Vector3) the first control point
  23984. * @param v2 (Vector3) the second control point
  23985. * @param v3 (Vector3) the end point of the Cubic Bezier
  23986. * @param nbPoints (integer) the wanted number of points in the curve
  23987. * @returns the created Curve3
  23988. */
  23989. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23990. /**
  23991. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  23992. * @param p1 (Vector3) the origin point of the Hermite Spline
  23993. * @param t1 (Vector3) the tangent vector at the origin point
  23994. * @param p2 (Vector3) the end point of the Hermite Spline
  23995. * @param t2 (Vector3) the tangent vector at the end point
  23996. * @param nbPoints (integer) the wanted number of points in the curve
  23997. * @returns the created Curve3
  23998. */
  23999. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24000. /**
  24001. * Returns a Curve3 object along a CatmullRom Spline curve :
  24002. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24003. * @param nbPoints (integer) the wanted number of points between each curve control points
  24004. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24005. * @returns the created Curve3
  24006. */
  24007. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24008. /**
  24009. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24010. * A Curve3 is designed from a series of successive Vector3.
  24011. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24012. * @param points points which make up the curve
  24013. */
  24014. constructor(points: Vector3[]);
  24015. /**
  24016. * @returns the Curve3 stored array of successive Vector3
  24017. */
  24018. getPoints(): Vector3[];
  24019. /**
  24020. * @returns the computed length (float) of the curve.
  24021. */
  24022. length(): number;
  24023. /**
  24024. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24025. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24026. * curveA and curveB keep unchanged.
  24027. * @param curve the curve to continue from this curve
  24028. * @returns the newly constructed curve
  24029. */
  24030. continue(curve: DeepImmutable<Curve3>): Curve3;
  24031. private _computeLength;
  24032. }
  24033. /**
  24034. * Contains position and normal vectors for a vertex
  24035. */
  24036. class PositionNormalVertex {
  24037. /** the position of the vertex (defaut: 0,0,0) */
  24038. position: Vector3;
  24039. /** the normal of the vertex (defaut: 0,1,0) */
  24040. normal: Vector3;
  24041. /**
  24042. * Creates a PositionNormalVertex
  24043. * @param position the position of the vertex (defaut: 0,0,0)
  24044. * @param normal the normal of the vertex (defaut: 0,1,0)
  24045. */
  24046. constructor(
  24047. /** the position of the vertex (defaut: 0,0,0) */
  24048. position?: Vector3,
  24049. /** the normal of the vertex (defaut: 0,1,0) */
  24050. normal?: Vector3);
  24051. /**
  24052. * Clones the PositionNormalVertex
  24053. * @returns the cloned PositionNormalVertex
  24054. */
  24055. clone(): PositionNormalVertex;
  24056. }
  24057. /**
  24058. * Contains position, normal and uv vectors for a vertex
  24059. */
  24060. class PositionNormalTextureVertex {
  24061. /** the position of the vertex (defaut: 0,0,0) */
  24062. position: Vector3;
  24063. /** the normal of the vertex (defaut: 0,1,0) */
  24064. normal: Vector3;
  24065. /** the uv of the vertex (default: 0,0) */
  24066. uv: Vector2;
  24067. /**
  24068. * Creates a PositionNormalTextureVertex
  24069. * @param position the position of the vertex (defaut: 0,0,0)
  24070. * @param normal the normal of the vertex (defaut: 0,1,0)
  24071. * @param uv the uv of the vertex (default: 0,0)
  24072. */
  24073. constructor(
  24074. /** the position of the vertex (defaut: 0,0,0) */
  24075. position?: Vector3,
  24076. /** the normal of the vertex (defaut: 0,1,0) */
  24077. normal?: Vector3,
  24078. /** the uv of the vertex (default: 0,0) */
  24079. uv?: Vector2);
  24080. /**
  24081. * Clones the PositionNormalTextureVertex
  24082. * @returns the cloned PositionNormalTextureVertex
  24083. */
  24084. clone(): PositionNormalTextureVertex;
  24085. }
  24086. /**
  24087. * @hidden
  24088. */
  24089. class Tmp {
  24090. static Color3: Color3[];
  24091. static Color4: Color4[];
  24092. static Vector2: Vector2[];
  24093. static Vector3: Vector3[];
  24094. static Vector4: Vector4[];
  24095. static Quaternion: Quaternion[];
  24096. static Matrix: Matrix[];
  24097. }
  24098. }
  24099. declare module BABYLON {
  24100. /**
  24101. * Class representing spherical polynomial coefficients to the 3rd degree
  24102. */
  24103. class SphericalPolynomial {
  24104. /**
  24105. * The x coefficients of the spherical polynomial
  24106. */
  24107. x: Vector3;
  24108. /**
  24109. * The y coefficients of the spherical polynomial
  24110. */
  24111. y: Vector3;
  24112. /**
  24113. * The z coefficients of the spherical polynomial
  24114. */
  24115. z: Vector3;
  24116. /**
  24117. * The xx coefficients of the spherical polynomial
  24118. */
  24119. xx: Vector3;
  24120. /**
  24121. * The yy coefficients of the spherical polynomial
  24122. */
  24123. yy: Vector3;
  24124. /**
  24125. * The zz coefficients of the spherical polynomial
  24126. */
  24127. zz: Vector3;
  24128. /**
  24129. * The xy coefficients of the spherical polynomial
  24130. */
  24131. xy: Vector3;
  24132. /**
  24133. * The yz coefficients of the spherical polynomial
  24134. */
  24135. yz: Vector3;
  24136. /**
  24137. * The zx coefficients of the spherical polynomial
  24138. */
  24139. zx: Vector3;
  24140. /**
  24141. * Adds an ambient color to the spherical polynomial
  24142. * @param color the color to add
  24143. */
  24144. addAmbient(color: Color3): void;
  24145. /**
  24146. * Scales the spherical polynomial by the given amount
  24147. * @param scale the amount to scale
  24148. */
  24149. scale(scale: number): void;
  24150. /**
  24151. * Gets the spherical polynomial from harmonics
  24152. * @param harmonics the spherical harmonics
  24153. * @returns the spherical polynomial
  24154. */
  24155. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24156. /**
  24157. * Constructs a spherical polynomial from an array.
  24158. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24159. * @returns the spherical polynomial
  24160. */
  24161. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24162. }
  24163. /**
  24164. * Class representing spherical harmonics coefficients to the 3rd degree
  24165. */
  24166. class SphericalHarmonics {
  24167. /**
  24168. * The l0,0 coefficients of the spherical harmonics
  24169. */
  24170. l00: Vector3;
  24171. /**
  24172. * The l1,-1 coefficients of the spherical harmonics
  24173. */
  24174. l1_1: Vector3;
  24175. /**
  24176. * The l1,0 coefficients of the spherical harmonics
  24177. */
  24178. l10: Vector3;
  24179. /**
  24180. * The l1,1 coefficients of the spherical harmonics
  24181. */
  24182. l11: Vector3;
  24183. /**
  24184. * The l2,-2 coefficients of the spherical harmonics
  24185. */
  24186. l2_2: Vector3;
  24187. /**
  24188. * The l2,-1 coefficients of the spherical harmonics
  24189. */
  24190. l2_1: Vector3;
  24191. /**
  24192. * The l2,0 coefficients of the spherical harmonics
  24193. */
  24194. l20: Vector3;
  24195. /**
  24196. * The l2,1 coefficients of the spherical harmonics
  24197. */
  24198. l21: Vector3;
  24199. /**
  24200. * The l2,2 coefficients of the spherical harmonics
  24201. */
  24202. lL22: Vector3;
  24203. /**
  24204. * Adds a light to the spherical harmonics
  24205. * @param direction the direction of the light
  24206. * @param color the color of the light
  24207. * @param deltaSolidAngle the delta solid angle of the light
  24208. */
  24209. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24210. /**
  24211. * Scales the spherical harmonics by the given amount
  24212. * @param scale the amount to scale
  24213. */
  24214. scale(scale: number): void;
  24215. /**
  24216. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24217. *
  24218. * ```
  24219. * E_lm = A_l * L_lm
  24220. * ```
  24221. *
  24222. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24223. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24224. * the scaling factors are given in equation 9.
  24225. */
  24226. convertIncidentRadianceToIrradiance(): void;
  24227. /**
  24228. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24229. *
  24230. * ```
  24231. * L = (1/pi) * E * rho
  24232. * ```
  24233. *
  24234. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24235. */
  24236. convertIrradianceToLambertianRadiance(): void;
  24237. /**
  24238. * Gets the spherical harmonics from polynomial
  24239. * @param polynomial the spherical polynomial
  24240. * @returns the spherical harmonics
  24241. */
  24242. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24243. /**
  24244. * Constructs a spherical harmonics from an array.
  24245. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24246. * @returns the spherical harmonics
  24247. */
  24248. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24249. }
  24250. }
  24251. declare module BABYLON {
  24252. /**
  24253. * Class used to store all common mesh properties
  24254. */
  24255. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24256. /** No occlusion */
  24257. static OCCLUSION_TYPE_NONE: number;
  24258. /** Occlusion set to optimisitic */
  24259. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24260. /** Occlusion set to strict */
  24261. static OCCLUSION_TYPE_STRICT: number;
  24262. /** Use an accurante occlusion algorithm */
  24263. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24264. /** Use a conservative occlusion algorithm */
  24265. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24266. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24267. static readonly CULLINGSTRATEGY_STANDARD: number;
  24268. /** Culling strategy with bounding sphere only and then frustum culling */
  24269. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24270. /**
  24271. * No billboard
  24272. */
  24273. static readonly BILLBOARDMODE_NONE: number;
  24274. /** Billboard on X axis */
  24275. static readonly BILLBOARDMODE_X: number;
  24276. /** Billboard on Y axis */
  24277. static readonly BILLBOARDMODE_Y: number;
  24278. /** Billboard on Z axis */
  24279. static readonly BILLBOARDMODE_Z: number;
  24280. /** Billboard on all axes */
  24281. static readonly BILLBOARDMODE_ALL: number;
  24282. private _facetData;
  24283. /** Gets ot sets the culling strategy to use to find visible meshes */
  24284. cullingStrategy: number;
  24285. /**
  24286. * Gets the number of facets in the mesh
  24287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24288. */
  24289. readonly facetNb: number;
  24290. /**
  24291. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24293. */
  24294. partitioningSubdivisions: number;
  24295. /**
  24296. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24297. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24299. */
  24300. partitioningBBoxRatio: number;
  24301. /**
  24302. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24303. * Works only for updatable meshes.
  24304. * Doesn't work with multi-materials
  24305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24306. */
  24307. mustDepthSortFacets: boolean;
  24308. /**
  24309. * The location (Vector3) where the facet depth sort must be computed from.
  24310. * By default, the active camera position.
  24311. * Used only when facet depth sort is enabled
  24312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24313. */
  24314. facetDepthSortFrom: Vector3;
  24315. /**
  24316. * gets a boolean indicating if facetData is enabled
  24317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24318. */
  24319. readonly isFacetDataEnabled: boolean;
  24320. /** @hidden */
  24321. _updateNonUniformScalingState(value: boolean): boolean;
  24322. /**
  24323. * An event triggered when this mesh collides with another one
  24324. */
  24325. onCollideObservable: Observable<AbstractMesh>;
  24326. private _onCollideObserver;
  24327. /** Set a function to call when this mesh collides with another one */
  24328. onCollide: () => void;
  24329. /**
  24330. * An event triggered when the collision's position changes
  24331. */
  24332. onCollisionPositionChangeObservable: Observable<Vector3>;
  24333. private _onCollisionPositionChangeObserver;
  24334. /** Set a function to call when the collision's position changes */
  24335. onCollisionPositionChange: () => void;
  24336. /**
  24337. * An event triggered when material is changed
  24338. */
  24339. onMaterialChangedObservable: Observable<AbstractMesh>;
  24340. /**
  24341. * Gets or sets the orientation for POV movement & rotation
  24342. */
  24343. definedFacingForward: boolean;
  24344. /** @hidden */
  24345. _occlusionQuery: Nullable<WebGLQuery>;
  24346. private _visibility;
  24347. /**
  24348. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24349. */
  24350. /**
  24351. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24352. */
  24353. visibility: number;
  24354. /** Gets or sets the alpha index used to sort transparent meshes
  24355. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24356. */
  24357. alphaIndex: number;
  24358. /**
  24359. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24360. */
  24361. isVisible: boolean;
  24362. /**
  24363. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24364. */
  24365. isPickable: boolean;
  24366. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24367. showSubMeshesBoundingBox: boolean;
  24368. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24369. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24370. */
  24371. isBlocker: boolean;
  24372. /**
  24373. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24374. */
  24375. enablePointerMoveEvents: boolean;
  24376. /**
  24377. * Specifies the rendering group id for this mesh (0 by default)
  24378. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24379. */
  24380. renderingGroupId: number;
  24381. private _material;
  24382. /** Gets or sets current material */
  24383. material: Nullable<Material>;
  24384. private _receiveShadows;
  24385. /**
  24386. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24387. * @see http://doc.babylonjs.com/babylon101/shadows
  24388. */
  24389. receiveShadows: boolean;
  24390. /** Defines color to use when rendering outline */
  24391. outlineColor: Color3;
  24392. /** Define width to use when rendering outline */
  24393. outlineWidth: number;
  24394. /** Defines color to use when rendering overlay */
  24395. overlayColor: Color3;
  24396. /** Defines alpha to use when rendering overlay */
  24397. overlayAlpha: number;
  24398. private _hasVertexAlpha;
  24399. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24400. hasVertexAlpha: boolean;
  24401. private _useVertexColors;
  24402. /** 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) */
  24403. useVertexColors: boolean;
  24404. private _computeBonesUsingShaders;
  24405. /**
  24406. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24407. */
  24408. computeBonesUsingShaders: boolean;
  24409. private _numBoneInfluencers;
  24410. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24411. numBoneInfluencers: number;
  24412. private _applyFog;
  24413. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24414. applyFog: boolean;
  24415. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24416. useOctreeForRenderingSelection: boolean;
  24417. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24418. useOctreeForPicking: boolean;
  24419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24420. useOctreeForCollisions: boolean;
  24421. private _layerMask;
  24422. /**
  24423. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24424. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24425. */
  24426. layerMask: number;
  24427. /**
  24428. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24429. */
  24430. alwaysSelectAsActiveMesh: boolean;
  24431. /**
  24432. * Gets or sets the current action manager
  24433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24434. */
  24435. actionManager: Nullable<ActionManager>;
  24436. private _checkCollisions;
  24437. private _collisionMask;
  24438. private _collisionGroup;
  24439. /**
  24440. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24442. */
  24443. ellipsoid: Vector3;
  24444. /**
  24445. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24447. */
  24448. ellipsoidOffset: Vector3;
  24449. private _collider;
  24450. private _oldPositionForCollisions;
  24451. private _diffPositionForCollisions;
  24452. /**
  24453. * Gets or sets a collision mask used to mask collisions (default is -1).
  24454. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24455. */
  24456. collisionMask: number;
  24457. /**
  24458. * Gets or sets the current collision group mask (-1 by default).
  24459. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24460. */
  24461. collisionGroup: number;
  24462. /**
  24463. * Defines edge width used when edgesRenderer is enabled
  24464. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24465. */
  24466. edgesWidth: number;
  24467. /**
  24468. * Defines edge color used when edgesRenderer is enabled
  24469. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24470. */
  24471. edgesColor: Color4;
  24472. /** @hidden */
  24473. _edgesRenderer: Nullable<IEdgesRenderer>;
  24474. /** @hidden */
  24475. _masterMesh: Nullable<AbstractMesh>;
  24476. /** @hidden */
  24477. _boundingInfo: Nullable<BoundingInfo>;
  24478. /** @hidden */
  24479. _renderId: number;
  24480. /**
  24481. * Gets or sets the list of subMeshes
  24482. * @see http://doc.babylonjs.com/how_to/multi_materials
  24483. */
  24484. subMeshes: SubMesh[];
  24485. /** @hidden */
  24486. _intersectionsInProgress: AbstractMesh[];
  24487. /** @hidden */
  24488. _unIndexed: boolean;
  24489. /** @hidden */
  24490. _lightSources: Light[];
  24491. /** @hidden */
  24492. readonly _positions: Nullable<Vector3[]>;
  24493. /** @hidden */
  24494. _waitingActions: any;
  24495. /** @hidden */
  24496. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24497. private _skeleton;
  24498. /** @hidden */
  24499. _bonesTransformMatrices: Nullable<Float32Array>;
  24500. /**
  24501. * Gets or sets a skeleton to apply skining transformations
  24502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24503. */
  24504. skeleton: Nullable<Skeleton>;
  24505. /**
  24506. * An event triggered when the mesh is rebuilt.
  24507. */
  24508. onRebuildObservable: Observable<AbstractMesh>;
  24509. /**
  24510. * Creates a new AbstractMesh
  24511. * @param name defines the name of the mesh
  24512. * @param scene defines the hosting scene
  24513. */
  24514. constructor(name: string, scene?: Nullable<Scene>);
  24515. /**
  24516. * Returns the string "AbstractMesh"
  24517. * @returns "AbstractMesh"
  24518. */
  24519. getClassName(): string;
  24520. /**
  24521. * Gets a string representation of the current mesh
  24522. * @param fullDetails defines a boolean indicating if full details must be included
  24523. * @returns a string representation of the current mesh
  24524. */
  24525. toString(fullDetails?: boolean): string;
  24526. /** @hidden */
  24527. _rebuild(): void;
  24528. /** @hidden */
  24529. _resyncLightSources(): void;
  24530. /** @hidden */
  24531. _resyncLighSource(light: Light): void;
  24532. /** @hidden */
  24533. _unBindEffect(): void;
  24534. /** @hidden */
  24535. _removeLightSource(light: Light): void;
  24536. private _markSubMeshesAsDirty;
  24537. /** @hidden */
  24538. _markSubMeshesAsLightDirty(): void;
  24539. /** @hidden */
  24540. _markSubMeshesAsAttributesDirty(): void;
  24541. /** @hidden */
  24542. _markSubMeshesAsMiscDirty(): void;
  24543. /**
  24544. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24545. */
  24546. scaling: Vector3;
  24547. /**
  24548. * Returns true if the mesh is blocked. Implemented by child classes
  24549. */
  24550. readonly isBlocked: boolean;
  24551. /**
  24552. * Returns the mesh itself by default. Implemented by child classes
  24553. * @param camera defines the camera to use to pick the right LOD level
  24554. * @returns the currentAbstractMesh
  24555. */
  24556. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24557. /**
  24558. * Returns 0 by default. Implemented by child classes
  24559. * @returns an integer
  24560. */
  24561. getTotalVertices(): number;
  24562. /**
  24563. * Returns a positive integer : the total number of indices in this mesh geometry.
  24564. * @returns the numner of indices or zero if the mesh has no geometry.
  24565. */
  24566. getTotalIndices(): number;
  24567. /**
  24568. * Returns null by default. Implemented by child classes
  24569. * @returns null
  24570. */
  24571. getIndices(): Nullable<IndicesArray>;
  24572. /**
  24573. * Returns the array of the requested vertex data kind. Implemented by child classes
  24574. * @param kind defines the vertex data kind to use
  24575. * @returns null
  24576. */
  24577. getVerticesData(kind: string): Nullable<FloatArray>;
  24578. /**
  24579. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24580. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24581. * Note that a new underlying VertexBuffer object is created each call.
  24582. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24583. * @param kind defines vertex data kind:
  24584. * * BABYLON.VertexBuffer.PositionKind
  24585. * * BABYLON.VertexBuffer.UVKind
  24586. * * BABYLON.VertexBuffer.UV2Kind
  24587. * * BABYLON.VertexBuffer.UV3Kind
  24588. * * BABYLON.VertexBuffer.UV4Kind
  24589. * * BABYLON.VertexBuffer.UV5Kind
  24590. * * BABYLON.VertexBuffer.UV6Kind
  24591. * * BABYLON.VertexBuffer.ColorKind
  24592. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24593. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24594. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24595. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24596. * @param data defines the data source
  24597. * @param updatable defines if the data must be flagged as updatable (or static)
  24598. * @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
  24599. * @returns the current mesh
  24600. */
  24601. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24602. /**
  24603. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24604. * If the mesh has no geometry, it is simply returned as it is.
  24605. * @param kind defines vertex data kind:
  24606. * * BABYLON.VertexBuffer.PositionKind
  24607. * * BABYLON.VertexBuffer.UVKind
  24608. * * BABYLON.VertexBuffer.UV2Kind
  24609. * * BABYLON.VertexBuffer.UV3Kind
  24610. * * BABYLON.VertexBuffer.UV4Kind
  24611. * * BABYLON.VertexBuffer.UV5Kind
  24612. * * BABYLON.VertexBuffer.UV6Kind
  24613. * * BABYLON.VertexBuffer.ColorKind
  24614. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24615. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24616. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24617. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24618. * @param data defines the data source
  24619. * @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
  24620. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24621. * @returns the current mesh
  24622. */
  24623. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24624. /**
  24625. * Sets the mesh indices,
  24626. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24627. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24628. * @param totalVertices Defines the total number of vertices
  24629. * @returns the current mesh
  24630. */
  24631. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24632. /**
  24633. * Gets a boolean indicating if specific vertex data is present
  24634. * @param kind defines the vertex data kind to use
  24635. * @returns true is data kind is present
  24636. */
  24637. isVerticesDataPresent(kind: string): boolean;
  24638. /**
  24639. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24640. * @returns a BoundingInfo
  24641. */
  24642. getBoundingInfo(): BoundingInfo;
  24643. /**
  24644. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24645. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24646. * @returns the current mesh
  24647. */
  24648. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24649. /**
  24650. * Overwrite the current bounding info
  24651. * @param boundingInfo defines the new bounding info
  24652. * @returns the current mesh
  24653. */
  24654. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24655. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24656. readonly useBones: boolean;
  24657. /** @hidden */
  24658. _preActivate(): void;
  24659. /** @hidden */
  24660. _preActivateForIntermediateRendering(renderId: number): void;
  24661. /** @hidden */
  24662. _activate(renderId: number): void;
  24663. /**
  24664. * Gets the current world matrix
  24665. * @returns a Matrix
  24666. */
  24667. getWorldMatrix(): Matrix;
  24668. /** @hidden */
  24669. _getWorldMatrixDeterminant(): number;
  24670. /**
  24671. * Perform relative position change from the point of view of behind the front of the mesh.
  24672. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24673. * Supports definition of mesh facing forward or backward
  24674. * @param amountRight defines the distance on the right axis
  24675. * @param amountUp defines the distance on the up axis
  24676. * @param amountForward defines the distance on the forward axis
  24677. * @returns the current mesh
  24678. */
  24679. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24680. /**
  24681. * Calculate relative position change from the point of view of behind the front of the mesh.
  24682. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24683. * Supports definition of mesh facing forward or backward
  24684. * @param amountRight defines the distance on the right axis
  24685. * @param amountUp defines the distance on the up axis
  24686. * @param amountForward defines the distance on the forward axis
  24687. * @returns the new displacement vector
  24688. */
  24689. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24690. /**
  24691. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24692. * Supports definition of mesh facing forward or backward
  24693. * @param flipBack defines the flip
  24694. * @param twirlClockwise defines the twirl
  24695. * @param tiltRight defines the tilt
  24696. * @returns the current mesh
  24697. */
  24698. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24699. /**
  24700. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24701. * Supports definition of mesh facing forward or backward.
  24702. * @param flipBack defines the flip
  24703. * @param twirlClockwise defines the twirl
  24704. * @param tiltRight defines the tilt
  24705. * @returns the new rotation vector
  24706. */
  24707. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24708. /**
  24709. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24710. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24711. * @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
  24712. * @returns the new bounding vectors
  24713. */
  24714. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24715. min: Vector3;
  24716. max: Vector3;
  24717. };
  24718. /**
  24719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24720. * This means the mesh underlying bounding box and sphere are recomputed.
  24721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24722. * @returns the current mesh
  24723. */
  24724. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24725. /** @hidden */
  24726. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24727. /** @hidden */
  24728. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24729. /** @hidden */
  24730. _updateBoundingInfo(): AbstractMesh;
  24731. /** @hidden */
  24732. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24733. /** @hidden */
  24734. protected _afterComputeWorldMatrix(): void;
  24735. /**
  24736. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24737. * A mesh is in the frustum if its bounding box intersects the frustum
  24738. * @param frustumPlanes defines the frustum to test
  24739. * @returns true if the mesh is in the frustum planes
  24740. */
  24741. isInFrustum(frustumPlanes: Plane[]): boolean;
  24742. /**
  24743. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24744. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24745. * @param frustumPlanes defines the frustum to test
  24746. * @returns true if the mesh is completely in the frustum planes
  24747. */
  24748. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24749. /**
  24750. * True if the mesh intersects another mesh or a SolidParticle object
  24751. * @param mesh defines a target mesh or SolidParticle to test
  24752. * @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)
  24753. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24754. * @returns true if there is an intersection
  24755. */
  24756. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24757. /**
  24758. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24759. * @param point defines the point to test
  24760. * @returns true if there is an intersection
  24761. */
  24762. intersectsPoint(point: Vector3): boolean;
  24763. /**
  24764. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24766. */
  24767. checkCollisions: boolean;
  24768. /**
  24769. * Gets Collider object used to compute collisions (not physics)
  24770. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24771. */
  24772. readonly collider: Collider;
  24773. /**
  24774. * Move the mesh using collision engine
  24775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24776. * @param displacement defines the requested displacement vector
  24777. * @returns the current mesh
  24778. */
  24779. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24780. private _onCollisionPositionChange;
  24781. /** @hidden */
  24782. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24783. /** @hidden */
  24784. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24785. /** @hidden */
  24786. _checkCollision(collider: Collider): AbstractMesh;
  24787. /** @hidden */
  24788. _generatePointsArray(): boolean;
  24789. /**
  24790. * Checks if the passed Ray intersects with the mesh
  24791. * @param ray defines the ray to use
  24792. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24793. * @returns the picking info
  24794. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24795. */
  24796. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24797. /**
  24798. * Clones the current mesh
  24799. * @param name defines the mesh name
  24800. * @param newParent defines the new mesh parent
  24801. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24802. * @returns the new mesh
  24803. */
  24804. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24805. /**
  24806. * Disposes all the submeshes of the current meshnp
  24807. * @returns the current mesh
  24808. */
  24809. releaseSubMeshes(): AbstractMesh;
  24810. /**
  24811. * Releases resources associated with this abstract mesh.
  24812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24814. */
  24815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24816. /**
  24817. * Adds the passed mesh as a child to the current mesh
  24818. * @param mesh defines the child mesh
  24819. * @returns the current mesh
  24820. */
  24821. addChild(mesh: AbstractMesh): AbstractMesh;
  24822. /**
  24823. * Removes the passed mesh from the current mesh children list
  24824. * @param mesh defines the child mesh
  24825. * @returns the current mesh
  24826. */
  24827. removeChild(mesh: AbstractMesh): AbstractMesh;
  24828. /** @hidden */
  24829. private _initFacetData;
  24830. /**
  24831. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24832. * This method can be called within the render loop.
  24833. * 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
  24834. * @returns the current mesh
  24835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24836. */
  24837. updateFacetData(): AbstractMesh;
  24838. /**
  24839. * Returns the facetLocalNormals array.
  24840. * The normals are expressed in the mesh local spac
  24841. * @returns an array of Vector3
  24842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24843. */
  24844. getFacetLocalNormals(): Vector3[];
  24845. /**
  24846. * Returns the facetLocalPositions array.
  24847. * The facet positions are expressed in the mesh local space
  24848. * @returns an array of Vector3
  24849. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24850. */
  24851. getFacetLocalPositions(): Vector3[];
  24852. /**
  24853. * Returns the facetLocalPartioning array
  24854. * @returns an array of array of numbers
  24855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24856. */
  24857. getFacetLocalPartitioning(): number[][];
  24858. /**
  24859. * Returns the i-th facet position in the world system.
  24860. * This method allocates a new Vector3 per call
  24861. * @param i defines the facet index
  24862. * @returns a new Vector3
  24863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24864. */
  24865. getFacetPosition(i: number): Vector3;
  24866. /**
  24867. * Sets the reference Vector3 with the i-th facet position in the world system
  24868. * @param i defines the facet index
  24869. * @param ref defines the target vector
  24870. * @returns the current mesh
  24871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24872. */
  24873. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24874. /**
  24875. * Returns the i-th facet normal in the world system.
  24876. * This method allocates a new Vector3 per call
  24877. * @param i defines the facet index
  24878. * @returns a new Vector3
  24879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24880. */
  24881. getFacetNormal(i: number): Vector3;
  24882. /**
  24883. * Sets the reference Vector3 with the i-th facet normal in the world system
  24884. * @param i defines the facet index
  24885. * @param ref defines the target vector
  24886. * @returns the current mesh
  24887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24888. */
  24889. getFacetNormalToRef(i: number, ref: Vector3): this;
  24890. /**
  24891. * 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)
  24892. * @param x defines x coordinate
  24893. * @param y defines y coordinate
  24894. * @param z defines z coordinate
  24895. * @returns the array of facet indexes
  24896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24897. */
  24898. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24899. /**
  24900. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24901. * @param projected sets as the (x,y,z) world projection on the facet
  24902. * @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
  24903. * @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
  24904. * @param x defines x coordinate
  24905. * @param y defines y coordinate
  24906. * @param z defines z coordinate
  24907. * @returns the face index if found (or null instead)
  24908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24909. */
  24910. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24911. /**
  24912. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24913. * @param projected sets as the (x,y,z) local projection on the facet
  24914. * @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
  24915. * @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
  24916. * @param x defines x coordinate
  24917. * @param y defines y coordinate
  24918. * @param z defines z coordinate
  24919. * @returns the face index if found (or null instead)
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24921. */
  24922. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24923. /**
  24924. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24925. * @returns the parameters
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24927. */
  24928. getFacetDataParameters(): any;
  24929. /**
  24930. * Disables the feature FacetData and frees the related memory
  24931. * @returns the current mesh
  24932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24933. */
  24934. disableFacetData(): AbstractMesh;
  24935. /**
  24936. * Updates the AbstractMesh indices array
  24937. * @param indices defines the data source
  24938. * @returns the current mesh
  24939. */
  24940. updateIndices(indices: IndicesArray): AbstractMesh;
  24941. /**
  24942. * Creates new normals data for the mesh
  24943. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24944. * @returns the current mesh
  24945. */
  24946. createNormals(updatable: boolean): AbstractMesh;
  24947. /**
  24948. * Align the mesh with a normal
  24949. * @param normal defines the normal to use
  24950. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24951. * @returns the current mesh
  24952. */
  24953. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24954. /** @hidden */
  24955. _checkOcclusionQuery(): boolean;
  24956. }
  24957. }
  24958. declare module BABYLON {
  24959. /**
  24960. * Class used to store data that will be store in GPU memory
  24961. */
  24962. class Buffer {
  24963. private _engine;
  24964. private _buffer;
  24965. /** @hidden */
  24966. _data: Nullable<DataArray>;
  24967. private _updatable;
  24968. private _instanced;
  24969. /**
  24970. * Gets the byte stride.
  24971. */
  24972. readonly byteStride: number;
  24973. /**
  24974. * Constructor
  24975. * @param engine the engine
  24976. * @param data the data to use for this buffer
  24977. * @param updatable whether the data is updatable
  24978. * @param stride the stride (optional)
  24979. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24980. * @param instanced whether the buffer is instanced (optional)
  24981. * @param useBytes set to true if the stride in in bytes (optional)
  24982. */
  24983. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24984. /**
  24985. * Create a new VertexBuffer based on the current buffer
  24986. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24987. * @param offset defines offset in the buffer (0 by default)
  24988. * @param size defines the size in floats of attributes (position is 3 for instance)
  24989. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24990. * @param instanced defines if the vertex buffer contains indexed data
  24991. * @param useBytes defines if the offset and stride are in bytes
  24992. * @returns the new vertex buffer
  24993. */
  24994. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24995. /**
  24996. * Gets a boolean indicating if the Buffer is updatable?
  24997. * @returns true if the buffer is updatable
  24998. */
  24999. isUpdatable(): boolean;
  25000. /**
  25001. * Gets current buffer's data
  25002. * @returns a DataArray or null
  25003. */
  25004. getData(): Nullable<DataArray>;
  25005. /**
  25006. * Gets underlying native buffer
  25007. * @returns underlying native buffer
  25008. */
  25009. getBuffer(): Nullable<WebGLBuffer>;
  25010. /**
  25011. * Gets the stride in float32 units (i.e. byte stride / 4).
  25012. * May not be an integer if the byte stride is not divisible by 4.
  25013. * DEPRECATED. Use byteStride instead.
  25014. * @returns the stride in float32 units
  25015. */
  25016. getStrideSize(): number;
  25017. /**
  25018. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25019. * @param data defines the data to store
  25020. */
  25021. create(data?: Nullable<DataArray>): void;
  25022. /** @hidden */
  25023. _rebuild(): void;
  25024. /**
  25025. * Update current buffer data
  25026. * @param data defines the data to store
  25027. */
  25028. update(data: DataArray): void;
  25029. /**
  25030. * Updates the data directly.
  25031. * @param data the new data
  25032. * @param offset the new offset
  25033. * @param vertexCount the vertex count (optional)
  25034. * @param useBytes set to true if the offset is in bytes
  25035. */
  25036. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25037. /**
  25038. * Release all resources
  25039. */
  25040. dispose(): void;
  25041. }
  25042. }
  25043. declare module BABYLON {
  25044. /**
  25045. * Class for building Constructive Solid Geometry
  25046. */
  25047. class CSG {
  25048. private polygons;
  25049. /**
  25050. * The world matrix
  25051. */
  25052. matrix: Matrix;
  25053. /**
  25054. * Stores the position
  25055. */
  25056. position: Vector3;
  25057. /**
  25058. * Stores the rotation
  25059. */
  25060. rotation: Vector3;
  25061. /**
  25062. * Stores the rotation quaternion
  25063. */
  25064. rotationQuaternion: Nullable<Quaternion>;
  25065. /**
  25066. * Stores the scaling vector
  25067. */
  25068. scaling: Vector3;
  25069. /**
  25070. * Convert the BABYLON.Mesh to BABYLON.CSG
  25071. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25072. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25073. */
  25074. static FromMesh(mesh: Mesh): CSG;
  25075. /**
  25076. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25077. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25078. */
  25079. private static FromPolygons;
  25080. /**
  25081. * Clones, or makes a deep copy, of the BABYLON.CSG
  25082. * @returns A new BABYLON.CSG
  25083. */
  25084. clone(): CSG;
  25085. /**
  25086. * Unions this CSG with another CSG
  25087. * @param csg The CSG to union against this CSG
  25088. * @returns The unioned CSG
  25089. */
  25090. union(csg: CSG): CSG;
  25091. /**
  25092. * Unions this CSG with another CSG in place
  25093. * @param csg The CSG to union against this CSG
  25094. */
  25095. unionInPlace(csg: CSG): void;
  25096. /**
  25097. * Subtracts this CSG with another CSG
  25098. * @param csg The CSG to subtract against this CSG
  25099. * @returns A new BABYLON.CSG
  25100. */
  25101. subtract(csg: CSG): CSG;
  25102. /**
  25103. * Subtracts this CSG with another CSG in place
  25104. * @param csg The CSG to subtact against this CSG
  25105. */
  25106. subtractInPlace(csg: CSG): void;
  25107. /**
  25108. * Intersect this CSG with another CSG
  25109. * @param csg The CSG to intersect against this CSG
  25110. * @returns A new BABYLON.CSG
  25111. */
  25112. intersect(csg: CSG): CSG;
  25113. /**
  25114. * Intersects this CSG with another CSG in place
  25115. * @param csg The CSG to intersect against this CSG
  25116. */
  25117. intersectInPlace(csg: CSG): void;
  25118. /**
  25119. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25120. * not modified.
  25121. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25122. */
  25123. inverse(): CSG;
  25124. /**
  25125. * Inverses the BABYLON.CSG in place
  25126. */
  25127. inverseInPlace(): void;
  25128. /**
  25129. * This is used to keep meshes transformations so they can be restored
  25130. * when we build back a Babylon Mesh
  25131. * NB : All CSG operations are performed in world coordinates
  25132. * @param csg The BABYLON.CSG to copy the transform attributes from
  25133. * @returns This BABYLON.CSG
  25134. */
  25135. copyTransformAttributes(csg: CSG): CSG;
  25136. /**
  25137. * Build Raw mesh from CSG
  25138. * Coordinates here are in world space
  25139. * @param name The name of the mesh geometry
  25140. * @param scene The BABYLON.Scene
  25141. * @param keepSubMeshes Specifies if the submeshes should be kept
  25142. * @returns A new BABYLON.Mesh
  25143. */
  25144. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25145. /**
  25146. * Build Mesh from CSG taking material and transforms into account
  25147. * @param name The name of the BABYLON.Mesh
  25148. * @param material The material of the BABYLON.Mesh
  25149. * @param scene The BABYLON.Scene
  25150. * @param keepSubMeshes Specifies if submeshes should be kept
  25151. * @returns The new BABYLON.Mesh
  25152. */
  25153. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25154. }
  25155. }
  25156. declare module BABYLON {
  25157. /**
  25158. * Class used to store geometry data (vertex buffers + index buffer)
  25159. */
  25160. class Geometry implements IGetSetVerticesData {
  25161. /**
  25162. * Gets or sets the ID of the geometry
  25163. */
  25164. id: string;
  25165. /**
  25166. * Gets or sets the unique ID of the geometry
  25167. */
  25168. uniqueId: number;
  25169. /**
  25170. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25171. */
  25172. delayLoadState: number;
  25173. /**
  25174. * Gets the file containing the data to load when running in delay load state
  25175. */
  25176. delayLoadingFile: Nullable<string>;
  25177. /**
  25178. * Callback called when the geometry is updated
  25179. */
  25180. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25181. private _scene;
  25182. private _engine;
  25183. private _meshes;
  25184. private _totalVertices;
  25185. /** @hidden */
  25186. _indices: IndicesArray;
  25187. /** @hidden */
  25188. _vertexBuffers: {
  25189. [key: string]: VertexBuffer;
  25190. };
  25191. private _isDisposed;
  25192. private _extend;
  25193. private _boundingBias;
  25194. /** @hidden */
  25195. _delayInfo: Array<string>;
  25196. private _indexBuffer;
  25197. private _indexBufferIsUpdatable;
  25198. /** @hidden */
  25199. _boundingInfo: Nullable<BoundingInfo>;
  25200. /** @hidden */
  25201. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25202. /** @hidden */
  25203. _softwareSkinningFrameId: number;
  25204. private _vertexArrayObjects;
  25205. private _updatable;
  25206. /** @hidden */
  25207. _positions: Nullable<Vector3[]>;
  25208. /**
  25209. * 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
  25210. */
  25211. /**
  25212. * 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
  25213. */
  25214. boundingBias: Vector2;
  25215. /**
  25216. * Static function used to attach a new empty geometry to a mesh
  25217. * @param mesh defines the mesh to attach the geometry to
  25218. * @returns the new Geometry
  25219. */
  25220. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25221. /**
  25222. * Creates a new geometry
  25223. * @param id defines the unique ID
  25224. * @param scene defines the hosting scene
  25225. * @param vertexData defines the VertexData used to get geometry data
  25226. * @param updatable defines if geometry must be updatable (false by default)
  25227. * @param mesh defines the mesh that will be associated with the geometry
  25228. */
  25229. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25230. /**
  25231. * Gets the current extend of the geometry
  25232. */
  25233. readonly extend: {
  25234. minimum: Vector3;
  25235. maximum: Vector3;
  25236. };
  25237. /**
  25238. * Gets the hosting scene
  25239. * @returns the hosting Scene
  25240. */
  25241. getScene(): Scene;
  25242. /**
  25243. * Gets the hosting engine
  25244. * @returns the hosting Engine
  25245. */
  25246. getEngine(): Engine;
  25247. /**
  25248. * Defines if the geometry is ready to use
  25249. * @returns true if the geometry is ready to be used
  25250. */
  25251. isReady(): boolean;
  25252. /**
  25253. * Gets a value indicating that the geometry should not be serialized
  25254. */
  25255. readonly doNotSerialize: boolean;
  25256. /** @hidden */
  25257. _rebuild(): void;
  25258. /**
  25259. * Affects all geometry data in one call
  25260. * @param vertexData defines the geometry data
  25261. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25262. */
  25263. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25264. /**
  25265. * Set specific vertex data
  25266. * @param kind defines the data kind (Position, normal, etc...)
  25267. * @param data defines the vertex data to use
  25268. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25269. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25270. */
  25271. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25272. /**
  25273. * Removes a specific vertex data
  25274. * @param kind defines the data kind (Position, normal, etc...)
  25275. */
  25276. removeVerticesData(kind: string): void;
  25277. /**
  25278. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25279. * @param buffer defines the vertex buffer to use
  25280. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25281. */
  25282. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25283. /**
  25284. * Update a specific vertex buffer
  25285. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25286. * It will do nothing if the buffer is not updatable
  25287. * @param kind defines the data kind (Position, normal, etc...)
  25288. * @param data defines the data to use
  25289. * @param offset defines the offset in the target buffer where to store the data
  25290. * @param useBytes set to true if the offset is in bytes
  25291. */
  25292. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25293. /**
  25294. * Update a specific vertex buffer
  25295. * This function will create a new buffer if the current one is not updatable
  25296. * @param kind defines the data kind (Position, normal, etc...)
  25297. * @param data defines the data to use
  25298. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25299. */
  25300. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25301. private _updateBoundingInfo;
  25302. /** @hidden */
  25303. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25304. /**
  25305. * Gets total number of vertices
  25306. * @returns the total number of vertices
  25307. */
  25308. getTotalVertices(): number;
  25309. /**
  25310. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25311. * @param kind defines the data kind (Position, normal, etc...)
  25312. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25313. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25314. * @returns a float array containing vertex data
  25315. */
  25316. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25317. /**
  25318. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25319. * @param kind defines the data kind (Position, normal, etc...)
  25320. * @returns true if the vertex buffer with the specified kind is updatable
  25321. */
  25322. isVertexBufferUpdatable(kind: string): boolean;
  25323. /**
  25324. * Gets a specific vertex buffer
  25325. * @param kind defines the data kind (Position, normal, etc...)
  25326. * @returns a VertexBuffer
  25327. */
  25328. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25329. /**
  25330. * Returns all vertex buffers
  25331. * @return an object holding all vertex buffers indexed by kind
  25332. */
  25333. getVertexBuffers(): Nullable<{
  25334. [key: string]: VertexBuffer;
  25335. }>;
  25336. /**
  25337. * Gets a boolean indicating if specific vertex buffer is present
  25338. * @param kind defines the data kind (Position, normal, etc...)
  25339. * @returns true if data is present
  25340. */
  25341. isVerticesDataPresent(kind: string): boolean;
  25342. /**
  25343. * Gets a list of all attached data kinds (Position, normal, etc...)
  25344. * @returns a list of string containing all kinds
  25345. */
  25346. getVerticesDataKinds(): string[];
  25347. /**
  25348. * Update index buffer
  25349. * @param indices defines the indices to store in the index buffer
  25350. * @param offset defines the offset in the target buffer where to store the data
  25351. */
  25352. updateIndices(indices: IndicesArray, offset?: number): void;
  25353. /**
  25354. * Creates a new index buffer
  25355. * @param indices defines the indices to store in the index buffer
  25356. * @param totalVertices defines the total number of vertices (could be null)
  25357. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25358. */
  25359. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25360. /**
  25361. * Return the total number of indices
  25362. * @returns the total number of indices
  25363. */
  25364. getTotalIndices(): number;
  25365. /**
  25366. * Gets the index buffer array
  25367. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25368. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25369. * @returns the index buffer array
  25370. */
  25371. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25372. /**
  25373. * Gets the index buffer
  25374. * @return the index buffer
  25375. */
  25376. getIndexBuffer(): Nullable<WebGLBuffer>;
  25377. /** @hidden */
  25378. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25379. /**
  25380. * Release the associated resources for a specific mesh
  25381. * @param mesh defines the source mesh
  25382. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25383. */
  25384. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25385. /**
  25386. * Apply current geometry to a given mesh
  25387. * @param mesh defines the mesh to apply geometry to
  25388. */
  25389. applyToMesh(mesh: Mesh): void;
  25390. private _updateExtend;
  25391. private _applyToMesh;
  25392. private notifyUpdate;
  25393. /**
  25394. * Load the geometry if it was flagged as delay loaded
  25395. * @param scene defines the hosting scene
  25396. * @param onLoaded defines a callback called when the geometry is loaded
  25397. */
  25398. load(scene: Scene, onLoaded?: () => void): void;
  25399. private _queueLoad;
  25400. /**
  25401. * Invert the geometry to move from a right handed system to a left handed one.
  25402. */
  25403. toLeftHanded(): void;
  25404. /** @hidden */
  25405. _resetPointsArrayCache(): void;
  25406. /** @hidden */
  25407. _generatePointsArray(): boolean;
  25408. /**
  25409. * Gets a value indicating if the geometry is disposed
  25410. * @returns true if the geometry was disposed
  25411. */
  25412. isDisposed(): boolean;
  25413. private _disposeVertexArrayObjects;
  25414. /**
  25415. * Free all associated resources
  25416. */
  25417. dispose(): void;
  25418. /**
  25419. * Clone the current geometry into a new geometry
  25420. * @param id defines the unique ID of the new geometry
  25421. * @returns a new geometry object
  25422. */
  25423. copy(id: string): Geometry;
  25424. /**
  25425. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25426. * @return a JSON representation of the current geometry data (without the vertices data)
  25427. */
  25428. serialize(): any;
  25429. private toNumberArray;
  25430. /**
  25431. * Serialize all vertices data into a JSON oject
  25432. * @returns a JSON representation of the current geometry data
  25433. */
  25434. serializeVerticeData(): any;
  25435. /**
  25436. * Extracts a clone of a mesh geometry
  25437. * @param mesh defines the source mesh
  25438. * @param id defines the unique ID of the new geometry object
  25439. * @returns the new geometry object
  25440. */
  25441. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25442. /**
  25443. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25444. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25445. * Be aware Math.random() could cause collisions, but:
  25446. * "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"
  25447. * @returns a string containing a new GUID
  25448. */
  25449. static RandomId(): string;
  25450. /** @hidden */
  25451. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25452. private static _CleanMatricesWeights;
  25453. /**
  25454. * Create a new geometry from persisted data (Using .babylon file format)
  25455. * @param parsedVertexData defines the persisted data
  25456. * @param scene defines the hosting scene
  25457. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25458. * @returns the new geometry object
  25459. */
  25460. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25461. }
  25462. /**
  25463. * Abstract class used to provide common services for all typed geometries
  25464. * @hidden
  25465. */
  25466. class _PrimitiveGeometry extends Geometry {
  25467. private _canBeRegenerated;
  25468. private _beingRegenerated;
  25469. /**
  25470. * Creates a new typed geometry
  25471. * @param id defines the unique ID of the geometry
  25472. * @param scene defines the hosting scene
  25473. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25474. * @param mesh defines the hosting mesh (can be null)
  25475. */
  25476. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25477. /**
  25478. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25479. * @returns true if the geometry can be regenerated
  25480. */
  25481. canBeRegenerated(): boolean;
  25482. /**
  25483. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25484. */
  25485. regenerate(): void;
  25486. /**
  25487. * Clone the geometry
  25488. * @param id defines the unique ID of the new geometry
  25489. * @returns the new geometry
  25490. */
  25491. asNewGeometry(id: string): Geometry;
  25492. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25493. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25494. /** @hidden */
  25495. _regenerateVertexData(): VertexData;
  25496. copy(id: string): Geometry;
  25497. serialize(): any;
  25498. }
  25499. /**
  25500. * Creates a ribbon geometry
  25501. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25502. */
  25503. class RibbonGeometry extends _PrimitiveGeometry {
  25504. /**
  25505. * Defines the array of paths to use
  25506. */
  25507. pathArray: Vector3[][];
  25508. /**
  25509. * Defines if the last and first points of each path in your pathArray must be joined
  25510. */
  25511. closeArray: boolean;
  25512. /**
  25513. * Defines if the last and first points of each path in your pathArray must be joined
  25514. */
  25515. closePath: boolean;
  25516. /**
  25517. * Defines the offset between points
  25518. */
  25519. offset: number;
  25520. /**
  25521. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25522. */
  25523. side: number;
  25524. /**
  25525. * Creates a ribbon geometry
  25526. * @param id defines the unique ID of the geometry
  25527. * @param scene defines the hosting scene
  25528. * @param pathArray defines the array of paths to use
  25529. * @param closeArray defines if the last path and the first path must be joined
  25530. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25531. * @param offset defines the offset between points
  25532. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25533. * @param mesh defines the hosting mesh (can be null)
  25534. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25535. */
  25536. constructor(id: string, scene: Scene,
  25537. /**
  25538. * Defines the array of paths to use
  25539. */
  25540. pathArray: Vector3[][],
  25541. /**
  25542. * Defines if the last and first points of each path in your pathArray must be joined
  25543. */
  25544. closeArray: boolean,
  25545. /**
  25546. * Defines if the last and first points of each path in your pathArray must be joined
  25547. */
  25548. closePath: boolean,
  25549. /**
  25550. * Defines the offset between points
  25551. */
  25552. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25553. /**
  25554. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25555. */
  25556. side?: number);
  25557. /** @hidden */
  25558. _regenerateVertexData(): VertexData;
  25559. copy(id: string): Geometry;
  25560. }
  25561. /**
  25562. * Creates a box geometry
  25563. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25564. */
  25565. class BoxGeometry extends _PrimitiveGeometry {
  25566. /**
  25567. * Defines the zise of the box (width, height and depth are the same)
  25568. */
  25569. size: number;
  25570. /**
  25571. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25572. */
  25573. side: number;
  25574. /**
  25575. * Creates a box geometry
  25576. * @param id defines the unique ID of the geometry
  25577. * @param scene defines the hosting scene
  25578. * @param size defines the zise of the box (width, height and depth are the same)
  25579. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25580. * @param mesh defines the hosting mesh (can be null)
  25581. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25582. */
  25583. constructor(id: string, scene: Scene,
  25584. /**
  25585. * Defines the zise of the box (width, height and depth are the same)
  25586. */
  25587. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25588. /**
  25589. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25590. */
  25591. side?: number);
  25592. /** @hidden */
  25593. _regenerateVertexData(): VertexData;
  25594. copy(id: string): Geometry;
  25595. serialize(): any;
  25596. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25597. }
  25598. /**
  25599. * Creates a sphere geometry
  25600. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25601. */
  25602. class SphereGeometry extends _PrimitiveGeometry {
  25603. /**
  25604. * Defines the number of segments to use to create the sphere
  25605. */
  25606. segments: number;
  25607. /**
  25608. * Defines the diameter of the sphere
  25609. */
  25610. diameter: number;
  25611. /**
  25612. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25613. */
  25614. side: number;
  25615. /**
  25616. * Create a new sphere geometry
  25617. * @param id defines the unique ID of the geometry
  25618. * @param scene defines the hosting scene
  25619. * @param segments defines the number of segments to use to create the sphere
  25620. * @param diameter defines the diameter of the sphere
  25621. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25622. * @param mesh defines the hosting mesh (can be null)
  25623. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25624. */
  25625. constructor(id: string, scene: Scene,
  25626. /**
  25627. * Defines the number of segments to use to create the sphere
  25628. */
  25629. segments: number,
  25630. /**
  25631. * Defines the diameter of the sphere
  25632. */
  25633. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25634. /**
  25635. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25636. */
  25637. side?: number);
  25638. /** @hidden */
  25639. _regenerateVertexData(): VertexData;
  25640. copy(id: string): Geometry;
  25641. serialize(): any;
  25642. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25643. }
  25644. /**
  25645. * Creates a disc geometry
  25646. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25647. */
  25648. class DiscGeometry extends _PrimitiveGeometry {
  25649. /**
  25650. * Defines the radius of the disc
  25651. */
  25652. radius: number;
  25653. /**
  25654. * Defines the tesselation factor to apply to the disc
  25655. */
  25656. tessellation: number;
  25657. /**
  25658. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25659. */
  25660. side: number;
  25661. /**
  25662. * Creates a new disc geometry
  25663. * @param id defines the unique ID of the geometry
  25664. * @param scene defines the hosting scene
  25665. * @param radius defines the radius of the disc
  25666. * @param tessellation defines the tesselation factor to apply to the disc
  25667. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25668. * @param mesh defines the hosting mesh (can be null)
  25669. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25670. */
  25671. constructor(id: string, scene: Scene,
  25672. /**
  25673. * Defines the radius of the disc
  25674. */
  25675. radius: number,
  25676. /**
  25677. * Defines the tesselation factor to apply to the disc
  25678. */
  25679. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25680. /**
  25681. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25682. */
  25683. side?: number);
  25684. /** @hidden */
  25685. _regenerateVertexData(): VertexData;
  25686. copy(id: string): Geometry;
  25687. }
  25688. /**
  25689. * Creates a new cylinder geometry
  25690. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25691. */
  25692. class CylinderGeometry extends _PrimitiveGeometry {
  25693. /**
  25694. * Defines the height of the cylinder
  25695. */
  25696. height: number;
  25697. /**
  25698. * Defines the diameter of the cylinder's top cap
  25699. */
  25700. diameterTop: number;
  25701. /**
  25702. * Defines the diameter of the cylinder's bottom cap
  25703. */
  25704. diameterBottom: number;
  25705. /**
  25706. * Defines the tessellation factor to apply to the cylinder
  25707. */
  25708. tessellation: number;
  25709. /**
  25710. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25711. */
  25712. subdivisions: number;
  25713. /**
  25714. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25715. */
  25716. side: number;
  25717. /**
  25718. * Creates a new cylinder geometry
  25719. * @param id defines the unique ID of the geometry
  25720. * @param scene defines the hosting scene
  25721. * @param height defines the height of the cylinder
  25722. * @param diameterTop defines the diameter of the cylinder's top cap
  25723. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25724. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25725. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25726. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25727. * @param mesh defines the hosting mesh (can be null)
  25728. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25729. */
  25730. constructor(id: string, scene: Scene,
  25731. /**
  25732. * Defines the height of the cylinder
  25733. */
  25734. height: number,
  25735. /**
  25736. * Defines the diameter of the cylinder's top cap
  25737. */
  25738. diameterTop: number,
  25739. /**
  25740. * Defines the diameter of the cylinder's bottom cap
  25741. */
  25742. diameterBottom: number,
  25743. /**
  25744. * Defines the tessellation factor to apply to the cylinder
  25745. */
  25746. tessellation: number,
  25747. /**
  25748. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25749. */
  25750. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25751. /**
  25752. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25753. */
  25754. side?: number);
  25755. /** @hidden */
  25756. _regenerateVertexData(): VertexData;
  25757. copy(id: string): Geometry;
  25758. serialize(): any;
  25759. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25760. }
  25761. /**
  25762. * Creates a new torus geometry
  25763. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25764. */
  25765. class TorusGeometry extends _PrimitiveGeometry {
  25766. /**
  25767. * Defines the diameter of the torus
  25768. */
  25769. diameter: number;
  25770. /**
  25771. * Defines the thickness of the torus (ie. internal diameter)
  25772. */
  25773. thickness: number;
  25774. /**
  25775. * Defines the tesselation factor to apply to the torus
  25776. */
  25777. tessellation: number;
  25778. /**
  25779. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25780. */
  25781. side: number;
  25782. /**
  25783. * Creates a new torus geometry
  25784. * @param id defines the unique ID of the geometry
  25785. * @param scene defines the hosting scene
  25786. * @param diameter defines the diameter of the torus
  25787. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25788. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25789. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25790. * @param mesh defines the hosting mesh (can be null)
  25791. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25792. */
  25793. constructor(id: string, scene: Scene,
  25794. /**
  25795. * Defines the diameter of the torus
  25796. */
  25797. diameter: number,
  25798. /**
  25799. * Defines the thickness of the torus (ie. internal diameter)
  25800. */
  25801. thickness: number,
  25802. /**
  25803. * Defines the tesselation factor to apply to the torus
  25804. */
  25805. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25806. /**
  25807. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25808. */
  25809. side?: number);
  25810. /** @hidden */
  25811. _regenerateVertexData(): VertexData;
  25812. copy(id: string): Geometry;
  25813. serialize(): any;
  25814. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25815. }
  25816. /**
  25817. * Creates a new ground geometry
  25818. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25819. */
  25820. class GroundGeometry extends _PrimitiveGeometry {
  25821. /**
  25822. * Defines the width of the ground
  25823. */
  25824. width: number;
  25825. /**
  25826. * Defines the height of the ground
  25827. */
  25828. height: number;
  25829. /**
  25830. * Defines the subdivisions to apply to the ground
  25831. */
  25832. subdivisions: number;
  25833. /**
  25834. * Creates a new ground geometry
  25835. * @param id defines the unique ID of the geometry
  25836. * @param scene defines the hosting scene
  25837. * @param width defines the width of the ground
  25838. * @param height defines the height of the ground
  25839. * @param subdivisions defines the subdivisions to apply to the ground
  25840. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25841. * @param mesh defines the hosting mesh (can be null)
  25842. */
  25843. constructor(id: string, scene: Scene,
  25844. /**
  25845. * Defines the width of the ground
  25846. */
  25847. width: number,
  25848. /**
  25849. * Defines the height of the ground
  25850. */
  25851. height: number,
  25852. /**
  25853. * Defines the subdivisions to apply to the ground
  25854. */
  25855. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25856. /** @hidden */
  25857. _regenerateVertexData(): VertexData;
  25858. copy(id: string): Geometry;
  25859. serialize(): any;
  25860. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25861. }
  25862. /**
  25863. * Creates a tiled ground geometry
  25864. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25865. */
  25866. class TiledGroundGeometry extends _PrimitiveGeometry {
  25867. /**
  25868. * Defines the minimum value on X axis
  25869. */
  25870. xmin: number;
  25871. /**
  25872. * Defines the minimum value on Z axis
  25873. */
  25874. zmin: number;
  25875. /**
  25876. * Defines the maximum value on X axis
  25877. */
  25878. xmax: number;
  25879. /**
  25880. * Defines the maximum value on Z axis
  25881. */
  25882. zmax: number;
  25883. /**
  25884. * Defines the subdivisions to apply to the ground
  25885. */
  25886. subdivisions: {
  25887. w: number;
  25888. h: number;
  25889. };
  25890. /**
  25891. * Defines the precision to use when computing the tiles
  25892. */
  25893. precision: {
  25894. w: number;
  25895. h: number;
  25896. };
  25897. /**
  25898. * Creates a tiled ground geometry
  25899. * @param id defines the unique ID of the geometry
  25900. * @param scene defines the hosting scene
  25901. * @param xmin defines the minimum value on X axis
  25902. * @param zmin defines the minimum value on Z axis
  25903. * @param xmax defines the maximum value on X axis
  25904. * @param zmax defines the maximum value on Z axis
  25905. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25906. * @param precision defines the precision to use when computing the tiles
  25907. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25908. * @param mesh defines the hosting mesh (can be null)
  25909. */
  25910. constructor(id: string, scene: Scene,
  25911. /**
  25912. * Defines the minimum value on X axis
  25913. */
  25914. xmin: number,
  25915. /**
  25916. * Defines the minimum value on Z axis
  25917. */
  25918. zmin: number,
  25919. /**
  25920. * Defines the maximum value on X axis
  25921. */
  25922. xmax: number,
  25923. /**
  25924. * Defines the maximum value on Z axis
  25925. */
  25926. zmax: number,
  25927. /**
  25928. * Defines the subdivisions to apply to the ground
  25929. */
  25930. subdivisions: {
  25931. w: number;
  25932. h: number;
  25933. },
  25934. /**
  25935. * Defines the precision to use when computing the tiles
  25936. */
  25937. precision: {
  25938. w: number;
  25939. h: number;
  25940. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25941. /** @hidden */
  25942. _regenerateVertexData(): VertexData;
  25943. copy(id: string): Geometry;
  25944. }
  25945. /**
  25946. * Creates a plane geometry
  25947. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25948. */
  25949. class PlaneGeometry extends _PrimitiveGeometry {
  25950. /**
  25951. * Defines the size of the plane (width === height)
  25952. */
  25953. size: number;
  25954. /**
  25955. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25956. */
  25957. side: number;
  25958. /**
  25959. * Creates a plane geometry
  25960. * @param id defines the unique ID of the geometry
  25961. * @param scene defines the hosting scene
  25962. * @param size defines the size of the plane (width === height)
  25963. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25964. * @param mesh defines the hosting mesh (can be null)
  25965. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25966. */
  25967. constructor(id: string, scene: Scene,
  25968. /**
  25969. * Defines the size of the plane (width === height)
  25970. */
  25971. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25972. /**
  25973. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25974. */
  25975. side?: number);
  25976. /** @hidden */
  25977. _regenerateVertexData(): VertexData;
  25978. copy(id: string): Geometry;
  25979. serialize(): any;
  25980. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25981. }
  25982. /**
  25983. * Creates a torus knot geometry
  25984. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25985. */
  25986. class TorusKnotGeometry extends _PrimitiveGeometry {
  25987. /**
  25988. * Defines the radius of the torus knot
  25989. */
  25990. radius: number;
  25991. /**
  25992. * Defines the thickness of the torus knot tube
  25993. */
  25994. tube: number;
  25995. /**
  25996. * Defines the number of radial segments
  25997. */
  25998. radialSegments: number;
  25999. /**
  26000. * Defines the number of tubular segments
  26001. */
  26002. tubularSegments: number;
  26003. /**
  26004. * Defines the first number of windings
  26005. */
  26006. p: number;
  26007. /**
  26008. * Defines the second number of windings
  26009. */
  26010. q: number;
  26011. /**
  26012. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26013. */
  26014. side: number;
  26015. /**
  26016. * Creates a torus knot geometry
  26017. * @param id defines the unique ID of the geometry
  26018. * @param scene defines the hosting scene
  26019. * @param radius defines the radius of the torus knot
  26020. * @param tube defines the thickness of the torus knot tube
  26021. * @param radialSegments defines the number of radial segments
  26022. * @param tubularSegments defines the number of tubular segments
  26023. * @param p defines the first number of windings
  26024. * @param q defines the second number of windings
  26025. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26026. * @param mesh defines the hosting mesh (can be null)
  26027. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26028. */
  26029. constructor(id: string, scene: Scene,
  26030. /**
  26031. * Defines the radius of the torus knot
  26032. */
  26033. radius: number,
  26034. /**
  26035. * Defines the thickness of the torus knot tube
  26036. */
  26037. tube: number,
  26038. /**
  26039. * Defines the number of radial segments
  26040. */
  26041. radialSegments: number,
  26042. /**
  26043. * Defines the number of tubular segments
  26044. */
  26045. tubularSegments: number,
  26046. /**
  26047. * Defines the first number of windings
  26048. */
  26049. p: number,
  26050. /**
  26051. * Defines the second number of windings
  26052. */
  26053. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26054. /**
  26055. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26056. */
  26057. side?: number);
  26058. /** @hidden */
  26059. _regenerateVertexData(): VertexData;
  26060. copy(id: string): Geometry;
  26061. serialize(): any;
  26062. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26063. }
  26064. }
  26065. declare module BABYLON {
  26066. /**
  26067. * Mesh representing the gorund
  26068. */
  26069. class GroundMesh extends Mesh {
  26070. /** If octree should be generated */
  26071. generateOctree: boolean;
  26072. private _heightQuads;
  26073. /** @hidden */
  26074. _subdivisionsX: number;
  26075. /** @hidden */
  26076. _subdivisionsY: number;
  26077. /** @hidden */
  26078. _width: number;
  26079. /** @hidden */
  26080. _height: number;
  26081. /** @hidden */
  26082. _minX: number;
  26083. /** @hidden */
  26084. _maxX: number;
  26085. /** @hidden */
  26086. _minZ: number;
  26087. /** @hidden */
  26088. _maxZ: number;
  26089. constructor(name: string, scene: Scene);
  26090. /**
  26091. * "GroundMesh"
  26092. * @returns "GroundMesh"
  26093. */
  26094. getClassName(): string;
  26095. /**
  26096. * The minimum of x and y subdivisions
  26097. */
  26098. readonly subdivisions: number;
  26099. /**
  26100. * X subdivisions
  26101. */
  26102. readonly subdivisionsX: number;
  26103. /**
  26104. * Y subdivisions
  26105. */
  26106. readonly subdivisionsY: number;
  26107. /**
  26108. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26109. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26110. * @param chunksCount the number of subdivisions for x and y
  26111. * @param octreeBlocksSize (Default: 32)
  26112. */
  26113. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26114. /**
  26115. * Returns a height (y) value in the Worl system :
  26116. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26117. * @param x x coordinate
  26118. * @param z z coordinate
  26119. * @returns the ground y position if (x, z) are outside the ground surface.
  26120. */
  26121. getHeightAtCoordinates(x: number, z: number): number;
  26122. /**
  26123. * Returns a normalized vector (Vector3) orthogonal to the ground
  26124. * at the ground coordinates (x, z) expressed in the World system.
  26125. * @param x x coordinate
  26126. * @param z z coordinate
  26127. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26128. */
  26129. getNormalAtCoordinates(x: number, z: number): Vector3;
  26130. /**
  26131. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26132. * at the ground coordinates (x, z) expressed in the World system.
  26133. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26134. * @param x x coordinate
  26135. * @param z z coordinate
  26136. * @param ref vector to store the result
  26137. * @returns the GroundMesh.
  26138. */
  26139. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26140. /**
  26141. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26142. * if the ground has been updated.
  26143. * This can be used in the render loop.
  26144. * @returns the GroundMesh.
  26145. */
  26146. updateCoordinateHeights(): GroundMesh;
  26147. private _getFacetAt;
  26148. private _initHeightQuads;
  26149. private _computeHeightQuads;
  26150. /**
  26151. * Serializes this ground mesh
  26152. * @param serializationObject object to write serialization to
  26153. */
  26154. serialize(serializationObject: any): void;
  26155. /**
  26156. * Parses a serialized ground mesh
  26157. * @param parsedMesh the serialized mesh
  26158. * @param scene the scene to create the ground mesh in
  26159. * @returns the created ground mesh
  26160. */
  26161. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26162. }
  26163. }
  26164. declare module BABYLON {
  26165. /**
  26166. * Creates an instance based on a source mesh.
  26167. */
  26168. class InstancedMesh extends AbstractMesh {
  26169. private _sourceMesh;
  26170. private _currentLOD;
  26171. /** @hidden */
  26172. _indexInSourceMeshInstanceArray: number;
  26173. constructor(name: string, source: Mesh);
  26174. /**
  26175. * Returns the string "InstancedMesh".
  26176. */
  26177. getClassName(): string;
  26178. /**
  26179. * If the source mesh receives shadows
  26180. */
  26181. readonly receiveShadows: boolean;
  26182. /**
  26183. * The material of the source mesh
  26184. */
  26185. readonly material: Nullable<Material>;
  26186. /**
  26187. * Visibility of the source mesh
  26188. */
  26189. readonly visibility: number;
  26190. /**
  26191. * Skeleton of the source mesh
  26192. */
  26193. readonly skeleton: Nullable<Skeleton>;
  26194. /**
  26195. * Rendering ground id of the source mesh
  26196. */
  26197. renderingGroupId: number;
  26198. /**
  26199. * Returns the total number of vertices (integer).
  26200. */
  26201. getTotalVertices(): number;
  26202. /**
  26203. * Returns a positive integer : the total number of indices in this mesh geometry.
  26204. * @returns the numner of indices or zero if the mesh has no geometry.
  26205. */
  26206. getTotalIndices(): number;
  26207. /**
  26208. * The source mesh of the instance
  26209. */
  26210. readonly sourceMesh: Mesh;
  26211. /**
  26212. * Is this node ready to be used/rendered
  26213. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26214. * @return {boolean} is it ready
  26215. */
  26216. isReady(completeCheck?: boolean): boolean;
  26217. /**
  26218. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26219. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26220. * @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.
  26221. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26222. */
  26223. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26224. /**
  26225. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26226. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26227. * The `data` are either a numeric array either a Float32Array.
  26228. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26229. * 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).
  26230. * Note that a new underlying VertexBuffer object is created each call.
  26231. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26232. *
  26233. * Possible `kind` values :
  26234. * - BABYLON.VertexBuffer.PositionKind
  26235. * - BABYLON.VertexBuffer.UVKind
  26236. * - BABYLON.VertexBuffer.UV2Kind
  26237. * - BABYLON.VertexBuffer.UV3Kind
  26238. * - BABYLON.VertexBuffer.UV4Kind
  26239. * - BABYLON.VertexBuffer.UV5Kind
  26240. * - BABYLON.VertexBuffer.UV6Kind
  26241. * - BABYLON.VertexBuffer.ColorKind
  26242. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26243. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26244. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26245. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26246. *
  26247. * Returns the Mesh.
  26248. */
  26249. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26250. /**
  26251. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26252. * If the mesh has no geometry, it is simply returned as it is.
  26253. * The `data` are either a numeric array either a Float32Array.
  26254. * No new underlying VertexBuffer object is created.
  26255. * 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.
  26256. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26257. *
  26258. * Possible `kind` values :
  26259. * - BABYLON.VertexBuffer.PositionKind
  26260. * - BABYLON.VertexBuffer.UVKind
  26261. * - BABYLON.VertexBuffer.UV2Kind
  26262. * - BABYLON.VertexBuffer.UV3Kind
  26263. * - BABYLON.VertexBuffer.UV4Kind
  26264. * - BABYLON.VertexBuffer.UV5Kind
  26265. * - BABYLON.VertexBuffer.UV6Kind
  26266. * - BABYLON.VertexBuffer.ColorKind
  26267. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26268. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26269. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26270. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26271. *
  26272. * Returns the Mesh.
  26273. */
  26274. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26275. /**
  26276. * Sets the mesh indices.
  26277. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26278. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26279. * This method creates a new index buffer each call.
  26280. * Returns the Mesh.
  26281. */
  26282. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26283. /**
  26284. * Boolean : True if the mesh owns the requested kind of data.
  26285. */
  26286. isVerticesDataPresent(kind: string): boolean;
  26287. /**
  26288. * Returns an array of indices (IndicesArray).
  26289. */
  26290. getIndices(): Nullable<IndicesArray>;
  26291. readonly _positions: Nullable<Vector3[]>;
  26292. /**
  26293. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26294. * This means the mesh underlying bounding box and sphere are recomputed.
  26295. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26296. * @returns the current mesh
  26297. */
  26298. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26299. /** @hidden */
  26300. _preActivate(): InstancedMesh;
  26301. /** @hidden */
  26302. _activate(renderId: number): InstancedMesh;
  26303. /**
  26304. * Returns the current associated LOD AbstractMesh.
  26305. */
  26306. getLOD(camera: Camera): AbstractMesh;
  26307. /** @hidden */
  26308. _syncSubMeshes(): InstancedMesh;
  26309. /** @hidden */
  26310. _generatePointsArray(): boolean;
  26311. /**
  26312. * Creates a new InstancedMesh from the current mesh.
  26313. * - name (string) : the cloned mesh name
  26314. * - newParent (optional Node) : the optional Node to parent the clone to.
  26315. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26316. *
  26317. * Returns the clone.
  26318. */
  26319. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26320. /**
  26321. * Disposes the InstancedMesh.
  26322. * Returns nothing.
  26323. */
  26324. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26325. }
  26326. }
  26327. declare module BABYLON {
  26328. /**
  26329. * Line mesh
  26330. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26331. */
  26332. class LinesMesh extends Mesh {
  26333. /**
  26334. * If vertex color should be applied to the mesh
  26335. */
  26336. useVertexColor?: boolean | undefined;
  26337. /**
  26338. * If vertex alpha should be applied to the mesh
  26339. */
  26340. useVertexAlpha?: boolean | undefined;
  26341. /**
  26342. * Color of the line (Default: White)
  26343. */
  26344. color: Color3;
  26345. /**
  26346. * Alpha of the line (Default: 1)
  26347. */
  26348. alpha: number;
  26349. /**
  26350. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26351. * This margin is expressed in world space coordinates, so its value may vary.
  26352. * Default value is 0.1
  26353. */
  26354. intersectionThreshold: number;
  26355. private _colorShader;
  26356. /**
  26357. * Creates a new LinesMesh
  26358. * @param name defines the name
  26359. * @param scene defines the hosting scene
  26360. * @param parent defines the parent mesh if any
  26361. * @param source defines the optional source LinesMesh used to clone data from
  26362. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26363. * When false, achieved by calling a clone(), also passing False.
  26364. * This will make creation of children, recursive.
  26365. * @param useVertexColor defines if this LinesMesh supports vertex color
  26366. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26367. */
  26368. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26369. /**
  26370. * If vertex color should be applied to the mesh
  26371. */
  26372. useVertexColor?: boolean | undefined,
  26373. /**
  26374. * If vertex alpha should be applied to the mesh
  26375. */
  26376. useVertexAlpha?: boolean | undefined);
  26377. /**
  26378. * Returns the string "LineMesh"
  26379. */
  26380. getClassName(): string;
  26381. /**
  26382. * @hidden
  26383. */
  26384. /**
  26385. * @hidden
  26386. */
  26387. material: Material;
  26388. /**
  26389. * @hidden
  26390. */
  26391. readonly checkCollisions: boolean;
  26392. /** @hidden */
  26393. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26394. /** @hidden */
  26395. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26396. /**
  26397. * Disposes of the line mesh
  26398. * @param doNotRecurse If children should be disposed
  26399. */
  26400. dispose(doNotRecurse?: boolean): void;
  26401. /**
  26402. * Returns a new LineMesh object cloned from the current one.
  26403. */
  26404. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26405. /**
  26406. * Creates a new InstancedLinesMesh object from the mesh model.
  26407. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26408. * @param name defines the name of the new instance
  26409. * @returns a new InstancedLinesMesh
  26410. */
  26411. createInstance(name: string): InstancedLinesMesh;
  26412. }
  26413. /**
  26414. * Creates an instance based on a source LinesMesh
  26415. */
  26416. class InstancedLinesMesh extends InstancedMesh {
  26417. /**
  26418. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26419. * This margin is expressed in world space coordinates, so its value may vary.
  26420. * Initilized with the intersectionThreshold value of the source LinesMesh
  26421. */
  26422. intersectionThreshold: number;
  26423. constructor(name: string, source: LinesMesh);
  26424. /**
  26425. * Returns the string "InstancedLinesMesh".
  26426. */
  26427. getClassName(): string;
  26428. }
  26429. }
  26430. declare module BABYLON {
  26431. /**
  26432. * @hidden
  26433. **/
  26434. class _CreationDataStorage {
  26435. closePath?: boolean;
  26436. closeArray?: boolean;
  26437. idx: number[];
  26438. dashSize: number;
  26439. gapSize: number;
  26440. path3D: Path3D;
  26441. pathArray: Vector3[][];
  26442. arc: number;
  26443. radius: number;
  26444. cap: number;
  26445. tessellation: number;
  26446. }
  26447. /**
  26448. * @hidden
  26449. **/
  26450. class _InstanceDataStorage {
  26451. visibleInstances: any;
  26452. renderIdForInstances: number[];
  26453. batchCache: _InstancesBatch;
  26454. instancesBufferSize: number;
  26455. instancesBuffer: Nullable<Buffer>;
  26456. instancesData: Float32Array;
  26457. overridenInstanceCount: number;
  26458. }
  26459. /**
  26460. * @hidden
  26461. **/
  26462. class _InstancesBatch {
  26463. mustReturn: boolean;
  26464. visibleInstances: Nullable<InstancedMesh[]>[];
  26465. renderSelf: boolean[];
  26466. }
  26467. /**
  26468. * Class used to represent renderable models
  26469. */
  26470. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26471. /**
  26472. * Mesh side orientation : usually the external or front surface
  26473. */
  26474. static readonly FRONTSIDE: number;
  26475. /**
  26476. * Mesh side orientation : usually the internal or back surface
  26477. */
  26478. static readonly BACKSIDE: number;
  26479. /**
  26480. * Mesh side orientation : both internal and external or front and back surfaces
  26481. */
  26482. static readonly DOUBLESIDE: number;
  26483. /**
  26484. * Mesh side orientation : by default, `FRONTSIDE`
  26485. */
  26486. static readonly DEFAULTSIDE: number;
  26487. /**
  26488. * Mesh cap setting : no cap
  26489. */
  26490. static readonly NO_CAP: number;
  26491. /**
  26492. * Mesh cap setting : one cap at the beginning of the mesh
  26493. */
  26494. static readonly CAP_START: number;
  26495. /**
  26496. * Mesh cap setting : one cap at the end of the mesh
  26497. */
  26498. static readonly CAP_END: number;
  26499. /**
  26500. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26501. */
  26502. static readonly CAP_ALL: number;
  26503. private _onBeforeRenderObservable;
  26504. private _onAfterRenderObservable;
  26505. private _onBeforeDrawObservable;
  26506. /**
  26507. * An event triggered before rendering the mesh
  26508. */
  26509. readonly onBeforeRenderObservable: Observable<Mesh>;
  26510. /**
  26511. * An event triggered after rendering the mesh
  26512. */
  26513. readonly onAfterRenderObservable: Observable<Mesh>;
  26514. /**
  26515. * An event triggered before drawing the mesh
  26516. */
  26517. readonly onBeforeDrawObservable: Observable<Mesh>;
  26518. private _onBeforeDrawObserver;
  26519. /**
  26520. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26521. */
  26522. onBeforeDraw: () => void;
  26523. /**
  26524. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26525. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26526. */
  26527. delayLoadState: number;
  26528. /**
  26529. * Gets the list of instances created from this mesh
  26530. * it is not supposed to be modified manually.
  26531. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26532. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26533. */
  26534. instances: InstancedMesh[];
  26535. /**
  26536. * Gets the file containing delay loading data for this mesh
  26537. */
  26538. delayLoadingFile: string;
  26539. /** @hidden */
  26540. _binaryInfo: any;
  26541. private _LODLevels;
  26542. /**
  26543. * User defined function used to change how LOD level selection is done
  26544. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26545. */
  26546. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26547. private _morphTargetManager;
  26548. /**
  26549. * Gets or sets the morph target manager
  26550. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26551. */
  26552. morphTargetManager: Nullable<MorphTargetManager>;
  26553. /** @hidden */
  26554. _creationDataStorage: Nullable<_CreationDataStorage>;
  26555. /** @hidden */
  26556. _geometry: Nullable<Geometry>;
  26557. /** @hidden */
  26558. _delayInfo: Array<string>;
  26559. /** @hidden */
  26560. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26561. /** @hidden */
  26562. _instanceDataStorage: _InstanceDataStorage;
  26563. private _effectiveMaterial;
  26564. /** @hidden */
  26565. _shouldGenerateFlatShading: boolean;
  26566. private _preActivateId;
  26567. /** @hidden */
  26568. _originalBuilderSideOrientation: number;
  26569. /**
  26570. * Use this property to change the original side orientation defined at construction time
  26571. */
  26572. overrideMaterialSideOrientation: Nullable<number>;
  26573. private _areNormalsFrozen;
  26574. private _sourcePositions;
  26575. private _sourceNormals;
  26576. private _source;
  26577. private meshMap;
  26578. /**
  26579. * Gets the source mesh (the one used to clone this one from)
  26580. */
  26581. readonly source: Nullable<Mesh>;
  26582. /**
  26583. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26584. */
  26585. isUnIndexed: boolean;
  26586. /**
  26587. * @constructor
  26588. * @param name The value used by scene.getMeshByName() to do a lookup.
  26589. * @param scene The scene to add this mesh to.
  26590. * @param parent The parent of this mesh, if it has one
  26591. * @param source An optional Mesh from which geometry is shared, cloned.
  26592. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26593. * When false, achieved by calling a clone(), also passing False.
  26594. * This will make creation of children, recursive.
  26595. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26596. */
  26597. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26598. /**
  26599. * Gets the class name
  26600. * @returns the string "Mesh".
  26601. */
  26602. getClassName(): string;
  26603. /**
  26604. * Returns a description of this mesh
  26605. * @param fullDetails define if full details about this mesh must be used
  26606. * @returns a descriptive string representing this mesh
  26607. */
  26608. toString(fullDetails?: boolean): string;
  26609. /** @hidden */
  26610. _unBindEffect(): void;
  26611. /**
  26612. * Gets a boolean indicating if this mesh has LOD
  26613. */
  26614. readonly hasLODLevels: boolean;
  26615. /**
  26616. * Gets the list of MeshLODLevel associated with the current mesh
  26617. * @returns an array of MeshLODLevel
  26618. */
  26619. getLODLevels(): MeshLODLevel[];
  26620. private _sortLODLevels;
  26621. /**
  26622. * Add a mesh as LOD level triggered at the given distance.
  26623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26624. * @param distance The distance from the center of the object to show this level
  26625. * @param mesh The mesh to be added as LOD level (can be null)
  26626. * @return This mesh (for chaining)
  26627. */
  26628. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26629. /**
  26630. * Returns the LOD level mesh at the passed distance or null if not found.
  26631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26632. * @param distance The distance from the center of the object to show this level
  26633. * @returns a Mesh or `null`
  26634. */
  26635. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26636. /**
  26637. * Remove a mesh from the LOD array
  26638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26639. * @param mesh defines the mesh to be removed
  26640. * @return This mesh (for chaining)
  26641. */
  26642. removeLODLevel(mesh: Mesh): Mesh;
  26643. /**
  26644. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26645. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26646. * @param camera defines the camera to use to compute distance
  26647. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26648. * @return This mesh (for chaining)
  26649. */
  26650. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26651. /**
  26652. * Gets the mesh internal Geometry object
  26653. */
  26654. readonly geometry: Nullable<Geometry>;
  26655. /**
  26656. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26657. * @returns the total number of vertices
  26658. */
  26659. getTotalVertices(): number;
  26660. /**
  26661. * Returns the content of an associated vertex buffer
  26662. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26663. * - BABYLON.VertexBuffer.PositionKind
  26664. * - BABYLON.VertexBuffer.UVKind
  26665. * - BABYLON.VertexBuffer.UV2Kind
  26666. * - BABYLON.VertexBuffer.UV3Kind
  26667. * - BABYLON.VertexBuffer.UV4Kind
  26668. * - BABYLON.VertexBuffer.UV5Kind
  26669. * - BABYLON.VertexBuffer.UV6Kind
  26670. * - BABYLON.VertexBuffer.ColorKind
  26671. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26672. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26673. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26674. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26675. * @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
  26676. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26677. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26678. */
  26679. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26680. /**
  26681. * Returns the mesh VertexBuffer object from the requested `kind`
  26682. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26683. * - BABYLON.VertexBuffer.PositionKind
  26684. * - BABYLON.VertexBuffer.UVKind
  26685. * - BABYLON.VertexBuffer.UV2Kind
  26686. * - BABYLON.VertexBuffer.UV3Kind
  26687. * - BABYLON.VertexBuffer.UV4Kind
  26688. * - BABYLON.VertexBuffer.UV5Kind
  26689. * - BABYLON.VertexBuffer.UV6Kind
  26690. * - BABYLON.VertexBuffer.ColorKind
  26691. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26692. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26693. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26694. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26695. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26696. */
  26697. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26698. /**
  26699. * Tests if a specific vertex buffer is associated with this mesh
  26700. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26701. * - BABYLON.VertexBuffer.PositionKind
  26702. * - BABYLON.VertexBuffer.UVKind
  26703. * - BABYLON.VertexBuffer.UV2Kind
  26704. * - BABYLON.VertexBuffer.UV3Kind
  26705. * - BABYLON.VertexBuffer.UV4Kind
  26706. * - BABYLON.VertexBuffer.UV5Kind
  26707. * - BABYLON.VertexBuffer.UV6Kind
  26708. * - BABYLON.VertexBuffer.ColorKind
  26709. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26710. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26711. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26712. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26713. * @returns a boolean
  26714. */
  26715. isVerticesDataPresent(kind: string): boolean;
  26716. /**
  26717. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26718. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26719. * - BABYLON.VertexBuffer.PositionKind
  26720. * - BABYLON.VertexBuffer.UVKind
  26721. * - BABYLON.VertexBuffer.UV2Kind
  26722. * - BABYLON.VertexBuffer.UV3Kind
  26723. * - BABYLON.VertexBuffer.UV4Kind
  26724. * - BABYLON.VertexBuffer.UV5Kind
  26725. * - BABYLON.VertexBuffer.UV6Kind
  26726. * - BABYLON.VertexBuffer.ColorKind
  26727. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26728. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26729. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26730. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26731. * @returns a boolean
  26732. */
  26733. isVertexBufferUpdatable(kind: string): boolean;
  26734. /**
  26735. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26736. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26737. * - BABYLON.VertexBuffer.PositionKind
  26738. * - BABYLON.VertexBuffer.UVKind
  26739. * - BABYLON.VertexBuffer.UV2Kind
  26740. * - BABYLON.VertexBuffer.UV3Kind
  26741. * - BABYLON.VertexBuffer.UV4Kind
  26742. * - BABYLON.VertexBuffer.UV5Kind
  26743. * - BABYLON.VertexBuffer.UV6Kind
  26744. * - BABYLON.VertexBuffer.ColorKind
  26745. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26746. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26747. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26748. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26749. * @returns an array of strings
  26750. */
  26751. getVerticesDataKinds(): string[];
  26752. /**
  26753. * Returns a positive integer : the total number of indices in this mesh geometry.
  26754. * @returns the numner of indices or zero if the mesh has no geometry.
  26755. */
  26756. getTotalIndices(): number;
  26757. /**
  26758. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26759. * @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.
  26760. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26761. * @returns the indices array or an empty array if the mesh has no geometry
  26762. */
  26763. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26764. readonly isBlocked: boolean;
  26765. /**
  26766. * Determine if the current mesh is ready to be rendered
  26767. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26768. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26769. * @returns true if all associated assets are ready (material, textures, shaders)
  26770. */
  26771. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26772. /**
  26773. * 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.
  26774. */
  26775. readonly areNormalsFrozen: boolean;
  26776. /**
  26777. * 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.
  26778. * @returns the current mesh
  26779. */
  26780. freezeNormals(): Mesh;
  26781. /**
  26782. * 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
  26783. * @returns the current mesh
  26784. */
  26785. unfreezeNormals(): Mesh;
  26786. /**
  26787. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26788. */
  26789. overridenInstanceCount: number;
  26790. /** @hidden */
  26791. _preActivate(): Mesh;
  26792. /** @hidden */
  26793. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26794. /** @hidden */
  26795. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26796. /**
  26797. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26798. * This means the mesh underlying bounding box and sphere are recomputed.
  26799. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26800. * @returns the current mesh
  26801. */
  26802. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26803. /** @hidden */
  26804. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26805. /**
  26806. * This function will subdivide the mesh into multiple submeshes
  26807. * @param count defines the expected number of submeshes
  26808. */
  26809. subdivide(count: number): void;
  26810. /**
  26811. * Copy a FloatArray into a specific associated vertex buffer
  26812. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26813. * - BABYLON.VertexBuffer.PositionKind
  26814. * - BABYLON.VertexBuffer.UVKind
  26815. * - BABYLON.VertexBuffer.UV2Kind
  26816. * - BABYLON.VertexBuffer.UV3Kind
  26817. * - BABYLON.VertexBuffer.UV4Kind
  26818. * - BABYLON.VertexBuffer.UV5Kind
  26819. * - BABYLON.VertexBuffer.UV6Kind
  26820. * - BABYLON.VertexBuffer.ColorKind
  26821. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26822. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26823. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26824. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26825. * @param data defines the data source
  26826. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26827. * @param stride defines the data stride size (can be null)
  26828. * @returns the current mesh
  26829. */
  26830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26831. /**
  26832. * Flags an associated vertex buffer as updatable
  26833. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26834. * - BABYLON.VertexBuffer.PositionKind
  26835. * - BABYLON.VertexBuffer.UVKind
  26836. * - BABYLON.VertexBuffer.UV2Kind
  26837. * - BABYLON.VertexBuffer.UV3Kind
  26838. * - BABYLON.VertexBuffer.UV4Kind
  26839. * - BABYLON.VertexBuffer.UV5Kind
  26840. * - BABYLON.VertexBuffer.UV6Kind
  26841. * - BABYLON.VertexBuffer.ColorKind
  26842. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26843. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26844. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26845. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26846. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26847. */
  26848. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26849. /**
  26850. * Sets the mesh global Vertex Buffer
  26851. * @param buffer defines the buffer to use
  26852. * @returns the current mesh
  26853. */
  26854. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26855. /**
  26856. * Update a specific associated vertex buffer
  26857. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26858. * - BABYLON.VertexBuffer.PositionKind
  26859. * - BABYLON.VertexBuffer.UVKind
  26860. * - BABYLON.VertexBuffer.UV2Kind
  26861. * - BABYLON.VertexBuffer.UV3Kind
  26862. * - BABYLON.VertexBuffer.UV4Kind
  26863. * - BABYLON.VertexBuffer.UV5Kind
  26864. * - BABYLON.VertexBuffer.UV6Kind
  26865. * - BABYLON.VertexBuffer.ColorKind
  26866. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26867. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26868. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26869. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26870. * @param data defines the data source
  26871. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26872. * @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)
  26873. * @returns the current mesh
  26874. */
  26875. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26876. /**
  26877. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26878. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26879. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26880. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26881. * @returns the current mesh
  26882. */
  26883. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26884. /**
  26885. * Creates a un-shared specific occurence of the geometry for the mesh.
  26886. * @returns the current mesh
  26887. */
  26888. makeGeometryUnique(): Mesh;
  26889. /**
  26890. * Set the index buffer of this mesh
  26891. * @param indices defines the source data
  26892. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26893. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26894. * @returns the current mesh
  26895. */
  26896. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26897. /**
  26898. * Update the current index buffer
  26899. * @param indices defines the source data
  26900. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26901. * @returns the current mesh
  26902. */
  26903. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26904. /**
  26905. * Invert the geometry to move from a right handed system to a left handed one.
  26906. * @returns the current mesh
  26907. */
  26908. toLeftHanded(): Mesh;
  26909. /** @hidden */
  26910. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26911. /** @hidden */
  26912. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26913. /**
  26914. * Registers for this mesh a javascript function called just before the rendering process
  26915. * @param func defines the function to call before rendering this mesh
  26916. * @returns the current mesh
  26917. */
  26918. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26919. /**
  26920. * Disposes a previously registered javascript function called before the rendering
  26921. * @param func defines the function to remove
  26922. * @returns the current mesh
  26923. */
  26924. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26925. /**
  26926. * Registers for this mesh a javascript function called just after the rendering is complete
  26927. * @param func defines the function to call after rendering this mesh
  26928. * @returns the current mesh
  26929. */
  26930. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26931. /**
  26932. * Disposes a previously registered javascript function called after the rendering.
  26933. * @param func defines the function to remove
  26934. * @returns the current mesh
  26935. */
  26936. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26937. /** @hidden */
  26938. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26939. /** @hidden */
  26940. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26941. /** @hidden */
  26942. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26943. /**
  26944. * 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
  26945. * @param subMesh defines the subMesh to render
  26946. * @param enableAlphaMode defines if alpha mode can be changed
  26947. * @returns the current mesh
  26948. */
  26949. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26950. private _onBeforeDraw;
  26951. /**
  26952. * Renormalize the mesh and patch it up if there are no weights
  26953. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26954. * However in the case of zero weights then we set just a single influence to 1.
  26955. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26956. */
  26957. cleanMatrixWeights(): void;
  26958. private normalizeSkinFourWeights;
  26959. private normalizeSkinWeightsAndExtra;
  26960. /**
  26961. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26962. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26963. * the user know there was an issue with importing the mesh
  26964. * @returns a validation object with skinned, valid and report string
  26965. */
  26966. validateSkinning(): {
  26967. skinned: boolean;
  26968. valid: boolean;
  26969. report: string;
  26970. };
  26971. /** @hidden */
  26972. _checkDelayState(): Mesh;
  26973. private _queueLoad;
  26974. /**
  26975. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26976. * A mesh is in the frustum if its bounding box intersects the frustum
  26977. * @param frustumPlanes defines the frustum to test
  26978. * @returns true if the mesh is in the frustum planes
  26979. */
  26980. isInFrustum(frustumPlanes: Plane[]): boolean;
  26981. /**
  26982. * Sets the mesh material by the material or multiMaterial `id` property
  26983. * @param id is a string identifying the material or the multiMaterial
  26984. * @returns the current mesh
  26985. */
  26986. setMaterialByID(id: string): Mesh;
  26987. /**
  26988. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26989. * @returns an array of IAnimatable
  26990. */
  26991. getAnimatables(): IAnimatable[];
  26992. /**
  26993. * Modifies the mesh geometry according to the passed transformation matrix.
  26994. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26995. * The mesh normals are modified using the same transformation.
  26996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26997. * @param transform defines the transform matrix to use
  26998. * @see http://doc.babylonjs.com/resources/baking_transformations
  26999. * @returns the current mesh
  27000. */
  27001. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27002. /**
  27003. * Modifies the mesh geometry according to its own current World Matrix.
  27004. * The mesh World Matrix is then reset.
  27005. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27006. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27007. * @see http://doc.babylonjs.com/resources/baking_transformations
  27008. * @returns the current mesh
  27009. */
  27010. bakeCurrentTransformIntoVertices(): Mesh;
  27011. /** @hidden */
  27012. readonly _positions: Nullable<Vector3[]>;
  27013. /** @hidden */
  27014. _resetPointsArrayCache(): Mesh;
  27015. /** @hidden */
  27016. _generatePointsArray(): boolean;
  27017. /**
  27018. * Returns a new Mesh object generated from the current mesh properties.
  27019. * This method must not get confused with createInstance()
  27020. * @param name is a string, the name given to the new mesh
  27021. * @param newParent can be any Node object (default `null`)
  27022. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27023. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27024. * @returns a new mesh
  27025. */
  27026. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27027. /**
  27028. * Releases resources associated with this mesh.
  27029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27031. */
  27032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27033. /**
  27034. * Modifies the mesh geometry according to a displacement map.
  27035. * 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.
  27036. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27037. * @param url is a string, the URL from the image file is to be downloaded.
  27038. * @param minHeight is the lower limit of the displacement.
  27039. * @param maxHeight is the upper limit of the displacement.
  27040. * @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.
  27041. * @param uvOffset is an optional vector2 used to offset UV.
  27042. * @param uvScale is an optional vector2 used to scale UV.
  27043. * @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.
  27044. * @returns the Mesh.
  27045. */
  27046. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27047. /**
  27048. * Modifies the mesh geometry according to a displacementMap buffer.
  27049. * 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.
  27050. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27051. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27052. * @param heightMapWidth is the width of the buffer image.
  27053. * @param heightMapHeight is the height of the buffer image.
  27054. * @param minHeight is the lower limit of the displacement.
  27055. * @param maxHeight is the upper limit of the displacement.
  27056. * @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.
  27057. * @param uvOffset is an optional vector2 used to offset UV.
  27058. * @param uvScale is an optional vector2 used to scale UV.
  27059. * @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.
  27060. * @returns the Mesh.
  27061. */
  27062. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27063. /**
  27064. * Modify the mesh to get a flat shading rendering.
  27065. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27066. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27067. * @returns current mesh
  27068. */
  27069. convertToFlatShadedMesh(): Mesh;
  27070. /**
  27071. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27072. * In other words, more vertices, no more indices and a single bigger VBO.
  27073. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27074. * @returns current mesh
  27075. */
  27076. convertToUnIndexedMesh(): Mesh;
  27077. /**
  27078. * Inverses facet orientations.
  27079. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27080. * @param flipNormals will also inverts the normals
  27081. * @returns current mesh
  27082. */
  27083. flipFaces(flipNormals?: boolean): Mesh;
  27084. /**
  27085. * Creates a new InstancedMesh object from the mesh model.
  27086. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27087. * @param name defines the name of the new instance
  27088. * @returns a new InstancedMesh
  27089. */
  27090. createInstance(name: string): InstancedMesh;
  27091. /**
  27092. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27093. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27094. * @returns the current mesh
  27095. */
  27096. synchronizeInstances(): Mesh;
  27097. /**
  27098. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27099. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27100. * This should be used together with the simplification to avoid disappearing triangles.
  27101. * @param successCallback an optional success callback to be called after the optimization finished.
  27102. * @returns the current mesh
  27103. */
  27104. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27105. /**
  27106. * Serialize current mesh
  27107. * @param serializationObject defines the object which will receive the serialization data
  27108. */
  27109. serialize(serializationObject: any): void;
  27110. /** @hidden */
  27111. _syncGeometryWithMorphTargetManager(): void;
  27112. /**
  27113. * Returns a new Mesh object parsed from the source provided.
  27114. * @param parsedMesh is the source
  27115. * @param scene defines the hosting scene
  27116. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27117. * @returns a new Mesh
  27118. */
  27119. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27120. /**
  27121. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27122. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27123. * @param name defines the name of the mesh to create
  27124. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27125. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27126. * @param closePath creates a seam between the first and the last points of each path of the path array
  27127. * @param offset is taken in account only if the `pathArray` is containing a single path
  27128. * @param scene defines the hosting scene
  27129. * @param updatable defines if the mesh must be flagged as updatable
  27130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27131. * @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)
  27132. * @returns a new Mesh
  27133. */
  27134. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27135. /**
  27136. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27137. * @param name defines the name of the mesh to create
  27138. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27139. * @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
  27140. * @param scene defines the hosting scene
  27141. * @param updatable defines if the mesh must be flagged as updatable
  27142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27143. * @returns a new Mesh
  27144. */
  27145. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27146. /**
  27147. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27148. * @param name defines the name of the mesh to create
  27149. * @param size sets the size (float) of each box side (default 1)
  27150. * @param scene defines the hosting scene
  27151. * @param updatable defines if the mesh must be flagged as updatable
  27152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27153. * @returns a new Mesh
  27154. */
  27155. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27156. /**
  27157. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27158. * @param name defines the name of the mesh to create
  27159. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27160. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27161. * @param scene defines the hosting scene
  27162. * @param updatable defines if the mesh must be flagged as updatable
  27163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27164. * @returns a new Mesh
  27165. */
  27166. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27167. /**
  27168. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27169. * @param name defines the name of the mesh to create
  27170. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27171. * @param diameterTop set the top cap diameter (floats, default 1)
  27172. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27173. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27174. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27175. * @param scene defines the hosting scene
  27176. * @param updatable defines if the mesh must be flagged as updatable
  27177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27178. * @returns a new Mesh
  27179. */
  27180. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27181. /**
  27182. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27183. * @param name defines the name of the mesh to create
  27184. * @param diameter sets the diameter size (float) of the torus (default 1)
  27185. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27186. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27187. * @param scene defines the hosting scene
  27188. * @param updatable defines if the mesh must be flagged as updatable
  27189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27190. * @returns a new Mesh
  27191. */
  27192. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27193. /**
  27194. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27195. * @param name defines the name of the mesh to create
  27196. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27197. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27198. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27199. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27200. * @param p the number of windings on X axis (positive integers, default 2)
  27201. * @param q the number of windings on Y axis (positive integers, default 3)
  27202. * @param scene defines the hosting scene
  27203. * @param updatable defines if the mesh must be flagged as updatable
  27204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27205. * @returns a new Mesh
  27206. */
  27207. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27208. /**
  27209. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27210. * @param name defines the name of the mesh to create
  27211. * @param points is an array successive Vector3
  27212. * @param scene defines the hosting scene
  27213. * @param updatable defines if the mesh must be flagged as updatable
  27214. * @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).
  27215. * @returns a new Mesh
  27216. */
  27217. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27218. /**
  27219. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27220. * @param name defines the name of the mesh to create
  27221. * @param points is an array successive Vector3
  27222. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27223. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27224. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27225. * @param scene defines the hosting scene
  27226. * @param updatable defines if the mesh must be flagged as updatable
  27227. * @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)
  27228. * @returns a new Mesh
  27229. */
  27230. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27231. /**
  27232. * Creates a polygon mesh.
  27233. * Please consider using the same method from the MeshBuilder class instead.
  27234. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27235. * 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.
  27236. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27237. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27238. * Remember you can only change the shape positions, not their number when updating a polygon.
  27239. */
  27240. /**
  27241. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27242. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27243. * @param name defines the name of the mesh to create
  27244. * @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
  27245. * @param scene defines the hosting scene
  27246. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27247. * @param updatable defines if the mesh must be flagged as updatable
  27248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27249. * @returns a new Mesh
  27250. */
  27251. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27252. /**
  27253. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27254. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27255. * @param name defines the name of the mesh to create
  27256. * @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
  27257. * @param depth defines the height of extrusion
  27258. * @param scene defines the hosting scene
  27259. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27260. * @param updatable defines if the mesh must be flagged as updatable
  27261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27262. * @returns a new Mesh
  27263. */
  27264. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27265. /**
  27266. * Creates an extruded shape mesh.
  27267. * 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
  27268. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27270. * @param name defines the name of the mesh to create
  27271. * @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
  27272. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27273. * @param scale is the value to scale the shape
  27274. * @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
  27275. * @param 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
  27276. * @param scene defines the hosting scene
  27277. * @param updatable defines if the mesh must be flagged as updatable
  27278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27279. * @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)
  27280. * @returns a new Mesh
  27281. */
  27282. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27283. /**
  27284. * Creates an custom extruded shape mesh.
  27285. * The custom extrusion is a parametric shape.
  27286. * It has no predefined shape. Its final shape will depend on the input parameters.
  27287. * Please consider using the same method from the MeshBuilder class instead
  27288. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27289. * @param name defines the name of the mesh to create
  27290. * @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
  27291. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27292. * @param scaleFunction is a custom Javascript function called on each path point
  27293. * @param rotationFunction is a custom Javascript function called on each path point
  27294. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27295. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27296. * @param 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
  27297. * @param scene defines the hosting scene
  27298. * @param updatable defines if the mesh must be flagged as updatable
  27299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27300. * @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)
  27301. * @returns a new Mesh
  27302. */
  27303. 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;
  27304. /**
  27305. * Creates lathe mesh.
  27306. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27307. * Please consider using the same method from the MeshBuilder class instead
  27308. * @param name defines the name of the mesh to create
  27309. * @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
  27310. * @param radius is the radius value of the lathe
  27311. * @param tessellation is the side number of the lathe.
  27312. * @param scene defines the hosting scene
  27313. * @param updatable defines if the mesh must be flagged as updatable
  27314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27315. * @returns a new Mesh
  27316. */
  27317. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27318. /**
  27319. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27320. * @param name defines the name of the mesh to create
  27321. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27322. * @param scene defines the hosting scene
  27323. * @param updatable defines if the mesh must be flagged as updatable
  27324. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27325. * @returns a new Mesh
  27326. */
  27327. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27328. /**
  27329. * Creates a ground mesh.
  27330. * Please consider using the same method from the MeshBuilder class instead
  27331. * @param name defines the name of the mesh to create
  27332. * @param width set the width of the ground
  27333. * @param height set the height of the ground
  27334. * @param subdivisions sets the number of subdivisions per side
  27335. * @param scene defines the hosting scene
  27336. * @param updatable defines if the mesh must be flagged as updatable
  27337. * @returns a new Mesh
  27338. */
  27339. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27340. /**
  27341. * Creates a tiled ground mesh.
  27342. * Please consider using the same method from the MeshBuilder class instead
  27343. * @param name defines the name of the mesh to create
  27344. * @param xmin set the ground minimum X coordinate
  27345. * @param zmin set the ground minimum Y coordinate
  27346. * @param xmax set the ground maximum X coordinate
  27347. * @param zmax set the ground maximum Z coordinate
  27348. * @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
  27349. * @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
  27350. * @param scene defines the hosting scene
  27351. * @param updatable defines if the mesh must be flagged as updatable
  27352. * @returns a new Mesh
  27353. */
  27354. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27355. w: number;
  27356. h: number;
  27357. }, precision: {
  27358. w: number;
  27359. h: number;
  27360. }, scene: Scene, updatable?: boolean): Mesh;
  27361. /**
  27362. * Creates a ground mesh from a height map.
  27363. * Please consider using the same method from the MeshBuilder class instead
  27364. * @see http://doc.babylonjs.com/babylon101/height_map
  27365. * @param name defines the name of the mesh to create
  27366. * @param url sets the URL of the height map image resource
  27367. * @param width set the ground width size
  27368. * @param height set the ground height size
  27369. * @param subdivisions sets the number of subdivision per side
  27370. * @param minHeight is the minimum altitude on the ground
  27371. * @param maxHeight is the maximum altitude on the ground
  27372. * @param scene defines the hosting scene
  27373. * @param updatable defines if the mesh must be flagged as updatable
  27374. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27375. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27376. * @returns a new Mesh
  27377. */
  27378. 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;
  27379. /**
  27380. * Creates a tube mesh.
  27381. * The tube is a parametric shape.
  27382. * It has no predefined shape. Its final shape will depend on the input parameters.
  27383. * Please consider using the same method from the MeshBuilder class instead
  27384. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27385. * @param name defines the name of the mesh to create
  27386. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27387. * @param radius sets the tube radius size
  27388. * @param tessellation is the number of sides on the tubular surface
  27389. * @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
  27390. * @param 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
  27391. * @param scene defines the hosting scene
  27392. * @param updatable defines if the mesh must be flagged as updatable
  27393. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27394. * @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)
  27395. * @returns a new Mesh
  27396. */
  27397. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27398. (i: number, distance: number): number;
  27399. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27400. /**
  27401. * Creates a polyhedron mesh.
  27402. * Please consider using the same method from the MeshBuilder class instead.
  27403. * * 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
  27404. * * The parameter `size` (positive float, default 1) sets the polygon size
  27405. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27406. * * 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`
  27407. * * 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
  27408. * * 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)`)
  27409. * * 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
  27410. * * 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
  27411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27412. * * 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
  27413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27414. * @param name defines the name of the mesh to create
  27415. * @param options defines the options used to create the mesh
  27416. * @param scene defines the hosting scene
  27417. * @returns a new Mesh
  27418. */
  27419. static CreatePolyhedron(name: string, options: {
  27420. type?: number;
  27421. size?: number;
  27422. sizeX?: number;
  27423. sizeY?: number;
  27424. sizeZ?: number;
  27425. custom?: any;
  27426. faceUV?: Vector4[];
  27427. faceColors?: Color4[];
  27428. updatable?: boolean;
  27429. sideOrientation?: number;
  27430. }, scene: Scene): Mesh;
  27431. /**
  27432. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27433. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27434. * * 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`)
  27435. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27436. * * 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
  27437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27438. * * 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
  27439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27440. * @param name defines the name of the mesh
  27441. * @param options defines the options used to create the mesh
  27442. * @param scene defines the hosting scene
  27443. * @returns a new Mesh
  27444. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27445. */
  27446. static CreateIcoSphere(name: string, options: {
  27447. radius?: number;
  27448. flat?: boolean;
  27449. subdivisions?: number;
  27450. sideOrientation?: number;
  27451. updatable?: boolean;
  27452. }, scene: Scene): Mesh;
  27453. /**
  27454. * Creates a decal mesh.
  27455. * Please consider using the same method from the MeshBuilder class instead.
  27456. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27457. * @param name defines the name of the mesh
  27458. * @param sourceMesh defines the mesh receiving the decal
  27459. * @param position sets the position of the decal in world coordinates
  27460. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27461. * @param size sets the decal scaling
  27462. * @param angle sets the angle to rotate the decal
  27463. * @returns a new Mesh
  27464. */
  27465. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27466. /**
  27467. * Prepare internal position array for software CPU skinning
  27468. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27469. */
  27470. setPositionsForCPUSkinning(): Float32Array;
  27471. /**
  27472. * Prepare internal normal array for software CPU skinning
  27473. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27474. */
  27475. setNormalsForCPUSkinning(): Float32Array;
  27476. /**
  27477. * Updates the vertex buffer by applying transformation from the bones
  27478. * @param skeleton defines the skeleton to apply to current mesh
  27479. * @returns the current mesh
  27480. */
  27481. applySkeleton(skeleton: Skeleton): Mesh;
  27482. /**
  27483. * 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
  27484. * @param meshes defines the list of meshes to scan
  27485. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27486. */
  27487. static MinMax(meshes: AbstractMesh[]): {
  27488. min: Vector3;
  27489. max: Vector3;
  27490. };
  27491. /**
  27492. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27493. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27494. * @returns a vector3
  27495. */
  27496. static Center(meshesOrMinMaxVector: {
  27497. min: Vector3;
  27498. max: Vector3;
  27499. } | AbstractMesh[]): Vector3;
  27500. /**
  27501. * Merge the array of meshes into a single mesh for performance reasons.
  27502. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27503. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27504. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27505. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27506. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27507. * @returns a new mesh
  27508. */
  27509. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27510. /** @hidden */
  27511. addInstance(instance: InstancedMesh): void;
  27512. /** @hidden */
  27513. removeInstance(instance: InstancedMesh): void;
  27514. }
  27515. }
  27516. declare module BABYLON {
  27517. /**
  27518. * Define an interface for all classes that will get and set the data on vertices
  27519. */
  27520. interface IGetSetVerticesData {
  27521. /**
  27522. * Gets a boolean indicating if specific vertex data is present
  27523. * @param kind defines the vertex data kind to use
  27524. * @returns true is data kind is present
  27525. */
  27526. isVerticesDataPresent(kind: string): boolean;
  27527. /**
  27528. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27529. * @param kind defines the data kind (Position, normal, etc...)
  27530. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27532. * @returns a float array containing vertex data
  27533. */
  27534. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27535. /**
  27536. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27537. * @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.
  27538. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27539. * @returns the indices array or an empty array if the mesh has no geometry
  27540. */
  27541. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27542. /**
  27543. * Set specific vertex data
  27544. * @param kind defines the data kind (Position, normal, etc...)
  27545. * @param data defines the vertex data to use
  27546. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27547. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27548. */
  27549. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27550. /**
  27551. * Update a specific associated vertex buffer
  27552. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27553. * - BABYLON.VertexBuffer.PositionKind
  27554. * - BABYLON.VertexBuffer.UVKind
  27555. * - BABYLON.VertexBuffer.UV2Kind
  27556. * - BABYLON.VertexBuffer.UV3Kind
  27557. * - BABYLON.VertexBuffer.UV4Kind
  27558. * - BABYLON.VertexBuffer.UV5Kind
  27559. * - BABYLON.VertexBuffer.UV6Kind
  27560. * - BABYLON.VertexBuffer.ColorKind
  27561. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27562. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27563. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27564. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27565. * @param data defines the data source
  27566. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27567. * @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)
  27568. */
  27569. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27570. /**
  27571. * Creates a new index buffer
  27572. * @param indices defines the indices to store in the index buffer
  27573. * @param totalVertices defines the total number of vertices (could be null)
  27574. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27575. */
  27576. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27577. }
  27578. /**
  27579. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27580. */
  27581. class VertexData {
  27582. /**
  27583. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27584. */
  27585. positions: Nullable<FloatArray>;
  27586. /**
  27587. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27588. */
  27589. normals: Nullable<FloatArray>;
  27590. /**
  27591. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27592. */
  27593. tangents: Nullable<FloatArray>;
  27594. /**
  27595. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27596. */
  27597. uvs: Nullable<FloatArray>;
  27598. /**
  27599. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27600. */
  27601. uvs2: Nullable<FloatArray>;
  27602. /**
  27603. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27604. */
  27605. uvs3: Nullable<FloatArray>;
  27606. /**
  27607. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27608. */
  27609. uvs4: Nullable<FloatArray>;
  27610. /**
  27611. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27612. */
  27613. uvs5: Nullable<FloatArray>;
  27614. /**
  27615. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27616. */
  27617. uvs6: Nullable<FloatArray>;
  27618. /**
  27619. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27620. */
  27621. colors: Nullable<FloatArray>;
  27622. /**
  27623. * 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).
  27624. */
  27625. matricesIndices: Nullable<FloatArray>;
  27626. /**
  27627. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27628. */
  27629. matricesWeights: Nullable<FloatArray>;
  27630. /**
  27631. * An array extending the number of possible indices
  27632. */
  27633. matricesIndicesExtra: Nullable<FloatArray>;
  27634. /**
  27635. * An array extending the number of possible weights when the number of indices is extended
  27636. */
  27637. matricesWeightsExtra: Nullable<FloatArray>;
  27638. /**
  27639. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27640. */
  27641. indices: Nullable<IndicesArray>;
  27642. /**
  27643. * Uses the passed data array to set the set the values for the specified kind of data
  27644. * @param data a linear array of floating numbers
  27645. * @param kind the type of data that is being set, eg positions, colors etc
  27646. */
  27647. set(data: FloatArray, kind: string): void;
  27648. /**
  27649. * Associates the vertexData to the passed Mesh.
  27650. * Sets it as updatable or not (default `false`)
  27651. * @param mesh the mesh the vertexData is applied to
  27652. * @param updatable when used and having the value true allows new data to update the vertexData
  27653. * @returns the VertexData
  27654. */
  27655. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27656. /**
  27657. * Associates the vertexData to the passed Geometry.
  27658. * Sets it as updatable or not (default `false`)
  27659. * @param geometry the geometry the vertexData is applied to
  27660. * @param updatable when used and having the value true allows new data to update the vertexData
  27661. * @returns VertexData
  27662. */
  27663. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27664. /**
  27665. * Updates the associated mesh
  27666. * @param mesh the mesh to be updated
  27667. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27668. * @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
  27669. * @returns VertexData
  27670. */
  27671. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27672. /**
  27673. * Updates the associated geometry
  27674. * @param geometry the geometry to be updated
  27675. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27676. * @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
  27677. * @returns VertexData.
  27678. */
  27679. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27680. private _applyTo;
  27681. private _update;
  27682. /**
  27683. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27684. * @param matrix the transforming matrix
  27685. * @returns the VertexData
  27686. */
  27687. transform(matrix: Matrix): VertexData;
  27688. /**
  27689. * Merges the passed VertexData into the current one
  27690. * @param other the VertexData to be merged into the current one
  27691. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27692. * @returns the modified VertexData
  27693. */
  27694. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27695. private _mergeElement;
  27696. private _validate;
  27697. /**
  27698. * Serializes the VertexData
  27699. * @returns a serialized object
  27700. */
  27701. serialize(): any;
  27702. /**
  27703. * Extracts the vertexData from a mesh
  27704. * @param mesh the mesh from which to extract the VertexData
  27705. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27706. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27707. * @returns the object VertexData associated to the passed mesh
  27708. */
  27709. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27710. /**
  27711. * Extracts the vertexData from the geometry
  27712. * @param geometry the geometry from which to extract the VertexData
  27713. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27714. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27715. * @returns the object VertexData associated to the passed mesh
  27716. */
  27717. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27718. private static _ExtractFrom;
  27719. /**
  27720. * Creates the VertexData for a Ribbon
  27721. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27722. * * pathArray array of paths, each of which an array of successive Vector3
  27723. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27724. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27725. * * 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
  27726. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27727. * * 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)
  27728. * * 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)
  27729. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27730. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27731. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27732. * @returns the VertexData of the ribbon
  27733. */
  27734. static CreateRibbon(options: {
  27735. pathArray: Vector3[][];
  27736. closeArray?: boolean;
  27737. closePath?: boolean;
  27738. offset?: number;
  27739. sideOrientation?: number;
  27740. frontUVs?: Vector4;
  27741. backUVs?: Vector4;
  27742. invertUV?: boolean;
  27743. uvs?: Vector2[];
  27744. colors?: Color4[];
  27745. }): VertexData;
  27746. /**
  27747. * Creates the VertexData for a box
  27748. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27749. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27750. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27751. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27752. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27753. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27754. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27755. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27756. * * 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)
  27757. * * 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)
  27758. * @returns the VertexData of the box
  27759. */
  27760. static CreateBox(options: {
  27761. size?: number;
  27762. width?: number;
  27763. height?: number;
  27764. depth?: number;
  27765. faceUV?: Vector4[];
  27766. faceColors?: Color4[];
  27767. sideOrientation?: number;
  27768. frontUVs?: Vector4;
  27769. backUVs?: Vector4;
  27770. }): VertexData;
  27771. /**
  27772. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27773. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27774. * * segments sets the number of horizontal strips optional, default 32
  27775. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27776. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27777. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27778. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27779. * * 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
  27780. * * 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
  27781. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27782. * * 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)
  27783. * * 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)
  27784. * @returns the VertexData of the ellipsoid
  27785. */
  27786. static CreateSphere(options: {
  27787. segments?: number;
  27788. diameter?: number;
  27789. diameterX?: number;
  27790. diameterY?: number;
  27791. diameterZ?: number;
  27792. arc?: number;
  27793. slice?: number;
  27794. sideOrientation?: number;
  27795. frontUVs?: Vector4;
  27796. backUVs?: Vector4;
  27797. }): VertexData;
  27798. /**
  27799. * Creates the VertexData for a cylinder, cone or prism
  27800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27801. * * height sets the height (y direction) of the cylinder, optional, default 2
  27802. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27803. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27804. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27805. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27806. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27807. * * 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
  27808. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27809. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27810. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27811. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27812. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27813. * * 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)
  27814. * * 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)
  27815. * @returns the VertexData of the cylinder, cone or prism
  27816. */
  27817. static CreateCylinder(options: {
  27818. height?: number;
  27819. diameterTop?: number;
  27820. diameterBottom?: number;
  27821. diameter?: number;
  27822. tessellation?: number;
  27823. subdivisions?: number;
  27824. arc?: number;
  27825. faceColors?: Color4[];
  27826. faceUV?: Vector4[];
  27827. hasRings?: boolean;
  27828. enclose?: boolean;
  27829. sideOrientation?: number;
  27830. frontUVs?: Vector4;
  27831. backUVs?: Vector4;
  27832. }): VertexData;
  27833. /**
  27834. * Creates the VertexData for a torus
  27835. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27836. * * diameter the diameter of the torus, optional default 1
  27837. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27838. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27839. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27840. * * 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)
  27841. * * 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)
  27842. * @returns the VertexData of the torus
  27843. */
  27844. static CreateTorus(options: {
  27845. diameter?: number;
  27846. thickness?: number;
  27847. tessellation?: number;
  27848. sideOrientation?: number;
  27849. frontUVs?: Vector4;
  27850. backUVs?: Vector4;
  27851. }): VertexData;
  27852. /**
  27853. * Creates the VertexData of the LineSystem
  27854. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27855. * - lines an array of lines, each line being an array of successive Vector3
  27856. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27857. * @returns the VertexData of the LineSystem
  27858. */
  27859. static CreateLineSystem(options: {
  27860. lines: Vector3[][];
  27861. colors?: Nullable<Color4[][]>;
  27862. }): VertexData;
  27863. /**
  27864. * Create the VertexData for a DashedLines
  27865. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27866. * - points an array successive Vector3
  27867. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27868. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27869. * - dashNb the intended total number of dashes, optional, default 200
  27870. * @returns the VertexData for the DashedLines
  27871. */
  27872. static CreateDashedLines(options: {
  27873. points: Vector3[];
  27874. dashSize?: number;
  27875. gapSize?: number;
  27876. dashNb?: number;
  27877. }): VertexData;
  27878. /**
  27879. * Creates the VertexData for a Ground
  27880. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27881. * - width the width (x direction) of the ground, optional, default 1
  27882. * - height the height (z direction) of the ground, optional, default 1
  27883. * - subdivisions the number of subdivisions per side, optional, default 1
  27884. * @returns the VertexData of the Ground
  27885. */
  27886. static CreateGround(options: {
  27887. width?: number;
  27888. height?: number;
  27889. subdivisions?: number;
  27890. subdivisionsX?: number;
  27891. subdivisionsY?: number;
  27892. }): VertexData;
  27893. /**
  27894. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27895. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27896. * * xmin the ground minimum X coordinate, optional, default -1
  27897. * * zmin the ground minimum Z coordinate, optional, default -1
  27898. * * xmax the ground maximum X coordinate, optional, default 1
  27899. * * zmax the ground maximum Z coordinate, optional, default 1
  27900. * * 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}
  27901. * * 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}
  27902. * @returns the VertexData of the TiledGround
  27903. */
  27904. static CreateTiledGround(options: {
  27905. xmin: number;
  27906. zmin: number;
  27907. xmax: number;
  27908. zmax: number;
  27909. subdivisions?: {
  27910. w: number;
  27911. h: number;
  27912. };
  27913. precision?: {
  27914. w: number;
  27915. h: number;
  27916. };
  27917. }): VertexData;
  27918. /**
  27919. * Creates the VertexData of the Ground designed from a heightmap
  27920. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27921. * * width the width (x direction) of the ground
  27922. * * height the height (z direction) of the ground
  27923. * * subdivisions the number of subdivisions per side
  27924. * * minHeight the minimum altitude on the ground, optional, default 0
  27925. * * maxHeight the maximum altitude on the ground, optional default 1
  27926. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27927. * * buffer the array holding the image color data
  27928. * * bufferWidth the width of image
  27929. * * bufferHeight the height of image
  27930. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27931. * @returns the VertexData of the Ground designed from a heightmap
  27932. */
  27933. static CreateGroundFromHeightMap(options: {
  27934. width: number;
  27935. height: number;
  27936. subdivisions: number;
  27937. minHeight: number;
  27938. maxHeight: number;
  27939. colorFilter: Color3;
  27940. buffer: Uint8Array;
  27941. bufferWidth: number;
  27942. bufferHeight: number;
  27943. alphaFilter: number;
  27944. }): VertexData;
  27945. /**
  27946. * Creates the VertexData for a Plane
  27947. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27948. * * size sets the width and height of the plane to the value of size, optional default 1
  27949. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27950. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27951. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27952. * * 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)
  27953. * * 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)
  27954. * @returns the VertexData of the box
  27955. */
  27956. static CreatePlane(options: {
  27957. size?: number;
  27958. width?: number;
  27959. height?: number;
  27960. sideOrientation?: number;
  27961. frontUVs?: Vector4;
  27962. backUVs?: Vector4;
  27963. }): VertexData;
  27964. /**
  27965. * Creates the VertexData of the Disc or regular Polygon
  27966. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27967. * * radius the radius of the disc, optional default 0.5
  27968. * * tessellation the number of polygon sides, optional, default 64
  27969. * * 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
  27970. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27971. * * 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)
  27972. * * 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)
  27973. * @returns the VertexData of the box
  27974. */
  27975. static CreateDisc(options: {
  27976. radius?: number;
  27977. tessellation?: number;
  27978. arc?: number;
  27979. sideOrientation?: number;
  27980. frontUVs?: Vector4;
  27981. backUVs?: Vector4;
  27982. }): VertexData;
  27983. /**
  27984. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27985. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27986. * @param polygon a mesh built from polygonTriangulation.build()
  27987. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27988. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27989. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27990. * @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)
  27991. * @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)
  27992. * @returns the VertexData of the Polygon
  27993. */
  27994. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27995. /**
  27996. * Creates the VertexData of the IcoSphere
  27997. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27998. * * radius the radius of the IcoSphere, optional default 1
  27999. * * radiusX allows stretching in the x direction, optional, default radius
  28000. * * radiusY allows stretching in the y direction, optional, default radius
  28001. * * radiusZ allows stretching in the z direction, optional, default radius
  28002. * * flat when true creates a flat shaded mesh, optional, default true
  28003. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28004. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28005. * * 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)
  28006. * * 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)
  28007. * @returns the VertexData of the IcoSphere
  28008. */
  28009. static CreateIcoSphere(options: {
  28010. radius?: number;
  28011. radiusX?: number;
  28012. radiusY?: number;
  28013. radiusZ?: number;
  28014. flat?: boolean;
  28015. subdivisions?: number;
  28016. sideOrientation?: number;
  28017. frontUVs?: Vector4;
  28018. backUVs?: Vector4;
  28019. }): VertexData;
  28020. /**
  28021. * Creates the VertexData for a Polyhedron
  28022. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28023. * * type provided types are:
  28024. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28025. * * 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)
  28026. * * size the size of the IcoSphere, optional default 1
  28027. * * sizeX allows stretching in the x direction, optional, default size
  28028. * * sizeY allows stretching in the y direction, optional, default size
  28029. * * sizeZ allows stretching in the z direction, optional, default size
  28030. * * 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
  28031. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28032. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28033. * * flat when true creates a flat shaded mesh, optional, default true
  28034. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28035. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28036. * * 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)
  28037. * * 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)
  28038. * @returns the VertexData of the Polyhedron
  28039. */
  28040. static CreatePolyhedron(options: {
  28041. type?: number;
  28042. size?: number;
  28043. sizeX?: number;
  28044. sizeY?: number;
  28045. sizeZ?: number;
  28046. custom?: any;
  28047. faceUV?: Vector4[];
  28048. faceColors?: Color4[];
  28049. flat?: boolean;
  28050. sideOrientation?: number;
  28051. frontUVs?: Vector4;
  28052. backUVs?: Vector4;
  28053. }): VertexData;
  28054. /**
  28055. * Creates the VertexData for a TorusKnot
  28056. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28057. * * radius the radius of the torus knot, optional, default 2
  28058. * * tube the thickness of the tube, optional, default 0.5
  28059. * * radialSegments the number of sides on each tube segments, optional, default 32
  28060. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28061. * * p the number of windings around the z axis, optional, default 2
  28062. * * q the number of windings around the x axis, optional, default 3
  28063. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28064. * * 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)
  28065. * * 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)
  28066. * @returns the VertexData of the Torus Knot
  28067. */
  28068. static CreateTorusKnot(options: {
  28069. radius?: number;
  28070. tube?: number;
  28071. radialSegments?: number;
  28072. tubularSegments?: number;
  28073. p?: number;
  28074. q?: number;
  28075. sideOrientation?: number;
  28076. frontUVs?: Vector4;
  28077. backUVs?: Vector4;
  28078. }): VertexData;
  28079. /**
  28080. * Compute normals for given positions and indices
  28081. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28082. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28083. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28084. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28085. * * facetNormals : optional array of facet normals (vector3)
  28086. * * facetPositions : optional array of facet positions (vector3)
  28087. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28088. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28089. * * bInfo : optional bounding info, required for facetPartitioning computation
  28090. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28091. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28092. * * useRightHandedSystem: optional boolean to for right handed system computation
  28093. * * depthSort : optional boolean to enable the facet depth sort computation
  28094. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28095. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28096. */
  28097. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28098. facetNormals?: any;
  28099. facetPositions?: any;
  28100. facetPartitioning?: any;
  28101. ratio?: number;
  28102. bInfo?: any;
  28103. bbSize?: Vector3;
  28104. subDiv?: any;
  28105. useRightHandedSystem?: boolean;
  28106. depthSort?: boolean;
  28107. distanceTo?: Vector3;
  28108. depthSortedFacets?: any;
  28109. }): void;
  28110. private static _ComputeSides;
  28111. /**
  28112. * Applies VertexData created from the imported parameters to the geometry
  28113. * @param parsedVertexData the parsed data from an imported file
  28114. * @param geometry the geometry to apply the VertexData to
  28115. */
  28116. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28117. }
  28118. }
  28119. declare module BABYLON {
  28120. /**
  28121. * Class containing static functions to help procedurally build meshes
  28122. */
  28123. class MeshBuilder {
  28124. private static updateSideOrientation;
  28125. /**
  28126. * Creates a box mesh
  28127. * * The parameter `size` sets the size (float) of each box side (default 1)
  28128. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28129. * * 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)
  28130. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28132. * * 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
  28133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28134. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28135. * @param name defines the name of the mesh
  28136. * @param options defines the options used to create the mesh
  28137. * @param scene defines the hosting scene
  28138. * @returns the box mesh
  28139. */
  28140. static CreateBox(name: string, options: {
  28141. size?: number;
  28142. width?: number;
  28143. height?: number;
  28144. depth?: number;
  28145. faceUV?: Vector4[];
  28146. faceColors?: Color4[];
  28147. sideOrientation?: number;
  28148. frontUVs?: Vector4;
  28149. backUVs?: Vector4;
  28150. updatable?: boolean;
  28151. }, scene?: Nullable<Scene>): Mesh;
  28152. /**
  28153. * Creates a sphere mesh
  28154. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28155. * * 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`)
  28156. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28157. * * 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
  28158. * * 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)
  28159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28160. * * 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
  28161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28162. * @param name defines the name of the mesh
  28163. * @param options defines the options used to create the mesh
  28164. * @param scene defines the hosting scene
  28165. * @returns the sphere mesh
  28166. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28167. */
  28168. static CreateSphere(name: string, options: {
  28169. segments?: number;
  28170. diameter?: number;
  28171. diameterX?: number;
  28172. diameterY?: number;
  28173. diameterZ?: number;
  28174. arc?: number;
  28175. slice?: number;
  28176. sideOrientation?: number;
  28177. frontUVs?: Vector4;
  28178. backUVs?: Vector4;
  28179. updatable?: boolean;
  28180. }, scene: any): Mesh;
  28181. /**
  28182. * Creates a plane polygonal mesh. By default, this is a disc
  28183. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28184. * * 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
  28185. * * 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
  28186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28187. * * 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
  28188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28189. * @param name defines the name of the mesh
  28190. * @param options defines the options used to create the mesh
  28191. * @param scene defines the hosting scene
  28192. * @returns the plane polygonal mesh
  28193. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28194. */
  28195. static CreateDisc(name: string, options: {
  28196. radius?: number;
  28197. tessellation?: number;
  28198. arc?: number;
  28199. updatable?: boolean;
  28200. sideOrientation?: number;
  28201. frontUVs?: Vector4;
  28202. backUVs?: Vector4;
  28203. }, scene?: Nullable<Scene>): Mesh;
  28204. /**
  28205. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28206. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28207. * * 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`)
  28208. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28209. * * 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
  28210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28211. * * 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
  28212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28213. * @param name defines the name of the mesh
  28214. * @param options defines the options used to create the mesh
  28215. * @param scene defines the hosting scene
  28216. * @returns the icosahedron mesh
  28217. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28218. */
  28219. static CreateIcoSphere(name: string, options: {
  28220. radius?: number;
  28221. radiusX?: number;
  28222. radiusY?: number;
  28223. radiusZ?: number;
  28224. flat?: boolean;
  28225. subdivisions?: number;
  28226. sideOrientation?: number;
  28227. frontUVs?: Vector4;
  28228. backUVs?: Vector4;
  28229. updatable?: boolean;
  28230. }, scene: Scene): Mesh;
  28231. /**
  28232. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28233. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28234. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28235. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28236. * * 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
  28237. * * 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
  28238. * * 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
  28239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28240. * * 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
  28241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28242. * * 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
  28243. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28244. * * 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
  28245. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28247. * @param name defines the name of the mesh
  28248. * @param options defines the options used to create the mesh
  28249. * @param scene defines the hosting scene
  28250. * @returns the ribbon mesh
  28251. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28253. */
  28254. static CreateRibbon(name: string, options: {
  28255. pathArray: Vector3[][];
  28256. closeArray?: boolean;
  28257. closePath?: boolean;
  28258. offset?: number;
  28259. updatable?: boolean;
  28260. sideOrientation?: number;
  28261. frontUVs?: Vector4;
  28262. backUVs?: Vector4;
  28263. instance?: Mesh;
  28264. invertUV?: boolean;
  28265. uvs?: Vector2[];
  28266. colors?: Color4[];
  28267. }, scene?: Nullable<Scene>): Mesh;
  28268. /**
  28269. * Creates a cylinder or a cone mesh
  28270. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28271. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28272. * * 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.
  28273. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28274. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28275. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28276. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28277. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28278. * * 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).
  28279. * * 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
  28280. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28281. * * 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
  28282. * * 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.
  28283. * * If `enclose` is false, a ring surface is one element.
  28284. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28285. * * 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
  28286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28287. * * 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
  28288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28289. * @param name defines the name of the mesh
  28290. * @param options defines the options used to create the mesh
  28291. * @param scene defines the hosting scene
  28292. * @returns the cylinder mesh
  28293. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28294. */
  28295. static CreateCylinder(name: string, options: {
  28296. height?: number;
  28297. diameterTop?: number;
  28298. diameterBottom?: number;
  28299. diameter?: number;
  28300. tessellation?: number;
  28301. subdivisions?: number;
  28302. arc?: number;
  28303. faceColors?: Color4[];
  28304. faceUV?: Vector4[];
  28305. updatable?: boolean;
  28306. hasRings?: boolean;
  28307. enclose?: boolean;
  28308. sideOrientation?: number;
  28309. frontUVs?: Vector4;
  28310. backUVs?: Vector4;
  28311. }, scene: any): Mesh;
  28312. /**
  28313. * Creates a torus mesh
  28314. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28315. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28316. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28318. * * 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
  28319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28320. * @param name defines the name of the mesh
  28321. * @param options defines the options used to create the mesh
  28322. * @param scene defines the hosting scene
  28323. * @returns the torus mesh
  28324. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28325. */
  28326. static CreateTorus(name: string, options: {
  28327. diameter?: number;
  28328. thickness?: number;
  28329. tessellation?: number;
  28330. updatable?: boolean;
  28331. sideOrientation?: number;
  28332. frontUVs?: Vector4;
  28333. backUVs?: Vector4;
  28334. }, scene: any): Mesh;
  28335. /**
  28336. * Creates a torus knot mesh
  28337. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28338. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28339. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28340. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28342. * * 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
  28343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28344. * @param name defines the name of the mesh
  28345. * @param options defines the options used to create the mesh
  28346. * @param scene defines the hosting scene
  28347. * @returns the torus knot mesh
  28348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28349. */
  28350. static CreateTorusKnot(name: string, options: {
  28351. radius?: number;
  28352. tube?: number;
  28353. radialSegments?: number;
  28354. tubularSegments?: number;
  28355. p?: number;
  28356. q?: number;
  28357. updatable?: boolean;
  28358. sideOrientation?: number;
  28359. frontUVs?: Vector4;
  28360. backUVs?: Vector4;
  28361. }, scene: any): Mesh;
  28362. /**
  28363. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28364. * * 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
  28365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28366. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28367. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28368. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28369. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28370. * * 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
  28371. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28374. * @param name defines the name of the new line system
  28375. * @param options defines the options used to create the line system
  28376. * @param scene defines the hosting scene
  28377. * @returns a new line system mesh
  28378. */
  28379. static CreateLineSystem(name: string, options: {
  28380. lines: Vector3[][];
  28381. updatable?: boolean;
  28382. instance?: Nullable<LinesMesh>;
  28383. colors?: Nullable<Color4[][]>;
  28384. useVertexAlpha?: boolean;
  28385. }, scene: Nullable<Scene>): LinesMesh;
  28386. /**
  28387. * Creates a line mesh
  28388. * 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
  28389. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28390. * * The parameter `points` is an array successive Vector3
  28391. * * 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
  28392. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28393. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28394. * * When updating an instance, remember that only point positions can change, not the number of points
  28395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28397. * @param name defines the name of the new line system
  28398. * @param options defines the options used to create the line system
  28399. * @param scene defines the hosting scene
  28400. * @returns a new line mesh
  28401. */
  28402. static CreateLines(name: string, options: {
  28403. points: Vector3[];
  28404. updatable?: boolean;
  28405. instance?: Nullable<LinesMesh>;
  28406. colors?: Color4[];
  28407. useVertexAlpha?: boolean;
  28408. }, scene?: Nullable<Scene>): LinesMesh;
  28409. /**
  28410. * Creates a dashed line mesh
  28411. * * 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
  28412. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28413. * * The parameter `points` is an array successive Vector3
  28414. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28415. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28416. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28417. * * 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
  28418. * * When updating an instance, remember that only point positions can change, not the number of points
  28419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28420. * @param name defines the name of the mesh
  28421. * @param options defines the options used to create the mesh
  28422. * @param scene defines the hosting scene
  28423. * @returns the dashed line mesh
  28424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28425. */
  28426. static CreateDashedLines(name: string, options: {
  28427. points: Vector3[];
  28428. dashSize?: number;
  28429. gapSize?: number;
  28430. dashNb?: number;
  28431. updatable?: boolean;
  28432. instance?: LinesMesh;
  28433. }, scene?: Nullable<Scene>): LinesMesh;
  28434. /**
  28435. * 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.
  28436. * * 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.
  28437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28438. * * 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.
  28439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28440. * * 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
  28441. * * 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
  28442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28444. * * 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
  28445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28447. * @param name defines the name of the mesh
  28448. * @param options defines the options used to create the mesh
  28449. * @param scene defines the hosting scene
  28450. * @returns the extruded shape mesh
  28451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28453. */
  28454. static ExtrudeShape(name: string, options: {
  28455. shape: Vector3[];
  28456. path: Vector3[];
  28457. scale?: number;
  28458. rotation?: number;
  28459. cap?: number;
  28460. updatable?: boolean;
  28461. sideOrientation?: number;
  28462. frontUVs?: Vector4;
  28463. backUVs?: Vector4;
  28464. instance?: Mesh;
  28465. invertUV?: boolean;
  28466. }, scene?: Nullable<Scene>): Mesh;
  28467. /**
  28468. * Creates an custom extruded shape mesh.
  28469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28470. * * 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.
  28471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28472. * * 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
  28473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28474. * * 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
  28475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28478. * * 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
  28479. * * 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
  28480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28482. * * 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
  28483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28485. * @param name defines the name of the mesh
  28486. * @param options defines the options used to create the mesh
  28487. * @param scene defines the hosting scene
  28488. * @returns the custom extruded shape mesh
  28489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28492. */
  28493. static ExtrudeShapeCustom(name: string, options: {
  28494. shape: Vector3[];
  28495. path: Vector3[];
  28496. scaleFunction?: any;
  28497. rotationFunction?: any;
  28498. ribbonCloseArray?: boolean;
  28499. ribbonClosePath?: boolean;
  28500. cap?: number;
  28501. updatable?: boolean;
  28502. sideOrientation?: number;
  28503. frontUVs?: Vector4;
  28504. backUVs?: Vector4;
  28505. instance?: Mesh;
  28506. invertUV?: boolean;
  28507. }, scene: Scene): Mesh;
  28508. /**
  28509. * Creates lathe mesh.
  28510. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28511. * * 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
  28512. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28513. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28514. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28515. * * 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
  28516. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28517. * * 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
  28518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28519. * * 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
  28520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28522. * @param name defines the name of the mesh
  28523. * @param options defines the options used to create the mesh
  28524. * @param scene defines the hosting scene
  28525. * @returns the lathe mesh
  28526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28527. */
  28528. static CreateLathe(name: string, options: {
  28529. shape: Vector3[];
  28530. radius?: number;
  28531. tessellation?: number;
  28532. clip?: number;
  28533. arc?: number;
  28534. closed?: boolean;
  28535. updatable?: boolean;
  28536. sideOrientation?: number;
  28537. frontUVs?: Vector4;
  28538. backUVs?: Vector4;
  28539. cap?: number;
  28540. invertUV?: boolean;
  28541. }, scene: Scene): Mesh;
  28542. /**
  28543. * Creates a plane mesh
  28544. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28545. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28546. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28548. * * 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
  28549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28550. * @param name defines the name of the mesh
  28551. * @param options defines the options used to create the mesh
  28552. * @param scene defines the hosting scene
  28553. * @returns the plane mesh
  28554. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28555. */
  28556. static CreatePlane(name: string, options: {
  28557. size?: number;
  28558. width?: number;
  28559. height?: number;
  28560. sideOrientation?: number;
  28561. frontUVs?: Vector4;
  28562. backUVs?: Vector4;
  28563. updatable?: boolean;
  28564. sourcePlane?: Plane;
  28565. }, scene: Scene): Mesh;
  28566. /**
  28567. * Creates a ground mesh
  28568. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28569. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28571. * @param name defines the name of the mesh
  28572. * @param options defines the options used to create the mesh
  28573. * @param scene defines the hosting scene
  28574. * @returns the ground mesh
  28575. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28576. */
  28577. static CreateGround(name: string, options: {
  28578. width?: number;
  28579. height?: number;
  28580. subdivisions?: number;
  28581. subdivisionsX?: number;
  28582. subdivisionsY?: number;
  28583. updatable?: boolean;
  28584. }, scene: any): Mesh;
  28585. /**
  28586. * Creates a tiled ground mesh
  28587. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28588. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28589. * * 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
  28590. * * 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
  28591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28592. * @param name defines the name of the mesh
  28593. * @param options defines the options used to create the mesh
  28594. * @param scene defines the hosting scene
  28595. * @returns the tiled ground mesh
  28596. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28597. */
  28598. static CreateTiledGround(name: string, options: {
  28599. xmin: number;
  28600. zmin: number;
  28601. xmax: number;
  28602. zmax: number;
  28603. subdivisions?: {
  28604. w: number;
  28605. h: number;
  28606. };
  28607. precision?: {
  28608. w: number;
  28609. h: number;
  28610. };
  28611. updatable?: boolean;
  28612. }, scene: Scene): Mesh;
  28613. /**
  28614. * Creates a ground mesh from a height map
  28615. * * The parameter `url` sets the URL of the height map image resource.
  28616. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28617. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28618. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28619. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28620. * * 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.
  28621. * * 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).
  28622. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28624. * @param name defines the name of the mesh
  28625. * @param url defines the url to the height map
  28626. * @param options defines the options used to create the mesh
  28627. * @param scene defines the hosting scene
  28628. * @returns the ground mesh
  28629. * @see https://doc.babylonjs.com/babylon101/height_map
  28630. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28631. */
  28632. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28633. width?: number;
  28634. height?: number;
  28635. subdivisions?: number;
  28636. minHeight?: number;
  28637. maxHeight?: number;
  28638. colorFilter?: Color3;
  28639. alphaFilter?: number;
  28640. updatable?: boolean;
  28641. onReady?: (mesh: GroundMesh) => void;
  28642. }, scene: Scene): GroundMesh;
  28643. /**
  28644. * Creates a polygon mesh
  28645. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28646. * * 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
  28647. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28649. * * 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)
  28650. * * Remember you can only change the shape positions, not their number when updating a polygon
  28651. * @param name defines the name of the mesh
  28652. * @param options defines the options used to create the mesh
  28653. * @param scene defines the hosting scene
  28654. * @returns the polygon mesh
  28655. */
  28656. static CreatePolygon(name: string, options: {
  28657. shape: Vector3[];
  28658. holes?: Vector3[][];
  28659. depth?: number;
  28660. faceUV?: Vector4[];
  28661. faceColors?: Color4[];
  28662. updatable?: boolean;
  28663. sideOrientation?: number;
  28664. frontUVs?: Vector4;
  28665. backUVs?: Vector4;
  28666. }, scene: Scene): Mesh;
  28667. /**
  28668. * Creates an extruded polygon mesh, with depth in the Y direction.
  28669. * * 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)
  28670. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28671. * @param name defines the name of the mesh
  28672. * @param options defines the options used to create the mesh
  28673. * @param scene defines the hosting scene
  28674. * @returns the polygon mesh
  28675. */
  28676. static ExtrudePolygon(name: string, options: {
  28677. shape: Vector3[];
  28678. holes?: Vector3[][];
  28679. depth?: number;
  28680. faceUV?: Vector4[];
  28681. faceColors?: Color4[];
  28682. updatable?: boolean;
  28683. sideOrientation?: number;
  28684. frontUVs?: Vector4;
  28685. backUVs?: Vector4;
  28686. }, scene: Scene): Mesh;
  28687. /**
  28688. * Creates a tube mesh.
  28689. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28690. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28691. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28692. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28693. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28694. * * 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)
  28695. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28696. * * 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
  28697. * * 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
  28698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28699. * * 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
  28700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28702. * @param name defines the name of the mesh
  28703. * @param options defines the options used to create the mesh
  28704. * @param scene defines the hosting scene
  28705. * @returns the tube mesh
  28706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28707. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28708. */
  28709. static CreateTube(name: string, options: {
  28710. path: Vector3[];
  28711. radius?: number;
  28712. tessellation?: number;
  28713. radiusFunction?: {
  28714. (i: number, distance: number): number;
  28715. };
  28716. cap?: number;
  28717. arc?: number;
  28718. updatable?: boolean;
  28719. sideOrientation?: number;
  28720. frontUVs?: Vector4;
  28721. backUVs?: Vector4;
  28722. instance?: Mesh;
  28723. invertUV?: boolean;
  28724. }, scene: Scene): Mesh;
  28725. /**
  28726. * Creates a polyhedron mesh
  28727. * * 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
  28728. * * The parameter `size` (positive float, default 1) sets the polygon size
  28729. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28730. * * 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`
  28731. * * 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
  28732. * * 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)`)
  28733. * * 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
  28734. * * 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
  28735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28736. * * 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
  28737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28738. * @param name defines the name of the mesh
  28739. * @param options defines the options used to create the mesh
  28740. * @param scene defines the hosting scene
  28741. * @returns the polyhedron mesh
  28742. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28743. */
  28744. static CreatePolyhedron(name: string, options: {
  28745. type?: number;
  28746. size?: number;
  28747. sizeX?: number;
  28748. sizeY?: number;
  28749. sizeZ?: number;
  28750. custom?: any;
  28751. faceUV?: Vector4[];
  28752. faceColors?: Color4[];
  28753. flat?: boolean;
  28754. updatable?: boolean;
  28755. sideOrientation?: number;
  28756. frontUVs?: Vector4;
  28757. backUVs?: Vector4;
  28758. }, scene: Scene): Mesh;
  28759. /**
  28760. * Creates a decal mesh.
  28761. * 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
  28762. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28763. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28764. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28765. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28766. * @param name defines the name of the mesh
  28767. * @param sourceMesh defines the mesh where the decal must be applied
  28768. * @param options defines the options used to create the mesh
  28769. * @param scene defines the hosting scene
  28770. * @returns the decal mesh
  28771. * @see https://doc.babylonjs.com/how_to/decals
  28772. */
  28773. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28774. position?: Vector3;
  28775. normal?: Vector3;
  28776. size?: Vector3;
  28777. angle?: number;
  28778. }): Mesh;
  28779. private static _ExtrudeShapeGeneric;
  28780. }
  28781. }
  28782. declare module BABYLON {
  28783. /**
  28784. * Class used to represent a specific level of detail of a mesh
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28786. */
  28787. class MeshLODLevel {
  28788. /** Defines the distance where this level should star being displayed */
  28789. distance: number;
  28790. /** Defines the mesh to use to render this level */
  28791. mesh: Nullable<Mesh>;
  28792. /**
  28793. * Creates a new LOD level
  28794. * @param distance defines the distance where this level should star being displayed
  28795. * @param mesh defines the mesh to use to render this level
  28796. */
  28797. constructor(
  28798. /** Defines the distance where this level should star being displayed */
  28799. distance: number,
  28800. /** Defines the mesh to use to render this level */
  28801. mesh: Nullable<Mesh>);
  28802. }
  28803. }
  28804. declare module BABYLON {
  28805. /**
  28806. * A simplifier interface for future simplification implementations
  28807. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28808. */
  28809. interface ISimplifier {
  28810. /**
  28811. * Simplification of a given mesh according to the given settings.
  28812. * Since this requires computation, it is assumed that the function runs async.
  28813. * @param settings The settings of the simplification, including quality and distance
  28814. * @param successCallback A callback that will be called after the mesh was simplified.
  28815. * @param errorCallback in case of an error, this callback will be called. optional.
  28816. */
  28817. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28818. }
  28819. /**
  28820. * Expected simplification settings.
  28821. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28822. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28823. */
  28824. interface ISimplificationSettings {
  28825. /**
  28826. * Gets or sets the expected quality
  28827. */
  28828. quality: number;
  28829. /**
  28830. * Gets or sets the distance when this optimized version should be used
  28831. */
  28832. distance: number;
  28833. /**
  28834. * Gets an already optimized mesh
  28835. */
  28836. optimizeMesh?: boolean;
  28837. }
  28838. /**
  28839. * Class used to specify simplification options
  28840. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28841. */
  28842. class SimplificationSettings implements ISimplificationSettings {
  28843. /** expected quality */
  28844. quality: number;
  28845. /** distance when this optimized version should be used */
  28846. distance: number;
  28847. /** already optimized mesh */
  28848. optimizeMesh?: boolean | undefined;
  28849. /**
  28850. * Creates a SimplificationSettings
  28851. * @param quality expected quality
  28852. * @param distance distance when this optimized version should be used
  28853. * @param optimizeMesh already optimized mesh
  28854. */
  28855. constructor(
  28856. /** expected quality */
  28857. quality: number,
  28858. /** distance when this optimized version should be used */
  28859. distance: number,
  28860. /** already optimized mesh */
  28861. optimizeMesh?: boolean | undefined);
  28862. }
  28863. /**
  28864. * Interface used to define a simplification task
  28865. */
  28866. interface ISimplificationTask {
  28867. /**
  28868. * Array of settings
  28869. */
  28870. settings: Array<ISimplificationSettings>;
  28871. /**
  28872. * Simplification type
  28873. */
  28874. simplificationType: SimplificationType;
  28875. /**
  28876. * Mesh to simplify
  28877. */
  28878. mesh: Mesh;
  28879. /**
  28880. * Callback called on success
  28881. */
  28882. successCallback?: () => void;
  28883. /**
  28884. * Defines if parallel processing can be used
  28885. */
  28886. parallelProcessing: boolean;
  28887. }
  28888. /**
  28889. * Queue used to order the simplification tasks
  28890. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28891. */
  28892. class SimplificationQueue {
  28893. private _simplificationArray;
  28894. /**
  28895. * Gets a boolean indicating that the process is still running
  28896. */
  28897. running: boolean;
  28898. /**
  28899. * Creates a new queue
  28900. */
  28901. constructor();
  28902. /**
  28903. * Adds a new simplification task
  28904. * @param task defines a task to add
  28905. */
  28906. addTask(task: ISimplificationTask): void;
  28907. /**
  28908. * Execute next task
  28909. */
  28910. executeNext(): void;
  28911. /**
  28912. * Execute a simplification task
  28913. * @param task defines the task to run
  28914. */
  28915. runSimplification(task: ISimplificationTask): void;
  28916. private getSimplifier;
  28917. }
  28918. /**
  28919. * The implemented types of simplification
  28920. * At the moment only Quadratic Error Decimation is implemented
  28921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28922. */
  28923. enum SimplificationType {
  28924. /** Quadratic error decimation */
  28925. QUADRATIC = 0
  28926. }
  28927. }
  28928. declare module BABYLON {
  28929. interface Scene {
  28930. /** @hidden (Backing field) */
  28931. _simplificationQueue: SimplificationQueue;
  28932. /**
  28933. * Gets or sets the simplification queue attached to the scene
  28934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28935. */
  28936. simplificationQueue: SimplificationQueue;
  28937. }
  28938. interface Mesh {
  28939. /**
  28940. * Simplify the mesh according to the given array of settings.
  28941. * Function will return immediately and will simplify async
  28942. * @param settings a collection of simplification settings
  28943. * @param parallelProcessing should all levels calculate parallel or one after the other
  28944. * @param simplificationType the type of simplification to run
  28945. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28946. * @returns the current mesh
  28947. */
  28948. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28949. }
  28950. /**
  28951. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28952. * created in a scene
  28953. */
  28954. class SimplicationQueueSceneComponent implements ISceneComponent {
  28955. /**
  28956. * The component name helpfull to identify the component in the list of scene components.
  28957. */
  28958. readonly name: string;
  28959. /**
  28960. * The scene the component belongs to.
  28961. */
  28962. scene: Scene;
  28963. /**
  28964. * Creates a new instance of the component for the given scene
  28965. * @param scene Defines the scene to register the component in
  28966. */
  28967. constructor(scene: Scene);
  28968. /**
  28969. * Registers the component in a given scene
  28970. */
  28971. register(): void;
  28972. /**
  28973. * Rebuilds the elements related to this component in case of
  28974. * context lost for instance.
  28975. */
  28976. rebuild(): void;
  28977. /**
  28978. * Disposes the component and the associated ressources
  28979. */
  28980. dispose(): void;
  28981. private _beforeCameraUpdate;
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. /**
  28986. * Polygon
  28987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28988. */
  28989. class Polygon {
  28990. /**
  28991. * Creates a rectangle
  28992. * @param xmin bottom X coord
  28993. * @param ymin bottom Y coord
  28994. * @param xmax top X coord
  28995. * @param ymax top Y coord
  28996. * @returns points that make the resulting rectation
  28997. */
  28998. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28999. /**
  29000. * Creates a circle
  29001. * @param radius radius of circle
  29002. * @param cx scale in x
  29003. * @param cy scale in y
  29004. * @param numberOfSides number of sides that make up the circle
  29005. * @returns points that make the resulting circle
  29006. */
  29007. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29008. /**
  29009. * Creates a polygon from input string
  29010. * @param input Input polygon data
  29011. * @returns the parsed points
  29012. */
  29013. static Parse(input: string): Vector2[];
  29014. /**
  29015. * Starts building a polygon from x and y coordinates
  29016. * @param x x coordinate
  29017. * @param y y coordinate
  29018. * @returns the started path2
  29019. */
  29020. static StartingAt(x: number, y: number): Path2;
  29021. }
  29022. /**
  29023. * Builds a polygon
  29024. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29025. */
  29026. class PolygonMeshBuilder {
  29027. private _points;
  29028. private _outlinepoints;
  29029. private _holes;
  29030. private _name;
  29031. private _scene;
  29032. private _epoints;
  29033. private _eholes;
  29034. private _addToepoint;
  29035. /**
  29036. * Creates a PolygonMeshBuilder
  29037. * @param name name of the builder
  29038. * @param contours Path of the polygon
  29039. * @param scene scene to add to
  29040. */
  29041. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29042. /**
  29043. * Adds a whole within the polygon
  29044. * @param hole Array of points defining the hole
  29045. * @returns this
  29046. */
  29047. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29048. /**
  29049. * Creates the polygon
  29050. * @param updatable If the mesh should be updatable
  29051. * @param depth The depth of the mesh created
  29052. * @returns the created mesh
  29053. */
  29054. build(updatable?: boolean, depth?: number): Mesh;
  29055. /**
  29056. * Adds a side to the polygon
  29057. * @param positions points that make the polygon
  29058. * @param normals normals of the polygon
  29059. * @param uvs uvs of the polygon
  29060. * @param indices indices of the polygon
  29061. * @param bounds bounds of the polygon
  29062. * @param points points of the polygon
  29063. * @param depth depth of the polygon
  29064. * @param flip flip of the polygon
  29065. */
  29066. private addSide;
  29067. }
  29068. }
  29069. declare module BABYLON {
  29070. /**
  29071. * Base class for submeshes
  29072. */
  29073. class BaseSubMesh {
  29074. /** @hidden */
  29075. _materialDefines: Nullable<MaterialDefines>;
  29076. /** @hidden */
  29077. _materialEffect: Nullable<Effect>;
  29078. /**
  29079. * Gets associated effect
  29080. */
  29081. readonly effect: Nullable<Effect>;
  29082. /**
  29083. * Sets associated effect (effect used to render this submesh)
  29084. * @param effect defines the effect to associate with
  29085. * @param defines defines the set of defines used to compile this effect
  29086. */
  29087. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29088. }
  29089. /**
  29090. * Defines a subdivision inside a mesh
  29091. */
  29092. class SubMesh extends BaseSubMesh implements ICullable {
  29093. /** the material index to use */
  29094. materialIndex: number;
  29095. /** vertex index start */
  29096. verticesStart: number;
  29097. /** vertices count */
  29098. verticesCount: number;
  29099. /** index start */
  29100. indexStart: number;
  29101. /** indices count */
  29102. indexCount: number;
  29103. /** @hidden */
  29104. _linesIndexCount: number;
  29105. private _mesh;
  29106. private _renderingMesh;
  29107. private _boundingInfo;
  29108. private _linesIndexBuffer;
  29109. /** @hidden */
  29110. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29111. /** @hidden */
  29112. _trianglePlanes: Plane[];
  29113. /** @hidden */
  29114. _lastColliderTransformMatrix: Matrix;
  29115. /** @hidden */
  29116. _renderId: number;
  29117. /** @hidden */
  29118. _alphaIndex: number;
  29119. /** @hidden */
  29120. _distanceToCamera: number;
  29121. /** @hidden */
  29122. _id: number;
  29123. private _currentMaterial;
  29124. /**
  29125. * Add a new submesh to a mesh
  29126. * @param materialIndex defines the material index to use
  29127. * @param verticesStart defines vertex index start
  29128. * @param verticesCount defines vertices count
  29129. * @param indexStart defines index start
  29130. * @param indexCount defines indices count
  29131. * @param mesh defines the parent mesh
  29132. * @param renderingMesh defines an optional rendering mesh
  29133. * @param createBoundingBox defines if bounding box should be created for this submesh
  29134. * @returns the new submesh
  29135. */
  29136. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29137. /**
  29138. * Creates a new submesh
  29139. * @param materialIndex defines the material index to use
  29140. * @param verticesStart defines vertex index start
  29141. * @param verticesCount defines vertices count
  29142. * @param indexStart defines index start
  29143. * @param indexCount defines indices count
  29144. * @param mesh defines the parent mesh
  29145. * @param renderingMesh defines an optional rendering mesh
  29146. * @param createBoundingBox defines if bounding box should be created for this submesh
  29147. */
  29148. constructor(
  29149. /** the material index to use */
  29150. materialIndex: number,
  29151. /** vertex index start */
  29152. verticesStart: number,
  29153. /** vertices count */
  29154. verticesCount: number,
  29155. /** index start */
  29156. indexStart: number,
  29157. /** indices count */
  29158. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29159. /**
  29160. * Returns true if this submesh covers the entire parent mesh
  29161. * @ignorenaming
  29162. */
  29163. readonly IsGlobal: boolean;
  29164. /**
  29165. * Returns the submesh BoudingInfo object
  29166. * @returns current bounding info (or mesh's one if the submesh is global)
  29167. */
  29168. getBoundingInfo(): BoundingInfo;
  29169. /**
  29170. * Sets the submesh BoundingInfo
  29171. * @param boundingInfo defines the new bounding info to use
  29172. * @returns the SubMesh
  29173. */
  29174. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29175. /**
  29176. * Returns the mesh of the current submesh
  29177. * @return the parent mesh
  29178. */
  29179. getMesh(): AbstractMesh;
  29180. /**
  29181. * Returns the rendering mesh of the submesh
  29182. * @returns the rendering mesh (could be different from parent mesh)
  29183. */
  29184. getRenderingMesh(): Mesh;
  29185. /**
  29186. * Returns the submesh material
  29187. * @returns null or the current material
  29188. */
  29189. getMaterial(): Nullable<Material>;
  29190. /**
  29191. * Sets a new updated BoundingInfo object to the submesh
  29192. * @returns the SubMesh
  29193. */
  29194. refreshBoundingInfo(): SubMesh;
  29195. /** @hidden */
  29196. _checkCollision(collider: Collider): boolean;
  29197. /**
  29198. * Updates the submesh BoundingInfo
  29199. * @param world defines the world matrix to use to update the bounding info
  29200. * @returns the submesh
  29201. */
  29202. updateBoundingInfo(world: Matrix): SubMesh;
  29203. /**
  29204. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29205. * @param frustumPlanes defines the frustum planes
  29206. * @returns true if the submesh is intersecting with the frustum
  29207. */
  29208. isInFrustum(frustumPlanes: Plane[]): boolean;
  29209. /**
  29210. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29211. * @param frustumPlanes defines the frustum planes
  29212. * @returns true if the submesh is inside the frustum
  29213. */
  29214. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29215. /**
  29216. * Renders the submesh
  29217. * @param enableAlphaMode defines if alpha needs to be used
  29218. * @returns the submesh
  29219. */
  29220. render(enableAlphaMode: boolean): SubMesh;
  29221. /**
  29222. * @hidden
  29223. */
  29224. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29225. /**
  29226. * Checks if the submesh intersects with a ray
  29227. * @param ray defines the ray to test
  29228. * @returns true is the passed ray intersects the submesh bounding box
  29229. */
  29230. canIntersects(ray: Ray): boolean;
  29231. /**
  29232. * Intersects current submesh with a ray
  29233. * @param ray defines the ray to test
  29234. * @param positions defines mesh's positions array
  29235. * @param indices defines mesh's indices array
  29236. * @param fastCheck defines if only bounding info should be used
  29237. * @returns intersection info or null if no intersection
  29238. */
  29239. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29240. /** @hidden */
  29241. private _intersectLines;
  29242. /** @hidden */
  29243. private _intersectTriangles;
  29244. /** @hidden */
  29245. _rebuild(): void;
  29246. /**
  29247. * Creates a new submesh from the passed mesh
  29248. * @param newMesh defines the new hosting mesh
  29249. * @param newRenderingMesh defines an optional rendering mesh
  29250. * @returns the new submesh
  29251. */
  29252. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29253. /**
  29254. * Release associated resources
  29255. */
  29256. dispose(): void;
  29257. /**
  29258. * Creates a new submesh from indices data
  29259. * @param materialIndex the index of the main mesh material
  29260. * @param startIndex the index where to start the copy in the mesh indices array
  29261. * @param indexCount the number of indices to copy then from the startIndex
  29262. * @param mesh the main mesh to create the submesh from
  29263. * @param renderingMesh the optional rendering mesh
  29264. * @returns a new submesh
  29265. */
  29266. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29267. }
  29268. }
  29269. declare module BABYLON {
  29270. /**
  29271. * 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.
  29272. * @see https://doc.babylonjs.com/how_to/transformnode
  29273. */
  29274. class TransformNode extends Node {
  29275. /**
  29276. * Object will not rotate to face the camera
  29277. */
  29278. static BILLBOARDMODE_NONE: number;
  29279. /**
  29280. * Object will rotate to face the camera but only on the x axis
  29281. */
  29282. static BILLBOARDMODE_X: number;
  29283. /**
  29284. * Object will rotate to face the camera but only on the y axis
  29285. */
  29286. static BILLBOARDMODE_Y: number;
  29287. /**
  29288. * Object will rotate to face the camera but only on the z axis
  29289. */
  29290. static BILLBOARDMODE_Z: number;
  29291. /**
  29292. * Object will rotate to face the camera
  29293. */
  29294. static BILLBOARDMODE_ALL: number;
  29295. private _forward;
  29296. private _forwardInverted;
  29297. private _up;
  29298. private _right;
  29299. private _rightInverted;
  29300. private _position;
  29301. private _rotation;
  29302. private _rotationQuaternion;
  29303. protected _scaling: Vector3;
  29304. protected _isDirty: boolean;
  29305. private _transformToBoneReferal;
  29306. /**
  29307. * Set the billboard mode. Default is 0.
  29308. *
  29309. * | Value | Type | Description |
  29310. * | --- | --- | --- |
  29311. * | 0 | BILLBOARDMODE_NONE | |
  29312. * | 1 | BILLBOARDMODE_X | |
  29313. * | 2 | BILLBOARDMODE_Y | |
  29314. * | 4 | BILLBOARDMODE_Z | |
  29315. * | 7 | BILLBOARDMODE_ALL | |
  29316. *
  29317. */
  29318. billboardMode: number;
  29319. /**
  29320. * 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
  29321. */
  29322. scalingDeterminant: number;
  29323. /**
  29324. * Sets the distance of the object to max, often used by skybox
  29325. */
  29326. infiniteDistance: boolean;
  29327. /**
  29328. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29329. * By default the system will update normals to compensate
  29330. */
  29331. ignoreNonUniformScaling: boolean;
  29332. /** @hidden */
  29333. _poseMatrix: Matrix;
  29334. private _localWorld;
  29335. private _absolutePosition;
  29336. private _pivotMatrix;
  29337. private _pivotMatrixInverse;
  29338. protected _postMultiplyPivotMatrix: boolean;
  29339. protected _isWorldMatrixFrozen: boolean;
  29340. /** @hidden */
  29341. _indexInSceneTransformNodesArray: number;
  29342. /**
  29343. * An event triggered after the world matrix is updated
  29344. */
  29345. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29346. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29347. /**
  29348. * Gets a string identifying the name of the class
  29349. * @returns "TransformNode" string
  29350. */
  29351. getClassName(): string;
  29352. /**
  29353. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29354. */
  29355. position: Vector3;
  29356. /**
  29357. * 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)).
  29358. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29359. */
  29360. rotation: Vector3;
  29361. /**
  29362. * 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)).
  29363. */
  29364. scaling: Vector3;
  29365. /**
  29366. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29367. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29368. */
  29369. rotationQuaternion: Nullable<Quaternion>;
  29370. /**
  29371. * The forward direction of that transform in world space.
  29372. */
  29373. readonly forward: Vector3;
  29374. /**
  29375. * The up direction of that transform in world space.
  29376. */
  29377. readonly up: Vector3;
  29378. /**
  29379. * The right direction of that transform in world space.
  29380. */
  29381. readonly right: Vector3;
  29382. /**
  29383. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29384. * @param matrix the matrix to copy the pose from
  29385. * @returns this TransformNode.
  29386. */
  29387. updatePoseMatrix(matrix: Matrix): TransformNode;
  29388. /**
  29389. * Returns the mesh Pose matrix.
  29390. * @returns the pose matrix
  29391. */
  29392. getPoseMatrix(): Matrix;
  29393. /** @hidden */
  29394. _isSynchronized(): boolean;
  29395. /** @hidden */
  29396. _initCache(): void;
  29397. /**
  29398. * Flag the transform node as dirty (Forcing it to update everything)
  29399. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29400. * @returns this transform node
  29401. */
  29402. markAsDirty(property: string): TransformNode;
  29403. /**
  29404. * Returns the current mesh absolute position.
  29405. * Returns a Vector3.
  29406. */
  29407. readonly absolutePosition: Vector3;
  29408. /**
  29409. * Sets a new matrix to apply before all other transformation
  29410. * @param matrix defines the transform matrix
  29411. * @returns the current TransformNode
  29412. */
  29413. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29414. /**
  29415. * Sets a new pivot matrix to the current node
  29416. * @param matrix defines the new pivot matrix to use
  29417. * @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
  29418. * @returns the current TransformNode
  29419. */
  29420. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29421. /**
  29422. * Returns the mesh pivot matrix.
  29423. * Default : Identity.
  29424. * @returns the matrix
  29425. */
  29426. getPivotMatrix(): Matrix;
  29427. /**
  29428. * Prevents the World matrix to be computed any longer.
  29429. * @returns the TransformNode.
  29430. */
  29431. freezeWorldMatrix(): TransformNode;
  29432. /**
  29433. * Allows back the World matrix computation.
  29434. * @returns the TransformNode.
  29435. */
  29436. unfreezeWorldMatrix(): this;
  29437. /**
  29438. * True if the World matrix has been frozen.
  29439. */
  29440. readonly isWorldMatrixFrozen: boolean;
  29441. /**
  29442. * Retuns the mesh absolute position in the World.
  29443. * @returns a Vector3.
  29444. */
  29445. getAbsolutePosition(): Vector3;
  29446. /**
  29447. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29448. * @param absolutePosition the absolute position to set
  29449. * @returns the TransformNode.
  29450. */
  29451. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29452. /**
  29453. * Sets the mesh position in its local space.
  29454. * @param vector3 the position to set in localspace
  29455. * @returns the TransformNode.
  29456. */
  29457. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29458. /**
  29459. * Returns the mesh position in the local space from the current World matrix values.
  29460. * @returns a new Vector3.
  29461. */
  29462. getPositionExpressedInLocalSpace(): Vector3;
  29463. /**
  29464. * Translates the mesh along the passed Vector3 in its local space.
  29465. * @param vector3 the distance to translate in localspace
  29466. * @returns the TransformNode.
  29467. */
  29468. locallyTranslate(vector3: Vector3): TransformNode;
  29469. private static _lookAtVectorCache;
  29470. /**
  29471. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29472. * @param targetPoint the position (must be in same space as current mesh) to look at
  29473. * @param yawCor optional yaw (y-axis) correction in radians
  29474. * @param pitchCor optional pitch (x-axis) correction in radians
  29475. * @param rollCor optional roll (z-axis) correction in radians
  29476. * @param space the choosen space of the target
  29477. * @returns the TransformNode.
  29478. */
  29479. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29480. /**
  29481. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29482. * This Vector3 is expressed in the World space.
  29483. * @param localAxis axis to rotate
  29484. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29485. */
  29486. getDirection(localAxis: Vector3): Vector3;
  29487. /**
  29488. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29489. * localAxis is expressed in the mesh local space.
  29490. * result is computed in the Wordl space from the mesh World matrix.
  29491. * @param localAxis axis to rotate
  29492. * @param result the resulting transformnode
  29493. * @returns this TransformNode.
  29494. */
  29495. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29496. /**
  29497. * Sets a new pivot point to the current node
  29498. * @param point defines the new pivot point to use
  29499. * @param space defines if the point is in world or local space (local by default)
  29500. * @returns the current TransformNode
  29501. */
  29502. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29503. /**
  29504. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29505. * @returns the pivot point
  29506. */
  29507. getPivotPoint(): Vector3;
  29508. /**
  29509. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29510. * @param result the vector3 to store the result
  29511. * @returns this TransformNode.
  29512. */
  29513. getPivotPointToRef(result: Vector3): TransformNode;
  29514. /**
  29515. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29516. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29517. */
  29518. getAbsolutePivotPoint(): Vector3;
  29519. /**
  29520. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29521. * @param result vector3 to store the result
  29522. * @returns this TransformNode.
  29523. */
  29524. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29525. /**
  29526. * Defines the passed node as the parent of the current node.
  29527. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29528. * @param node the node ot set as the parent
  29529. * @returns this TransformNode.
  29530. */
  29531. setParent(node: Nullable<Node>): TransformNode;
  29532. private _nonUniformScaling;
  29533. /**
  29534. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29535. */
  29536. readonly nonUniformScaling: boolean;
  29537. /** @hidden */
  29538. _updateNonUniformScalingState(value: boolean): boolean;
  29539. /**
  29540. * Attach the current TransformNode to another TransformNode associated with a bone
  29541. * @param bone Bone affecting the TransformNode
  29542. * @param affectedTransformNode TransformNode associated with the bone
  29543. * @returns this object
  29544. */
  29545. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29546. /**
  29547. * Detach the transform node if its associated with a bone
  29548. * @returns this object
  29549. */
  29550. detachFromBone(): TransformNode;
  29551. private static _rotationAxisCache;
  29552. /**
  29553. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29554. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29555. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29556. * The passed axis is also normalized.
  29557. * @param axis the axis to rotate around
  29558. * @param amount the amount to rotate in radians
  29559. * @param space Space to rotate in (Default: local)
  29560. * @returns the TransformNode.
  29561. */
  29562. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29563. /**
  29564. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29565. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29566. * The passed axis is also normalized. .
  29567. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29568. * @param point the point to rotate around
  29569. * @param axis the axis to rotate around
  29570. * @param amount the amount to rotate in radians
  29571. * @returns the TransformNode
  29572. */
  29573. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29574. /**
  29575. * Translates the mesh along the axis vector for the passed distance in the given space.
  29576. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29577. * @param axis the axis to translate in
  29578. * @param distance the distance to translate
  29579. * @param space Space to rotate in (Default: local)
  29580. * @returns the TransformNode.
  29581. */
  29582. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29583. /**
  29584. * Adds a rotation step to the mesh current rotation.
  29585. * x, y, z are Euler angles expressed in radians.
  29586. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29587. * This means this rotation is made in the mesh local space only.
  29588. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29589. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29590. * ```javascript
  29591. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29592. * ```
  29593. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29594. * 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.
  29595. * @param x Rotation to add
  29596. * @param y Rotation to add
  29597. * @param z Rotation to add
  29598. * @returns the TransformNode.
  29599. */
  29600. addRotation(x: number, y: number, z: number): TransformNode;
  29601. /**
  29602. * Computes the world matrix of the node
  29603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29604. * @returns the world matrix
  29605. */
  29606. computeWorldMatrix(force?: boolean): Matrix;
  29607. protected _afterComputeWorldMatrix(): void;
  29608. /**
  29609. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29610. * @param func callback function to add
  29611. *
  29612. * @returns the TransformNode.
  29613. */
  29614. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29615. /**
  29616. * Removes a registered callback function.
  29617. * @param func callback function to remove
  29618. * @returns the TransformNode.
  29619. */
  29620. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29621. /**
  29622. * Gets the position of the current mesh in camera space
  29623. * @param camera defines the camera to use
  29624. * @returns a position
  29625. */
  29626. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29627. /**
  29628. * Returns the distance from the mesh to the active camera
  29629. * @param camera defines the camera to use
  29630. * @returns the distance
  29631. */
  29632. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29633. /**
  29634. * Clone the current transform node
  29635. * @param name Name of the new clone
  29636. * @param newParent New parent for the clone
  29637. * @param doNotCloneChildren Do not clone children hierarchy
  29638. * @returns the new transform node
  29639. */
  29640. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29641. /**
  29642. * Serializes the objects information.
  29643. * @param currentSerializationObject defines the object to serialize in
  29644. * @returns the serialized object
  29645. */
  29646. serialize(currentSerializationObject?: any): any;
  29647. /**
  29648. * Returns a new TransformNode object parsed from the source provided.
  29649. * @param parsedTransformNode is the source.
  29650. * @param scene the scne the object belongs to
  29651. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29652. * @returns a new TransformNode object parsed from the source provided.
  29653. */
  29654. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29655. /**
  29656. * Releases resources associated with this transform node.
  29657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29659. */
  29660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29661. }
  29662. }
  29663. declare module BABYLON {
  29664. /**
  29665. * Specialized buffer used to store vertex data
  29666. */
  29667. class VertexBuffer {
  29668. /** @hidden */
  29669. _buffer: Buffer;
  29670. private _kind;
  29671. private _size;
  29672. private _ownsBuffer;
  29673. private _instanced;
  29674. private _instanceDivisor;
  29675. /**
  29676. * The byte type.
  29677. */
  29678. static readonly BYTE: number;
  29679. /**
  29680. * The unsigned byte type.
  29681. */
  29682. static readonly UNSIGNED_BYTE: number;
  29683. /**
  29684. * The short type.
  29685. */
  29686. static readonly SHORT: number;
  29687. /**
  29688. * The unsigned short type.
  29689. */
  29690. static readonly UNSIGNED_SHORT: number;
  29691. /**
  29692. * The integer type.
  29693. */
  29694. static readonly INT: number;
  29695. /**
  29696. * The unsigned integer type.
  29697. */
  29698. static readonly UNSIGNED_INT: number;
  29699. /**
  29700. * The float type.
  29701. */
  29702. static readonly FLOAT: number;
  29703. /**
  29704. * Gets or sets the instance divisor when in instanced mode
  29705. */
  29706. instanceDivisor: number;
  29707. /**
  29708. * Gets the byte stride.
  29709. */
  29710. readonly byteStride: number;
  29711. /**
  29712. * Gets the byte offset.
  29713. */
  29714. readonly byteOffset: number;
  29715. /**
  29716. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29717. */
  29718. readonly normalized: boolean;
  29719. /**
  29720. * Gets the data type of each component in the array.
  29721. */
  29722. readonly type: number;
  29723. /**
  29724. * Constructor
  29725. * @param engine the engine
  29726. * @param data the data to use for this vertex buffer
  29727. * @param kind the vertex buffer kind
  29728. * @param updatable whether the data is updatable
  29729. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29730. * @param stride the stride (optional)
  29731. * @param instanced whether the buffer is instanced (optional)
  29732. * @param offset the offset of the data (optional)
  29733. * @param size the number of components (optional)
  29734. * @param type the type of the component (optional)
  29735. * @param normalized whether the data contains normalized data (optional)
  29736. * @param useBytes set to true if stride and offset are in bytes (optional)
  29737. */
  29738. 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);
  29739. /** @hidden */
  29740. _rebuild(): void;
  29741. /**
  29742. * Returns the kind of the VertexBuffer (string)
  29743. * @returns a string
  29744. */
  29745. getKind(): string;
  29746. /**
  29747. * Gets a boolean indicating if the VertexBuffer is updatable?
  29748. * @returns true if the buffer is updatable
  29749. */
  29750. isUpdatable(): boolean;
  29751. /**
  29752. * Gets current buffer's data
  29753. * @returns a DataArray or null
  29754. */
  29755. getData(): Nullable<DataArray>;
  29756. /**
  29757. * Gets underlying native buffer
  29758. * @returns underlying native buffer
  29759. */
  29760. getBuffer(): Nullable<WebGLBuffer>;
  29761. /**
  29762. * Gets the stride in float32 units (i.e. byte stride / 4).
  29763. * May not be an integer if the byte stride is not divisible by 4.
  29764. * DEPRECATED. Use byteStride instead.
  29765. * @returns the stride in float32 units
  29766. */
  29767. getStrideSize(): number;
  29768. /**
  29769. * Returns the offset as a multiple of the type byte length.
  29770. * DEPRECATED. Use byteOffset instead.
  29771. * @returns the offset in bytes
  29772. */
  29773. getOffset(): number;
  29774. /**
  29775. * Returns the number of components per vertex attribute (integer)
  29776. * @returns the size in float
  29777. */
  29778. getSize(): number;
  29779. /**
  29780. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29781. * @returns true if this buffer is instanced
  29782. */
  29783. getIsInstanced(): boolean;
  29784. /**
  29785. * Returns the instancing divisor, zero for non-instanced (integer).
  29786. * @returns a number
  29787. */
  29788. getInstanceDivisor(): number;
  29789. /**
  29790. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29791. * @param data defines the data to store
  29792. */
  29793. create(data?: DataArray): void;
  29794. /**
  29795. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29796. * This function will create a new buffer if the current one is not updatable
  29797. * @param data defines the data to store
  29798. */
  29799. update(data: DataArray): void;
  29800. /**
  29801. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29802. * Returns the directly updated WebGLBuffer.
  29803. * @param data the new data
  29804. * @param offset the new offset
  29805. * @param useBytes set to true if the offset is in bytes
  29806. */
  29807. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29808. /**
  29809. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29810. */
  29811. dispose(): void;
  29812. /**
  29813. * Enumerates each value of this vertex buffer as numbers.
  29814. * @param count the number of values to enumerate
  29815. * @param callback the callback function called for each value
  29816. */
  29817. forEach(count: number, callback: (value: number, index: number) => void): void;
  29818. /**
  29819. * Positions
  29820. */
  29821. static readonly PositionKind: string;
  29822. /**
  29823. * Normals
  29824. */
  29825. static readonly NormalKind: string;
  29826. /**
  29827. * Tangents
  29828. */
  29829. static readonly TangentKind: string;
  29830. /**
  29831. * Texture coordinates
  29832. */
  29833. static readonly UVKind: string;
  29834. /**
  29835. * Texture coordinates 2
  29836. */
  29837. static readonly UV2Kind: string;
  29838. /**
  29839. * Texture coordinates 3
  29840. */
  29841. static readonly UV3Kind: string;
  29842. /**
  29843. * Texture coordinates 4
  29844. */
  29845. static readonly UV4Kind: string;
  29846. /**
  29847. * Texture coordinates 5
  29848. */
  29849. static readonly UV5Kind: string;
  29850. /**
  29851. * Texture coordinates 6
  29852. */
  29853. static readonly UV6Kind: string;
  29854. /**
  29855. * Colors
  29856. */
  29857. static readonly ColorKind: string;
  29858. /**
  29859. * Matrix indices (for bones)
  29860. */
  29861. static readonly MatricesIndicesKind: string;
  29862. /**
  29863. * Matrix weights (for bones)
  29864. */
  29865. static readonly MatricesWeightsKind: string;
  29866. /**
  29867. * Additional matrix indices (for bones)
  29868. */
  29869. static readonly MatricesIndicesExtraKind: string;
  29870. /**
  29871. * Additional matrix weights (for bones)
  29872. */
  29873. static readonly MatricesWeightsExtraKind: string;
  29874. /**
  29875. * Deduces the stride given a kind.
  29876. * @param kind The kind string to deduce
  29877. * @returns The deduced stride
  29878. */
  29879. static DeduceStride(kind: string): number;
  29880. /**
  29881. * Gets the byte length of the given type.
  29882. * @param type the type
  29883. * @returns the number of bytes
  29884. */
  29885. static GetTypeByteLength(type: number): number;
  29886. /**
  29887. * Enumerates each value of the given parameters as numbers.
  29888. * @param data the data to enumerate
  29889. * @param byteOffset the byte offset of the data
  29890. * @param byteStride the byte stride of the data
  29891. * @param componentCount the number of components per element
  29892. * @param componentType the type of the component
  29893. * @param count the total number of components
  29894. * @param normalized whether the data is normalized
  29895. * @param callback the callback function called for each value
  29896. */
  29897. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29898. private static _GetFloatValue;
  29899. }
  29900. }
  29901. declare module BABYLON {
  29902. /**
  29903. * Defines a target to use with MorphTargetManager
  29904. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29905. */
  29906. class MorphTarget implements IAnimatable {
  29907. /** defines the name of the target */
  29908. name: string;
  29909. /**
  29910. * Gets or sets the list of animations
  29911. */
  29912. animations: Animation[];
  29913. private _scene;
  29914. private _positions;
  29915. private _normals;
  29916. private _tangents;
  29917. private _influence;
  29918. /**
  29919. * Observable raised when the influence changes
  29920. */
  29921. onInfluenceChanged: Observable<boolean>;
  29922. /** @hidden */
  29923. _onDataLayoutChanged: Observable<void>;
  29924. /**
  29925. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29926. */
  29927. influence: number;
  29928. /**
  29929. * Gets or sets the id of the morph Target
  29930. */
  29931. id: string;
  29932. private _animationPropertiesOverride;
  29933. /**
  29934. * Gets or sets the animation properties override
  29935. */
  29936. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29937. /**
  29938. * Creates a new MorphTarget
  29939. * @param name defines the name of the target
  29940. * @param influence defines the influence to use
  29941. */
  29942. constructor(
  29943. /** defines the name of the target */
  29944. name: string, influence?: number, scene?: Nullable<Scene>);
  29945. /**
  29946. * Gets a boolean defining if the target contains position data
  29947. */
  29948. readonly hasPositions: boolean;
  29949. /**
  29950. * Gets a boolean defining if the target contains normal data
  29951. */
  29952. readonly hasNormals: boolean;
  29953. /**
  29954. * Gets a boolean defining if the target contains tangent data
  29955. */
  29956. readonly hasTangents: boolean;
  29957. /**
  29958. * Affects position data to this target
  29959. * @param data defines the position data to use
  29960. */
  29961. setPositions(data: Nullable<FloatArray>): void;
  29962. /**
  29963. * Gets the position data stored in this target
  29964. * @returns a FloatArray containing the position data (or null if not present)
  29965. */
  29966. getPositions(): Nullable<FloatArray>;
  29967. /**
  29968. * Affects normal data to this target
  29969. * @param data defines the normal data to use
  29970. */
  29971. setNormals(data: Nullable<FloatArray>): void;
  29972. /**
  29973. * Gets the normal data stored in this target
  29974. * @returns a FloatArray containing the normal data (or null if not present)
  29975. */
  29976. getNormals(): Nullable<FloatArray>;
  29977. /**
  29978. * Affects tangent data to this target
  29979. * @param data defines the tangent data to use
  29980. */
  29981. setTangents(data: Nullable<FloatArray>): void;
  29982. /**
  29983. * Gets the tangent data stored in this target
  29984. * @returns a FloatArray containing the tangent data (or null if not present)
  29985. */
  29986. getTangents(): Nullable<FloatArray>;
  29987. /**
  29988. * Serializes the current target into a Serialization object
  29989. * @returns the serialized object
  29990. */
  29991. serialize(): any;
  29992. /**
  29993. * Returns the string "MorphTarget"
  29994. * @returns "MorphTarget"
  29995. */
  29996. getClassName(): string;
  29997. /**
  29998. * Creates a new target from serialized data
  29999. * @param serializationObject defines the serialized data to use
  30000. * @returns a new MorphTarget
  30001. */
  30002. static Parse(serializationObject: any): MorphTarget;
  30003. /**
  30004. * Creates a MorphTarget from mesh data
  30005. * @param mesh defines the source mesh
  30006. * @param name defines the name to use for the new target
  30007. * @param influence defines the influence to attach to the target
  30008. * @returns a new MorphTarget
  30009. */
  30010. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30011. }
  30012. }
  30013. declare module BABYLON {
  30014. /**
  30015. * This class is used to deform meshes using morphing between different targets
  30016. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30017. */
  30018. class MorphTargetManager {
  30019. private _targets;
  30020. private _targetInfluenceChangedObservers;
  30021. private _targetDataLayoutChangedObservers;
  30022. private _activeTargets;
  30023. private _scene;
  30024. private _influences;
  30025. private _supportsNormals;
  30026. private _supportsTangents;
  30027. private _vertexCount;
  30028. private _uniqueId;
  30029. private _tempInfluences;
  30030. /**
  30031. * Creates a new MorphTargetManager
  30032. * @param scene defines the current scene
  30033. */
  30034. constructor(scene?: Nullable<Scene>);
  30035. /**
  30036. * Gets the unique ID of this manager
  30037. */
  30038. readonly uniqueId: number;
  30039. /**
  30040. * Gets the number of vertices handled by this manager
  30041. */
  30042. readonly vertexCount: number;
  30043. /**
  30044. * Gets a boolean indicating if this manager supports morphing of normals
  30045. */
  30046. readonly supportsNormals: boolean;
  30047. /**
  30048. * Gets a boolean indicating if this manager supports morphing of tangents
  30049. */
  30050. readonly supportsTangents: boolean;
  30051. /**
  30052. * Gets the number of targets stored in this manager
  30053. */
  30054. readonly numTargets: number;
  30055. /**
  30056. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30057. */
  30058. readonly numInfluencers: number;
  30059. /**
  30060. * Gets the list of influences (one per target)
  30061. */
  30062. readonly influences: Float32Array;
  30063. /**
  30064. * Gets the active target at specified index. An active target is a target with an influence > 0
  30065. * @param index defines the index to check
  30066. * @returns the requested target
  30067. */
  30068. getActiveTarget(index: number): MorphTarget;
  30069. /**
  30070. * Gets the target at specified index
  30071. * @param index defines the index to check
  30072. * @returns the requested target
  30073. */
  30074. getTarget(index: number): MorphTarget;
  30075. /**
  30076. * Add a new target to this manager
  30077. * @param target defines the target to add
  30078. */
  30079. addTarget(target: MorphTarget): void;
  30080. /**
  30081. * Removes a target from the manager
  30082. * @param target defines the target to remove
  30083. */
  30084. removeTarget(target: MorphTarget): void;
  30085. /**
  30086. * Serializes the current manager into a Serialization object
  30087. * @returns the serialized object
  30088. */
  30089. serialize(): any;
  30090. private _syncActiveTargets;
  30091. /**
  30092. * Syncrhonize the targets with all the meshes using this morph target manager
  30093. */
  30094. synchronize(): void;
  30095. /**
  30096. * Creates a new MorphTargetManager from serialized data
  30097. * @param serializationObject defines the serialized data
  30098. * @param scene defines the hosting scene
  30099. * @returns the new MorphTargetManager
  30100. */
  30101. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. /**
  30106. * Class used to enable access to IndexedDB
  30107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30108. */
  30109. class Database implements IOfflineProvider {
  30110. private _callbackManifestChecked;
  30111. private _currentSceneUrl;
  30112. private _db;
  30113. private _enableSceneOffline;
  30114. private _enableTexturesOffline;
  30115. private _manifestVersionFound;
  30116. private _mustUpdateRessources;
  30117. private _hasReachedQuota;
  30118. private _isSupported;
  30119. private _idbFactory;
  30120. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30121. private static IsUASupportingBlobStorage;
  30122. /**
  30123. * Gets a boolean indicating if Database storate is enabled (off by default)
  30124. */
  30125. static IDBStorageEnabled: boolean;
  30126. /**
  30127. * Gets a boolean indicating if scene must be saved in the database
  30128. */
  30129. readonly enableSceneOffline: boolean;
  30130. /**
  30131. * Gets a boolean indicating if textures must be saved in the database
  30132. */
  30133. readonly enableTexturesOffline: boolean;
  30134. /**
  30135. * Creates a new Database
  30136. * @param urlToScene defines the url to load the scene
  30137. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30138. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30139. */
  30140. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30141. private static _ParseURL;
  30142. private static _ReturnFullUrlLocation;
  30143. private _checkManifestFile;
  30144. /**
  30145. * Open the database and make it available
  30146. * @param successCallback defines the callback to call on success
  30147. * @param errorCallback defines the callback to call on error
  30148. */
  30149. open(successCallback: () => void, errorCallback: () => void): void;
  30150. /**
  30151. * Loads an image from the database
  30152. * @param url defines the url to load from
  30153. * @param image defines the target DOM image
  30154. */
  30155. loadImage(url: string, image: HTMLImageElement): void;
  30156. private _loadImageFromDBAsync;
  30157. private _saveImageIntoDBAsync;
  30158. private _checkVersionFromDB;
  30159. private _loadVersionFromDBAsync;
  30160. private _saveVersionIntoDBAsync;
  30161. /**
  30162. * Loads a file from database
  30163. * @param url defines the URL to load from
  30164. * @param sceneLoaded defines a callback to call on success
  30165. * @param progressCallBack defines a callback to call when progress changed
  30166. * @param errorCallback defines a callback to call on error
  30167. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30168. */
  30169. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30170. private _loadFileAsync;
  30171. private _saveFileAsync;
  30172. }
  30173. }
  30174. declare module BABYLON {
  30175. /**
  30176. * Class used to enable access to offline support
  30177. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30178. */
  30179. interface IOfflineProvider {
  30180. /**
  30181. * Gets a boolean indicating if scene must be saved in the database
  30182. */
  30183. enableSceneOffline: boolean;
  30184. /**
  30185. * Gets a boolean indicating if textures must be saved in the database
  30186. */
  30187. enableTexturesOffline: boolean;
  30188. /**
  30189. * Open the offline support and make it available
  30190. * @param successCallback defines the callback to call on success
  30191. * @param errorCallback defines the callback to call on error
  30192. */
  30193. open(successCallback: () => void, errorCallback: () => void): void;
  30194. /**
  30195. * Loads an image from the offline support
  30196. * @param url defines the url to load from
  30197. * @param image defines the target DOM image
  30198. */
  30199. loadImage(url: string, image: HTMLImageElement): void;
  30200. /**
  30201. * Loads a file from offline support
  30202. * @param url defines the URL to load from
  30203. * @param sceneLoaded defines a callback to call on success
  30204. * @param progressCallBack defines a callback to call when progress changed
  30205. * @param errorCallback defines a callback to call on error
  30206. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30207. */
  30208. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30209. }
  30210. }
  30211. declare module BABYLON {
  30212. /**
  30213. * This represents the base class for particle system in Babylon.
  30214. * 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.
  30215. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30216. * @example https://doc.babylonjs.com/babylon101/particles
  30217. */
  30218. class BaseParticleSystem {
  30219. /**
  30220. * Source color is added to the destination color without alpha affecting the result
  30221. */
  30222. static BLENDMODE_ONEONE: number;
  30223. /**
  30224. * Blend current color and particle color using particle’s alpha
  30225. */
  30226. static BLENDMODE_STANDARD: number;
  30227. /**
  30228. * Add current color and particle color multiplied by particle’s alpha
  30229. */
  30230. static BLENDMODE_ADD: number;
  30231. /**
  30232. * Multiply current color with particle color
  30233. */
  30234. static BLENDMODE_MULTIPLY: number;
  30235. /**
  30236. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30237. */
  30238. static BLENDMODE_MULTIPLYADD: number;
  30239. /**
  30240. * List of animations used by the particle system.
  30241. */
  30242. animations: Animation[];
  30243. /**
  30244. * The id of the Particle system.
  30245. */
  30246. id: string;
  30247. /**
  30248. * The friendly name of the Particle system.
  30249. */
  30250. name: string;
  30251. /**
  30252. * The rendering group used by the Particle system to chose when to render.
  30253. */
  30254. renderingGroupId: number;
  30255. /**
  30256. * The emitter represents the Mesh or position we are attaching the particle system to.
  30257. */
  30258. emitter: Nullable<AbstractMesh | Vector3>;
  30259. /**
  30260. * The maximum number of particles to emit per frame
  30261. */
  30262. emitRate: number;
  30263. /**
  30264. * If you want to launch only a few particles at once, that can be done, as well.
  30265. */
  30266. manualEmitCount: number;
  30267. /**
  30268. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30269. */
  30270. updateSpeed: number;
  30271. /**
  30272. * The amount of time the particle system is running (depends of the overall update speed).
  30273. */
  30274. targetStopDuration: number;
  30275. /**
  30276. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30277. */
  30278. disposeOnStop: boolean;
  30279. /**
  30280. * Minimum power of emitting particles.
  30281. */
  30282. minEmitPower: number;
  30283. /**
  30284. * Maximum power of emitting particles.
  30285. */
  30286. maxEmitPower: number;
  30287. /**
  30288. * Minimum life time of emitting particles.
  30289. */
  30290. minLifeTime: number;
  30291. /**
  30292. * Maximum life time of emitting particles.
  30293. */
  30294. maxLifeTime: number;
  30295. /**
  30296. * Minimum Size of emitting particles.
  30297. */
  30298. minSize: number;
  30299. /**
  30300. * Maximum Size of emitting particles.
  30301. */
  30302. maxSize: number;
  30303. /**
  30304. * Minimum scale of emitting particles on X axis.
  30305. */
  30306. minScaleX: number;
  30307. /**
  30308. * Maximum scale of emitting particles on X axis.
  30309. */
  30310. maxScaleX: number;
  30311. /**
  30312. * Minimum scale of emitting particles on Y axis.
  30313. */
  30314. minScaleY: number;
  30315. /**
  30316. * Maximum scale of emitting particles on Y axis.
  30317. */
  30318. maxScaleY: number;
  30319. /**
  30320. * Gets or sets the minimal initial rotation in radians.
  30321. */
  30322. minInitialRotation: number;
  30323. /**
  30324. * Gets or sets the maximal initial rotation in radians.
  30325. */
  30326. maxInitialRotation: number;
  30327. /**
  30328. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30329. */
  30330. minAngularSpeed: number;
  30331. /**
  30332. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30333. */
  30334. maxAngularSpeed: number;
  30335. /**
  30336. * The texture used to render each particle. (this can be a spritesheet)
  30337. */
  30338. particleTexture: Nullable<Texture>;
  30339. /**
  30340. * The layer mask we are rendering the particles through.
  30341. */
  30342. layerMask: number;
  30343. /**
  30344. * This can help using your own shader to render the particle system.
  30345. * The according effect will be created
  30346. */
  30347. customShader: any;
  30348. /**
  30349. * By default particle system starts as soon as they are created. This prevents the
  30350. * automatic start to happen and let you decide when to start emitting particles.
  30351. */
  30352. preventAutoStart: boolean;
  30353. private _noiseTexture;
  30354. /**
  30355. * Gets or sets a texture used to add random noise to particle positions
  30356. */
  30357. noiseTexture: Nullable<ProceduralTexture>;
  30358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30359. noiseStrength: Vector3;
  30360. /**
  30361. * Callback triggered when the particle animation is ending.
  30362. */
  30363. onAnimationEnd: Nullable<() => void>;
  30364. /**
  30365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30366. */
  30367. blendMode: number;
  30368. /**
  30369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30370. * to override the particles.
  30371. */
  30372. forceDepthWrite: boolean;
  30373. /** 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 */
  30374. preWarmCycles: number;
  30375. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30376. preWarmStepOffset: number;
  30377. /**
  30378. * 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)
  30379. */
  30380. spriteCellChangeSpeed: number;
  30381. /**
  30382. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30383. */
  30384. startSpriteCellID: number;
  30385. /**
  30386. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30387. */
  30388. endSpriteCellID: number;
  30389. /**
  30390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30391. */
  30392. spriteCellWidth: number;
  30393. /**
  30394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30395. */
  30396. spriteCellHeight: number;
  30397. /**
  30398. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30399. */
  30400. spriteRandomStartCell: boolean;
  30401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30402. translationPivot: Vector2;
  30403. /** @hidden */
  30404. protected _isAnimationSheetEnabled: boolean;
  30405. /**
  30406. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30407. */
  30408. beginAnimationOnStart: boolean;
  30409. /**
  30410. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30411. */
  30412. beginAnimationFrom: number;
  30413. /**
  30414. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30415. */
  30416. beginAnimationTo: number;
  30417. /**
  30418. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30419. */
  30420. beginAnimationLoop: boolean;
  30421. /**
  30422. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30423. */
  30424. isAnimationSheetEnabled: boolean;
  30425. /**
  30426. * Get hosting scene
  30427. * @returns the scene
  30428. */
  30429. getScene(): Scene;
  30430. /**
  30431. * You can use gravity if you want to give an orientation to your particles.
  30432. */
  30433. gravity: Vector3;
  30434. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30435. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30436. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30437. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30438. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30439. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30440. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30441. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30442. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30443. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30444. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30445. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30446. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30447. /**
  30448. * Defines the delay in milliseconds before starting the system (0 by default)
  30449. */
  30450. startDelay: number;
  30451. /**
  30452. * Gets the current list of drag gradients.
  30453. * You must use addDragGradient and removeDragGradient to udpate this list
  30454. * @returns the list of drag gradients
  30455. */
  30456. getDragGradients(): Nullable<Array<FactorGradient>>;
  30457. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30458. limitVelocityDamping: number;
  30459. /**
  30460. * Gets the current list of limit velocity gradients.
  30461. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30462. * @returns the list of limit velocity gradients
  30463. */
  30464. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30465. /**
  30466. * Gets the current list of color gradients.
  30467. * You must use addColorGradient and removeColorGradient to udpate this list
  30468. * @returns the list of color gradients
  30469. */
  30470. getColorGradients(): Nullable<Array<ColorGradient>>;
  30471. /**
  30472. * Gets the current list of size gradients.
  30473. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30474. * @returns the list of size gradients
  30475. */
  30476. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30477. /**
  30478. * Gets the current list of color remap gradients.
  30479. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30480. * @returns the list of color remap gradients
  30481. */
  30482. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30483. /**
  30484. * Gets the current list of alpha remap gradients.
  30485. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30486. * @returns the list of alpha remap gradients
  30487. */
  30488. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30489. /**
  30490. * Gets the current list of life time gradients.
  30491. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30492. * @returns the list of life time gradients
  30493. */
  30494. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30495. /**
  30496. * Gets the current list of angular speed gradients.
  30497. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30498. * @returns the list of angular speed gradients
  30499. */
  30500. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30501. /**
  30502. * Gets the current list of velocity gradients.
  30503. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30504. * @returns the list of velocity gradients
  30505. */
  30506. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30507. /**
  30508. * Gets the current list of start size gradients.
  30509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30510. * @returns the list of start size gradients
  30511. */
  30512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30513. /**
  30514. * Gets the current list of emit rate gradients.
  30515. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30516. * @returns the list of emit rate gradients
  30517. */
  30518. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30519. /**
  30520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30522. */
  30523. direction1: Vector3;
  30524. /**
  30525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30527. */
  30528. direction2: Vector3;
  30529. /**
  30530. * 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.
  30531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30532. */
  30533. minEmitBox: Vector3;
  30534. /**
  30535. * 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.
  30536. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30537. */
  30538. maxEmitBox: Vector3;
  30539. /**
  30540. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30541. */
  30542. color1: Color4;
  30543. /**
  30544. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30545. */
  30546. color2: Color4;
  30547. /**
  30548. * Color the particle will have at the end of its lifetime
  30549. */
  30550. colorDead: Color4;
  30551. /**
  30552. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30553. */
  30554. textureMask: Color4;
  30555. /**
  30556. * The particle emitter type defines the emitter used by the particle system.
  30557. * It can be for example box, sphere, or cone...
  30558. */
  30559. particleEmitterType: IParticleEmitterType;
  30560. /** @hidden */
  30561. _isSubEmitter: boolean;
  30562. /**
  30563. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30564. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30565. */
  30566. billboardMode: number;
  30567. protected _isBillboardBased: boolean;
  30568. /**
  30569. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30570. */
  30571. isBillboardBased: boolean;
  30572. /**
  30573. * The scene the particle system belongs to.
  30574. */
  30575. protected _scene: Scene;
  30576. /**
  30577. * Local cache of defines for image processing.
  30578. */
  30579. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30580. /**
  30581. * Default configuration related to image processing available in the standard Material.
  30582. */
  30583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30584. /**
  30585. * Gets the image processing configuration used either in this material.
  30586. */
  30587. /**
  30588. * Sets the Default image processing configuration used either in the this material.
  30589. *
  30590. * If sets to null, the scene one is in use.
  30591. */
  30592. imageProcessingConfiguration: ImageProcessingConfiguration;
  30593. /**
  30594. * Attaches a new image processing configuration to the Standard Material.
  30595. * @param configuration
  30596. */
  30597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30598. /** @hidden */
  30599. protected _reset(): void;
  30600. /** @hidden */
  30601. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30602. /**
  30603. * Instantiates a particle system.
  30604. * 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.
  30605. * @param name The name of the particle system
  30606. */
  30607. constructor(name: string);
  30608. /**
  30609. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30612. * @returns the emitter
  30613. */
  30614. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30615. /**
  30616. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30617. * @param radius The radius of the hemisphere to emit from
  30618. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30619. * @returns the emitter
  30620. */
  30621. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30622. /**
  30623. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30624. * @param radius The radius of the sphere to emit from
  30625. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30626. * @returns the emitter
  30627. */
  30628. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30629. /**
  30630. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30631. * @param radius The radius of the sphere to emit from
  30632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30634. * @returns the emitter
  30635. */
  30636. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30637. /**
  30638. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30639. * @param radius The radius of the emission cylinder
  30640. * @param height The height of the emission cylinder
  30641. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30642. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30643. * @returns the emitter
  30644. */
  30645. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30646. /**
  30647. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30648. * @param radius The radius of the cylinder to emit from
  30649. * @param height The height of the emission cylinder
  30650. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30653. * @returns the emitter
  30654. */
  30655. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30656. /**
  30657. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30658. * @param radius The radius of the cone to emit from
  30659. * @param angle The base angle of the cone
  30660. * @returns the emitter
  30661. */
  30662. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30663. /**
  30664. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30665. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30666. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30667. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30668. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30669. * @returns the emitter
  30670. */
  30671. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. /**
  30676. * This represents a GPU particle system in Babylon
  30677. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30678. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30679. */
  30680. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30681. /**
  30682. * The layer mask we are rendering the particles through.
  30683. */
  30684. layerMask: number;
  30685. private _capacity;
  30686. private _activeCount;
  30687. private _currentActiveCount;
  30688. private _accumulatedCount;
  30689. private _renderEffect;
  30690. private _updateEffect;
  30691. private _buffer0;
  30692. private _buffer1;
  30693. private _spriteBuffer;
  30694. private _updateVAO;
  30695. private _renderVAO;
  30696. private _targetIndex;
  30697. private _sourceBuffer;
  30698. private _targetBuffer;
  30699. private _engine;
  30700. private _currentRenderId;
  30701. private _started;
  30702. private _stopped;
  30703. private _timeDelta;
  30704. private _randomTexture;
  30705. private _randomTexture2;
  30706. private _attributesStrideSize;
  30707. private _updateEffectOptions;
  30708. private _randomTextureSize;
  30709. private _actualFrame;
  30710. private readonly _rawTextureWidth;
  30711. /**
  30712. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30713. */
  30714. static readonly IsSupported: boolean;
  30715. /**
  30716. * An event triggered when the system is disposed.
  30717. */
  30718. onDisposeObservable: Observable<GPUParticleSystem>;
  30719. /**
  30720. * Gets the maximum number of particles active at the same time.
  30721. * @returns The max number of active particles.
  30722. */
  30723. getCapacity(): number;
  30724. /**
  30725. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30726. * to override the particles.
  30727. */
  30728. forceDepthWrite: boolean;
  30729. /**
  30730. * Gets or set the number of active particles
  30731. */
  30732. activeParticleCount: number;
  30733. private _preWarmDone;
  30734. /**
  30735. * Is this system ready to be used/rendered
  30736. * @return true if the system is ready
  30737. */
  30738. isReady(): boolean;
  30739. /**
  30740. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30741. * @returns True if it has been started, otherwise false.
  30742. */
  30743. isStarted(): boolean;
  30744. /**
  30745. * Starts the particle system and begins to emit
  30746. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30747. */
  30748. start(delay?: number): void;
  30749. /**
  30750. * Stops the particle system.
  30751. */
  30752. stop(): void;
  30753. /**
  30754. * Remove all active particles
  30755. */
  30756. reset(): void;
  30757. /**
  30758. * Returns the string "GPUParticleSystem"
  30759. * @returns a string containing the class name
  30760. */
  30761. getClassName(): string;
  30762. private _colorGradientsTexture;
  30763. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30764. /**
  30765. * Adds a new color gradient
  30766. * @param gradient defines the gradient to use (between 0 and 1)
  30767. * @param color1 defines the color to affect to the specified gradient
  30768. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30769. * @returns the current particle system
  30770. */
  30771. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30772. /**
  30773. * Remove a specific color gradient
  30774. * @param gradient defines the gradient to remove
  30775. * @returns the current particle system
  30776. */
  30777. removeColorGradient(gradient: number): GPUParticleSystem;
  30778. private _angularSpeedGradientsTexture;
  30779. private _sizeGradientsTexture;
  30780. private _velocityGradientsTexture;
  30781. private _limitVelocityGradientsTexture;
  30782. private _dragGradientsTexture;
  30783. private _addFactorGradient;
  30784. /**
  30785. * Adds a new size gradient
  30786. * @param gradient defines the gradient to use (between 0 and 1)
  30787. * @param factor defines the size factor to affect to the specified gradient
  30788. * @returns the current particle system
  30789. */
  30790. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30791. /**
  30792. * Remove a specific size gradient
  30793. * @param gradient defines the gradient to remove
  30794. * @returns the current particle system
  30795. */
  30796. removeSizeGradient(gradient: number): GPUParticleSystem;
  30797. /**
  30798. * Adds a new angular speed gradient
  30799. * @param gradient defines the gradient to use (between 0 and 1)
  30800. * @param factor defines the angular speed to affect to the specified gradient
  30801. * @returns the current particle system
  30802. */
  30803. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30804. /**
  30805. * Remove a specific angular speed gradient
  30806. * @param gradient defines the gradient to remove
  30807. * @returns the current particle system
  30808. */
  30809. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30810. /**
  30811. * Adds a new velocity gradient
  30812. * @param gradient defines the gradient to use (between 0 and 1)
  30813. * @param factor defines the velocity to affect to the specified gradient
  30814. * @returns the current particle system
  30815. */
  30816. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30817. /**
  30818. * Remove a specific velocity gradient
  30819. * @param gradient defines the gradient to remove
  30820. * @returns the current particle system
  30821. */
  30822. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30823. /**
  30824. * Adds a new limit velocity gradient
  30825. * @param gradient defines the gradient to use (between 0 and 1)
  30826. * @param factor defines the limit velocity value to affect to the specified gradient
  30827. * @returns the current particle system
  30828. */
  30829. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30830. /**
  30831. * Remove a specific limit velocity gradient
  30832. * @param gradient defines the gradient to remove
  30833. * @returns the current particle system
  30834. */
  30835. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30836. /**
  30837. * Adds a new drag gradient
  30838. * @param gradient defines the gradient to use (between 0 and 1)
  30839. * @param factor defines the drag value to affect to the specified gradient
  30840. * @returns the current particle system
  30841. */
  30842. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30843. /**
  30844. * Remove a specific drag gradient
  30845. * @param gradient defines the gradient to remove
  30846. * @returns the current particle system
  30847. */
  30848. removeDragGradient(gradient: number): GPUParticleSystem;
  30849. /**
  30850. * Not supported by GPUParticleSystem
  30851. * @param gradient defines the gradient to use (between 0 and 1)
  30852. * @param factor defines the emit rate value to affect to the specified gradient
  30853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30854. * @returns the current particle system
  30855. */
  30856. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30857. /**
  30858. * Not supported by GPUParticleSystem
  30859. * @param gradient defines the gradient to remove
  30860. * @returns the current particle system
  30861. */
  30862. removeEmitRateGradient(gradient: number): IParticleSystem;
  30863. /**
  30864. * Not supported by GPUParticleSystem
  30865. * @param gradient defines the gradient to use (between 0 and 1)
  30866. * @param factor defines the start size value to affect to the specified gradient
  30867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30868. * @returns the current particle system
  30869. */
  30870. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30871. /**
  30872. * Not supported by GPUParticleSystem
  30873. * @param gradient defines the gradient to remove
  30874. * @returns the current particle system
  30875. */
  30876. removeStartSizeGradient(gradient: number): IParticleSystem;
  30877. /**
  30878. * Not supported by GPUParticleSystem
  30879. * @param gradient defines the gradient to use (between 0 and 1)
  30880. * @param min defines the color remap minimal range
  30881. * @param max defines the color remap maximal range
  30882. * @returns the current particle system
  30883. */
  30884. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30885. /**
  30886. * Not supported by GPUParticleSystem
  30887. * @param gradient defines the gradient to remove
  30888. * @returns the current particle system
  30889. */
  30890. removeColorRemapGradient(gradient: number): IParticleSystem;
  30891. /**
  30892. * Not supported by GPUParticleSystem
  30893. * @param gradient defines the gradient to use (between 0 and 1)
  30894. * @param min defines the alpha remap minimal range
  30895. * @param max defines the alpha remap maximal range
  30896. * @returns the current particle system
  30897. */
  30898. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30899. /**
  30900. * Not supported by GPUParticleSystem
  30901. * @param gradient defines the gradient to remove
  30902. * @returns the current particle system
  30903. */
  30904. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30905. /**
  30906. * Not supported by GPUParticleSystem
  30907. * @param gradient defines the gradient to use (between 0 and 1)
  30908. * @param color defines the color to affect to the specified gradient
  30909. * @returns the current particle system
  30910. */
  30911. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30912. /**
  30913. * Not supported by GPUParticleSystem
  30914. * @param gradient defines the gradient to remove
  30915. * @returns the current particle system
  30916. */
  30917. removeRampGradient(gradient: number): IParticleSystem;
  30918. /**
  30919. * Not supported by GPUParticleSystem
  30920. * @returns the list of ramp gradients
  30921. */
  30922. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30923. /**
  30924. * Not supported by GPUParticleSystem
  30925. * Gets or sets a boolean indicating that ramp gradients must be used
  30926. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30927. */
  30928. useRampGradients: boolean;
  30929. /**
  30930. * Not supported by GPUParticleSystem
  30931. * @param gradient defines the gradient to use (between 0 and 1)
  30932. * @param factor defines the life time factor to affect to the specified gradient
  30933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30934. * @returns the current particle system
  30935. */
  30936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30937. /**
  30938. * Not supported by GPUParticleSystem
  30939. * @param gradient defines the gradient to remove
  30940. * @returns the current particle system
  30941. */
  30942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30943. /**
  30944. * Instantiates a GPU particle system.
  30945. * 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.
  30946. * @param name The name of the particle system
  30947. * @param options The options used to create the system
  30948. * @param scene The scene the particle system belongs to
  30949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30950. */
  30951. constructor(name: string, options: Partial<{
  30952. capacity: number;
  30953. randomTextureSize: number;
  30954. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30955. protected _reset(): void;
  30956. private _createUpdateVAO;
  30957. private _createRenderVAO;
  30958. private _initialize;
  30959. /** @hidden */
  30960. _recreateUpdateEffect(): void;
  30961. /** @hidden */
  30962. _recreateRenderEffect(): void;
  30963. /**
  30964. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30965. * @param preWarm defines if we are in the pre-warmimg phase
  30966. */
  30967. animate(preWarm?: boolean): void;
  30968. private _createFactorGradientTexture;
  30969. private _createSizeGradientTexture;
  30970. private _createAngularSpeedGradientTexture;
  30971. private _createVelocityGradientTexture;
  30972. private _createLimitVelocityGradientTexture;
  30973. private _createDragGradientTexture;
  30974. private _createColorGradientTexture;
  30975. /**
  30976. * Renders the particle system in its current state
  30977. * @param preWarm defines if the system should only update the particles but not render them
  30978. * @returns the current number of particles
  30979. */
  30980. render(preWarm?: boolean): number;
  30981. /**
  30982. * Rebuilds the particle system
  30983. */
  30984. rebuild(): void;
  30985. private _releaseBuffers;
  30986. private _releaseVAOs;
  30987. /**
  30988. * Disposes the particle system and free the associated resources
  30989. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30990. */
  30991. dispose(disposeTexture?: boolean): void;
  30992. /**
  30993. * Clones the particle system.
  30994. * @param name The name of the cloned object
  30995. * @param newEmitter The new emitter to use
  30996. * @returns the cloned particle system
  30997. */
  30998. clone(name: string, newEmitter: any): GPUParticleSystem;
  30999. /**
  31000. * Serializes the particle system to a JSON object.
  31001. * @returns the JSON object
  31002. */
  31003. serialize(): any;
  31004. /**
  31005. * Parses a JSON object to create a GPU particle system.
  31006. * @param parsedParticleSystem The JSON object to parse
  31007. * @param scene The scene to create the particle system in
  31008. * @param rootUrl The root url to use to load external dependencies like texture
  31009. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31010. * @returns the parsed GPU particle system
  31011. */
  31012. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31013. }
  31014. }
  31015. declare module BABYLON {
  31016. /**
  31017. * Interface representing a particle system in Babylon.js.
  31018. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31019. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31020. */
  31021. interface IParticleSystem {
  31022. /**
  31023. * List of animations used by the particle system.
  31024. */
  31025. animations: Animation[];
  31026. /**
  31027. * The id of the Particle system.
  31028. */
  31029. id: string;
  31030. /**
  31031. * The name of the Particle system.
  31032. */
  31033. name: string;
  31034. /**
  31035. * The emitter represents the Mesh or position we are attaching the particle system to.
  31036. */
  31037. emitter: Nullable<AbstractMesh | Vector3>;
  31038. /**
  31039. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31040. */
  31041. isBillboardBased: boolean;
  31042. /**
  31043. * The rendering group used by the Particle system to chose when to render.
  31044. */
  31045. renderingGroupId: number;
  31046. /**
  31047. * The layer mask we are rendering the particles through.
  31048. */
  31049. layerMask: number;
  31050. /**
  31051. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31052. */
  31053. updateSpeed: number;
  31054. /**
  31055. * The amount of time the particle system is running (depends of the overall update speed).
  31056. */
  31057. targetStopDuration: number;
  31058. /**
  31059. * The texture used to render each particle. (this can be a spritesheet)
  31060. */
  31061. particleTexture: Nullable<Texture>;
  31062. /**
  31063. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31064. */
  31065. blendMode: number;
  31066. /**
  31067. * Minimum life time of emitting particles.
  31068. */
  31069. minLifeTime: number;
  31070. /**
  31071. * Maximum life time of emitting particles.
  31072. */
  31073. maxLifeTime: number;
  31074. /**
  31075. * Minimum Size of emitting particles.
  31076. */
  31077. minSize: number;
  31078. /**
  31079. * Maximum Size of emitting particles.
  31080. */
  31081. maxSize: number;
  31082. /**
  31083. * Minimum scale of emitting particles on X axis.
  31084. */
  31085. minScaleX: number;
  31086. /**
  31087. * Maximum scale of emitting particles on X axis.
  31088. */
  31089. maxScaleX: number;
  31090. /**
  31091. * Minimum scale of emitting particles on Y axis.
  31092. */
  31093. minScaleY: number;
  31094. /**
  31095. * Maximum scale of emitting particles on Y axis.
  31096. */
  31097. maxScaleY: number;
  31098. /**
  31099. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31100. */
  31101. color1: Color4;
  31102. /**
  31103. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31104. */
  31105. color2: Color4;
  31106. /**
  31107. * Color the particle will have at the end of its lifetime.
  31108. */
  31109. colorDead: Color4;
  31110. /**
  31111. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31112. */
  31113. emitRate: number;
  31114. /**
  31115. * You can use gravity if you want to give an orientation to your particles.
  31116. */
  31117. gravity: Vector3;
  31118. /**
  31119. * Minimum power of emitting particles.
  31120. */
  31121. minEmitPower: number;
  31122. /**
  31123. * Maximum power of emitting particles.
  31124. */
  31125. maxEmitPower: number;
  31126. /**
  31127. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31128. */
  31129. minAngularSpeed: number;
  31130. /**
  31131. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31132. */
  31133. maxAngularSpeed: number;
  31134. /**
  31135. * Gets or sets the minimal initial rotation in radians.
  31136. */
  31137. minInitialRotation: number;
  31138. /**
  31139. * Gets or sets the maximal initial rotation in radians.
  31140. */
  31141. maxInitialRotation: number;
  31142. /**
  31143. * The particle emitter type defines the emitter used by the particle system.
  31144. * It can be for example box, sphere, or cone...
  31145. */
  31146. particleEmitterType: Nullable<IParticleEmitterType>;
  31147. /**
  31148. * Defines the delay in milliseconds before starting the system (0 by default)
  31149. */
  31150. startDelay: number;
  31151. /**
  31152. * 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
  31153. */
  31154. preWarmCycles: number;
  31155. /**
  31156. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31157. */
  31158. preWarmStepOffset: number;
  31159. /**
  31160. * 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)
  31161. */
  31162. spriteCellChangeSpeed: number;
  31163. /**
  31164. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31165. */
  31166. startSpriteCellID: number;
  31167. /**
  31168. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31169. */
  31170. endSpriteCellID: number;
  31171. /**
  31172. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31173. */
  31174. spriteCellWidth: number;
  31175. /**
  31176. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31177. */
  31178. spriteCellHeight: number;
  31179. /**
  31180. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31181. */
  31182. spriteRandomStartCell: boolean;
  31183. /**
  31184. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31185. */
  31186. isAnimationSheetEnabled: boolean;
  31187. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31188. translationPivot: Vector2;
  31189. /**
  31190. * Gets or sets a texture used to add random noise to particle positions
  31191. */
  31192. noiseTexture: Nullable<BaseTexture>;
  31193. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31194. noiseStrength: Vector3;
  31195. /**
  31196. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31197. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31198. */
  31199. billboardMode: number;
  31200. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31201. limitVelocityDamping: number;
  31202. /**
  31203. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31204. */
  31205. beginAnimationOnStart: boolean;
  31206. /**
  31207. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31208. */
  31209. beginAnimationFrom: number;
  31210. /**
  31211. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31212. */
  31213. beginAnimationTo: number;
  31214. /**
  31215. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31216. */
  31217. beginAnimationLoop: boolean;
  31218. /**
  31219. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31220. */
  31221. disposeOnStop: boolean;
  31222. /**
  31223. * Gets the maximum number of particles active at the same time.
  31224. * @returns The max number of active particles.
  31225. */
  31226. getCapacity(): number;
  31227. /**
  31228. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31229. * @returns True if it has been started, otherwise false.
  31230. */
  31231. isStarted(): boolean;
  31232. /**
  31233. * Animates the particle system for this frame.
  31234. */
  31235. animate(): void;
  31236. /**
  31237. * Renders the particle system in its current state.
  31238. * @returns the current number of particles
  31239. */
  31240. render(): number;
  31241. /**
  31242. * Dispose the particle system and frees its associated resources.
  31243. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31244. */
  31245. dispose(disposeTexture?: boolean): void;
  31246. /**
  31247. * Clones the particle system.
  31248. * @param name The name of the cloned object
  31249. * @param newEmitter The new emitter to use
  31250. * @returns the cloned particle system
  31251. */
  31252. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31253. /**
  31254. * Serializes the particle system to a JSON object.
  31255. * @returns the JSON object
  31256. */
  31257. serialize(): any;
  31258. /**
  31259. * Rebuild the particle system
  31260. */
  31261. rebuild(): void;
  31262. /**
  31263. * Starts the particle system and begins to emit
  31264. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31265. */
  31266. start(delay?: number): void;
  31267. /**
  31268. * Stops the particle system.
  31269. */
  31270. stop(): void;
  31271. /**
  31272. * Remove all active particles
  31273. */
  31274. reset(): void;
  31275. /**
  31276. * Is this system ready to be used/rendered
  31277. * @return true if the system is ready
  31278. */
  31279. isReady(): boolean;
  31280. /**
  31281. * Adds a new color gradient
  31282. * @param gradient defines the gradient to use (between 0 and 1)
  31283. * @param color1 defines the color to affect to the specified gradient
  31284. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31285. * @returns the current particle system
  31286. */
  31287. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31288. /**
  31289. * Remove a specific color gradient
  31290. * @param gradient defines the gradient to remove
  31291. * @returns the current particle system
  31292. */
  31293. removeColorGradient(gradient: number): IParticleSystem;
  31294. /**
  31295. * Adds a new size gradient
  31296. * @param gradient defines the gradient to use (between 0 and 1)
  31297. * @param factor defines the size factor to affect to the specified gradient
  31298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31299. * @returns the current particle system
  31300. */
  31301. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31302. /**
  31303. * Remove a specific size gradient
  31304. * @param gradient defines the gradient to remove
  31305. * @returns the current particle system
  31306. */
  31307. removeSizeGradient(gradient: number): IParticleSystem;
  31308. /**
  31309. * Gets the current list of color gradients.
  31310. * You must use addColorGradient and removeColorGradient to udpate this list
  31311. * @returns the list of color gradients
  31312. */
  31313. getColorGradients(): Nullable<Array<ColorGradient>>;
  31314. /**
  31315. * Gets the current list of size gradients.
  31316. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31317. * @returns the list of size gradients
  31318. */
  31319. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31320. /**
  31321. * Gets the current list of angular speed gradients.
  31322. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31323. * @returns the list of angular speed gradients
  31324. */
  31325. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31326. /**
  31327. * Adds a new angular speed gradient
  31328. * @param gradient defines the gradient to use (between 0 and 1)
  31329. * @param factor defines the angular speed to affect to the specified gradient
  31330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31331. * @returns the current particle system
  31332. */
  31333. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31334. /**
  31335. * Remove a specific angular speed gradient
  31336. * @param gradient defines the gradient to remove
  31337. * @returns the current particle system
  31338. */
  31339. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31340. /**
  31341. * Gets the current list of velocity gradients.
  31342. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31343. * @returns the list of velocity gradients
  31344. */
  31345. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31346. /**
  31347. * Adds a new velocity gradient
  31348. * @param gradient defines the gradient to use (between 0 and 1)
  31349. * @param factor defines the velocity to affect to the specified gradient
  31350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31351. * @returns the current particle system
  31352. */
  31353. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31354. /**
  31355. * Remove a specific velocity gradient
  31356. * @param gradient defines the gradient to remove
  31357. * @returns the current particle system
  31358. */
  31359. removeVelocityGradient(gradient: number): IParticleSystem;
  31360. /**
  31361. * Gets the current list of limit velocity gradients.
  31362. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31363. * @returns the list of limit velocity gradients
  31364. */
  31365. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31366. /**
  31367. * Adds a new limit velocity gradient
  31368. * @param gradient defines the gradient to use (between 0 and 1)
  31369. * @param factor defines the limit velocity to affect to the specified gradient
  31370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31371. * @returns the current particle system
  31372. */
  31373. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31374. /**
  31375. * Remove a specific limit velocity gradient
  31376. * @param gradient defines the gradient to remove
  31377. * @returns the current particle system
  31378. */
  31379. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31380. /**
  31381. * Adds a new drag gradient
  31382. * @param gradient defines the gradient to use (between 0 and 1)
  31383. * @param factor defines the drag to affect to the specified gradient
  31384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31385. * @returns the current particle system
  31386. */
  31387. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31388. /**
  31389. * Remove a specific drag gradient
  31390. * @param gradient defines the gradient to remove
  31391. * @returns the current particle system
  31392. */
  31393. removeDragGradient(gradient: number): IParticleSystem;
  31394. /**
  31395. * Gets the current list of drag gradients.
  31396. * You must use addDragGradient and removeDragGradient to udpate this list
  31397. * @returns the list of drag gradients
  31398. */
  31399. getDragGradients(): Nullable<Array<FactorGradient>>;
  31400. /**
  31401. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31402. * @param gradient defines the gradient to use (between 0 and 1)
  31403. * @param factor defines the emit rate to affect to the specified gradient
  31404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31405. * @returns the current particle system
  31406. */
  31407. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31408. /**
  31409. * Remove a specific emit rate gradient
  31410. * @param gradient defines the gradient to remove
  31411. * @returns the current particle system
  31412. */
  31413. removeEmitRateGradient(gradient: number): IParticleSystem;
  31414. /**
  31415. * Gets the current list of emit rate gradients.
  31416. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31417. * @returns the list of emit rate gradients
  31418. */
  31419. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31420. /**
  31421. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31422. * @param gradient defines the gradient to use (between 0 and 1)
  31423. * @param factor defines the start size to affect to the specified gradient
  31424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31425. * @returns the current particle system
  31426. */
  31427. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31428. /**
  31429. * Remove a specific start size gradient
  31430. * @param gradient defines the gradient to remove
  31431. * @returns the current particle system
  31432. */
  31433. removeStartSizeGradient(gradient: number): IParticleSystem;
  31434. /**
  31435. * Gets the current list of start size gradients.
  31436. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31437. * @returns the list of start size gradients
  31438. */
  31439. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31440. /**
  31441. * Adds a new life time gradient
  31442. * @param gradient defines the gradient to use (between 0 and 1)
  31443. * @param factor defines the life time factor to affect to the specified gradient
  31444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31445. * @returns the current particle system
  31446. */
  31447. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31448. /**
  31449. * Remove a specific life time gradient
  31450. * @param gradient defines the gradient to remove
  31451. * @returns the current particle system
  31452. */
  31453. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31454. /**
  31455. * Gets the current list of life time gradients.
  31456. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31457. * @returns the list of life time gradients
  31458. */
  31459. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31460. /**
  31461. * Gets the current list of color gradients.
  31462. * You must use addColorGradient and removeColorGradient to udpate this list
  31463. * @returns the list of color gradients
  31464. */
  31465. getColorGradients(): Nullable<Array<ColorGradient>>;
  31466. /**
  31467. * Adds a new ramp gradient used to remap particle colors
  31468. * @param gradient defines the gradient to use (between 0 and 1)
  31469. * @param color defines the color to affect to the specified gradient
  31470. * @returns the current particle system
  31471. */
  31472. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31473. /**
  31474. * Gets the current list of ramp gradients.
  31475. * You must use addRampGradient and removeRampGradient to udpate this list
  31476. * @returns the list of ramp gradients
  31477. */
  31478. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31479. /** Gets or sets a boolean indicating that ramp gradients must be used
  31480. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31481. */
  31482. useRampGradients: boolean;
  31483. /**
  31484. * Adds a new color remap gradient
  31485. * @param gradient defines the gradient to use (between 0 and 1)
  31486. * @param min defines the color remap minimal range
  31487. * @param max defines the color remap maximal range
  31488. * @returns the current particle system
  31489. */
  31490. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31491. /**
  31492. * Gets the current list of color remap gradients.
  31493. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31494. * @returns the list of color remap gradients
  31495. */
  31496. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31497. /**
  31498. * Adds a new alpha remap gradient
  31499. * @param gradient defines the gradient to use (between 0 and 1)
  31500. * @param min defines the alpha remap minimal range
  31501. * @param max defines the alpha remap maximal range
  31502. * @returns the current particle system
  31503. */
  31504. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31505. /**
  31506. * Gets the current list of alpha remap gradients.
  31507. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31508. * @returns the list of alpha remap gradients
  31509. */
  31510. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31511. /**
  31512. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31513. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31514. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31515. * @returns the emitter
  31516. */
  31517. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31518. /**
  31519. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31520. * @param radius The radius of the hemisphere to emit from
  31521. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31522. * @returns the emitter
  31523. */
  31524. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31525. /**
  31526. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31527. * @param radius The radius of the sphere to emit from
  31528. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31529. * @returns the emitter
  31530. */
  31531. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31532. /**
  31533. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31534. * @param radius The radius of the sphere to emit from
  31535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31537. * @returns the emitter
  31538. */
  31539. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31540. /**
  31541. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31542. * @param radius The radius of the emission cylinder
  31543. * @param height The height of the emission cylinder
  31544. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31545. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31546. * @returns the emitter
  31547. */
  31548. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31549. /**
  31550. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31551. * @param radius The radius of the cylinder to emit from
  31552. * @param height The height of the emission cylinder
  31553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31556. * @returns the emitter
  31557. */
  31558. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31559. /**
  31560. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31561. * @param radius The radius of the cone to emit from
  31562. * @param angle The base angle of the cone
  31563. * @returns the emitter
  31564. */
  31565. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31566. /**
  31567. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31570. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31571. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31572. * @returns the emitter
  31573. */
  31574. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31575. /**
  31576. * Get hosting scene
  31577. * @returns the scene
  31578. */
  31579. getScene(): Scene;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /**
  31584. * A particle represents one of the element emitted by a particle system.
  31585. * This is mainly define by its coordinates, direction, velocity and age.
  31586. */
  31587. class Particle {
  31588. /**
  31589. * The particle system the particle belongs to.
  31590. */
  31591. particleSystem: ParticleSystem;
  31592. private static _Count;
  31593. /**
  31594. * Unique ID of the particle
  31595. */
  31596. id: number;
  31597. /**
  31598. * The world position of the particle in the scene.
  31599. */
  31600. position: Vector3;
  31601. /**
  31602. * The world direction of the particle in the scene.
  31603. */
  31604. direction: Vector3;
  31605. /**
  31606. * The color of the particle.
  31607. */
  31608. color: Color4;
  31609. /**
  31610. * The color change of the particle per step.
  31611. */
  31612. colorStep: Color4;
  31613. /**
  31614. * Defines how long will the life of the particle be.
  31615. */
  31616. lifeTime: number;
  31617. /**
  31618. * The current age of the particle.
  31619. */
  31620. age: number;
  31621. /**
  31622. * The current size of the particle.
  31623. */
  31624. size: number;
  31625. /**
  31626. * The current scale of the particle.
  31627. */
  31628. scale: Vector2;
  31629. /**
  31630. * The current angle of the particle.
  31631. */
  31632. angle: number;
  31633. /**
  31634. * Defines how fast is the angle changing.
  31635. */
  31636. angularSpeed: number;
  31637. /**
  31638. * Defines the cell index used by the particle to be rendered from a sprite.
  31639. */
  31640. cellIndex: number;
  31641. /**
  31642. * The information required to support color remapping
  31643. */
  31644. remapData: Vector4;
  31645. /** @hidden */
  31646. _randomCellOffset?: number;
  31647. /** @hidden */
  31648. _initialDirection: Nullable<Vector3>;
  31649. /** @hidden */
  31650. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31651. /** @hidden */
  31652. _initialStartSpriteCellID: number;
  31653. /** @hidden */
  31654. _initialEndSpriteCellID: number;
  31655. /** @hidden */
  31656. _currentColorGradient: Nullable<ColorGradient>;
  31657. /** @hidden */
  31658. _currentColor1: Color4;
  31659. /** @hidden */
  31660. _currentColor2: Color4;
  31661. /** @hidden */
  31662. _currentSizeGradient: Nullable<FactorGradient>;
  31663. /** @hidden */
  31664. _currentSize1: number;
  31665. /** @hidden */
  31666. _currentSize2: number;
  31667. /** @hidden */
  31668. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31669. /** @hidden */
  31670. _currentAngularSpeed1: number;
  31671. /** @hidden */
  31672. _currentAngularSpeed2: number;
  31673. /** @hidden */
  31674. _currentVelocityGradient: Nullable<FactorGradient>;
  31675. /** @hidden */
  31676. _currentVelocity1: number;
  31677. /** @hidden */
  31678. _currentVelocity2: number;
  31679. /** @hidden */
  31680. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31681. /** @hidden */
  31682. _currentLimitVelocity1: number;
  31683. /** @hidden */
  31684. _currentLimitVelocity2: number;
  31685. /** @hidden */
  31686. _currentDragGradient: Nullable<FactorGradient>;
  31687. /** @hidden */
  31688. _currentDrag1: number;
  31689. /** @hidden */
  31690. _currentDrag2: number;
  31691. /** @hidden */
  31692. _randomNoiseCoordinates1: Vector3;
  31693. /** @hidden */
  31694. _randomNoiseCoordinates2: Vector3;
  31695. /**
  31696. * Creates a new instance Particle
  31697. * @param particleSystem the particle system the particle belongs to
  31698. */
  31699. constructor(
  31700. /**
  31701. * The particle system the particle belongs to.
  31702. */
  31703. particleSystem: ParticleSystem);
  31704. private updateCellInfoFromSystem;
  31705. /**
  31706. * Defines how the sprite cell index is updated for the particle
  31707. */
  31708. updateCellIndex(): void;
  31709. /** @hidden */
  31710. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31711. /** @hidden */
  31712. _inheritParticleInfoToSubEmitters(): void;
  31713. /** @hidden */
  31714. _reset(): void;
  31715. /**
  31716. * Copy the properties of particle to another one.
  31717. * @param other the particle to copy the information to.
  31718. */
  31719. copyTo(other: Particle): void;
  31720. }
  31721. }
  31722. declare module BABYLON {
  31723. /**
  31724. * This class is made for on one-liner static method to help creating particle system set.
  31725. */
  31726. class ParticleHelper {
  31727. /**
  31728. * Gets or sets base Assets URL
  31729. */
  31730. static BaseAssetsUrl: string;
  31731. /**
  31732. * Create a default particle system that you can tweak
  31733. * @param emitter defines the emitter to use
  31734. * @param capacity defines the system capacity (default is 500 particles)
  31735. * @param scene defines the hosting scene
  31736. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31737. * @returns the new Particle system
  31738. */
  31739. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31740. /**
  31741. * This is the main static method (one-liner) of this helper to create different particle systems
  31742. * @param type This string represents the type to the particle system to create
  31743. * @param scene The scene where the particle system should live
  31744. * @param gpu If the system will use gpu
  31745. * @returns the ParticleSystemSet created
  31746. */
  31747. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31748. /**
  31749. * Static function used to export a particle system to a ParticleSystemSet variable.
  31750. * Please note that the emitter shape is not exported
  31751. * @param systems defines the particle systems to export
  31752. * @returns the created particle system set
  31753. */
  31754. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31755. }
  31756. }
  31757. declare module BABYLON {
  31758. /**
  31759. * This represents a particle system in Babylon.
  31760. * 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.
  31761. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31762. * @example https://doc.babylonjs.com/babylon101/particles
  31763. */
  31764. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31765. /**
  31766. * Billboard mode will only apply to Y axis
  31767. */
  31768. static readonly BILLBOARDMODE_Y: number;
  31769. /**
  31770. * Billboard mode will apply to all axes
  31771. */
  31772. static readonly BILLBOARDMODE_ALL: number;
  31773. /**
  31774. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31775. */
  31776. static readonly BILLBOARDMODE_STRETCHED: number;
  31777. /**
  31778. * This function can be defined to provide custom update for active particles.
  31779. * This function will be called instead of regular update (age, position, color, etc.).
  31780. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31781. */
  31782. updateFunction: (particles: Particle[]) => void;
  31783. private _emitterWorldMatrix;
  31784. /**
  31785. * This function can be defined to specify initial direction for every new particle.
  31786. * It by default use the emitterType defined function
  31787. */
  31788. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31789. /**
  31790. * This function can be defined to specify initial position for every new particle.
  31791. * It by default use the emitterType defined function
  31792. */
  31793. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31794. /**
  31795. * @hidden
  31796. */
  31797. _inheritedVelocityOffset: Vector3;
  31798. /**
  31799. * An event triggered when the system is disposed
  31800. */
  31801. onDisposeObservable: Observable<ParticleSystem>;
  31802. private _onDisposeObserver;
  31803. /**
  31804. * Sets a callback that will be triggered when the system is disposed
  31805. */
  31806. onDispose: () => void;
  31807. private _particles;
  31808. private _epsilon;
  31809. private _capacity;
  31810. private _stockParticles;
  31811. private _newPartsExcess;
  31812. private _vertexData;
  31813. private _vertexBuffer;
  31814. private _vertexBuffers;
  31815. private _spriteBuffer;
  31816. private _indexBuffer;
  31817. private _effect;
  31818. private _customEffect;
  31819. private _cachedDefines;
  31820. private _scaledColorStep;
  31821. private _colorDiff;
  31822. private _scaledDirection;
  31823. private _scaledGravity;
  31824. private _currentRenderId;
  31825. private _alive;
  31826. private _useInstancing;
  31827. private _started;
  31828. private _stopped;
  31829. private _actualFrame;
  31830. private _scaledUpdateSpeed;
  31831. private _vertexBufferSize;
  31832. /** @hidden */
  31833. _currentEmitRateGradient: Nullable<FactorGradient>;
  31834. /** @hidden */
  31835. _currentEmitRate1: number;
  31836. /** @hidden */
  31837. _currentEmitRate2: number;
  31838. /** @hidden */
  31839. _currentStartSizeGradient: Nullable<FactorGradient>;
  31840. /** @hidden */
  31841. _currentStartSize1: number;
  31842. /** @hidden */
  31843. _currentStartSize2: number;
  31844. private readonly _rawTextureWidth;
  31845. private _rampGradientsTexture;
  31846. private _useRampGradients;
  31847. /** Gets or sets a boolean indicating that ramp gradients must be used
  31848. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31849. */
  31850. useRampGradients: boolean;
  31851. /**
  31852. * 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.
  31853. * 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: [])
  31854. */
  31855. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31856. private _subEmitters;
  31857. /**
  31858. * @hidden
  31859. * If the particle systems emitter should be disposed when the particle system is disposed
  31860. */
  31861. _disposeEmitterOnDispose: boolean;
  31862. /**
  31863. * The current active Sub-systems, this property is used by the root particle system only.
  31864. */
  31865. activeSubSystems: Array<ParticleSystem>;
  31866. private _rootParticleSystem;
  31867. /**
  31868. * Gets the current list of active particles
  31869. */
  31870. readonly particles: Particle[];
  31871. /**
  31872. * Returns the string "ParticleSystem"
  31873. * @returns a string containing the class name
  31874. */
  31875. getClassName(): string;
  31876. /**
  31877. * Instantiates a particle system.
  31878. * 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.
  31879. * @param name The name of the particle system
  31880. * @param capacity The max number of particles alive at the same time
  31881. * @param scene The scene the particle system belongs to
  31882. * @param customEffect a custom effect used to change the way particles are rendered by default
  31883. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31884. * @param epsilon Offset used to render the particles
  31885. */
  31886. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31887. private _addFactorGradient;
  31888. private _removeFactorGradient;
  31889. /**
  31890. * Adds a new life time gradient
  31891. * @param gradient defines the gradient to use (between 0 and 1)
  31892. * @param factor defines the life time factor to affect to the specified gradient
  31893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31894. * @returns the current particle system
  31895. */
  31896. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31897. /**
  31898. * Remove a specific life time gradient
  31899. * @param gradient defines the gradient to remove
  31900. * @returns the current particle system
  31901. */
  31902. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31903. /**
  31904. * Adds a new size gradient
  31905. * @param gradient defines the gradient to use (between 0 and 1)
  31906. * @param factor defines the size factor to affect to the specified gradient
  31907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31908. * @returns the current particle system
  31909. */
  31910. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31911. /**
  31912. * Remove a specific size gradient
  31913. * @param gradient defines the gradient to remove
  31914. * @returns the current particle system
  31915. */
  31916. removeSizeGradient(gradient: number): IParticleSystem;
  31917. /**
  31918. * Adds a new color remap gradient
  31919. * @param gradient defines the gradient to use (between 0 and 1)
  31920. * @param min defines the color remap minimal range
  31921. * @param max defines the color remap maximal range
  31922. * @returns the current particle system
  31923. */
  31924. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31925. /**
  31926. * Remove a specific color remap gradient
  31927. * @param gradient defines the gradient to remove
  31928. * @returns the current particle system
  31929. */
  31930. removeColorRemapGradient(gradient: number): IParticleSystem;
  31931. /**
  31932. * Adds a new alpha remap gradient
  31933. * @param gradient defines the gradient to use (between 0 and 1)
  31934. * @param min defines the alpha remap minimal range
  31935. * @param max defines the alpha remap maximal range
  31936. * @returns the current particle system
  31937. */
  31938. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31939. /**
  31940. * Remove a specific alpha remap gradient
  31941. * @param gradient defines the gradient to remove
  31942. * @returns the current particle system
  31943. */
  31944. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31945. /**
  31946. * Adds a new angular speed gradient
  31947. * @param gradient defines the gradient to use (between 0 and 1)
  31948. * @param factor defines the angular speed to affect to the specified gradient
  31949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31950. * @returns the current particle system
  31951. */
  31952. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31953. /**
  31954. * Remove a specific angular speed gradient
  31955. * @param gradient defines the gradient to remove
  31956. * @returns the current particle system
  31957. */
  31958. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31959. /**
  31960. * Adds a new velocity gradient
  31961. * @param gradient defines the gradient to use (between 0 and 1)
  31962. * @param factor defines the velocity to affect to the specified gradient
  31963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31964. * @returns the current particle system
  31965. */
  31966. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31967. /**
  31968. * Remove a specific velocity gradient
  31969. * @param gradient defines the gradient to remove
  31970. * @returns the current particle system
  31971. */
  31972. removeVelocityGradient(gradient: number): IParticleSystem;
  31973. /**
  31974. * Adds a new limit velocity gradient
  31975. * @param gradient defines the gradient to use (between 0 and 1)
  31976. * @param factor defines the limit velocity value to affect to the specified gradient
  31977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31978. * @returns the current particle system
  31979. */
  31980. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31981. /**
  31982. * Remove a specific limit velocity gradient
  31983. * @param gradient defines the gradient to remove
  31984. * @returns the current particle system
  31985. */
  31986. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31987. /**
  31988. * Adds a new drag gradient
  31989. * @param gradient defines the gradient to use (between 0 and 1)
  31990. * @param factor defines the drag value to affect to the specified gradient
  31991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31992. * @returns the current particle system
  31993. */
  31994. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31995. /**
  31996. * Remove a specific drag gradient
  31997. * @param gradient defines the gradient to remove
  31998. * @returns the current particle system
  31999. */
  32000. removeDragGradient(gradient: number): IParticleSystem;
  32001. /**
  32002. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32003. * @param gradient defines the gradient to use (between 0 and 1)
  32004. * @param factor defines the emit rate value to affect to the specified gradient
  32005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32006. * @returns the current particle system
  32007. */
  32008. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32009. /**
  32010. * Remove a specific emit rate gradient
  32011. * @param gradient defines the gradient to remove
  32012. * @returns the current particle system
  32013. */
  32014. removeEmitRateGradient(gradient: number): IParticleSystem;
  32015. /**
  32016. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32017. * @param gradient defines the gradient to use (between 0 and 1)
  32018. * @param factor defines the start size value to affect to the specified gradient
  32019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32020. * @returns the current particle system
  32021. */
  32022. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32023. /**
  32024. * Remove a specific start size gradient
  32025. * @param gradient defines the gradient to remove
  32026. * @returns the current particle system
  32027. */
  32028. removeStartSizeGradient(gradient: number): IParticleSystem;
  32029. private _createRampGradientTexture;
  32030. /**
  32031. * Gets the current list of ramp gradients.
  32032. * You must use addRampGradient and removeRampGradient to udpate this list
  32033. * @returns the list of ramp gradients
  32034. */
  32035. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32036. /**
  32037. * Adds a new ramp gradient used to remap particle colors
  32038. * @param gradient defines the gradient to use (between 0 and 1)
  32039. * @param color defines the color to affect to the specified gradient
  32040. * @returns the current particle system
  32041. */
  32042. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32043. /**
  32044. * Remove a specific ramp gradient
  32045. * @param gradient defines the gradient to remove
  32046. * @returns the current particle system
  32047. */
  32048. removeRampGradient(gradient: number): ParticleSystem;
  32049. /**
  32050. * Adds a new color gradient
  32051. * @param gradient defines the gradient to use (between 0 and 1)
  32052. * @param color1 defines the color to affect to the specified gradient
  32053. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32054. * @returns this particle system
  32055. */
  32056. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32057. /**
  32058. * Remove a specific color gradient
  32059. * @param gradient defines the gradient to remove
  32060. * @returns this particle system
  32061. */
  32062. removeColorGradient(gradient: number): IParticleSystem;
  32063. private _fetchR;
  32064. protected _reset(): void;
  32065. private _resetEffect;
  32066. private _createVertexBuffers;
  32067. private _createIndexBuffer;
  32068. /**
  32069. * Gets the maximum number of particles active at the same time.
  32070. * @returns The max number of active particles.
  32071. */
  32072. getCapacity(): number;
  32073. /**
  32074. * Gets whether there are still active particles in the system.
  32075. * @returns True if it is alive, otherwise false.
  32076. */
  32077. isAlive(): boolean;
  32078. /**
  32079. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32080. * @returns True if it has been started, otherwise false.
  32081. */
  32082. isStarted(): boolean;
  32083. private _prepareSubEmitterInternalArray;
  32084. /**
  32085. * Starts the particle system and begins to emit
  32086. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32087. */
  32088. start(delay?: number): void;
  32089. /**
  32090. * Stops the particle system.
  32091. * @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.
  32092. */
  32093. stop(stopSubEmitters?: boolean): void;
  32094. /**
  32095. * Remove all active particles
  32096. */
  32097. reset(): void;
  32098. /**
  32099. * @hidden (for internal use only)
  32100. */
  32101. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32102. /**
  32103. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32104. * Its lifetime will start back at 0.
  32105. */
  32106. recycleParticle: (particle: Particle) => void;
  32107. private _stopSubEmitters;
  32108. private _createParticle;
  32109. private _removeFromRoot;
  32110. private _emitFromParticle;
  32111. private _update;
  32112. /** @hidden */
  32113. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32114. /** @hidden */
  32115. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32116. /** @hidden */
  32117. private _getEffect;
  32118. /**
  32119. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32120. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32121. */
  32122. animate(preWarmOnly?: boolean): void;
  32123. private _appendParticleVertices;
  32124. /**
  32125. * Rebuilds the particle system.
  32126. */
  32127. rebuild(): void;
  32128. /**
  32129. * Is this system ready to be used/rendered
  32130. * @return true if the system is ready
  32131. */
  32132. isReady(): boolean;
  32133. private _render;
  32134. /**
  32135. * Renders the particle system in its current state.
  32136. * @returns the current number of particles
  32137. */
  32138. render(): number;
  32139. /**
  32140. * Disposes the particle system and free the associated resources
  32141. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32142. */
  32143. dispose(disposeTexture?: boolean): void;
  32144. /**
  32145. * Clones the particle system.
  32146. * @param name The name of the cloned object
  32147. * @param newEmitter The new emitter to use
  32148. * @returns the cloned particle system
  32149. */
  32150. clone(name: string, newEmitter: any): ParticleSystem;
  32151. /**
  32152. * Serializes the particle system to a JSON object.
  32153. * @returns the JSON object
  32154. */
  32155. serialize(): any;
  32156. /** @hidden */
  32157. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32158. /** @hidden */
  32159. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32160. /**
  32161. * Parses a JSON object to create a particle system.
  32162. * @param parsedParticleSystem The JSON object to parse
  32163. * @param scene The scene to create the particle system in
  32164. * @param rootUrl The root url to use to load external dependencies like texture
  32165. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32166. * @returns the Parsed particle system
  32167. */
  32168. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32169. }
  32170. }
  32171. declare module BABYLON {
  32172. interface Engine {
  32173. /**
  32174. * Create an effect to use with particle systems.
  32175. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32176. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32177. * @param uniformsNames defines a list of attribute names
  32178. * @param samplers defines an array of string used to represent textures
  32179. * @param defines defines the string containing the defines to use to compile the shaders
  32180. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32181. * @param onCompiled defines a function to call when the effect creation is successful
  32182. * @param onError defines a function to call when the effect creation has failed
  32183. * @returns the new Effect
  32184. */
  32185. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32186. }
  32187. interface Mesh {
  32188. /**
  32189. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32190. * @returns an array of IParticleSystem
  32191. */
  32192. getEmittedParticleSystems(): IParticleSystem[];
  32193. /**
  32194. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32195. * @returns an array of IParticleSystem
  32196. */
  32197. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32198. }
  32199. }
  32200. declare module BABYLON {
  32201. /**
  32202. * Represents a set of particle systems working together to create a specific effect
  32203. */
  32204. class ParticleSystemSet implements IDisposable {
  32205. private _emitterCreationOptions;
  32206. private _emitterNode;
  32207. /**
  32208. * Gets the particle system list
  32209. */
  32210. systems: IParticleSystem[];
  32211. /**
  32212. * Gets the emitter node used with this set
  32213. */
  32214. readonly emitterNode: Nullable<TransformNode>;
  32215. /**
  32216. * Creates a new emitter mesh as a sphere
  32217. * @param options defines the options used to create the sphere
  32218. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32219. * @param scene defines the hosting scene
  32220. */
  32221. setEmitterAsSphere(options: {
  32222. diameter: number;
  32223. segments: number;
  32224. color: Color3;
  32225. }, renderingGroupId: number, scene: Scene): void;
  32226. /**
  32227. * Starts all particle systems of the set
  32228. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32229. */
  32230. start(emitter?: AbstractMesh): void;
  32231. /**
  32232. * Release all associated resources
  32233. */
  32234. dispose(): void;
  32235. /**
  32236. * Serialize the set into a JSON compatible object
  32237. * @returns a JSON compatible representation of the set
  32238. */
  32239. serialize(): any;
  32240. /**
  32241. * Parse a new ParticleSystemSet from a serialized source
  32242. * @param data defines a JSON compatible representation of the set
  32243. * @param scene defines the hosting scene
  32244. * @param gpu defines if we want GPU particles or CPU particles
  32245. * @returns a new ParticleSystemSet
  32246. */
  32247. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32248. }
  32249. }
  32250. declare module BABYLON {
  32251. /**
  32252. * Represents one particle of a solid particle system.
  32253. */
  32254. class SolidParticle {
  32255. /**
  32256. * particle global index
  32257. */
  32258. idx: number;
  32259. /**
  32260. * The color of the particle
  32261. */
  32262. color: Nullable<Color4>;
  32263. /**
  32264. * The world space position of the particle.
  32265. */
  32266. position: Vector3;
  32267. /**
  32268. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32269. */
  32270. rotation: Vector3;
  32271. /**
  32272. * The world space rotation quaternion of the particle.
  32273. */
  32274. rotationQuaternion: Nullable<Quaternion>;
  32275. /**
  32276. * The scaling of the particle.
  32277. */
  32278. scaling: Vector3;
  32279. /**
  32280. * The uvs of the particle.
  32281. */
  32282. uvs: Vector4;
  32283. /**
  32284. * The current speed of the particle.
  32285. */
  32286. velocity: Vector3;
  32287. /**
  32288. * The pivot point in the particle local space.
  32289. */
  32290. pivot: Vector3;
  32291. /**
  32292. * Must the particle be translated from its pivot point in its local space ?
  32293. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32294. * Default : false
  32295. */
  32296. translateFromPivot: boolean;
  32297. /**
  32298. * Is the particle active or not ?
  32299. */
  32300. alive: boolean;
  32301. /**
  32302. * Is the particle visible or not ?
  32303. */
  32304. isVisible: boolean;
  32305. /**
  32306. * Index of this particle in the global "positions" array (Internal use)
  32307. * @hidden
  32308. */
  32309. _pos: number;
  32310. /**
  32311. * @hidden Index of this particle in the global "indices" array (Internal use)
  32312. */
  32313. _ind: number;
  32314. /**
  32315. * @hidden ModelShape of this particle (Internal use)
  32316. */
  32317. _model: ModelShape;
  32318. /**
  32319. * ModelShape id of this particle
  32320. */
  32321. shapeId: number;
  32322. /**
  32323. * Index of the particle in its shape id (Internal use)
  32324. */
  32325. idxInShape: number;
  32326. /**
  32327. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32328. */
  32329. _modelBoundingInfo: BoundingInfo;
  32330. /**
  32331. * @hidden Particle BoundingInfo object (Internal use)
  32332. */
  32333. _boundingInfo: BoundingInfo;
  32334. /**
  32335. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32336. */
  32337. _sps: SolidParticleSystem;
  32338. /**
  32339. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32340. */
  32341. _stillInvisible: boolean;
  32342. /**
  32343. * @hidden Last computed particle rotation matrix
  32344. */
  32345. _rotationMatrix: number[];
  32346. /**
  32347. * Parent particle Id, if any.
  32348. * Default null.
  32349. */
  32350. parentId: Nullable<number>;
  32351. /**
  32352. * @hidden Internal global position in the SPS.
  32353. */
  32354. _globalPosition: Vector3;
  32355. /**
  32356. * Creates a Solid Particle object.
  32357. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32358. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32359. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32360. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32361. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32362. * @param shapeId (integer) is the model shape identifier in the SPS.
  32363. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32364. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32365. */
  32366. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32367. /**
  32368. * Legacy support, changed scale to scaling
  32369. */
  32370. /**
  32371. * Legacy support, changed scale to scaling
  32372. */
  32373. scale: Vector3;
  32374. /**
  32375. * Legacy support, changed quaternion to rotationQuaternion
  32376. */
  32377. /**
  32378. * Legacy support, changed quaternion to rotationQuaternion
  32379. */
  32380. quaternion: Nullable<Quaternion>;
  32381. /**
  32382. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32383. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32384. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32385. * @returns true if it intersects
  32386. */
  32387. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32388. /**
  32389. * get the rotation matrix of the particle
  32390. * @hidden
  32391. */
  32392. getRotationMatrix(m: Matrix): void;
  32393. }
  32394. /**
  32395. * Represents the shape of the model used by one particle of a solid particle system.
  32396. * SPS internal tool, don't use it manually.
  32397. */
  32398. class ModelShape {
  32399. /**
  32400. * The shape id
  32401. * @hidden
  32402. */
  32403. shapeID: number;
  32404. /**
  32405. * flat array of model positions (internal use)
  32406. * @hidden
  32407. */
  32408. _shape: Vector3[];
  32409. /**
  32410. * flat array of model UVs (internal use)
  32411. * @hidden
  32412. */
  32413. _shapeUV: number[];
  32414. /**
  32415. * length of the shape in the model indices array (internal use)
  32416. * @hidden
  32417. */
  32418. _indicesLength: number;
  32419. /**
  32420. * Custom position function (internal use)
  32421. * @hidden
  32422. */
  32423. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32424. /**
  32425. * Custom vertex function (internal use)
  32426. * @hidden
  32427. */
  32428. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32429. /**
  32430. * 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.
  32431. * SPS internal tool, don't use it manually.
  32432. * @hidden
  32433. */
  32434. 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>);
  32435. }
  32436. /**
  32437. * Represents a Depth Sorted Particle in the solid particle system.
  32438. */
  32439. class DepthSortedParticle {
  32440. /**
  32441. * Index of the particle in the "indices" array
  32442. */
  32443. ind: number;
  32444. /**
  32445. * Length of the particle shape in the "indices" array
  32446. */
  32447. indicesLength: number;
  32448. /**
  32449. * Squared distance from the particle to the camera
  32450. */
  32451. sqDistance: number;
  32452. }
  32453. }
  32454. declare module BABYLON {
  32455. /**
  32456. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32457. *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.
  32458. * The SPS is also a particle system. It provides some methods to manage the particles.
  32459. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32460. *
  32461. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32462. */
  32463. class SolidParticleSystem implements IDisposable {
  32464. /**
  32465. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32466. * Example : var p = SPS.particles[i];
  32467. */
  32468. particles: SolidParticle[];
  32469. /**
  32470. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32471. */
  32472. nbParticles: number;
  32473. /**
  32474. * If the particles must ever face the camera (default false). Useful for planar particles.
  32475. */
  32476. billboard: boolean;
  32477. /**
  32478. * Recompute normals when adding a shape
  32479. */
  32480. recomputeNormals: boolean;
  32481. /**
  32482. * This a counter ofr your own usage. It's not set by any SPS functions.
  32483. */
  32484. counter: number;
  32485. /**
  32486. * The SPS name. This name is also given to the underlying mesh.
  32487. */
  32488. name: string;
  32489. /**
  32490. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32491. */
  32492. mesh: Mesh;
  32493. /**
  32494. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32495. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32496. */
  32497. vars: any;
  32498. /**
  32499. * This array is populated when the SPS is set as 'pickable'.
  32500. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32501. * Each element of this array is an object `{idx: int, faceId: int}`.
  32502. * `idx` is the picked particle index in the `SPS.particles` array
  32503. * `faceId` is the picked face index counted within this particle.
  32504. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32505. */
  32506. pickedParticles: {
  32507. idx: number;
  32508. faceId: number;
  32509. }[];
  32510. /**
  32511. * This array is populated when `enableDepthSort` is set to true.
  32512. * Each element of this array is an instance of the class DepthSortedParticle.
  32513. */
  32514. depthSortedParticles: DepthSortedParticle[];
  32515. /**
  32516. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32517. * @hidden
  32518. */
  32519. _bSphereOnly: boolean;
  32520. /**
  32521. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32522. * @hidden
  32523. */
  32524. _bSphereRadiusFactor: number;
  32525. private _scene;
  32526. private _positions;
  32527. private _indices;
  32528. private _normals;
  32529. private _colors;
  32530. private _uvs;
  32531. private _indices32;
  32532. private _positions32;
  32533. private _normals32;
  32534. private _fixedNormal32;
  32535. private _colors32;
  32536. private _uvs32;
  32537. private _index;
  32538. private _updatable;
  32539. private _pickable;
  32540. private _isVisibilityBoxLocked;
  32541. private _alwaysVisible;
  32542. private _depthSort;
  32543. private _shapeCounter;
  32544. private _copy;
  32545. private _color;
  32546. private _computeParticleColor;
  32547. private _computeParticleTexture;
  32548. private _computeParticleRotation;
  32549. private _computeParticleVertex;
  32550. private _computeBoundingBox;
  32551. private _depthSortParticles;
  32552. private _camera;
  32553. private _mustUnrotateFixedNormals;
  32554. private _particlesIntersect;
  32555. private _needs32Bits;
  32556. /**
  32557. * Creates a SPS (Solid Particle System) object.
  32558. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32559. * @param scene (Scene) is the scene in which the SPS is added.
  32560. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32561. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32562. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32563. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32564. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32565. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32566. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32567. */
  32568. constructor(name: string, scene: Scene, options?: {
  32569. updatable?: boolean;
  32570. isPickable?: boolean;
  32571. enableDepthSort?: boolean;
  32572. particleIntersection?: boolean;
  32573. boundingSphereOnly?: boolean;
  32574. bSphereRadiusFactor?: number;
  32575. });
  32576. /**
  32577. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32578. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32579. * @returns the created mesh
  32580. */
  32581. buildMesh(): Mesh;
  32582. /**
  32583. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32584. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32585. * Thus the particles generated from `digest()` have their property `position` set yet.
  32586. * @param mesh ( Mesh ) is the mesh to be digested
  32587. * @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
  32588. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32589. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32590. * @returns the current SPS
  32591. */
  32592. digest(mesh: Mesh, options?: {
  32593. facetNb?: number;
  32594. number?: number;
  32595. delta?: number;
  32596. }): SolidParticleSystem;
  32597. private _unrotateFixedNormals;
  32598. private _resetCopy;
  32599. private _meshBuilder;
  32600. private _posToShape;
  32601. private _uvsToShapeUV;
  32602. private _addParticle;
  32603. /**
  32604. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32605. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32606. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32607. * @param nb (positive integer) the number of particles to be created from this model
  32608. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32609. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32610. * @returns the number of shapes in the system
  32611. */
  32612. addShape(mesh: Mesh, nb: number, options?: {
  32613. positionFunction?: any;
  32614. vertexFunction?: any;
  32615. }): number;
  32616. private _rebuildParticle;
  32617. /**
  32618. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32619. * @returns the SPS.
  32620. */
  32621. rebuildMesh(): SolidParticleSystem;
  32622. /**
  32623. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32624. * This method calls `updateParticle()` for each particle of the SPS.
  32625. * For an animated SPS, it is usually called within the render loop.
  32626. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32627. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32628. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32629. * @returns the SPS.
  32630. */
  32631. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32632. /**
  32633. * Disposes the SPS.
  32634. */
  32635. dispose(): void;
  32636. /**
  32637. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32638. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32639. * @returns the SPS.
  32640. */
  32641. refreshVisibleSize(): SolidParticleSystem;
  32642. /**
  32643. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32644. * @param size the size (float) of the visibility box
  32645. * note : this doesn't lock the SPS mesh bounding box.
  32646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32647. */
  32648. setVisibilityBox(size: number): void;
  32649. /**
  32650. * Gets whether the SPS as always visible or not
  32651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32652. */
  32653. /**
  32654. * Sets the SPS as always visible or not
  32655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32656. */
  32657. isAlwaysVisible: boolean;
  32658. /**
  32659. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32660. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32661. */
  32662. /**
  32663. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32664. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32665. */
  32666. isVisibilityBoxLocked: boolean;
  32667. /**
  32668. * Tells to `setParticles()` to compute the particle rotations or not.
  32669. * Default value : true. The SPS is faster when it's set to false.
  32670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32671. */
  32672. /**
  32673. * Gets if `setParticles()` computes the particle rotations or not.
  32674. * Default value : true. The SPS is faster when it's set to false.
  32675. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32676. */
  32677. computeParticleRotation: boolean;
  32678. /**
  32679. * Tells to `setParticles()` to compute the particle colors or not.
  32680. * Default value : true. The SPS is faster when it's set to false.
  32681. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32682. */
  32683. /**
  32684. * Gets if `setParticles()` computes the particle colors or not.
  32685. * Default value : true. The SPS is faster when it's set to false.
  32686. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32687. */
  32688. computeParticleColor: boolean;
  32689. /**
  32690. * Gets if `setParticles()` computes the particle textures or not.
  32691. * Default value : true. The SPS is faster when it's set to false.
  32692. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32693. */
  32694. computeParticleTexture: boolean;
  32695. /**
  32696. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32697. * Default value : false. The SPS is faster when it's set to false.
  32698. * Note : the particle custom vertex positions aren't stored values.
  32699. */
  32700. /**
  32701. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32702. * Default value : false. The SPS is faster when it's set to false.
  32703. * Note : the particle custom vertex positions aren't stored values.
  32704. */
  32705. computeParticleVertex: boolean;
  32706. /**
  32707. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32708. */
  32709. /**
  32710. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32711. */
  32712. computeBoundingBox: boolean;
  32713. /**
  32714. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32715. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32716. * Default : `true`
  32717. */
  32718. /**
  32719. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32720. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32721. * Default : `true`
  32722. */
  32723. depthSortParticles: boolean;
  32724. /**
  32725. * This function does nothing. It may be overwritten to set all the particle first values.
  32726. * The SPS doesn't call this function, you may have to call it by your own.
  32727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32728. */
  32729. initParticles(): void;
  32730. /**
  32731. * This function does nothing. It may be overwritten to recycle a particle.
  32732. * The SPS doesn't call this function, you may have to call it by your own.
  32733. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32734. * @param particle The particle to recycle
  32735. * @returns the recycled particle
  32736. */
  32737. recycleParticle(particle: SolidParticle): SolidParticle;
  32738. /**
  32739. * Updates a particle : this function should be overwritten by the user.
  32740. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32742. * @example : just set a particle position or velocity and recycle conditions
  32743. * @param particle The particle to update
  32744. * @returns the updated particle
  32745. */
  32746. updateParticle(particle: SolidParticle): SolidParticle;
  32747. /**
  32748. * Updates a vertex of a particle : it can be overwritten by the user.
  32749. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32750. * @param particle the current particle
  32751. * @param vertex the current index of the current particle
  32752. * @param pt the index of the current vertex in the particle shape
  32753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32754. * @example : just set a vertex particle position
  32755. * @returns the updated vertex
  32756. */
  32757. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32758. /**
  32759. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32760. * This does nothing and may be overwritten by the user.
  32761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32763. * @param update the boolean update value actually passed to setParticles()
  32764. */
  32765. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32766. /**
  32767. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32768. * This will be passed three parameters.
  32769. * This does nothing and may be overwritten by the user.
  32770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param update the boolean update value actually passed to setParticles()
  32773. */
  32774. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32775. }
  32776. }
  32777. declare module BABYLON {
  32778. /**
  32779. * Type of sub emitter
  32780. */
  32781. enum SubEmitterType {
  32782. /**
  32783. * Attached to the particle over it's lifetime
  32784. */
  32785. ATTACHED = 0,
  32786. /**
  32787. * Created when the particle dies
  32788. */
  32789. END = 1
  32790. }
  32791. /**
  32792. * Sub emitter class used to emit particles from an existing particle
  32793. */
  32794. class SubEmitter {
  32795. /**
  32796. * the particle system to be used by the sub emitter
  32797. */
  32798. particleSystem: ParticleSystem;
  32799. /**
  32800. * Type of the submitter (Default: END)
  32801. */
  32802. type: SubEmitterType;
  32803. /**
  32804. * 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)
  32805. * Note: This only is supported when using an emitter of type Mesh
  32806. */
  32807. inheritDirection: boolean;
  32808. /**
  32809. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32810. */
  32811. inheritedVelocityAmount: number;
  32812. /**
  32813. * Creates a sub emitter
  32814. * @param particleSystem the particle system to be used by the sub emitter
  32815. */
  32816. constructor(
  32817. /**
  32818. * the particle system to be used by the sub emitter
  32819. */
  32820. particleSystem: ParticleSystem);
  32821. /**
  32822. * Clones the sub emitter
  32823. * @returns the cloned sub emitter
  32824. */
  32825. clone(): SubEmitter;
  32826. /**
  32827. * Serialize current object to a JSON object
  32828. * @returns the serialized object
  32829. */
  32830. serialize(): any;
  32831. /**
  32832. * Creates a new SubEmitter from a serialized JSON version
  32833. * @param serializationObject defines the JSON object to read from
  32834. * @param scene defines the hosting scene
  32835. * @param rootUrl defines the rootUrl for data loading
  32836. * @returns a new SubEmitter
  32837. */
  32838. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32839. /** Release associated resources */
  32840. dispose(): void;
  32841. }
  32842. }
  32843. declare module BABYLON {
  32844. /**
  32845. * Interface used to describe a physics joint
  32846. */
  32847. interface PhysicsImpostorJoint {
  32848. /** Defines the main impostor to which the joint is linked */
  32849. mainImpostor: PhysicsImpostor;
  32850. /** Defines the impostor that is connected to the main impostor using this joint */
  32851. connectedImpostor: PhysicsImpostor;
  32852. /** Defines the joint itself */
  32853. joint: PhysicsJoint;
  32854. }
  32855. /** @hidden */
  32856. interface IPhysicsEnginePlugin {
  32857. world: any;
  32858. name: string;
  32859. setGravity(gravity: Vector3): void;
  32860. setTimeStep(timeStep: number): void;
  32861. getTimeStep(): number;
  32862. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32863. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32864. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32865. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32866. removePhysicsBody(impostor: PhysicsImpostor): void;
  32867. generateJoint(joint: PhysicsImpostorJoint): void;
  32868. removeJoint(joint: PhysicsImpostorJoint): void;
  32869. isSupported(): boolean;
  32870. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32871. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32872. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32873. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32874. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32875. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32876. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32877. getBodyMass(impostor: PhysicsImpostor): number;
  32878. getBodyFriction(impostor: PhysicsImpostor): number;
  32879. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32880. getBodyRestitution(impostor: PhysicsImpostor): number;
  32881. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32882. sleepBody(impostor: PhysicsImpostor): void;
  32883. wakeUpBody(impostor: PhysicsImpostor): void;
  32884. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32885. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32886. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32887. getRadius(impostor: PhysicsImpostor): number;
  32888. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32890. dispose(): void;
  32891. }
  32892. /**
  32893. * Interface used to define a physics engine
  32894. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32895. */
  32896. interface IPhysicsEngine {
  32897. /**
  32898. * Gets the gravity vector used by the simulation
  32899. */
  32900. gravity: Vector3;
  32901. /**
  32902. * Sets the gravity vector used by the simulation
  32903. * @param gravity defines the gravity vector to use
  32904. */
  32905. setGravity(gravity: Vector3): void;
  32906. /**
  32907. * Set the time step of the physics engine.
  32908. * Default is 1/60.
  32909. * To slow it down, enter 1/600 for example.
  32910. * To speed it up, 1/30
  32911. * @param newTimeStep the new timestep to apply to this world.
  32912. */
  32913. setTimeStep(newTimeStep: number): void;
  32914. /**
  32915. * Get the time step of the physics engine.
  32916. * @returns the current time step
  32917. */
  32918. getTimeStep(): number;
  32919. /**
  32920. * Release all resources
  32921. */
  32922. dispose(): void;
  32923. /**
  32924. * Gets the name of the current physics plugin
  32925. * @returns the name of the plugin
  32926. */
  32927. getPhysicsPluginName(): string;
  32928. /**
  32929. * Adding a new impostor for the impostor tracking.
  32930. * This will be done by the impostor itself.
  32931. * @param impostor the impostor to add
  32932. */
  32933. addImpostor(impostor: PhysicsImpostor): void;
  32934. /**
  32935. * Remove an impostor from the engine.
  32936. * This impostor and its mesh will not longer be updated by the physics engine.
  32937. * @param impostor the impostor to remove
  32938. */
  32939. removeImpostor(impostor: PhysicsImpostor): void;
  32940. /**
  32941. * Add a joint to the physics engine
  32942. * @param mainImpostor defines the main impostor to which the joint is added.
  32943. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32944. * @param joint defines the joint that will connect both impostors.
  32945. */
  32946. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32947. /**
  32948. * Removes a joint from the simulation
  32949. * @param mainImpostor defines the impostor used with the joint
  32950. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32951. * @param joint defines the joint to remove
  32952. */
  32953. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32954. /**
  32955. * Gets the current plugin used to run the simulation
  32956. * @returns current plugin
  32957. */
  32958. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32959. /**
  32960. * Gets the list of physic impostors
  32961. * @returns an array of PhysicsImpostor
  32962. */
  32963. getImpostors(): Array<PhysicsImpostor>;
  32964. /**
  32965. * Gets the impostor for a physics enabled object
  32966. * @param object defines the object impersonated by the impostor
  32967. * @returns the PhysicsImpostor or null if not found
  32968. */
  32969. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32970. /**
  32971. * Gets the impostor for a physics body object
  32972. * @param body defines physics body used by the impostor
  32973. * @returns the PhysicsImpostor or null if not found
  32974. */
  32975. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32976. /**
  32977. * Called by the scene. No need to call it.
  32978. * @param delta defines the timespam between frames
  32979. */
  32980. _step(delta: number): void;
  32981. }
  32982. }
  32983. declare module BABYLON {
  32984. /**
  32985. * Class used to control physics engine
  32986. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32987. */
  32988. class PhysicsEngine implements IPhysicsEngine {
  32989. private _physicsPlugin;
  32990. /**
  32991. * Global value used to control the smallest number supported by the simulation
  32992. */
  32993. static Epsilon: number;
  32994. private _impostors;
  32995. private _joints;
  32996. /**
  32997. * Gets the gravity vector used by the simulation
  32998. */
  32999. gravity: Vector3;
  33000. /**
  33001. * Creates a new Physics Engine
  33002. * @param gravity defines the gravity vector used by the simulation
  33003. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33004. */
  33005. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33006. /**
  33007. * Sets the gravity vector used by the simulation
  33008. * @param gravity defines the gravity vector to use
  33009. */
  33010. setGravity(gravity: Vector3): void;
  33011. /**
  33012. * Set the time step of the physics engine.
  33013. * Default is 1/60.
  33014. * To slow it down, enter 1/600 for example.
  33015. * To speed it up, 1/30
  33016. * @param newTimeStep defines the new timestep to apply to this world.
  33017. */
  33018. setTimeStep(newTimeStep?: number): void;
  33019. /**
  33020. * Get the time step of the physics engine.
  33021. * @returns the current time step
  33022. */
  33023. getTimeStep(): number;
  33024. /**
  33025. * Release all resources
  33026. */
  33027. dispose(): void;
  33028. /**
  33029. * Gets the name of the current physics plugin
  33030. * @returns the name of the plugin
  33031. */
  33032. getPhysicsPluginName(): string;
  33033. /**
  33034. * Adding a new impostor for the impostor tracking.
  33035. * This will be done by the impostor itself.
  33036. * @param impostor the impostor to add
  33037. */
  33038. addImpostor(impostor: PhysicsImpostor): void;
  33039. /**
  33040. * Remove an impostor from the engine.
  33041. * This impostor and its mesh will not longer be updated by the physics engine.
  33042. * @param impostor the impostor to remove
  33043. */
  33044. removeImpostor(impostor: PhysicsImpostor): void;
  33045. /**
  33046. * Add a joint to the physics engine
  33047. * @param mainImpostor defines the main impostor to which the joint is added.
  33048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33049. * @param joint defines the joint that will connect both impostors.
  33050. */
  33051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33052. /**
  33053. * Removes a joint from the simulation
  33054. * @param mainImpostor defines the impostor used with the joint
  33055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33056. * @param joint defines the joint to remove
  33057. */
  33058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33059. /**
  33060. * Called by the scene. No need to call it.
  33061. * @param delta defines the timespam between frames
  33062. */
  33063. _step(delta: number): void;
  33064. /**
  33065. * Gets the current plugin used to run the simulation
  33066. * @returns current plugin
  33067. */
  33068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33069. /**
  33070. * Gets the list of physic impostors
  33071. * @returns an array of PhysicsImpostor
  33072. */
  33073. getImpostors(): Array<PhysicsImpostor>;
  33074. /**
  33075. * Gets the impostor for a physics enabled object
  33076. * @param object defines the object impersonated by the impostor
  33077. * @returns the PhysicsImpostor or null if not found
  33078. */
  33079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33080. /**
  33081. * Gets the impostor for a physics body object
  33082. * @param body defines physics body used by the impostor
  33083. * @returns the PhysicsImpostor or null if not found
  33084. */
  33085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33086. }
  33087. }
  33088. declare module BABYLON {
  33089. interface Scene {
  33090. /** @hidden (Backing field) */
  33091. _physicsEngine: Nullable<IPhysicsEngine>;
  33092. /**
  33093. * Gets the current physics engine
  33094. * @returns a IPhysicsEngine or null if none attached
  33095. */
  33096. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33097. /**
  33098. * Enables physics to the current scene
  33099. * @param gravity defines the scene's gravity for the physics engine
  33100. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33101. * @return a boolean indicating if the physics engine was initialized
  33102. */
  33103. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33104. /**
  33105. * Disables and disposes the physics engine associated with the scene
  33106. */
  33107. disablePhysicsEngine(): void;
  33108. /**
  33109. * Gets a boolean indicating if there is an active physics engine
  33110. * @returns a boolean indicating if there is an active physics engine
  33111. */
  33112. isPhysicsEnabled(): boolean;
  33113. /**
  33114. * Deletes a physics compound impostor
  33115. * @param compound defines the compound to delete
  33116. */
  33117. deleteCompoundImpostor(compound: any): void;
  33118. /**
  33119. * An event triggered when physic simulation is about to be run
  33120. */
  33121. onBeforePhysicsObservable: Observable<Scene>;
  33122. /**
  33123. * An event triggered when physic simulation has been done
  33124. */
  33125. onAfterPhysicsObservable: Observable<Scene>;
  33126. }
  33127. interface AbstractMesh {
  33128. /** @hidden */
  33129. _physicsImpostor: Nullable<PhysicsImpostor>;
  33130. /**
  33131. * Gets or sets impostor used for physic simulation
  33132. * @see http://doc.babylonjs.com/features/physics_engine
  33133. */
  33134. physicsImpostor: Nullable<PhysicsImpostor>;
  33135. /**
  33136. * Gets the current physics impostor
  33137. * @see http://doc.babylonjs.com/features/physics_engine
  33138. * @returns a physics impostor or null
  33139. */
  33140. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33141. /** Apply a physic impulse to the mesh
  33142. * @param force defines the force to apply
  33143. * @param contactPoint defines where to apply the force
  33144. * @returns the current mesh
  33145. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33146. */
  33147. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33148. /**
  33149. * Creates a physic joint between two meshes
  33150. * @param otherMesh defines the other mesh to use
  33151. * @param pivot1 defines the pivot to use on this mesh
  33152. * @param pivot2 defines the pivot to use on the other mesh
  33153. * @param options defines additional options (can be plugin dependent)
  33154. * @returns the current mesh
  33155. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33156. */
  33157. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33158. /** @hidden */
  33159. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33160. }
  33161. /**
  33162. * Defines the physics engine scene component responsible to manage a physics engine
  33163. */
  33164. class PhysicsEngineSceneComponent implements ISceneComponent {
  33165. /**
  33166. * The component name helpful to identify the component in the list of scene components.
  33167. */
  33168. readonly name: string;
  33169. /**
  33170. * The scene the component belongs to.
  33171. */
  33172. scene: Scene;
  33173. /**
  33174. * Creates a new instance of the component for the given scene
  33175. * @param scene Defines the scene to register the component in
  33176. */
  33177. constructor(scene: Scene);
  33178. /**
  33179. * Registers the component in a given scene
  33180. */
  33181. register(): void;
  33182. /**
  33183. * Rebuilds the elements related to this component in case of
  33184. * context lost for instance.
  33185. */
  33186. rebuild(): void;
  33187. /**
  33188. * Disposes the component and the associated ressources
  33189. */
  33190. dispose(): void;
  33191. }
  33192. }
  33193. declare module BABYLON {
  33194. /**
  33195. * A helper for physics simulations
  33196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33197. */
  33198. class PhysicsHelper {
  33199. private _scene;
  33200. private _physicsEngine;
  33201. /**
  33202. * Initializes the Physics helper
  33203. * @param scene Babylon.js scene
  33204. */
  33205. constructor(scene: Scene);
  33206. /**
  33207. * Applies a radial explosion impulse
  33208. * @param origin the origin of the explosion
  33209. * @param radius the explosion radius
  33210. * @param strength the explosion strength
  33211. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33212. * @returns A physics radial explosion event, or null
  33213. */
  33214. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33215. /**
  33216. * Applies a radial explosion force
  33217. * @param origin the origin of the explosion
  33218. * @param radius the explosion radius
  33219. * @param strength the explosion strength
  33220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33221. * @returns A physics radial explosion event, or null
  33222. */
  33223. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33224. /**
  33225. * Creates a gravitational field
  33226. * @param origin the origin of the explosion
  33227. * @param radius the explosion radius
  33228. * @param strength the explosion strength
  33229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33230. * @returns A physics gravitational field event, or null
  33231. */
  33232. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33233. /**
  33234. * Creates a physics updraft event
  33235. * @param origin the origin of the updraft
  33236. * @param radius the radius of the updraft
  33237. * @param strength the strength of the updraft
  33238. * @param height the height of the updraft
  33239. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33240. * @returns A physics updraft event, or null
  33241. */
  33242. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33243. /**
  33244. * Creates a physics vortex event
  33245. * @param origin the of the vortex
  33246. * @param radius the radius of the vortex
  33247. * @param strength the strength of the vortex
  33248. * @param height the height of the vortex
  33249. * @returns a Physics vortex event, or null
  33250. * A physics vortex event or null
  33251. */
  33252. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33253. }
  33254. /**
  33255. * Represents a physics radial explosion event
  33256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33257. */
  33258. class PhysicsRadialExplosionEvent {
  33259. private _scene;
  33260. private _sphere;
  33261. private _sphereOptions;
  33262. private _rays;
  33263. private _dataFetched;
  33264. /**
  33265. * Initializes a radial explosioin event
  33266. * @param scene BabylonJS scene
  33267. */
  33268. constructor(scene: Scene);
  33269. /**
  33270. * Returns the data related to the radial explosion event (sphere & rays).
  33271. * @returns The radial explosion event data
  33272. */
  33273. getData(): PhysicsRadialExplosionEventData;
  33274. /**
  33275. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33276. * @param impostor A physics imposter
  33277. * @param origin the origin of the explosion
  33278. * @param radius the explosion radius
  33279. * @param strength the explosion strength
  33280. * @param falloff possible options: Constant & Linear
  33281. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33282. */
  33283. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33284. /**
  33285. * Disposes the sphere.
  33286. * @param force Specifies if the sphere should be disposed by force
  33287. */
  33288. dispose(force?: boolean): void;
  33289. /*** Helpers ***/
  33290. private _prepareSphere;
  33291. private _intersectsWithSphere;
  33292. }
  33293. /**
  33294. * Represents a gravitational field event
  33295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33296. */
  33297. class PhysicsGravitationalFieldEvent {
  33298. private _physicsHelper;
  33299. private _scene;
  33300. private _origin;
  33301. private _radius;
  33302. private _strength;
  33303. private _falloff;
  33304. private _tickCallback;
  33305. private _sphere;
  33306. private _dataFetched;
  33307. /**
  33308. * Initializes the physics gravitational field event
  33309. * @param physicsHelper A physics helper
  33310. * @param scene BabylonJS scene
  33311. * @param origin The origin position of the gravitational field event
  33312. * @param radius The radius of the gravitational field event
  33313. * @param strength The strength of the gravitational field event
  33314. * @param falloff The falloff for the gravitational field event
  33315. */
  33316. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33317. /**
  33318. * Returns the data related to the gravitational field event (sphere).
  33319. * @returns A gravitational field event
  33320. */
  33321. getData(): PhysicsGravitationalFieldEventData;
  33322. /**
  33323. * Enables the gravitational field.
  33324. */
  33325. enable(): void;
  33326. /**
  33327. * Disables the gravitational field.
  33328. */
  33329. disable(): void;
  33330. /**
  33331. * Disposes the sphere.
  33332. * @param force The force to dispose from the gravitational field event
  33333. */
  33334. dispose(force?: boolean): void;
  33335. private _tick;
  33336. }
  33337. /**
  33338. * Represents a physics updraft event
  33339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33340. */
  33341. class PhysicsUpdraftEvent {
  33342. private _scene;
  33343. private _origin;
  33344. private _radius;
  33345. private _strength;
  33346. private _height;
  33347. private _updraftMode;
  33348. private _physicsEngine;
  33349. private _originTop;
  33350. private _originDirection;
  33351. private _tickCallback;
  33352. private _cylinder;
  33353. private _cylinderPosition;
  33354. private _dataFetched;
  33355. /**
  33356. * Initializes the physics updraft event
  33357. * @param _scene BabylonJS scene
  33358. * @param _origin The origin position of the updraft
  33359. * @param _radius The radius of the updraft
  33360. * @param _strength The strength of the updraft
  33361. * @param _height The height of the updraft
  33362. * @param _updraftMode The mode of the updraft
  33363. */
  33364. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33365. /**
  33366. * Returns the data related to the updraft event (cylinder).
  33367. * @returns A physics updraft event
  33368. */
  33369. getData(): PhysicsUpdraftEventData;
  33370. /**
  33371. * Enables the updraft.
  33372. */
  33373. enable(): void;
  33374. /**
  33375. * Disables the cortex.
  33376. */
  33377. disable(): void;
  33378. /**
  33379. * Disposes the sphere.
  33380. * @param force Specifies if the updraft should be disposed by force
  33381. */
  33382. dispose(force?: boolean): void;
  33383. private getImpostorForceAndContactPoint;
  33384. private _tick;
  33385. /*** Helpers ***/
  33386. private _prepareCylinder;
  33387. private _intersectsWithCylinder;
  33388. }
  33389. /**
  33390. * Represents a physics vortex event
  33391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33392. */
  33393. class PhysicsVortexEvent {
  33394. private _scene;
  33395. private _origin;
  33396. private _radius;
  33397. private _strength;
  33398. private _height;
  33399. private _physicsEngine;
  33400. private _originTop;
  33401. private _centripetalForceThreshold;
  33402. private _updraftMultiplier;
  33403. private _tickCallback;
  33404. private _cylinder;
  33405. private _cylinderPosition;
  33406. private _dataFetched;
  33407. /**
  33408. * Initializes the physics vortex event
  33409. * @param _scene The BabylonJS scene
  33410. * @param _origin The origin position of the vortex
  33411. * @param _radius The radius of the vortex
  33412. * @param _strength The strength of the vortex
  33413. * @param _height The height of the vortex
  33414. */
  33415. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33416. /**
  33417. * Returns the data related to the vortex event (cylinder).
  33418. * @returns The physics vortex event data
  33419. */
  33420. getData(): PhysicsVortexEventData;
  33421. /**
  33422. * Enables the vortex.
  33423. */
  33424. enable(): void;
  33425. /**
  33426. * Disables the cortex.
  33427. */
  33428. disable(): void;
  33429. /**
  33430. * Disposes the sphere.
  33431. * @param force
  33432. */
  33433. dispose(force?: boolean): void;
  33434. private getImpostorForceAndContactPoint;
  33435. private _tick;
  33436. /*** Helpers ***/
  33437. private _prepareCylinder;
  33438. private _intersectsWithCylinder;
  33439. }
  33440. /**
  33441. * The strenght of the force in correspondence to the distance of the affected object
  33442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33443. */
  33444. enum PhysicsRadialImpulseFalloff {
  33445. /** Defines that impulse is constant in strength across it's whole radius */
  33446. Constant = 0,
  33447. /** DEfines that impulse gets weaker if it's further from the origin */
  33448. Linear = 1
  33449. }
  33450. /**
  33451. * The strength of the force in correspondence to the distance of the affected object
  33452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33453. */
  33454. enum PhysicsUpdraftMode {
  33455. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33456. Center = 0,
  33457. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33458. Perpendicular = 1
  33459. }
  33460. /**
  33461. * Interface for a physics force and contact point
  33462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33463. */
  33464. interface PhysicsForceAndContactPoint {
  33465. /**
  33466. * The force applied at the contact point
  33467. */
  33468. force: Vector3;
  33469. /**
  33470. * The contact point
  33471. */
  33472. contactPoint: Vector3;
  33473. }
  33474. /**
  33475. * Interface for radial explosion event data
  33476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33477. */
  33478. interface PhysicsRadialExplosionEventData {
  33479. /**
  33480. * A sphere used for the radial explosion event
  33481. */
  33482. sphere: Mesh;
  33483. /**
  33484. * An array of rays for the radial explosion event
  33485. */
  33486. rays: Array<Ray>;
  33487. }
  33488. /**
  33489. * Interface for gravitational field event data
  33490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33491. */
  33492. interface PhysicsGravitationalFieldEventData {
  33493. /**
  33494. * A sphere mesh used for the gravitational field event
  33495. */
  33496. sphere: Mesh;
  33497. }
  33498. /**
  33499. * Interface for updraft event data
  33500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33501. */
  33502. interface PhysicsUpdraftEventData {
  33503. /**
  33504. * A cylinder used for the updraft event
  33505. */
  33506. cylinder: Mesh;
  33507. }
  33508. /**
  33509. * Interface for vortex event data
  33510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33511. */
  33512. interface PhysicsVortexEventData {
  33513. /**
  33514. * A cylinder used for the vortex event
  33515. */
  33516. cylinder: Mesh;
  33517. }
  33518. }
  33519. declare module BABYLON {
  33520. /**
  33521. * The interface for the physics imposter parameters
  33522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33523. */
  33524. interface PhysicsImpostorParameters {
  33525. /**
  33526. * The mass of the physics imposter
  33527. */
  33528. mass: number;
  33529. /**
  33530. * The friction of the physics imposter
  33531. */
  33532. friction?: number;
  33533. /**
  33534. * The coefficient of restitution of the physics imposter
  33535. */
  33536. restitution?: number;
  33537. /**
  33538. * The native options of the physics imposter
  33539. */
  33540. nativeOptions?: any;
  33541. /**
  33542. * Specifies if the parent should be ignored
  33543. */
  33544. ignoreParent?: boolean;
  33545. /**
  33546. * Specifies if bi-directional transformations should be disabled
  33547. */
  33548. disableBidirectionalTransformation?: boolean;
  33549. }
  33550. /**
  33551. * Interface for a physics-enabled object
  33552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33553. */
  33554. interface IPhysicsEnabledObject {
  33555. /**
  33556. * The position of the physics-enabled object
  33557. */
  33558. position: Vector3;
  33559. /**
  33560. * The rotation of the physics-enabled object
  33561. */
  33562. rotationQuaternion: Nullable<Quaternion>;
  33563. /**
  33564. * The scale of the physics-enabled object
  33565. */
  33566. scaling: Vector3;
  33567. /**
  33568. * The rotation of the physics-enabled object
  33569. */
  33570. rotation?: Vector3;
  33571. /**
  33572. * The parent of the physics-enabled object
  33573. */
  33574. parent?: any;
  33575. /**
  33576. * The bounding info of the physics-enabled object
  33577. * @returns The bounding info of the physics-enabled object
  33578. */
  33579. getBoundingInfo(): BoundingInfo;
  33580. /**
  33581. * Computes the world matrix
  33582. * @param force Specifies if the world matrix should be computed by force
  33583. * @returns A world matrix
  33584. */
  33585. computeWorldMatrix(force: boolean): Matrix;
  33586. /**
  33587. * Gets the world matrix
  33588. * @returns A world matrix
  33589. */
  33590. getWorldMatrix?(): Matrix;
  33591. /**
  33592. * Gets the child meshes
  33593. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33594. * @returns An array of abstract meshes
  33595. */
  33596. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33597. /**
  33598. * Gets the vertex data
  33599. * @param kind The type of vertex data
  33600. * @returns A nullable array of numbers, or a float32 array
  33601. */
  33602. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33603. /**
  33604. * Gets the indices from the mesh
  33605. * @returns A nullable array of index arrays
  33606. */
  33607. getIndices?(): Nullable<IndicesArray>;
  33608. /**
  33609. * Gets the scene from the mesh
  33610. * @returns the indices array or null
  33611. */
  33612. getScene?(): Scene;
  33613. /**
  33614. * Gets the absolute position from the mesh
  33615. * @returns the absolute position
  33616. */
  33617. getAbsolutePosition(): Vector3;
  33618. /**
  33619. * Gets the absolute pivot point from the mesh
  33620. * @returns the absolute pivot point
  33621. */
  33622. getAbsolutePivotPoint(): Vector3;
  33623. /**
  33624. * Rotates the mesh
  33625. * @param axis The axis of rotation
  33626. * @param amount The amount of rotation
  33627. * @param space The space of the rotation
  33628. * @returns The rotation transform node
  33629. */
  33630. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33631. /**
  33632. * Translates the mesh
  33633. * @param axis The axis of translation
  33634. * @param distance The distance of translation
  33635. * @param space The space of the translation
  33636. * @returns The transform node
  33637. */
  33638. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33639. /**
  33640. * Sets the absolute position of the mesh
  33641. * @param absolutePosition The absolute position of the mesh
  33642. * @returns The transform node
  33643. */
  33644. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33645. /**
  33646. * Gets the class name of the mesh
  33647. * @returns The class name
  33648. */
  33649. getClassName(): string;
  33650. }
  33651. /**
  33652. * Represents a physics imposter
  33653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33654. */
  33655. class PhysicsImpostor {
  33656. /**
  33657. * The physics-enabled object used as the physics imposter
  33658. */
  33659. object: IPhysicsEnabledObject;
  33660. /**
  33661. * The type of the physics imposter
  33662. */
  33663. type: number;
  33664. private _options;
  33665. private _scene?;
  33666. /**
  33667. * The default object size of the imposter
  33668. */
  33669. static DEFAULT_OBJECT_SIZE: Vector3;
  33670. /**
  33671. * The identity quaternion of the imposter
  33672. */
  33673. static IDENTITY_QUATERNION: Quaternion;
  33674. private _physicsEngine;
  33675. private _physicsBody;
  33676. private _bodyUpdateRequired;
  33677. private _onBeforePhysicsStepCallbacks;
  33678. private _onAfterPhysicsStepCallbacks;
  33679. private _onPhysicsCollideCallbacks;
  33680. private _deltaPosition;
  33681. private _deltaRotation;
  33682. private _deltaRotationConjugated;
  33683. private _parent;
  33684. private _isDisposed;
  33685. private static _tmpVecs;
  33686. private static _tmpQuat;
  33687. /**
  33688. * Specifies if the physics imposter is disposed
  33689. */
  33690. readonly isDisposed: boolean;
  33691. /**
  33692. * Gets the mass of the physics imposter
  33693. */
  33694. mass: number;
  33695. /**
  33696. * Gets the coefficient of friction
  33697. */
  33698. /**
  33699. * Sets the coefficient of friction
  33700. */
  33701. friction: number;
  33702. /**
  33703. * Gets the coefficient of restitution
  33704. */
  33705. /**
  33706. * Sets the coefficient of restitution
  33707. */
  33708. restitution: number;
  33709. /**
  33710. * The unique id of the physics imposter
  33711. * set by the physics engine when adding this impostor to the array
  33712. */
  33713. uniqueId: number;
  33714. private _joints;
  33715. /**
  33716. * Initializes the physics imposter
  33717. * @param object The physics-enabled object used as the physics imposter
  33718. * @param type The type of the physics imposter
  33719. * @param _options The options for the physics imposter
  33720. * @param _scene The Babylon scene
  33721. */
  33722. constructor(
  33723. /**
  33724. * The physics-enabled object used as the physics imposter
  33725. */
  33726. object: IPhysicsEnabledObject,
  33727. /**
  33728. * The type of the physics imposter
  33729. */
  33730. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33731. /**
  33732. * This function will completly initialize this impostor.
  33733. * It will create a new body - but only if this mesh has no parent.
  33734. * If it has, this impostor will not be used other than to define the impostor
  33735. * of the child mesh.
  33736. * @hidden
  33737. */
  33738. _init(): void;
  33739. private _getPhysicsParent;
  33740. /**
  33741. * Should a new body be generated.
  33742. * @returns boolean specifying if body initialization is required
  33743. */
  33744. isBodyInitRequired(): boolean;
  33745. /**
  33746. * Sets the updated scaling
  33747. * @param updated Specifies if the scaling is updated
  33748. */
  33749. setScalingUpdated(updated: boolean): void;
  33750. /**
  33751. * Force a regeneration of this or the parent's impostor's body.
  33752. * Use under cautious - This will remove all joints already implemented.
  33753. */
  33754. forceUpdate(): void;
  33755. /**
  33756. * Gets the body that holds this impostor. Either its own, or its parent.
  33757. */
  33758. /**
  33759. * Set the physics body. Used mainly by the physics engine/plugin
  33760. */
  33761. physicsBody: any;
  33762. /**
  33763. * Get the parent of the physics imposter
  33764. * @returns Physics imposter or null
  33765. */
  33766. /**
  33767. * Sets the parent of the physics imposter
  33768. */
  33769. parent: Nullable<PhysicsImpostor>;
  33770. /**
  33771. * Resets the update flags
  33772. */
  33773. resetUpdateFlags(): void;
  33774. /**
  33775. * Gets the object extend size
  33776. * @returns the object extend size
  33777. */
  33778. getObjectExtendSize(): Vector3;
  33779. /**
  33780. * Gets the object center
  33781. * @returns The object center
  33782. */
  33783. getObjectCenter(): Vector3;
  33784. /**
  33785. * Get a specific parametes from the options parameter
  33786. * @param paramName The object parameter name
  33787. * @returns The object parameter
  33788. */
  33789. getParam(paramName: string): any;
  33790. /**
  33791. * Sets a specific parameter in the options given to the physics plugin
  33792. * @param paramName The parameter name
  33793. * @param value The value of the parameter
  33794. */
  33795. setParam(paramName: string, value: number): void;
  33796. /**
  33797. * Specifically change the body's mass option. Won't recreate the physics body object
  33798. * @param mass The mass of the physics imposter
  33799. */
  33800. setMass(mass: number): void;
  33801. /**
  33802. * Gets the linear velocity
  33803. * @returns linear velocity or null
  33804. */
  33805. getLinearVelocity(): Nullable<Vector3>;
  33806. /**
  33807. * Sets the linear velocity
  33808. * @param velocity linear velocity or null
  33809. */
  33810. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33811. /**
  33812. * Gets the angular velocity
  33813. * @returns angular velocity or null
  33814. */
  33815. getAngularVelocity(): Nullable<Vector3>;
  33816. /**
  33817. * Sets the angular velocity
  33818. * @param velocity The velocity or null
  33819. */
  33820. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33821. /**
  33822. * Execute a function with the physics plugin native code
  33823. * Provide a function the will have two variables - the world object and the physics body object
  33824. * @param func The function to execute with the physics plugin native code
  33825. */
  33826. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33827. /**
  33828. * Register a function that will be executed before the physics world is stepping forward
  33829. * @param func The function to execute before the physics world is stepped forward
  33830. */
  33831. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33832. /**
  33833. * Unregister a function that will be executed before the physics world is stepping forward
  33834. * @param func The function to execute before the physics world is stepped forward
  33835. */
  33836. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33837. /**
  33838. * Register a function that will be executed after the physics step
  33839. * @param func The function to execute after physics step
  33840. */
  33841. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33842. /**
  33843. * Unregisters a function that will be executed after the physics step
  33844. * @param func The function to execute after physics step
  33845. */
  33846. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33847. /**
  33848. * register a function that will be executed when this impostor collides against a different body
  33849. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33850. * @param func Callback that is executed on collision
  33851. */
  33852. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33853. /**
  33854. * Unregisters the physics imposter on contact
  33855. * @param collideAgainst The physics object to collide against
  33856. * @param func Callback to execute on collision
  33857. */
  33858. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33859. private _tmpQuat;
  33860. private _tmpQuat2;
  33861. /**
  33862. * Get the parent rotation
  33863. * @returns The parent rotation
  33864. */
  33865. getParentsRotation(): Quaternion;
  33866. /**
  33867. * this function is executed by the physics engine.
  33868. */
  33869. beforeStep: () => void;
  33870. /**
  33871. * this function is executed by the physics engine
  33872. */
  33873. afterStep: () => void;
  33874. /**
  33875. * Legacy collision detection event support
  33876. */
  33877. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33878. /**
  33879. * event and body object due to cannon's event-based architecture.
  33880. */
  33881. onCollide: (e: {
  33882. body: any;
  33883. }) => void;
  33884. /**
  33885. * Apply a force
  33886. * @param force The force to apply
  33887. * @param contactPoint The contact point for the force
  33888. * @returns The physics imposter
  33889. */
  33890. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33891. /**
  33892. * Apply an impulse
  33893. * @param force The impulse force
  33894. * @param contactPoint The contact point for the impulse force
  33895. * @returns The physics imposter
  33896. */
  33897. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33898. /**
  33899. * A help function to create a joint
  33900. * @param otherImpostor A physics imposter used to create a joint
  33901. * @param jointType The type of joint
  33902. * @param jointData The data for the joint
  33903. * @returns The physics imposter
  33904. */
  33905. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33906. /**
  33907. * Add a joint to this impostor with a different impostor
  33908. * @param otherImpostor A physics imposter used to add a joint
  33909. * @param joint The joint to add
  33910. * @returns The physics imposter
  33911. */
  33912. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33913. /**
  33914. * Will keep this body still, in a sleep mode.
  33915. * @returns the physics imposter
  33916. */
  33917. sleep(): PhysicsImpostor;
  33918. /**
  33919. * Wake the body up.
  33920. * @returns The physics imposter
  33921. */
  33922. wakeUp(): PhysicsImpostor;
  33923. /**
  33924. * Clones the physics imposter
  33925. * @param newObject The physics imposter clones to this physics-enabled object
  33926. * @returns A nullable physics imposter
  33927. */
  33928. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33929. /**
  33930. * Disposes the physics imposter
  33931. */
  33932. dispose(): void;
  33933. /**
  33934. * Sets the delta position
  33935. * @param position The delta position amount
  33936. */
  33937. setDeltaPosition(position: Vector3): void;
  33938. /**
  33939. * Sets the delta rotation
  33940. * @param rotation The delta rotation amount
  33941. */
  33942. setDeltaRotation(rotation: Quaternion): void;
  33943. /**
  33944. * Gets the box size of the physics imposter and stores the result in the input parameter
  33945. * @param result Stores the box size
  33946. * @returns The physics imposter
  33947. */
  33948. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33949. /**
  33950. * Gets the radius of the physics imposter
  33951. * @returns Radius of the physics imposter
  33952. */
  33953. getRadius(): number;
  33954. /**
  33955. * Sync a bone with this impostor
  33956. * @param bone The bone to sync to the impostor.
  33957. * @param boneMesh The mesh that the bone is influencing.
  33958. * @param jointPivot The pivot of the joint / bone in local space.
  33959. * @param distToJoint Optional distance from the impostor to the joint.
  33960. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33961. */
  33962. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33963. /**
  33964. * Sync impostor to a bone
  33965. * @param bone The bone that the impostor will be synced to.
  33966. * @param boneMesh The mesh that the bone is influencing.
  33967. * @param jointPivot The pivot of the joint / bone in local space.
  33968. * @param distToJoint Optional distance from the impostor to the joint.
  33969. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33970. * @param boneAxis Optional vector3 axis the bone is aligned with
  33971. */
  33972. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33973. /**
  33974. * No-Imposter type
  33975. */
  33976. static NoImpostor: number;
  33977. /**
  33978. * Sphere-Imposter type
  33979. */
  33980. static SphereImpostor: number;
  33981. /**
  33982. * Box-Imposter type
  33983. */
  33984. static BoxImpostor: number;
  33985. /**
  33986. * Plane-Imposter type
  33987. */
  33988. static PlaneImpostor: number;
  33989. /**
  33990. * Mesh-imposter type
  33991. */
  33992. static MeshImpostor: number;
  33993. /**
  33994. * Cylinder-Imposter type
  33995. */
  33996. static CylinderImpostor: number;
  33997. /**
  33998. * Particle-Imposter type
  33999. */
  34000. static ParticleImpostor: number;
  34001. /**
  34002. * Heightmap-Imposter type
  34003. */
  34004. static HeightmapImpostor: number;
  34005. }
  34006. }
  34007. declare module BABYLON {
  34008. /**
  34009. * Interface for Physics-Joint data
  34010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34011. */
  34012. interface PhysicsJointData {
  34013. /**
  34014. * The main pivot of the joint
  34015. */
  34016. mainPivot?: Vector3;
  34017. /**
  34018. * The connected pivot of the joint
  34019. */
  34020. connectedPivot?: Vector3;
  34021. /**
  34022. * The main axis of the joint
  34023. */
  34024. mainAxis?: Vector3;
  34025. /**
  34026. * The connected axis of the joint
  34027. */
  34028. connectedAxis?: Vector3;
  34029. /**
  34030. * The collision of the joint
  34031. */
  34032. collision?: boolean;
  34033. /**
  34034. * Native Oimo/Cannon/Energy data
  34035. */
  34036. nativeParams?: any;
  34037. }
  34038. /**
  34039. * This is a holder class for the physics joint created by the physics plugin
  34040. * It holds a set of functions to control the underlying joint
  34041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34042. */
  34043. class PhysicsJoint {
  34044. /**
  34045. * The type of the physics joint
  34046. */
  34047. type: number;
  34048. /**
  34049. * The data for the physics joint
  34050. */
  34051. jointData: PhysicsJointData;
  34052. private _physicsJoint;
  34053. protected _physicsPlugin: IPhysicsEnginePlugin;
  34054. /**
  34055. * Initializes the physics joint
  34056. * @param type The type of the physics joint
  34057. * @param jointData The data for the physics joint
  34058. */
  34059. constructor(
  34060. /**
  34061. * The type of the physics joint
  34062. */
  34063. type: number,
  34064. /**
  34065. * The data for the physics joint
  34066. */
  34067. jointData: PhysicsJointData);
  34068. /**
  34069. * Gets the physics joint
  34070. */
  34071. /**
  34072. * Sets the physics joint
  34073. */
  34074. physicsJoint: any;
  34075. /**
  34076. * Sets the physics plugin
  34077. */
  34078. physicsPlugin: IPhysicsEnginePlugin;
  34079. /**
  34080. * Execute a function that is physics-plugin specific.
  34081. * @param {Function} func the function that will be executed.
  34082. * It accepts two parameters: the physics world and the physics joint
  34083. */
  34084. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34085. /**
  34086. * Distance-Joint type
  34087. */
  34088. static DistanceJoint: number;
  34089. /**
  34090. * Hinge-Joint type
  34091. */
  34092. static HingeJoint: number;
  34093. /**
  34094. * Ball-and-Socket joint type
  34095. */
  34096. static BallAndSocketJoint: number;
  34097. /**
  34098. * Wheel-Joint type
  34099. */
  34100. static WheelJoint: number;
  34101. /**
  34102. * Slider-Joint type
  34103. */
  34104. static SliderJoint: number;
  34105. /**
  34106. * Prismatic-Joint type
  34107. */
  34108. static PrismaticJoint: number;
  34109. /**
  34110. * Universal-Joint type
  34111. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34112. */
  34113. static UniversalJoint: number;
  34114. /**
  34115. * Hinge-Joint 2 type
  34116. */
  34117. static Hinge2Joint: number;
  34118. /**
  34119. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34120. */
  34121. static PointToPointJoint: number;
  34122. /**
  34123. * Spring-Joint type
  34124. */
  34125. static SpringJoint: number;
  34126. /**
  34127. * Lock-Joint type
  34128. */
  34129. static LockJoint: number;
  34130. }
  34131. /**
  34132. * A class representing a physics distance joint
  34133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34134. */
  34135. class DistanceJoint extends PhysicsJoint {
  34136. /**
  34137. *
  34138. * @param jointData The data for the Distance-Joint
  34139. */
  34140. constructor(jointData: DistanceJointData);
  34141. /**
  34142. * Update the predefined distance.
  34143. * @param maxDistance The maximum preferred distance
  34144. * @param minDistance The minimum preferred distance
  34145. */
  34146. updateDistance(maxDistance: number, minDistance?: number): void;
  34147. }
  34148. /**
  34149. * Represents a Motor-Enabled Joint
  34150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34151. */
  34152. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34153. /**
  34154. * Initializes the Motor-Enabled Joint
  34155. * @param type The type of the joint
  34156. * @param jointData The physica joint data for the joint
  34157. */
  34158. constructor(type: number, jointData: PhysicsJointData);
  34159. /**
  34160. * Set the motor values.
  34161. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34162. * @param force the force to apply
  34163. * @param maxForce max force for this motor.
  34164. */
  34165. setMotor(force?: number, maxForce?: number): void;
  34166. /**
  34167. * Set the motor's limits.
  34168. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34169. * @param upperLimit The upper limit of the motor
  34170. * @param lowerLimit The lower limit of the motor
  34171. */
  34172. setLimit(upperLimit: number, lowerLimit?: number): void;
  34173. }
  34174. /**
  34175. * This class represents a single physics Hinge-Joint
  34176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34177. */
  34178. class HingeJoint extends MotorEnabledJoint {
  34179. /**
  34180. * Initializes the Hinge-Joint
  34181. * @param jointData The joint data for the Hinge-Joint
  34182. */
  34183. constructor(jointData: PhysicsJointData);
  34184. /**
  34185. * Set the motor values.
  34186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34187. * @param {number} force the force to apply
  34188. * @param {number} maxForce max force for this motor.
  34189. */
  34190. setMotor(force?: number, maxForce?: number): void;
  34191. /**
  34192. * Set the motor's limits.
  34193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34194. * @param upperLimit The upper limit of the motor
  34195. * @param lowerLimit The lower limit of the motor
  34196. */
  34197. setLimit(upperLimit: number, lowerLimit?: number): void;
  34198. }
  34199. /**
  34200. * This class represents a dual hinge physics joint (same as wheel joint)
  34201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34202. */
  34203. class Hinge2Joint extends MotorEnabledJoint {
  34204. /**
  34205. * Initializes the Hinge2-Joint
  34206. * @param jointData The joint data for the Hinge2-Joint
  34207. */
  34208. constructor(jointData: PhysicsJointData);
  34209. /**
  34210. * Set the motor values.
  34211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34212. * @param {number} force the force to apply
  34213. * @param {number} maxForce max force for this motor.
  34214. * @param {motorIndex} the motor's index, 0 or 1.
  34215. */
  34216. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34217. /**
  34218. * Set the motor limits.
  34219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34220. * @param {number} upperLimit the upper limit
  34221. * @param {number} lowerLimit lower limit
  34222. * @param {motorIndex} the motor's index, 0 or 1.
  34223. */
  34224. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34225. }
  34226. /**
  34227. * Interface for a motor enabled joint
  34228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34229. */
  34230. interface IMotorEnabledJoint {
  34231. /**
  34232. * Physics joint
  34233. */
  34234. physicsJoint: any;
  34235. /**
  34236. * Sets the motor of the motor-enabled joint
  34237. * @param force The force of the motor
  34238. * @param maxForce The maximum force of the motor
  34239. * @param motorIndex The index of the motor
  34240. */
  34241. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34242. /**
  34243. * Sets the limit of the motor
  34244. * @param upperLimit The upper limit of the motor
  34245. * @param lowerLimit The lower limit of the motor
  34246. * @param motorIndex The index of the motor
  34247. */
  34248. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34249. }
  34250. /**
  34251. * Joint data for a Distance-Joint
  34252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34253. */
  34254. interface DistanceJointData extends PhysicsJointData {
  34255. /**
  34256. * Max distance the 2 joint objects can be apart
  34257. */
  34258. maxDistance: number;
  34259. }
  34260. /**
  34261. * Joint data from a spring joint
  34262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34263. */
  34264. interface SpringJointData extends PhysicsJointData {
  34265. /**
  34266. * Length of the spring
  34267. */
  34268. length: number;
  34269. /**
  34270. * Stiffness of the spring
  34271. */
  34272. stiffness: number;
  34273. /**
  34274. * Damping of the spring
  34275. */
  34276. damping: number;
  34277. /** this callback will be called when applying the force to the impostors. */
  34278. forceApplicationCallback: () => void;
  34279. }
  34280. }
  34281. declare module BABYLON {
  34282. interface AbstractScene {
  34283. /**
  34284. * The list of reflection probes added to the scene
  34285. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34286. */
  34287. reflectionProbes: Array<ReflectionProbe>;
  34288. /**
  34289. * Removes the given reflection probe from this scene.
  34290. * @param toRemove The reflection probe to remove
  34291. * @returns The index of the removed reflection probe
  34292. */
  34293. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34294. /**
  34295. * Adds the given reflection probe to this scene.
  34296. * @param newReflectionProbe The reflection probe to add
  34297. */
  34298. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34299. }
  34300. /**
  34301. * Class used to generate realtime reflection / refraction cube textures
  34302. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34303. */
  34304. class ReflectionProbe {
  34305. /** defines the name of the probe */
  34306. name: string;
  34307. private _scene;
  34308. private _renderTargetTexture;
  34309. private _projectionMatrix;
  34310. private _viewMatrix;
  34311. private _target;
  34312. private _add;
  34313. private _attachedMesh;
  34314. private _invertYAxis;
  34315. /** Gets or sets probe position (center of the cube map) */
  34316. position: Vector3;
  34317. /**
  34318. * Creates a new reflection probe
  34319. * @param name defines the name of the probe
  34320. * @param size defines the texture resolution (for each face)
  34321. * @param scene defines the hosting scene
  34322. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34323. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34324. */
  34325. constructor(
  34326. /** defines the name of the probe */
  34327. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34328. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34329. samples: number;
  34330. /** Gets or sets the refresh rate to use (on every frame by default) */
  34331. refreshRate: number;
  34332. /**
  34333. * Gets the hosting scene
  34334. * @returns a Scene
  34335. */
  34336. getScene(): Scene;
  34337. /** Gets the internal CubeTexture used to render to */
  34338. readonly cubeTexture: RenderTargetTexture;
  34339. /** Gets the list of meshes to render */
  34340. readonly renderList: Nullable<AbstractMesh[]>;
  34341. /**
  34342. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34343. * @param mesh defines the mesh to attach to
  34344. */
  34345. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34346. /**
  34347. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34348. * @param renderingGroupId The rendering group id corresponding to its index
  34349. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34350. */
  34351. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34352. /**
  34353. * Clean all associated resources
  34354. */
  34355. dispose(): void;
  34356. /**
  34357. * Converts the reflection probe information to a readable string for debug purpose.
  34358. * @param fullDetails Supports for multiple levels of logging within scene loading
  34359. * @returns the human readable reflection probe info
  34360. */
  34361. toString(fullDetails?: boolean): string;
  34362. /**
  34363. * Get the class name of the relfection probe.
  34364. * @returns "ReflectionProbe"
  34365. */
  34366. getClassName(): string;
  34367. /**
  34368. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34369. * @returns The JSON representation of the texture
  34370. */
  34371. serialize(): any;
  34372. /**
  34373. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34374. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34375. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34376. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34377. * @returns The parsed reflection probe if successful
  34378. */
  34379. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34380. }
  34381. }
  34382. declare module BABYLON {
  34383. interface Scene {
  34384. /** @hidden (Backing field) */
  34385. _boundingBoxRenderer: BoundingBoxRenderer;
  34386. /** @hidden (Backing field) */
  34387. _forceShowBoundingBoxes: boolean;
  34388. /**
  34389. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34390. */
  34391. forceShowBoundingBoxes: boolean;
  34392. /**
  34393. * Gets the bounding box renderer associated with the scene
  34394. * @returns a BoundingBoxRenderer
  34395. */
  34396. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34397. }
  34398. interface AbstractMesh {
  34399. /** @hidden (Backing field) */
  34400. _showBoundingBox: boolean;
  34401. /**
  34402. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34403. */
  34404. showBoundingBox: boolean;
  34405. }
  34406. /**
  34407. * Component responsible of rendering the bounding box of the meshes in a scene.
  34408. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34409. */
  34410. class BoundingBoxRenderer implements ISceneComponent {
  34411. /**
  34412. * The component name helpfull to identify the component in the list of scene components.
  34413. */
  34414. readonly name: string;
  34415. /**
  34416. * The scene the component belongs to.
  34417. */
  34418. scene: Scene;
  34419. /**
  34420. * Color of the bounding box lines placed in front of an object
  34421. */
  34422. frontColor: Color3;
  34423. /**
  34424. * Color of the bounding box lines placed behind an object
  34425. */
  34426. backColor: Color3;
  34427. /**
  34428. * Defines if the renderer should show the back lines or not
  34429. */
  34430. showBackLines: boolean;
  34431. /**
  34432. * @hidden
  34433. */
  34434. renderList: SmartArray<BoundingBox>;
  34435. private _colorShader;
  34436. private _vertexBuffers;
  34437. private _indexBuffer;
  34438. /**
  34439. * Instantiates a new bounding box renderer in a scene.
  34440. * @param scene the scene the renderer renders in
  34441. */
  34442. constructor(scene: Scene);
  34443. /**
  34444. * Registers the component in a given scene
  34445. */
  34446. register(): void;
  34447. private _evaluateSubMesh;
  34448. private _activeMesh;
  34449. private _prepareRessources;
  34450. private _createIndexBuffer;
  34451. /**
  34452. * Rebuilds the elements related to this component in case of
  34453. * context lost for instance.
  34454. */
  34455. rebuild(): void;
  34456. /**
  34457. * @hidden
  34458. */
  34459. reset(): void;
  34460. /**
  34461. * Render the bounding boxes of a specific rendering group
  34462. * @param renderingGroupId defines the rendering group to render
  34463. */
  34464. render(renderingGroupId: number): void;
  34465. /**
  34466. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34467. * @param mesh Define the mesh to render the occlusion bounding box for
  34468. */
  34469. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34470. /**
  34471. * Dispose and release the resources attached to this renderer.
  34472. */
  34473. dispose(): void;
  34474. }
  34475. }
  34476. declare module BABYLON {
  34477. /**
  34478. * This represents a depth renderer in Babylon.
  34479. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34480. */
  34481. class DepthRenderer {
  34482. private _scene;
  34483. private _depthMap;
  34484. private _effect;
  34485. private _cachedDefines;
  34486. private _camera;
  34487. /**
  34488. * Specifiess that the depth renderer will only be used within
  34489. * the camera it is created for.
  34490. * This can help forcing its rendering during the camera processing.
  34491. */
  34492. useOnlyInActiveCamera: boolean;
  34493. /**
  34494. * Instantiates a depth renderer
  34495. * @param scene The scene the renderer belongs to
  34496. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34497. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34498. */
  34499. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34500. /**
  34501. * Creates the depth rendering effect and checks if the effect is ready.
  34502. * @param subMesh The submesh to be used to render the depth map of
  34503. * @param useInstances If multiple world instances should be used
  34504. * @returns if the depth renderer is ready to render the depth map
  34505. */
  34506. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34507. /**
  34508. * Gets the texture which the depth map will be written to.
  34509. * @returns The depth map texture
  34510. */
  34511. getDepthMap(): RenderTargetTexture;
  34512. /**
  34513. * Disposes of the depth renderer.
  34514. */
  34515. dispose(): void;
  34516. }
  34517. }
  34518. declare module BABYLON {
  34519. interface Scene {
  34520. /** @hidden (Backing field) */
  34521. _depthRenderer: {
  34522. [id: string]: DepthRenderer;
  34523. };
  34524. /**
  34525. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34526. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34527. * @returns the created depth renderer
  34528. */
  34529. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34530. /**
  34531. * Disables a depth renderer for a given camera
  34532. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34533. */
  34534. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34535. }
  34536. /**
  34537. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  34538. * in several rendering techniques.
  34539. */
  34540. class DepthRendererSceneComponent implements ISceneComponent {
  34541. /**
  34542. * The component name helpfull to identify the component in the list of scene components.
  34543. */
  34544. readonly name: string;
  34545. /**
  34546. * The scene the component belongs to.
  34547. */
  34548. scene: Scene;
  34549. /**
  34550. * Creates a new instance of the component for the given scene
  34551. * @param scene Defines the scene to register the component in
  34552. */
  34553. constructor(scene: Scene);
  34554. /**
  34555. * Registers the component in a given scene
  34556. */
  34557. register(): void;
  34558. /**
  34559. * Rebuilds the elements related to this component in case of
  34560. * context lost for instance.
  34561. */
  34562. rebuild(): void;
  34563. /**
  34564. * Disposes the component and the associated ressources
  34565. */
  34566. dispose(): void;
  34567. private _gatherRenderTargets;
  34568. private _gatherActiveCameraRenderTargets;
  34569. }
  34570. }
  34571. declare module BABYLON {
  34572. interface AbstractMesh {
  34573. /**
  34574. * Disables the mesh edge rendering mode
  34575. * @returns the currentAbstractMesh
  34576. */
  34577. disableEdgesRendering(): AbstractMesh;
  34578. /**
  34579. * Enables the edge rendering mode on the mesh.
  34580. * This mode makes the mesh edges visible
  34581. * @param epsilon defines the maximal distance between two angles to detect a face
  34582. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34583. * @returns the currentAbstractMesh
  34584. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34585. */
  34586. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34587. /**
  34588. * Gets the edgesRenderer associated with the mesh
  34589. */
  34590. edgesRenderer: Nullable<EdgesRenderer>;
  34591. }
  34592. interface LinesMesh {
  34593. /**
  34594. * Enables the edge rendering mode on the mesh.
  34595. * This mode makes the mesh edges visible
  34596. * @param epsilon defines the maximal distance between two angles to detect a face
  34597. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34598. * @returns the currentAbstractMesh
  34599. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34600. */
  34601. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34602. }
  34603. interface InstancedLinesMesh {
  34604. /**
  34605. * Enables the edge rendering mode on the mesh.
  34606. * This mode makes the mesh edges visible
  34607. * @param epsilon defines the maximal distance between two angles to detect a face
  34608. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34609. * @returns the current InstancedLinesMesh
  34610. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34611. */
  34612. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34613. }
  34614. /**
  34615. * Defines the minimum contract an Edges renderer should follow.
  34616. */
  34617. interface IEdgesRenderer extends IDisposable {
  34618. /**
  34619. * Gets or sets a boolean indicating if the edgesRenderer is active
  34620. */
  34621. isEnabled: boolean;
  34622. /**
  34623. * Renders the edges of the attached mesh,
  34624. */
  34625. render(): void;
  34626. /**
  34627. * Checks wether or not the edges renderer is ready to render.
  34628. * @return true if ready, otherwise false.
  34629. */
  34630. isReady(): boolean;
  34631. }
  34632. /**
  34633. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34634. */
  34635. class EdgesRenderer implements IEdgesRenderer {
  34636. /**
  34637. * Define the size of the edges with an orthographic camera
  34638. */
  34639. edgesWidthScalerForOrthographic: number;
  34640. /**
  34641. * Define the size of the edges with a perspective camera
  34642. */
  34643. edgesWidthScalerForPerspective: number;
  34644. protected _source: AbstractMesh;
  34645. protected _linesPositions: number[];
  34646. protected _linesNormals: number[];
  34647. protected _linesIndices: number[];
  34648. protected _epsilon: number;
  34649. protected _indicesCount: number;
  34650. protected _lineShader: ShaderMaterial;
  34651. protected _ib: WebGLBuffer;
  34652. protected _buffers: {
  34653. [key: string]: Nullable<VertexBuffer>;
  34654. };
  34655. protected _checkVerticesInsteadOfIndices: boolean;
  34656. private _meshRebuildObserver;
  34657. private _meshDisposeObserver;
  34658. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34659. isEnabled: boolean;
  34660. /**
  34661. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34662. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34663. * @param source Mesh used to create edges
  34664. * @param epsilon sum of angles in adjacency to check for edge
  34665. * @param checkVerticesInsteadOfIndices
  34666. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34667. */
  34668. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34669. protected _prepareRessources(): void;
  34670. /** @hidden */
  34671. _rebuild(): void;
  34672. /**
  34673. * Releases the required resources for the edges renderer
  34674. */
  34675. dispose(): void;
  34676. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34677. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34678. /**
  34679. * Checks if the pair of p0 and p1 is en edge
  34680. * @param faceIndex
  34681. * @param edge
  34682. * @param faceNormals
  34683. * @param p0
  34684. * @param p1
  34685. * @private
  34686. */
  34687. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34688. /**
  34689. * push line into the position, normal and index buffer
  34690. * @protected
  34691. */
  34692. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34693. /**
  34694. * Generates lines edges from adjacencjes
  34695. * @private
  34696. */
  34697. _generateEdgesLines(): void;
  34698. /**
  34699. * Checks wether or not the edges renderer is ready to render.
  34700. * @return true if ready, otherwise false.
  34701. */
  34702. isReady(): boolean;
  34703. /**
  34704. * Renders the edges of the attached mesh,
  34705. */
  34706. render(): void;
  34707. }
  34708. }
  34709. declare module BABYLON {
  34710. /**
  34711. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34712. */
  34713. class GeometryBufferRenderer {
  34714. /**
  34715. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34716. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34717. */
  34718. static readonly POSITION_TEXTURE_TYPE: number;
  34719. /**
  34720. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34721. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34722. */
  34723. static readonly VELOCITY_TEXTURE_TYPE: number;
  34724. /**
  34725. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34726. * in order to compute objects velocities when enableVelocity is set to "true"
  34727. * @hidden
  34728. */
  34729. _previousTransformationMatrices: {
  34730. [index: number]: Matrix;
  34731. };
  34732. private _scene;
  34733. private _multiRenderTarget;
  34734. private _ratio;
  34735. private _enablePosition;
  34736. private _enableVelocity;
  34737. private _positionIndex;
  34738. private _velocityIndex;
  34739. protected _effect: Effect;
  34740. protected _cachedDefines: string;
  34741. /**
  34742. * Set the render list (meshes to be rendered) used in the G buffer.
  34743. */
  34744. renderList: Mesh[];
  34745. /**
  34746. * Gets wether or not G buffer are supported by the running hardware.
  34747. * This requires draw buffer supports
  34748. */
  34749. readonly isSupported: boolean;
  34750. /**
  34751. * Returns the index of the given texture type in the G-Buffer textures array
  34752. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34753. * @returns the index of the given texture type in the G-Buffer textures array
  34754. */
  34755. getTextureIndex(textureType: number): number;
  34756. /**
  34757. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34758. */
  34759. /**
  34760. * Sets whether or not objects positions are enabled for the G buffer.
  34761. */
  34762. enablePosition: boolean;
  34763. /**
  34764. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34765. */
  34766. /**
  34767. * Sets wether or not objects velocities are enabled for the G buffer.
  34768. */
  34769. enableVelocity: boolean;
  34770. /**
  34771. * Gets the scene associated with the buffer.
  34772. */
  34773. readonly scene: Scene;
  34774. /**
  34775. * Gets the ratio used by the buffer during its creation.
  34776. * How big is the buffer related to the main canvas.
  34777. */
  34778. readonly ratio: number;
  34779. /**
  34780. * Creates a new G Buffer for the scene
  34781. * @param scene The scene the buffer belongs to
  34782. * @param ratio How big is the buffer related to the main canvas.
  34783. */
  34784. constructor(scene: Scene, ratio?: number);
  34785. /**
  34786. * Checks wether everything is ready to render a submesh to the G buffer.
  34787. * @param subMesh the submesh to check readiness for
  34788. * @param useInstances is the mesh drawn using instance or not
  34789. * @returns true if ready otherwise false
  34790. */
  34791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34792. /**
  34793. * Gets the current underlying G Buffer.
  34794. * @returns the buffer
  34795. */
  34796. getGBuffer(): MultiRenderTarget;
  34797. /**
  34798. * Gets the number of samples used to render the buffer (anti aliasing).
  34799. */
  34800. /**
  34801. * Sets the number of samples used to render the buffer (anti aliasing).
  34802. */
  34803. samples: number;
  34804. /**
  34805. * Disposes the renderer and frees up associated resources.
  34806. */
  34807. dispose(): void;
  34808. protected _createRenderTargets(): void;
  34809. }
  34810. }
  34811. declare module BABYLON {
  34812. interface Scene {
  34813. /** @hidden (Backing field) */
  34814. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34815. /**
  34816. * Gets or Sets the current geometry buffer associated to the scene.
  34817. */
  34818. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34819. /**
  34820. * Enables a GeometryBufferRender and associates it with the scene
  34821. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34822. * @returns the GeometryBufferRenderer
  34823. */
  34824. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34825. /**
  34826. * Disables the GeometryBufferRender associated with the scene
  34827. */
  34828. disableGeometryBufferRenderer(): void;
  34829. }
  34830. /**
  34831. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34832. * in several rendering techniques.
  34833. */
  34834. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34835. /**
  34836. * The component name helpful to identify the component in the list of scene components.
  34837. */
  34838. readonly name: string;
  34839. /**
  34840. * The scene the component belongs to.
  34841. */
  34842. scene: Scene;
  34843. /**
  34844. * Creates a new instance of the component for the given scene
  34845. * @param scene Defines the scene to register the component in
  34846. */
  34847. constructor(scene: Scene);
  34848. /**
  34849. * Registers the component in a given scene
  34850. */
  34851. register(): void;
  34852. /**
  34853. * Rebuilds the elements related to this component in case of
  34854. * context lost for instance.
  34855. */
  34856. rebuild(): void;
  34857. /**
  34858. * Disposes the component and the associated ressources
  34859. */
  34860. dispose(): void;
  34861. private _gatherRenderTargets;
  34862. }
  34863. }
  34864. declare module BABYLON {
  34865. /**
  34866. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34867. */
  34868. class LineEdgesRenderer extends EdgesRenderer {
  34869. /**
  34870. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34871. * @param source LineMesh used to generate edges
  34872. * @param epsilon not important (specified angle for edge detection)
  34873. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34874. */
  34875. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34876. /**
  34877. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34878. */
  34879. _generateEdgesLines(): void;
  34880. }
  34881. }
  34882. declare module BABYLON {
  34883. interface Scene {
  34884. /** @hidden */
  34885. _outlineRenderer: OutlineRenderer;
  34886. /**
  34887. * Gets the outline renderer associated with the scene
  34888. * @returns a OutlineRenderer
  34889. */
  34890. getOutlineRenderer(): OutlineRenderer;
  34891. }
  34892. interface AbstractMesh {
  34893. /** @hidden (Backing field) */
  34894. _renderOutline: boolean;
  34895. /**
  34896. * Gets or sets a boolean indicating if the outline must be rendered as well
  34897. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34898. */
  34899. renderOutline: boolean;
  34900. /** @hidden (Backing field) */
  34901. _renderOverlay: boolean;
  34902. /**
  34903. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34904. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34905. */
  34906. renderOverlay: boolean;
  34907. }
  34908. /**
  34909. * This class is responsible to draw bothe outline/overlay of meshes.
  34910. * It should not be used directly but through the available method on mesh.
  34911. */
  34912. class OutlineRenderer implements ISceneComponent {
  34913. /**
  34914. * The name of the component. Each component must have a unique name.
  34915. */
  34916. name: string;
  34917. /**
  34918. * The scene the component belongs to.
  34919. */
  34920. scene: Scene;
  34921. /**
  34922. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34923. */
  34924. zOffset: number;
  34925. private _engine;
  34926. private _effect;
  34927. private _cachedDefines;
  34928. private _savedDepthWrite;
  34929. /**
  34930. * Instantiates a new outline renderer. (There could be only one per scene).
  34931. * @param scene Defines the scene it belongs to
  34932. */
  34933. constructor(scene: Scene);
  34934. /**
  34935. * Register the component to one instance of a scene.
  34936. */
  34937. register(): void;
  34938. /**
  34939. * Rebuilds the elements related to this component in case of
  34940. * context lost for instance.
  34941. */
  34942. rebuild(): void;
  34943. /**
  34944. * Disposes the component and the associated ressources.
  34945. */
  34946. dispose(): void;
  34947. /**
  34948. * Renders the outline in the canvas.
  34949. * @param subMesh Defines the sumesh to render
  34950. * @param batch Defines the batch of meshes in case of instances
  34951. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34952. */
  34953. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34954. /**
  34955. * Returns whether or not the outline renderer is ready for a given submesh.
  34956. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34957. * @param subMesh Defines the submesh to check readyness for
  34958. * @param useInstances Defines wheter wee are trying to render instances or not
  34959. * @returns true if ready otherwise false
  34960. */
  34961. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34962. private _beforeRenderingMesh;
  34963. private _afterRenderingMesh;
  34964. }
  34965. }
  34966. declare module BABYLON {
  34967. /**
  34968. * This represents the object necessary to create a rendering group.
  34969. * This is exclusively used and created by the rendering manager.
  34970. * To modify the behavior, you use the available helpers in your scene or meshes.
  34971. * @hidden
  34972. */
  34973. class RenderingGroup {
  34974. index: number;
  34975. private _scene;
  34976. private _opaqueSubMeshes;
  34977. private _transparentSubMeshes;
  34978. private _alphaTestSubMeshes;
  34979. private _depthOnlySubMeshes;
  34980. private _particleSystems;
  34981. private _spriteManagers;
  34982. private _opaqueSortCompareFn;
  34983. private _alphaTestSortCompareFn;
  34984. private _transparentSortCompareFn;
  34985. private _renderOpaque;
  34986. private _renderAlphaTest;
  34987. private _renderTransparent;
  34988. private _edgesRenderers;
  34989. onBeforeTransparentRendering: () => void;
  34990. /**
  34991. * Set the opaque sort comparison function.
  34992. * If null the sub meshes will be render in the order they were created
  34993. */
  34994. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34995. /**
  34996. * Set the alpha test sort comparison function.
  34997. * If null the sub meshes will be render in the order they were created
  34998. */
  34999. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35000. /**
  35001. * Set the transparent sort comparison function.
  35002. * If null the sub meshes will be render in the order they were created
  35003. */
  35004. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35005. /**
  35006. * Creates a new rendering group.
  35007. * @param index The rendering group index
  35008. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35009. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35010. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35011. */
  35012. 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>);
  35013. /**
  35014. * Render all the sub meshes contained in the group.
  35015. * @param customRenderFunction Used to override the default render behaviour of the group.
  35016. * @returns true if rendered some submeshes.
  35017. */
  35018. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35019. /**
  35020. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35021. * @param subMeshes The submeshes to render
  35022. */
  35023. private renderOpaqueSorted;
  35024. /**
  35025. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35026. * @param subMeshes The submeshes to render
  35027. */
  35028. private renderAlphaTestSorted;
  35029. /**
  35030. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35031. * @param subMeshes The submeshes to render
  35032. */
  35033. private renderTransparentSorted;
  35034. /**
  35035. * Renders the submeshes in a specified order.
  35036. * @param subMeshes The submeshes to sort before render
  35037. * @param sortCompareFn The comparison function use to sort
  35038. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35039. * @param transparent Specifies to activate blending if true
  35040. */
  35041. private static renderSorted;
  35042. /**
  35043. * Renders the submeshes in the order they were dispatched (no sort applied).
  35044. * @param subMeshes The submeshes to render
  35045. */
  35046. private static renderUnsorted;
  35047. /**
  35048. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35049. * are rendered back to front if in the same alpha index.
  35050. *
  35051. * @param a The first submesh
  35052. * @param b The second submesh
  35053. * @returns The result of the comparison
  35054. */
  35055. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35056. /**
  35057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35058. * are rendered back to front.
  35059. *
  35060. * @param a The first submesh
  35061. * @param b The second submesh
  35062. * @returns The result of the comparison
  35063. */
  35064. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  35065. /**
  35066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35067. * are rendered front to back (prevent overdraw).
  35068. *
  35069. * @param a The first submesh
  35070. * @param b The second submesh
  35071. * @returns The result of the comparison
  35072. */
  35073. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35074. /**
  35075. * Resets the different lists of submeshes to prepare a new frame.
  35076. */
  35077. prepare(): void;
  35078. dispose(): void;
  35079. /**
  35080. * Inserts the submesh in its correct queue depending on its material.
  35081. * @param subMesh The submesh to dispatch
  35082. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35083. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35084. */
  35085. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35086. dispatchSprites(spriteManager: ISpriteManager): void;
  35087. dispatchParticles(particleSystem: IParticleSystem): void;
  35088. private _renderParticles;
  35089. private _renderSprites;
  35090. }
  35091. }
  35092. declare module BABYLON {
  35093. /**
  35094. * Interface describing the different options available in the rendering manager
  35095. * regarding Auto Clear between groups.
  35096. */
  35097. interface IRenderingManagerAutoClearSetup {
  35098. /**
  35099. * Defines whether or not autoclear is enable.
  35100. */
  35101. autoClear: boolean;
  35102. /**
  35103. * Defines whether or not to autoclear the depth buffer.
  35104. */
  35105. depth: boolean;
  35106. /**
  35107. * Defines whether or not to autoclear the stencil buffer.
  35108. */
  35109. stencil: boolean;
  35110. }
  35111. /**
  35112. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35113. * It is enable to manage the different groups as well as the different necessary sort functions.
  35114. * This should not be used directly aside of the few static configurations
  35115. */
  35116. class RenderingManager {
  35117. /**
  35118. * The max id used for rendering groups (not included)
  35119. */
  35120. static MAX_RENDERINGGROUPS: number;
  35121. /**
  35122. * The min id used for rendering groups (included)
  35123. */
  35124. static MIN_RENDERINGGROUPS: number;
  35125. /**
  35126. * Used to globally prevent autoclearing scenes.
  35127. */
  35128. static AUTOCLEAR: boolean;
  35129. /**
  35130. * @hidden
  35131. */
  35132. _useSceneAutoClearSetup: boolean;
  35133. private _scene;
  35134. private _renderingGroups;
  35135. private _depthStencilBufferAlreadyCleaned;
  35136. private _autoClearDepthStencil;
  35137. private _customOpaqueSortCompareFn;
  35138. private _customAlphaTestSortCompareFn;
  35139. private _customTransparentSortCompareFn;
  35140. private _renderingGroupInfo;
  35141. /**
  35142. * Instantiates a new rendering group for a particular scene
  35143. * @param scene Defines the scene the groups belongs to
  35144. */
  35145. constructor(scene: Scene);
  35146. private _clearDepthStencilBuffer;
  35147. /**
  35148. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35149. * @hidden
  35150. */
  35151. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35152. /**
  35153. * Resets the different information of the group to prepare a new frame
  35154. * @hidden
  35155. */
  35156. reset(): void;
  35157. /**
  35158. * Dispose and release the group and its associated resources.
  35159. * @hidden
  35160. */
  35161. dispose(): void;
  35162. /**
  35163. * Clear the info related to rendering groups preventing retention points during dispose.
  35164. */
  35165. freeRenderingGroups(): void;
  35166. private _prepareRenderingGroup;
  35167. /**
  35168. * Add a sprite manager to the rendering manager in order to render it this frame.
  35169. * @param spriteManager Define the sprite manager to render
  35170. */
  35171. dispatchSprites(spriteManager: ISpriteManager): void;
  35172. /**
  35173. * Add a particle system to the rendering manager in order to render it this frame.
  35174. * @param particleSystem Define the particle system to render
  35175. */
  35176. dispatchParticles(particleSystem: IParticleSystem): void;
  35177. /**
  35178. * Add a submesh to the manager in order to render it this frame
  35179. * @param subMesh The submesh to dispatch
  35180. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35181. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35182. */
  35183. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35184. /**
  35185. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35186. * This allowed control for front to back rendering or reversly depending of the special needs.
  35187. *
  35188. * @param renderingGroupId The rendering group id corresponding to its index
  35189. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35190. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35191. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35192. */
  35193. 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;
  35194. /**
  35195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35196. *
  35197. * @param renderingGroupId The rendering group id corresponding to its index
  35198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35199. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35200. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35201. */
  35202. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35203. /**
  35204. * Gets the current auto clear configuration for one rendering group of the rendering
  35205. * manager.
  35206. * @param index the rendering group index to get the information for
  35207. * @returns The auto clear setup for the requested rendering group
  35208. */
  35209. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35210. }
  35211. }
  35212. declare module BABYLON {
  35213. /**
  35214. * Renders a layer on top of an existing scene
  35215. */
  35216. class UtilityLayerRenderer implements IDisposable {
  35217. /** the original scene that will be rendered on top of */
  35218. originalScene: Scene;
  35219. private _pointerCaptures;
  35220. private _lastPointerEvents;
  35221. private static _DefaultUtilityLayer;
  35222. private static _DefaultKeepDepthUtilityLayer;
  35223. /**
  35224. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35225. */
  35226. pickUtilitySceneFirst: boolean;
  35227. /**
  35228. * 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)
  35229. */
  35230. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35231. /**
  35232. * 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)
  35233. */
  35234. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35235. /**
  35236. * The scene that is rendered on top of the original scene
  35237. */
  35238. utilityLayerScene: Scene;
  35239. /**
  35240. * If the utility layer should automatically be rendered on top of existing scene
  35241. */
  35242. shouldRender: boolean;
  35243. /**
  35244. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35245. */
  35246. onlyCheckPointerDownEvents: boolean;
  35247. /**
  35248. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35249. */
  35250. processAllEvents: boolean;
  35251. /**
  35252. * Observable raised when the pointer move from the utility layer scene to the main scene
  35253. */
  35254. onPointerOutObservable: Observable<number>;
  35255. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35256. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35257. private _afterRenderObserver;
  35258. private _sceneDisposeObserver;
  35259. private _originalPointerObserver;
  35260. /**
  35261. * Instantiates a UtilityLayerRenderer
  35262. * @param originalScene the original scene that will be rendered on top of
  35263. */
  35264. constructor(
  35265. /** the original scene that will be rendered on top of */
  35266. originalScene: Scene);
  35267. private _notifyObservers;
  35268. /**
  35269. * Renders the utility layers scene on top of the original scene
  35270. */
  35271. render(): void;
  35272. /**
  35273. * Disposes of the renderer
  35274. */
  35275. dispose(): void;
  35276. private _updateCamera;
  35277. }
  35278. }
  35279. declare module BABYLON {
  35280. /**
  35281. * Class used to represent a sprite
  35282. * @see http://doc.babylonjs.com/babylon101/sprites
  35283. */
  35284. class Sprite {
  35285. /** defines the name */
  35286. name: string;
  35287. /** Gets or sets the current world position */
  35288. position: Vector3;
  35289. /** Gets or sets the main color */
  35290. color: Color4;
  35291. /** Gets or sets the width */
  35292. width: number;
  35293. /** Gets or sets the height */
  35294. height: number;
  35295. /** Gets or sets rotation angle */
  35296. angle: number;
  35297. /** Gets or sets the cell index in the sprite sheet */
  35298. cellIndex: number;
  35299. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35300. invertU: number;
  35301. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35302. invertV: number;
  35303. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35304. disposeWhenFinishedAnimating: boolean;
  35305. /** Gets the list of attached animations */
  35306. animations: Animation[];
  35307. /** Gets or sets a boolean indicating if the sprite can be picked */
  35308. isPickable: boolean;
  35309. /**
  35310. * Gets or sets the associated action manager
  35311. */
  35312. actionManager: Nullable<ActionManager>;
  35313. private _animationStarted;
  35314. private _loopAnimation;
  35315. private _fromIndex;
  35316. private _toIndex;
  35317. private _delay;
  35318. private _direction;
  35319. private _manager;
  35320. private _time;
  35321. private _onAnimationEnd;
  35322. /**
  35323. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35324. */
  35325. isVisible: boolean;
  35326. /**
  35327. * Gets or sets the sprite size
  35328. */
  35329. size: number;
  35330. /**
  35331. * Creates a new Sprite
  35332. * @param name defines the name
  35333. * @param manager defines the manager
  35334. */
  35335. constructor(
  35336. /** defines the name */
  35337. name: string, manager: ISpriteManager);
  35338. /**
  35339. * Starts an animation
  35340. * @param from defines the initial key
  35341. * @param to defines the end key
  35342. * @param loop defines if the animation must loop
  35343. * @param delay defines the start delay (in ms)
  35344. * @param onAnimationEnd defines a callback to call when animation ends
  35345. */
  35346. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35347. /** Stops current animation (if any) */
  35348. stopAnimation(): void;
  35349. /** @hidden */
  35350. _animate(deltaTime: number): void;
  35351. /** Release associated resources */
  35352. dispose(): void;
  35353. }
  35354. }
  35355. declare module BABYLON {
  35356. /**
  35357. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35358. */
  35359. interface ISpriteManager extends IDisposable {
  35360. /**
  35361. * Restricts the camera to viewing objects with the same layerMask.
  35362. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35363. */
  35364. layerMask: number;
  35365. /**
  35366. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35367. */
  35368. isPickable: boolean;
  35369. /**
  35370. * Specifies the rendering group id for this mesh (0 by default)
  35371. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35372. */
  35373. renderingGroupId: number;
  35374. /**
  35375. * Defines the list of sprites managed by the manager.
  35376. */
  35377. sprites: Array<Sprite>;
  35378. /**
  35379. * Tests the intersection of a sprite with a specific ray.
  35380. * @param ray The ray we are sending to test the collision
  35381. * @param camera The camera space we are sending rays in
  35382. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35383. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35384. * @returns picking info or null.
  35385. */
  35386. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35387. /**
  35388. * Renders the list of sprites on screen.
  35389. */
  35390. render(): void;
  35391. }
  35392. /**
  35393. * Class used to manage multiple sprites on the same spritesheet
  35394. * @see http://doc.babylonjs.com/babylon101/sprites
  35395. */
  35396. class SpriteManager implements ISpriteManager {
  35397. /** defines the manager's name */
  35398. name: string;
  35399. /** Gets the list of sprites */
  35400. sprites: Sprite[];
  35401. /** Gets or sets the rendering group id (0 by default) */
  35402. renderingGroupId: number;
  35403. /** Gets or sets camera layer mask */
  35404. layerMask: number;
  35405. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35406. fogEnabled: boolean;
  35407. /** Gets or sets a boolean indicating if the sprites are pickable */
  35408. isPickable: boolean;
  35409. /** Defines the default width of a cell in the spritesheet */
  35410. cellWidth: number;
  35411. /** Defines the default height of a cell in the spritesheet */
  35412. cellHeight: number;
  35413. /**
  35414. * An event triggered when the manager is disposed.
  35415. */
  35416. onDisposeObservable: Observable<SpriteManager>;
  35417. private _onDisposeObserver;
  35418. /**
  35419. * Callback called when the manager is disposed
  35420. */
  35421. onDispose: () => void;
  35422. private _capacity;
  35423. private _spriteTexture;
  35424. private _epsilon;
  35425. private _scene;
  35426. private _vertexData;
  35427. private _buffer;
  35428. private _vertexBuffers;
  35429. private _indexBuffer;
  35430. private _effectBase;
  35431. private _effectFog;
  35432. /**
  35433. * Gets or sets the spritesheet texture
  35434. */
  35435. texture: Texture;
  35436. /**
  35437. * Creates a new sprite manager
  35438. * @param name defines the manager's name
  35439. * @param imgUrl defines the sprite sheet url
  35440. * @param capacity defines the maximum allowed number of sprites
  35441. * @param cellSize defines the size of a sprite cell
  35442. * @param scene defines the hosting scene
  35443. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35444. * @param samplingMode defines the smapling mode to use with spritesheet
  35445. */
  35446. constructor(
  35447. /** defines the manager's name */
  35448. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35449. private _appendSpriteVertex;
  35450. /**
  35451. * Intersects the sprites with a ray
  35452. * @param ray defines the ray to intersect with
  35453. * @param camera defines the current active camera
  35454. * @param predicate defines a predicate used to select candidate sprites
  35455. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35456. * @returns null if no hit or a PickingInfo
  35457. */
  35458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35459. /**
  35460. * Render all child sprites
  35461. */
  35462. render(): void;
  35463. /**
  35464. * Release associated resources
  35465. */
  35466. dispose(): void;
  35467. }
  35468. }
  35469. declare module BABYLON {
  35470. interface Scene {
  35471. /** @hidden */
  35472. _pointerOverSprite: Nullable<Sprite>;
  35473. /** @hidden */
  35474. _pickedDownSprite: Nullable<Sprite>;
  35475. /** @hidden */
  35476. _tempSpritePickingRay: Nullable<Ray>;
  35477. /**
  35478. * All of the sprite managers added to this scene
  35479. * @see http://doc.babylonjs.com/babylon101/sprites
  35480. */
  35481. spriteManagers: Array<ISpriteManager>;
  35482. /**
  35483. * An event triggered when sprites rendering is about to start
  35484. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35485. */
  35486. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35487. /**
  35488. * An event triggered when sprites rendering is done
  35489. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35490. */
  35491. onAfterSpritesRenderingObservable: Observable<Scene>;
  35492. /** @hidden */
  35493. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35494. /** Launch a ray to try to pick a sprite in the scene
  35495. * @param x position on screen
  35496. * @param y position on screen
  35497. * @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
  35498. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35499. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35500. * @returns a PickingInfo
  35501. */
  35502. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35503. /** Use the given ray to pick a sprite in the scene
  35504. * @param ray The ray (in world space) to use to pick meshes
  35505. * @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
  35506. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35507. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35508. * @returns a PickingInfo
  35509. */
  35510. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35511. /**
  35512. * Force the sprite under the pointer
  35513. * @param sprite defines the sprite to use
  35514. */
  35515. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35516. /**
  35517. * Gets the sprite under the pointer
  35518. * @returns a Sprite or null if no sprite is under the pointer
  35519. */
  35520. getPointerOverSprite(): Nullable<Sprite>;
  35521. }
  35522. /**
  35523. * Defines the sprite scene component responsible to manage sprites
  35524. * in a given scene.
  35525. */
  35526. class SpriteSceneComponent implements ISceneComponent {
  35527. /**
  35528. * The component name helpfull to identify the component in the list of scene components.
  35529. */
  35530. readonly name: string;
  35531. /**
  35532. * The scene the component belongs to.
  35533. */
  35534. scene: Scene;
  35535. /** @hidden */
  35536. private _spritePredicate;
  35537. /**
  35538. * Creates a new instance of the component for the given scene
  35539. * @param scene Defines the scene to register the component in
  35540. */
  35541. constructor(scene: Scene);
  35542. /**
  35543. * Registers the component in a given scene
  35544. */
  35545. register(): void;
  35546. /**
  35547. * Rebuilds the elements related to this component in case of
  35548. * context lost for instance.
  35549. */
  35550. rebuild(): void;
  35551. /**
  35552. * Disposes the component and the associated ressources.
  35553. */
  35554. dispose(): void;
  35555. private _pickSpriteButKeepRay;
  35556. private _pointerMove;
  35557. private _pointerDown;
  35558. private _pointerUp;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. /**
  35563. * @hidden
  35564. **/
  35565. class _AlphaState {
  35566. private _isAlphaBlendDirty;
  35567. private _isBlendFunctionParametersDirty;
  35568. private _isBlendEquationParametersDirty;
  35569. private _isBlendConstantsDirty;
  35570. private _alphaBlend;
  35571. private _blendFunctionParameters;
  35572. private _blendEquationParameters;
  35573. private _blendConstants;
  35574. /**
  35575. * Initializes the state.
  35576. */
  35577. constructor();
  35578. readonly isDirty: boolean;
  35579. alphaBlend: boolean;
  35580. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35581. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35582. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35583. reset(): void;
  35584. apply(gl: WebGLRenderingContext): void;
  35585. }
  35586. }
  35587. declare module BABYLON {
  35588. /**
  35589. * @hidden
  35590. **/
  35591. class _DepthCullingState {
  35592. private _isDepthTestDirty;
  35593. private _isDepthMaskDirty;
  35594. private _isDepthFuncDirty;
  35595. private _isCullFaceDirty;
  35596. private _isCullDirty;
  35597. private _isZOffsetDirty;
  35598. private _isFrontFaceDirty;
  35599. private _depthTest;
  35600. private _depthMask;
  35601. private _depthFunc;
  35602. private _cull;
  35603. private _cullFace;
  35604. private _zOffset;
  35605. private _frontFace;
  35606. /**
  35607. * Initializes the state.
  35608. */
  35609. constructor();
  35610. readonly isDirty: boolean;
  35611. zOffset: number;
  35612. cullFace: Nullable<number>;
  35613. cull: Nullable<boolean>;
  35614. depthFunc: Nullable<number>;
  35615. depthMask: boolean;
  35616. depthTest: boolean;
  35617. frontFace: Nullable<number>;
  35618. reset(): void;
  35619. apply(gl: WebGLRenderingContext): void;
  35620. }
  35621. }
  35622. declare module BABYLON {
  35623. /**
  35624. * @hidden
  35625. **/
  35626. class _StencilState {
  35627. private _isStencilTestDirty;
  35628. private _isStencilMaskDirty;
  35629. private _isStencilFuncDirty;
  35630. private _isStencilOpDirty;
  35631. private _stencilTest;
  35632. private _stencilMask;
  35633. private _stencilFunc;
  35634. private _stencilFuncRef;
  35635. private _stencilFuncMask;
  35636. private _stencilOpStencilFail;
  35637. private _stencilOpDepthFail;
  35638. private _stencilOpStencilDepthPass;
  35639. readonly isDirty: boolean;
  35640. stencilFunc: number;
  35641. stencilFuncRef: number;
  35642. stencilFuncMask: number;
  35643. stencilOpStencilFail: number;
  35644. stencilOpDepthFail: number;
  35645. stencilOpStencilDepthPass: number;
  35646. stencilMask: number;
  35647. stencilTest: boolean;
  35648. constructor();
  35649. reset(): void;
  35650. apply(gl: WebGLRenderingContext): void;
  35651. }
  35652. }
  35653. declare module BABYLON {
  35654. /**
  35655. * Postprocess used to generate anaglyphic rendering
  35656. */
  35657. class AnaglyphPostProcess extends PostProcess {
  35658. private _passedProcess;
  35659. /**
  35660. * Creates a new AnaglyphPostProcess
  35661. * @param name defines postprocess name
  35662. * @param options defines creation options or target ratio scale
  35663. * @param rigCameras defines cameras using this postprocess
  35664. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35665. * @param engine defines hosting engine
  35666. * @param reusable defines if the postprocess will be reused multiple times per frame
  35667. */
  35668. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35669. }
  35670. }
  35671. declare module BABYLON {
  35672. /**
  35673. * Post process used to render in black and white
  35674. */
  35675. class BlackAndWhitePostProcess extends PostProcess {
  35676. /**
  35677. * Linear about to convert he result to black and white (default: 1)
  35678. */
  35679. degree: number;
  35680. /**
  35681. * Creates a black and white post process
  35682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35683. * @param name The name of the effect.
  35684. * @param options The required width/height ratio to downsize to before computing the render pass.
  35685. * @param camera The camera to apply the render pass to.
  35686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35687. * @param engine The engine which the post process will be applied. (default: current engine)
  35688. * @param reusable If the post process can be reused on the same frame. (default: false)
  35689. */
  35690. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35691. }
  35692. }
  35693. declare module BABYLON {
  35694. /**
  35695. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35696. */
  35697. class BloomEffect extends PostProcessRenderEffect {
  35698. private bloomScale;
  35699. /**
  35700. * @hidden Internal
  35701. */
  35702. _effects: Array<PostProcess>;
  35703. /**
  35704. * @hidden Internal
  35705. */
  35706. _downscale: ExtractHighlightsPostProcess;
  35707. private _blurX;
  35708. private _blurY;
  35709. private _merge;
  35710. /**
  35711. * The luminance threshold to find bright areas of the image to bloom.
  35712. */
  35713. threshold: number;
  35714. /**
  35715. * The strength of the bloom.
  35716. */
  35717. weight: number;
  35718. /**
  35719. * Specifies the size of the bloom blur kernel, relative to the final output size
  35720. */
  35721. kernel: number;
  35722. /**
  35723. * Creates a new instance of @see BloomEffect
  35724. * @param scene The scene the effect belongs to.
  35725. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35726. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35727. * @param bloomWeight The the strength of bloom.
  35728. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35729. * @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)
  35730. */
  35731. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35732. /**
  35733. * Disposes each of the internal effects for a given camera.
  35734. * @param camera The camera to dispose the effect on.
  35735. */
  35736. disposeEffects(camera: Camera): void;
  35737. /**
  35738. * @hidden Internal
  35739. */
  35740. _updateEffects(): void;
  35741. /**
  35742. * Internal
  35743. * @returns if all the contained post processes are ready.
  35744. * @hidden
  35745. */
  35746. _isReady(): boolean;
  35747. }
  35748. }
  35749. declare module BABYLON {
  35750. /**
  35751. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35752. */
  35753. class BloomMergePostProcess extends PostProcess {
  35754. /** Weight of the bloom to be added to the original input. */
  35755. weight: number;
  35756. /**
  35757. * Creates a new instance of @see BloomMergePostProcess
  35758. * @param name The name of the effect.
  35759. * @param originalFromInput Post process which's input will be used for the merge.
  35760. * @param blurred Blurred highlights post process which's output will be used.
  35761. * @param weight Weight of the bloom to be added to the original input.
  35762. * @param options The required width/height ratio to downsize to before computing the render pass.
  35763. * @param camera The camera to apply the render pass to.
  35764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35765. * @param engine The engine which the post process will be applied. (default: current engine)
  35766. * @param reusable If the post process can be reused on the same frame. (default: false)
  35767. * @param textureType Type of textures used when performing the post process. (default: 0)
  35768. * @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)
  35769. */
  35770. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35771. /** Weight of the bloom to be added to the original input. */
  35772. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35773. }
  35774. }
  35775. declare module BABYLON {
  35776. /**
  35777. * The Blur Post Process which blurs an image based on a kernel and direction.
  35778. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35779. */
  35780. class BlurPostProcess extends PostProcess {
  35781. /** The direction in which to blur the image. */
  35782. direction: Vector2;
  35783. private blockCompilation;
  35784. protected _kernel: number;
  35785. protected _idealKernel: number;
  35786. protected _packedFloat: boolean;
  35787. private _staticDefines;
  35788. /**
  35789. * Sets the length in pixels of the blur sample region
  35790. */
  35791. /**
  35792. * Gets the length in pixels of the blur sample region
  35793. */
  35794. kernel: number;
  35795. /**
  35796. * Sets wether or not the blur needs to unpack/repack floats
  35797. */
  35798. /**
  35799. * Gets wether or not the blur is unpacking/repacking floats
  35800. */
  35801. packedFloat: boolean;
  35802. /**
  35803. * Creates a new instance BlurPostProcess
  35804. * @param name The name of the effect.
  35805. * @param direction The direction in which to blur the image.
  35806. * @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.
  35807. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35808. * @param camera The camera to apply the render pass to.
  35809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35810. * @param engine The engine which the post process will be applied. (default: current engine)
  35811. * @param reusable If the post process can be reused on the same frame. (default: false)
  35812. * @param textureType Type of textures used when performing the post process. (default: 0)
  35813. * @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)
  35814. */
  35815. constructor(name: string,
  35816. /** The direction in which to blur the image. */
  35817. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35818. /**
  35819. * Updates the effect with the current post process compile time values and recompiles the shader.
  35820. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35821. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35822. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35823. * @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
  35824. * @param onCompiled Called when the shader has been compiled.
  35825. * @param onError Called if there is an error when compiling a shader.
  35826. */
  35827. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35828. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35829. /**
  35830. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35831. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35832. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35833. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35834. * The gaps between physical kernels are compensated for in the weighting of the samples
  35835. * @param idealKernel Ideal blur kernel.
  35836. * @return Nearest best kernel.
  35837. */
  35838. protected _nearestBestKernel(idealKernel: number): number;
  35839. /**
  35840. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35841. * @param x The point on the Gaussian distribution to sample.
  35842. * @return the value of the Gaussian function at x.
  35843. */
  35844. protected _gaussianWeight(x: number): number;
  35845. /**
  35846. * Generates a string that can be used as a floating point number in GLSL.
  35847. * @param x Value to print.
  35848. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35849. * @return GLSL float string.
  35850. */
  35851. protected _glslFloat(x: number, decimalFigures?: number): string;
  35852. }
  35853. }
  35854. declare module BABYLON {
  35855. /**
  35856. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35857. */
  35858. class ChromaticAberrationPostProcess extends PostProcess {
  35859. /**
  35860. * The amount of seperation of rgb channels (default: 30)
  35861. */
  35862. aberrationAmount: number;
  35863. /**
  35864. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35865. */
  35866. radialIntensity: number;
  35867. /**
  35868. * 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))
  35869. */
  35870. direction: Vector2;
  35871. /**
  35872. * 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))
  35873. */
  35874. centerPosition: Vector2;
  35875. /**
  35876. * Creates a new instance ChromaticAberrationPostProcess
  35877. * @param name The name of the effect.
  35878. * @param screenWidth The width of the screen to apply the effect on.
  35879. * @param screenHeight The height of the screen to apply the effect on.
  35880. * @param options The required width/height ratio to downsize to before computing the render pass.
  35881. * @param camera The camera to apply the render pass to.
  35882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35883. * @param engine The engine which the post process will be applied. (default: current engine)
  35884. * @param reusable If the post process can be reused on the same frame. (default: false)
  35885. * @param textureType Type of textures used when performing the post process. (default: 0)
  35886. * @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)
  35887. */
  35888. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35889. }
  35890. }
  35891. declare module BABYLON {
  35892. /**
  35893. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35894. */
  35895. class CircleOfConfusionPostProcess extends PostProcess {
  35896. /**
  35897. * 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.
  35898. */
  35899. lensSize: number;
  35900. /**
  35901. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35902. */
  35903. fStop: number;
  35904. /**
  35905. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35906. */
  35907. focusDistance: number;
  35908. /**
  35909. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35910. */
  35911. focalLength: number;
  35912. private _depthTexture;
  35913. /**
  35914. * Creates a new instance CircleOfConfusionPostProcess
  35915. * @param name The name of the effect.
  35916. * @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.
  35917. * @param options The required width/height ratio to downsize to before computing the render pass.
  35918. * @param camera The camera to apply the render pass to.
  35919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35920. * @param engine The engine which the post process will be applied. (default: current engine)
  35921. * @param reusable If the post process can be reused on the same frame. (default: false)
  35922. * @param textureType Type of textures used when performing the post process. (default: 0)
  35923. * @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)
  35924. */
  35925. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35926. /**
  35927. * 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.
  35928. */
  35929. depthTexture: RenderTargetTexture;
  35930. }
  35931. }
  35932. declare module BABYLON {
  35933. /**
  35934. *
  35935. * This post-process allows the modification of rendered colors by using
  35936. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35937. *
  35938. * The object needs to be provided an url to a texture containing the color
  35939. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35940. * Use an image editing software to tweak the LUT to match your needs.
  35941. *
  35942. * For an example of a color LUT, see here:
  35943. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35944. * For explanations on color grading, see here:
  35945. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35946. *
  35947. */
  35948. class ColorCorrectionPostProcess extends PostProcess {
  35949. private _colorTableTexture;
  35950. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35951. }
  35952. }
  35953. declare module BABYLON {
  35954. /**
  35955. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35956. * input texture to perform effects such as edge detection or sharpening
  35957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35958. */
  35959. class ConvolutionPostProcess extends PostProcess {
  35960. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35961. kernel: number[];
  35962. /**
  35963. * Creates a new instance ConvolutionPostProcess
  35964. * @param name The name of the effect.
  35965. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35966. * @param options The required width/height ratio to downsize to before computing the render pass.
  35967. * @param camera The camera to apply the render pass to.
  35968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35969. * @param engine The engine which the post process will be applied. (default: current engine)
  35970. * @param reusable If the post process can be reused on the same frame. (default: false)
  35971. * @param textureType Type of textures used when performing the post process. (default: 0)
  35972. */
  35973. constructor(name: string,
  35974. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35975. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35976. /**
  35977. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35978. */
  35979. static EdgeDetect0Kernel: number[];
  35980. /**
  35981. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35982. */
  35983. static EdgeDetect1Kernel: number[];
  35984. /**
  35985. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35986. */
  35987. static EdgeDetect2Kernel: number[];
  35988. /**
  35989. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35990. */
  35991. static SharpenKernel: number[];
  35992. /**
  35993. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35994. */
  35995. static EmbossKernel: number[];
  35996. /**
  35997. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35998. */
  35999. static GaussianKernel: number[];
  36000. }
  36001. }
  36002. declare module BABYLON {
  36003. /**
  36004. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  36005. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  36006. * based on samples that have a large difference in distance than the center pixel.
  36007. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  36008. */
  36009. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  36010. direction: Vector2;
  36011. /**
  36012. * Creates a new instance CircleOfConfusionPostProcess
  36013. * @param name The name of the effect.
  36014. * @param scene The scene the effect belongs to.
  36015. * @param direction The direction the blur should be applied.
  36016. * @param kernel The size of the kernel used to blur.
  36017. * @param options The required width/height ratio to downsize to before computing the render pass.
  36018. * @param camera The camera to apply the render pass to.
  36019. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  36020. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  36021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36022. * @param engine The engine which the post process will be applied. (default: current engine)
  36023. * @param reusable If the post process can be reused on the same frame. (default: false)
  36024. * @param textureType Type of textures used when performing the post process. (default: 0)
  36025. * @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)
  36026. */
  36027. 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);
  36028. }
  36029. }
  36030. declare module BABYLON {
  36031. /**
  36032. * Specifies the level of max blur that should be applied when using the depth of field effect
  36033. */
  36034. enum DepthOfFieldEffectBlurLevel {
  36035. /**
  36036. * Subtle blur
  36037. */
  36038. Low = 0,
  36039. /**
  36040. * Medium blur
  36041. */
  36042. Medium = 1,
  36043. /**
  36044. * Large blur
  36045. */
  36046. High = 2
  36047. }
  36048. /**
  36049. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  36050. */
  36051. class DepthOfFieldEffect extends PostProcessRenderEffect {
  36052. private _circleOfConfusion;
  36053. /**
  36054. * @hidden Internal, blurs from high to low
  36055. */
  36056. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  36057. private _depthOfFieldBlurY;
  36058. private _dofMerge;
  36059. /**
  36060. * @hidden Internal post processes in depth of field effect
  36061. */
  36062. _effects: Array<PostProcess>;
  36063. /**
  36064. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  36065. */
  36066. focalLength: number;
  36067. /**
  36068. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  36069. */
  36070. fStop: number;
  36071. /**
  36072. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  36073. */
  36074. focusDistance: number;
  36075. /**
  36076. * 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.
  36077. */
  36078. lensSize: number;
  36079. /**
  36080. * Creates a new instance DepthOfFieldEffect
  36081. * @param scene The scene the effect belongs to.
  36082. * @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.
  36083. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  36084. * @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)
  36085. */
  36086. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  36087. /**
  36088. * 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.
  36089. */
  36090. depthTexture: RenderTargetTexture;
  36091. /**
  36092. * Disposes each of the internal effects for a given camera.
  36093. * @param camera The camera to dispose the effect on.
  36094. */
  36095. disposeEffects(camera: Camera): void;
  36096. /**
  36097. * @hidden Internal
  36098. */
  36099. _updateEffects(): void;
  36100. /**
  36101. * Internal
  36102. * @returns if all the contained post processes are ready.
  36103. * @hidden
  36104. */
  36105. _isReady(): boolean;
  36106. }
  36107. }
  36108. declare module BABYLON {
  36109. /**
  36110. * Options to be set when merging outputs from the default pipeline.
  36111. */
  36112. class DepthOfFieldMergePostProcessOptions {
  36113. /**
  36114. * The original image to merge on top of
  36115. */
  36116. originalFromInput: PostProcess;
  36117. /**
  36118. * Parameters to perform the merge of the depth of field effect
  36119. */
  36120. depthOfField?: {
  36121. circleOfConfusion: PostProcess;
  36122. blurSteps: Array<PostProcess>;
  36123. };
  36124. /**
  36125. * Parameters to perform the merge of bloom effect
  36126. */
  36127. bloom?: {
  36128. blurred: PostProcess;
  36129. weight: number;
  36130. };
  36131. }
  36132. /**
  36133. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  36134. */
  36135. class DepthOfFieldMergePostProcess extends PostProcess {
  36136. private blurSteps;
  36137. /**
  36138. * Creates a new instance of DepthOfFieldMergePostProcess
  36139. * @param name The name of the effect.
  36140. * @param originalFromInput Post process which's input will be used for the merge.
  36141. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  36142. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  36143. * @param options The required width/height ratio to downsize to before computing the render pass.
  36144. * @param camera The camera to apply the render pass to.
  36145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36146. * @param engine The engine which the post process will be applied. (default: current engine)
  36147. * @param reusable If the post process can be reused on the same frame. (default: false)
  36148. * @param textureType Type of textures used when performing the post process. (default: 0)
  36149. * @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)
  36150. */
  36151. 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);
  36152. /**
  36153. * Updates the effect with the current post process compile time values and recompiles the shader.
  36154. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36155. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36156. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36157. * @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
  36158. * @param onCompiled Called when the shader has been compiled.
  36159. * @param onError Called if there is an error when compiling a shader.
  36160. */
  36161. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36162. }
  36163. }
  36164. declare module BABYLON {
  36165. /**
  36166. * DisplayPassPostProcess which produces an output the same as it's input
  36167. */
  36168. class DisplayPassPostProcess extends PostProcess {
  36169. /**
  36170. * Creates the DisplayPassPostProcess
  36171. * @param name The name of the effect.
  36172. * @param options The required width/height ratio to downsize to before computing the render pass.
  36173. * @param camera The camera to apply the render pass to.
  36174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36175. * @param engine The engine which the post process will be applied. (default: current engine)
  36176. * @param reusable If the post process can be reused on the same frame. (default: false)
  36177. */
  36178. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36179. }
  36180. }
  36181. declare module BABYLON {
  36182. /**
  36183. * 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.
  36184. */
  36185. class ExtractHighlightsPostProcess extends PostProcess {
  36186. /**
  36187. * The luminance threshold, pixels below this value will be set to black.
  36188. */
  36189. threshold: number;
  36190. /** @hidden */
  36191. _exposure: number;
  36192. /**
  36193. * Post process which has the input texture to be used when performing highlight extraction
  36194. * @hidden
  36195. */
  36196. _inputPostProcess: Nullable<PostProcess>;
  36197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36198. }
  36199. }
  36200. declare module BABYLON {
  36201. /**
  36202. * Applies a kernel filter to the image
  36203. */
  36204. class FilterPostProcess extends PostProcess {
  36205. /** The matrix to be applied to the image */
  36206. kernelMatrix: Matrix;
  36207. /**
  36208. *
  36209. * @param name The name of the effect.
  36210. * @param kernelMatrix The matrix to be applied to the image
  36211. * @param options The required width/height ratio to downsize to before computing the render pass.
  36212. * @param camera The camera to apply the render pass to.
  36213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36214. * @param engine The engine which the post process will be applied. (default: current engine)
  36215. * @param reusable If the post process can be reused on the same frame. (default: false)
  36216. */
  36217. constructor(name: string,
  36218. /** The matrix to be applied to the image */
  36219. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36220. }
  36221. }
  36222. declare module BABYLON {
  36223. /**
  36224. * Fxaa post process
  36225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  36226. */
  36227. class FxaaPostProcess extends PostProcess {
  36228. /** @hidden */
  36229. texelWidth: number;
  36230. /** @hidden */
  36231. texelHeight: number;
  36232. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36233. private _getDefines;
  36234. }
  36235. }
  36236. declare module BABYLON {
  36237. /**
  36238. * The GrainPostProcess adds noise to the image at mid luminance levels
  36239. */
  36240. class GrainPostProcess extends PostProcess {
  36241. /**
  36242. * The intensity of the grain added (default: 30)
  36243. */
  36244. intensity: number;
  36245. /**
  36246. * If the grain should be randomized on every frame
  36247. */
  36248. animated: boolean;
  36249. /**
  36250. * Creates a new instance of @see GrainPostProcess
  36251. * @param name The name of the effect.
  36252. * @param options The required width/height ratio to downsize to before computing the render pass.
  36253. * @param camera The camera to apply the render pass to.
  36254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36255. * @param engine The engine which the post process will be applied. (default: current engine)
  36256. * @param reusable If the post process can be reused on the same frame. (default: false)
  36257. * @param textureType Type of textures used when performing the post process. (default: 0)
  36258. * @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)
  36259. */
  36260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36261. }
  36262. }
  36263. declare module BABYLON {
  36264. /**
  36265. * Extracts highlights from the image
  36266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36267. */
  36268. class HighlightsPostProcess extends PostProcess {
  36269. /**
  36270. * Extracts highlights from the image
  36271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36272. * @param name The name of the effect.
  36273. * @param options The required width/height ratio to downsize to before computing the render pass.
  36274. * @param camera The camera to apply the render pass to.
  36275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36276. * @param engine The engine which the post process will be applied. (default: current engine)
  36277. * @param reusable If the post process can be reused on the same frame. (default: false)
  36278. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  36279. */
  36280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  36281. }
  36282. }
  36283. declare module BABYLON {
  36284. /**
  36285. * ImageProcessingPostProcess
  36286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  36287. */
  36288. class ImageProcessingPostProcess extends PostProcess {
  36289. /**
  36290. * Default configuration related to image processing available in the PBR Material.
  36291. */
  36292. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36293. /**
  36294. * Gets the image processing configuration used either in this material.
  36295. */
  36296. /**
  36297. * Sets the Default image processing configuration used either in the this material.
  36298. *
  36299. * If sets to null, the scene one is in use.
  36300. */
  36301. imageProcessingConfiguration: ImageProcessingConfiguration;
  36302. /**
  36303. * Keep track of the image processing observer to allow dispose and replace.
  36304. */
  36305. private _imageProcessingObserver;
  36306. /**
  36307. * Attaches a new image processing configuration to the PBR Material.
  36308. * @param configuration
  36309. */
  36310. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  36311. /**
  36312. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36313. */
  36314. /**
  36315. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  36316. */
  36317. colorCurves: Nullable<ColorCurves>;
  36318. /**
  36319. * Gets wether the color curves effect is enabled.
  36320. */
  36321. /**
  36322. * Sets wether the color curves effect is enabled.
  36323. */
  36324. colorCurvesEnabled: boolean;
  36325. /**
  36326. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36327. */
  36328. /**
  36329. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  36330. */
  36331. colorGradingTexture: Nullable<BaseTexture>;
  36332. /**
  36333. * Gets wether the color grading effect is enabled.
  36334. */
  36335. /**
  36336. * Gets wether the color grading effect is enabled.
  36337. */
  36338. colorGradingEnabled: boolean;
  36339. /**
  36340. * Gets exposure used in the effect.
  36341. */
  36342. /**
  36343. * Sets exposure used in the effect.
  36344. */
  36345. exposure: number;
  36346. /**
  36347. * Gets wether tonemapping is enabled or not.
  36348. */
  36349. /**
  36350. * Sets wether tonemapping is enabled or not
  36351. */
  36352. toneMappingEnabled: boolean;
  36353. /**
  36354. * Gets contrast used in the effect.
  36355. */
  36356. /**
  36357. * Sets contrast used in the effect.
  36358. */
  36359. contrast: number;
  36360. /**
  36361. * Gets Vignette stretch size.
  36362. */
  36363. /**
  36364. * Sets Vignette stretch size.
  36365. */
  36366. vignetteStretch: number;
  36367. /**
  36368. * Gets Vignette centre X Offset.
  36369. */
  36370. /**
  36371. * Sets Vignette centre X Offset.
  36372. */
  36373. vignetteCentreX: number;
  36374. /**
  36375. * Gets Vignette centre Y Offset.
  36376. */
  36377. /**
  36378. * Sets Vignette centre Y Offset.
  36379. */
  36380. vignetteCentreY: number;
  36381. /**
  36382. * Gets Vignette weight or intensity of the vignette effect.
  36383. */
  36384. /**
  36385. * Sets Vignette weight or intensity of the vignette effect.
  36386. */
  36387. vignetteWeight: number;
  36388. /**
  36389. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36390. * if vignetteEnabled is set to true.
  36391. */
  36392. /**
  36393. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  36394. * if vignetteEnabled is set to true.
  36395. */
  36396. vignetteColor: Color4;
  36397. /**
  36398. * Gets Camera field of view used by the Vignette effect.
  36399. */
  36400. /**
  36401. * Sets Camera field of view used by the Vignette effect.
  36402. */
  36403. vignetteCameraFov: number;
  36404. /**
  36405. * Gets the vignette blend mode allowing different kind of effect.
  36406. */
  36407. /**
  36408. * Sets the vignette blend mode allowing different kind of effect.
  36409. */
  36410. vignetteBlendMode: number;
  36411. /**
  36412. * Gets wether the vignette effect is enabled.
  36413. */
  36414. /**
  36415. * Sets wether the vignette effect is enabled.
  36416. */
  36417. vignetteEnabled: boolean;
  36418. private _fromLinearSpace;
  36419. /**
  36420. * Gets wether the input of the processing is in Gamma or Linear Space.
  36421. */
  36422. /**
  36423. * Sets wether the input of the processing is in Gamma or Linear Space.
  36424. */
  36425. fromLinearSpace: boolean;
  36426. /**
  36427. * Defines cache preventing GC.
  36428. */
  36429. private _defines;
  36430. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  36431. /**
  36432. * "ImageProcessingPostProcess"
  36433. * @returns "ImageProcessingPostProcess"
  36434. */
  36435. getClassName(): string;
  36436. protected _updateParameters(): void;
  36437. dispose(camera?: Camera): void;
  36438. }
  36439. }
  36440. declare module BABYLON {
  36441. /**
  36442. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  36443. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  36444. * As an example, all you have to do is to create the post-process:
  36445. * var mb = new BABYLON.MotionBlurPostProcess(
  36446. * 'mb', // The name of the effect.
  36447. * scene, // The scene containing the objects to blur according to their velocity.
  36448. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36449. * camera // The camera to apply the render pass to.
  36450. * );
  36451. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36452. */
  36453. class MotionBlurPostProcess extends PostProcess {
  36454. /**
  36455. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36456. */
  36457. motionStrength: number;
  36458. /**
  36459. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36460. */
  36461. /**
  36462. * Sets the number of iterations to be used for motion blur quality
  36463. */
  36464. motionBlurSamples: number;
  36465. private _motionBlurSamples;
  36466. private _geometryBufferRenderer;
  36467. /**
  36468. * Creates a new instance MotionBlurPostProcess
  36469. * @param name The name of the effect.
  36470. * @param scene The scene containing the objects to blur according to their velocity.
  36471. * @param options The required width/height ratio to downsize to before computing the render pass.
  36472. * @param camera The camera to apply the render pass to.
  36473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36474. * @param engine The engine which the post process will be applied. (default: current engine)
  36475. * @param reusable If the post process can be reused on the same frame. (default: false)
  36476. * @param textureType Type of textures used when performing the post process. (default: 0)
  36477. * @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)
  36478. */
  36479. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36480. /**
  36481. * Disposes the post process.
  36482. * @param camera The camera to dispose the post process on.
  36483. */
  36484. dispose(camera?: Camera): void;
  36485. }
  36486. }
  36487. declare module BABYLON {
  36488. /**
  36489. * PassPostProcess which produces an output the same as it's input
  36490. */
  36491. class PassPostProcess extends PostProcess {
  36492. /**
  36493. * Creates the PassPostProcess
  36494. * @param name The name of the effect.
  36495. * @param options The required width/height ratio to downsize to before computing the render pass.
  36496. * @param camera The camera to apply the render pass to.
  36497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36498. * @param engine The engine which the post process will be applied. (default: current engine)
  36499. * @param reusable If the post process can be reused on the same frame. (default: false)
  36500. * @param textureType The type of texture to be used when performing the post processing.
  36501. * @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)
  36502. */
  36503. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36504. }
  36505. /**
  36506. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36507. */
  36508. class PassCubePostProcess extends PostProcess {
  36509. private _face;
  36510. /**
  36511. * Gets or sets the cube face to display.
  36512. * * 0 is +X
  36513. * * 1 is -X
  36514. * * 2 is +Y
  36515. * * 3 is -Y
  36516. * * 4 is +Z
  36517. * * 5 is -Z
  36518. */
  36519. face: number;
  36520. /**
  36521. * Creates the PassCubePostProcess
  36522. * @param name The name of the effect.
  36523. * @param options The required width/height ratio to downsize to before computing the render pass.
  36524. * @param camera The camera to apply the render pass to.
  36525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36526. * @param engine The engine which the post process will be applied. (default: current engine)
  36527. * @param reusable If the post process can be reused on the same frame. (default: false)
  36528. * @param textureType The type of texture to be used when performing the post processing.
  36529. * @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)
  36530. */
  36531. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36532. }
  36533. }
  36534. declare module BABYLON {
  36535. /**
  36536. * Size options for a post process
  36537. */
  36538. type PostProcessOptions = {
  36539. width: number;
  36540. height: number;
  36541. };
  36542. /**
  36543. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36544. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36545. */
  36546. class PostProcess {
  36547. /** Name of the PostProcess. */
  36548. name: string;
  36549. /**
  36550. * Width of the texture to apply the post process on
  36551. */
  36552. width: number;
  36553. /**
  36554. * Height of the texture to apply the post process on
  36555. */
  36556. height: number;
  36557. /**
  36558. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36559. * @hidden
  36560. */
  36561. _outputTexture: Nullable<InternalTexture>;
  36562. /**
  36563. * Sampling mode used by the shader
  36564. * See https://doc.babylonjs.com/classes/3.1/texture
  36565. */
  36566. renderTargetSamplingMode: number;
  36567. /**
  36568. * Clear color to use when screen clearing
  36569. */
  36570. clearColor: Color4;
  36571. /**
  36572. * If the buffer needs to be cleared before applying the post process. (default: true)
  36573. * Should be set to false if shader will overwrite all previous pixels.
  36574. */
  36575. autoClear: boolean;
  36576. /**
  36577. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36578. */
  36579. alphaMode: number;
  36580. /**
  36581. * Sets the setAlphaBlendConstants of the babylon engine
  36582. */
  36583. alphaConstants: Color4;
  36584. /**
  36585. * Animations to be used for the post processing
  36586. */
  36587. animations: Animation[];
  36588. /**
  36589. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36590. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36591. */
  36592. enablePixelPerfectMode: boolean;
  36593. /**
  36594. * Force the postprocess to be applied without taking in account viewport
  36595. */
  36596. forceFullscreenViewport: boolean;
  36597. /**
  36598. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36599. *
  36600. * | Value | Type | Description |
  36601. * | ----- | ----------------------------------- | ----------- |
  36602. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36603. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36604. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36605. *
  36606. */
  36607. scaleMode: number;
  36608. /**
  36609. * Force textures to be a power of two (default: false)
  36610. */
  36611. alwaysForcePOT: boolean;
  36612. private _samples;
  36613. /**
  36614. * Number of sample textures (default: 1)
  36615. */
  36616. samples: number;
  36617. /**
  36618. * Modify the scale of the post process to be the same as the viewport (default: false)
  36619. */
  36620. adaptScaleToCurrentViewport: boolean;
  36621. private _camera;
  36622. private _scene;
  36623. private _engine;
  36624. private _options;
  36625. private _reusable;
  36626. private _textureType;
  36627. /**
  36628. * Smart array of input and output textures for the post process.
  36629. * @hidden
  36630. */
  36631. _textures: SmartArray<InternalTexture>;
  36632. /**
  36633. * The index in _textures that corresponds to the output texture.
  36634. * @hidden
  36635. */
  36636. _currentRenderTextureInd: number;
  36637. private _effect;
  36638. private _samplers;
  36639. private _fragmentUrl;
  36640. private _vertexUrl;
  36641. private _parameters;
  36642. private _scaleRatio;
  36643. protected _indexParameters: any;
  36644. private _shareOutputWithPostProcess;
  36645. private _texelSize;
  36646. private _forcedOutputTexture;
  36647. /**
  36648. * An event triggered when the postprocess is activated.
  36649. */
  36650. onActivateObservable: Observable<Camera>;
  36651. private _onActivateObserver;
  36652. /**
  36653. * A function that is added to the onActivateObservable
  36654. */
  36655. onActivate: Nullable<(camera: Camera) => void>;
  36656. /**
  36657. * An event triggered when the postprocess changes its size.
  36658. */
  36659. onSizeChangedObservable: Observable<PostProcess>;
  36660. private _onSizeChangedObserver;
  36661. /**
  36662. * A function that is added to the onSizeChangedObservable
  36663. */
  36664. onSizeChanged: (postProcess: PostProcess) => void;
  36665. /**
  36666. * An event triggered when the postprocess applies its effect.
  36667. */
  36668. onApplyObservable: Observable<Effect>;
  36669. private _onApplyObserver;
  36670. /**
  36671. * A function that is added to the onApplyObservable
  36672. */
  36673. onApply: (effect: Effect) => void;
  36674. /**
  36675. * An event triggered before rendering the postprocess
  36676. */
  36677. onBeforeRenderObservable: Observable<Effect>;
  36678. private _onBeforeRenderObserver;
  36679. /**
  36680. * A function that is added to the onBeforeRenderObservable
  36681. */
  36682. onBeforeRender: (effect: Effect) => void;
  36683. /**
  36684. * An event triggered after rendering the postprocess
  36685. */
  36686. onAfterRenderObservable: Observable<Effect>;
  36687. private _onAfterRenderObserver;
  36688. /**
  36689. * A function that is added to the onAfterRenderObservable
  36690. */
  36691. onAfterRender: (efect: Effect) => void;
  36692. /**
  36693. * 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
  36694. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36695. */
  36696. inputTexture: InternalTexture;
  36697. /**
  36698. * Gets the camera which post process is applied to.
  36699. * @returns The camera the post process is applied to.
  36700. */
  36701. getCamera(): Camera;
  36702. /**
  36703. * Gets the texel size of the postprocess.
  36704. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36705. */
  36706. readonly texelSize: Vector2;
  36707. /**
  36708. * Creates a new instance PostProcess
  36709. * @param name The name of the PostProcess.
  36710. * @param fragmentUrl The url of the fragment shader to be used.
  36711. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36712. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36713. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36714. * @param camera The camera to apply the render pass to.
  36715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36716. * @param engine The engine which the post process will be applied. (default: current engine)
  36717. * @param reusable If the post process can be reused on the same frame. (default: false)
  36718. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36719. * @param textureType Type of textures used when performing the post process. (default: 0)
  36720. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36721. * @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
  36722. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36723. */
  36724. constructor(
  36725. /** Name of the PostProcess. */
  36726. 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);
  36727. /**
  36728. * Gets the engine which this post process belongs to.
  36729. * @returns The engine the post process was enabled with.
  36730. */
  36731. getEngine(): Engine;
  36732. /**
  36733. * The effect that is created when initializing the post process.
  36734. * @returns The created effect corrisponding the the postprocess.
  36735. */
  36736. getEffect(): Effect;
  36737. /**
  36738. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36739. * @param postProcess The post process to share the output with.
  36740. * @returns This post process.
  36741. */
  36742. shareOutputWith(postProcess: PostProcess): PostProcess;
  36743. /**
  36744. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36745. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36746. */
  36747. useOwnOutput(): void;
  36748. /**
  36749. * Updates the effect with the current post process compile time values and recompiles the shader.
  36750. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36751. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36752. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36753. * @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
  36754. * @param onCompiled Called when the shader has been compiled.
  36755. * @param onError Called if there is an error when compiling a shader.
  36756. */
  36757. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36758. /**
  36759. * The post process is reusable if it can be used multiple times within one frame.
  36760. * @returns If the post process is reusable
  36761. */
  36762. isReusable(): boolean;
  36763. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36764. markTextureDirty(): void;
  36765. /**
  36766. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36767. * 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.
  36768. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36769. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36770. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36771. * @returns The target texture that was bound to be written to.
  36772. */
  36773. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36774. /**
  36775. * If the post process is supported.
  36776. */
  36777. readonly isSupported: boolean;
  36778. /**
  36779. * The aspect ratio of the output texture.
  36780. */
  36781. readonly aspectRatio: number;
  36782. /**
  36783. * Get a value indicating if the post-process is ready to be used
  36784. * @returns true if the post-process is ready (shader is compiled)
  36785. */
  36786. isReady(): boolean;
  36787. /**
  36788. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36789. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36790. */
  36791. apply(): Nullable<Effect>;
  36792. private _disposeTextures;
  36793. /**
  36794. * Disposes the post process.
  36795. * @param camera The camera to dispose the post process on.
  36796. */
  36797. dispose(camera?: Camera): void;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36803. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36804. */
  36805. class PostProcessManager {
  36806. private _scene;
  36807. private _indexBuffer;
  36808. private _vertexBuffers;
  36809. /**
  36810. * Creates a new instance PostProcess
  36811. * @param scene The scene that the post process is associated with.
  36812. */
  36813. constructor(scene: Scene);
  36814. private _prepareBuffers;
  36815. private _buildIndexBuffer;
  36816. /**
  36817. * Rebuilds the vertex buffers of the manager.
  36818. * @hidden
  36819. */
  36820. _rebuild(): void;
  36821. /**
  36822. * Prepares a frame to be run through a post process.
  36823. * @param sourceTexture The input texture to the post procesess. (default: null)
  36824. * @param postProcesses An array of post processes to be run. (default: null)
  36825. * @returns True if the post processes were able to be run.
  36826. * @hidden
  36827. */
  36828. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36829. /**
  36830. * Manually render a set of post processes to a texture.
  36831. * @param postProcesses An array of post processes to be run.
  36832. * @param targetTexture The target texture to render to.
  36833. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36834. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36835. * @param lodLevel defines which lod of the texture to render to
  36836. */
  36837. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36838. /**
  36839. * Finalize the result of the output of the postprocesses.
  36840. * @param doNotPresent If true the result will not be displayed to the screen.
  36841. * @param targetTexture The target texture to render to.
  36842. * @param faceIndex The index of the face to bind the target texture to.
  36843. * @param postProcesses The array of post processes to render.
  36844. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36845. * @hidden
  36846. */
  36847. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36848. /**
  36849. * Disposes of the post process manager.
  36850. */
  36851. dispose(): void;
  36852. }
  36853. }
  36854. declare module BABYLON {
  36855. /**
  36856. * Post process which applies a refractin texture
  36857. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36858. */
  36859. class RefractionPostProcess extends PostProcess {
  36860. /** the base color of the refraction (used to taint the rendering) */
  36861. color: Color3;
  36862. /** simulated refraction depth */
  36863. depth: number;
  36864. /** the coefficient of the base color (0 to remove base color tainting) */
  36865. colorLevel: number;
  36866. private _refTexture;
  36867. private _ownRefractionTexture;
  36868. /**
  36869. * Gets or sets the refraction texture
  36870. * Please note that you are responsible for disposing the texture if you set it manually
  36871. */
  36872. refractionTexture: Texture;
  36873. /**
  36874. * Initializes the RefractionPostProcess
  36875. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36876. * @param name The name of the effect.
  36877. * @param refractionTextureUrl Url of the refraction texture to use
  36878. * @param color the base color of the refraction (used to taint the rendering)
  36879. * @param depth simulated refraction depth
  36880. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36881. * @param camera The camera to apply the render pass to.
  36882. * @param options The required width/height ratio to downsize to before computing the render pass.
  36883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36884. * @param engine The engine which the post process will be applied. (default: current engine)
  36885. * @param reusable If the post process can be reused on the same frame. (default: false)
  36886. */
  36887. constructor(name: string, refractionTextureUrl: string,
  36888. /** the base color of the refraction (used to taint the rendering) */
  36889. color: Color3,
  36890. /** simulated refraction depth */
  36891. depth: number,
  36892. /** the coefficient of the base color (0 to remove base color tainting) */
  36893. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36894. /**
  36895. * Disposes of the post process
  36896. * @param camera Camera to dispose post process on
  36897. */
  36898. dispose(camera: Camera): void;
  36899. }
  36900. }
  36901. declare module BABYLON {
  36902. /**
  36903. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36904. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36905. */
  36906. class SharpenPostProcess extends PostProcess {
  36907. /**
  36908. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36909. */
  36910. colorAmount: number;
  36911. /**
  36912. * How much sharpness should be applied (default: 0.3)
  36913. */
  36914. edgeAmount: number;
  36915. /**
  36916. * Creates a new instance ConvolutionPostProcess
  36917. * @param name The name of the effect.
  36918. * @param options The required width/height ratio to downsize to before computing the render pass.
  36919. * @param camera The camera to apply the render pass to.
  36920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36921. * @param engine The engine which the post process will be applied. (default: current engine)
  36922. * @param reusable If the post process can be reused on the same frame. (default: false)
  36923. * @param textureType Type of textures used when performing the post process. (default: 0)
  36924. * @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)
  36925. */
  36926. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. /**
  36931. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36932. */
  36933. class StereoscopicInterlacePostProcess extends PostProcess {
  36934. private _stepSize;
  36935. private _passedProcess;
  36936. /**
  36937. * Initializes a StereoscopicInterlacePostProcess
  36938. * @param name The name of the effect.
  36939. * @param rigCameras The rig cameras to be appled to the post process
  36940. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36942. * @param engine The engine which the post process will be applied. (default: current engine)
  36943. * @param reusable If the post process can be reused on the same frame. (default: false)
  36944. */
  36945. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. /** Defines operator used for tonemapping */
  36950. enum TonemappingOperator {
  36951. /** Hable */
  36952. Hable = 0,
  36953. /** Reinhard */
  36954. Reinhard = 1,
  36955. /** HejiDawson */
  36956. HejiDawson = 2,
  36957. /** Photographic */
  36958. Photographic = 3
  36959. }
  36960. /**
  36961. * Defines a post process to apply tone mapping
  36962. */
  36963. class TonemapPostProcess extends PostProcess {
  36964. private _operator;
  36965. /** Defines the required exposure adjustement */
  36966. exposureAdjustment: number;
  36967. /**
  36968. * Creates a new TonemapPostProcess
  36969. * @param name defines the name of the postprocess
  36970. * @param _operator defines the operator to use
  36971. * @param exposureAdjustment defines the required exposure adjustement
  36972. * @param camera defines the camera to use (can be null)
  36973. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36974. * @param engine defines the hosting engine (can be ignore if camera is set)
  36975. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36976. */
  36977. constructor(name: string, _operator: TonemappingOperator,
  36978. /** Defines the required exposure adjustement */
  36979. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36980. }
  36981. }
  36982. declare module BABYLON {
  36983. /**
  36984. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36985. */
  36986. class VolumetricLightScatteringPostProcess extends PostProcess {
  36987. private _volumetricLightScatteringPass;
  36988. private _volumetricLightScatteringRTT;
  36989. private _viewPort;
  36990. private _screenCoordinates;
  36991. private _cachedDefines;
  36992. /**
  36993. * If not undefined, the mesh position is computed from the attached node position
  36994. */
  36995. attachedNode: {
  36996. position: Vector3;
  36997. };
  36998. /**
  36999. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  37000. */
  37001. customMeshPosition: Vector3;
  37002. /**
  37003. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  37004. */
  37005. useCustomMeshPosition: boolean;
  37006. /**
  37007. * If the post-process should inverse the light scattering direction
  37008. */
  37009. invert: boolean;
  37010. /**
  37011. * The internal mesh used by the post-process
  37012. */
  37013. mesh: Mesh;
  37014. /**
  37015. * @hidden
  37016. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  37017. */
  37018. useDiffuseColor: boolean;
  37019. /**
  37020. * Array containing the excluded meshes not rendered in the internal pass
  37021. */
  37022. excludedMeshes: AbstractMesh[];
  37023. /**
  37024. * Controls the overall intensity of the post-process
  37025. */
  37026. exposure: number;
  37027. /**
  37028. * Dissipates each sample's contribution in range [0, 1]
  37029. */
  37030. decay: number;
  37031. /**
  37032. * Controls the overall intensity of each sample
  37033. */
  37034. weight: number;
  37035. /**
  37036. * Controls the density of each sample
  37037. */
  37038. density: number;
  37039. /**
  37040. * @constructor
  37041. * @param name The post-process name
  37042. * @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)
  37043. * @param camera The camera that the post-process will be attached to
  37044. * @param mesh The mesh used to create the light scattering
  37045. * @param samples The post-process quality, default 100
  37046. * @param samplingModeThe post-process filtering mode
  37047. * @param engine The babylon engine
  37048. * @param reusable If the post-process is reusable
  37049. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  37050. */
  37051. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  37052. /**
  37053. * Returns the string "VolumetricLightScatteringPostProcess"
  37054. * @returns "VolumetricLightScatteringPostProcess"
  37055. */
  37056. getClassName(): string;
  37057. private _isReady;
  37058. /**
  37059. * Sets the new light position for light scattering effect
  37060. * @param position The new custom light position
  37061. */
  37062. setCustomMeshPosition(position: Vector3): void;
  37063. /**
  37064. * Returns the light position for light scattering effect
  37065. * @return Vector3 The custom light position
  37066. */
  37067. getCustomMeshPosition(): Vector3;
  37068. /**
  37069. * Disposes the internal assets and detaches the post-process from the camera
  37070. */
  37071. dispose(camera: Camera): void;
  37072. /**
  37073. * Returns the render target texture used by the post-process
  37074. * @return the render target texture used by the post-process
  37075. */
  37076. getPass(): RenderTargetTexture;
  37077. private _meshExcluded;
  37078. private _createPass;
  37079. private _updateMeshScreenCoordinates;
  37080. /**
  37081. * Creates a default mesh for the Volumeric Light Scattering post-process
  37082. * @param name The mesh name
  37083. * @param scene The scene where to create the mesh
  37084. * @return the default mesh
  37085. */
  37086. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  37087. }
  37088. }
  37089. declare module BABYLON {
  37090. /**
  37091. * VRDistortionCorrectionPostProcess used for mobile VR
  37092. */
  37093. class VRDistortionCorrectionPostProcess extends PostProcess {
  37094. private _isRightEye;
  37095. private _distortionFactors;
  37096. private _postProcessScaleFactor;
  37097. private _lensCenterOffset;
  37098. private _scaleIn;
  37099. private _scaleFactor;
  37100. private _lensCenter;
  37101. /**
  37102. * Initializes the VRDistortionCorrectionPostProcess
  37103. * @param name The name of the effect.
  37104. * @param camera The camera to apply the render pass to.
  37105. * @param isRightEye If this is for the right eye distortion
  37106. * @param vrMetrics All the required metrics for the VR camera
  37107. */
  37108. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Class used to evalaute queries containing `and` and `or` operators
  37114. */
  37115. class AndOrNotEvaluator {
  37116. /**
  37117. * Evaluate a query
  37118. * @param query defines the query to evaluate
  37119. * @param evaluateCallback defines the callback used to filter result
  37120. * @returns true if the query matches
  37121. */
  37122. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37123. private static _HandleParenthesisContent;
  37124. private static _SimplifyNegation;
  37125. }
  37126. }
  37127. declare module BABYLON {
  37128. /**
  37129. * Defines the list of states available for a task inside a AssetsManager
  37130. */
  37131. enum AssetTaskState {
  37132. /**
  37133. * Initialization
  37134. */
  37135. INIT = 0,
  37136. /**
  37137. * Running
  37138. */
  37139. RUNNING = 1,
  37140. /**
  37141. * Done
  37142. */
  37143. DONE = 2,
  37144. /**
  37145. * Error
  37146. */
  37147. ERROR = 3
  37148. }
  37149. /**
  37150. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37151. */
  37152. abstract class AbstractAssetTask {
  37153. /**
  37154. * Task name
  37155. */ name: string;
  37156. /**
  37157. * Callback called when the task is successful
  37158. */
  37159. onSuccess: (task: any) => void;
  37160. /**
  37161. * Callback called when the task is not successful
  37162. */
  37163. onError: (task: any, message?: string, exception?: any) => void;
  37164. /**
  37165. * Creates a new AssetsManager
  37166. * @param name defines the name of the task
  37167. */
  37168. constructor(
  37169. /**
  37170. * Task name
  37171. */ name: string);
  37172. private _isCompleted;
  37173. private _taskState;
  37174. private _errorObject;
  37175. /**
  37176. * Get if the task is completed
  37177. */
  37178. readonly isCompleted: boolean;
  37179. /**
  37180. * Gets the current state of the task
  37181. */
  37182. readonly taskState: AssetTaskState;
  37183. /**
  37184. * Gets the current error object (if task is in error)
  37185. */
  37186. readonly errorObject: {
  37187. message?: string;
  37188. exception?: any;
  37189. };
  37190. /**
  37191. * Internal only
  37192. * @hidden
  37193. */
  37194. _setErrorObject(message?: string, exception?: any): void;
  37195. /**
  37196. * Execute the current task
  37197. * @param scene defines the scene where you want your assets to be loaded
  37198. * @param onSuccess is a callback called when the task is successfully executed
  37199. * @param onError is a callback called if an error occurs
  37200. */
  37201. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37202. /**
  37203. * Execute the current task
  37204. * @param scene defines the scene where you want your assets to be loaded
  37205. * @param onSuccess is a callback called when the task is successfully executed
  37206. * @param onError is a callback called if an error occurs
  37207. */
  37208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37209. /**
  37210. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37211. * This can be used with failed tasks that have the reason for failure fixed.
  37212. */
  37213. reset(): void;
  37214. private onErrorCallback;
  37215. private onDoneCallback;
  37216. }
  37217. /**
  37218. * Define the interface used by progress events raised during assets loading
  37219. */
  37220. interface IAssetsProgressEvent {
  37221. /**
  37222. * Defines the number of remaining tasks to process
  37223. */
  37224. remainingCount: number;
  37225. /**
  37226. * Defines the total number of tasks
  37227. */
  37228. totalCount: number;
  37229. /**
  37230. * Defines the task that was just processed
  37231. */
  37232. task: AbstractAssetTask;
  37233. }
  37234. /**
  37235. * Class used to share progress information about assets loading
  37236. */
  37237. class AssetsProgressEvent implements IAssetsProgressEvent {
  37238. /**
  37239. * Defines the number of remaining tasks to process
  37240. */
  37241. remainingCount: number;
  37242. /**
  37243. * Defines the total number of tasks
  37244. */
  37245. totalCount: number;
  37246. /**
  37247. * Defines the task that was just processed
  37248. */
  37249. task: AbstractAssetTask;
  37250. /**
  37251. * Creates a AssetsProgressEvent
  37252. * @param remainingCount defines the number of remaining tasks to process
  37253. * @param totalCount defines the total number of tasks
  37254. * @param task defines the task that was just processed
  37255. */
  37256. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37257. }
  37258. /**
  37259. * Define a task used by AssetsManager to load meshes
  37260. */
  37261. class MeshAssetTask extends AbstractAssetTask {
  37262. /**
  37263. * Defines the name of the task
  37264. */
  37265. name: string;
  37266. /**
  37267. * Defines the list of mesh's names you want to load
  37268. */
  37269. meshesNames: any;
  37270. /**
  37271. * Defines the root url to use as a base to load your meshes and associated resources
  37272. */
  37273. rootUrl: string;
  37274. /**
  37275. * Defines the filename of the scene to load from
  37276. */
  37277. sceneFilename: string;
  37278. /**
  37279. * Gets the list of loaded meshes
  37280. */
  37281. loadedMeshes: Array<AbstractMesh>;
  37282. /**
  37283. * Gets the list of loaded particle systems
  37284. */
  37285. loadedParticleSystems: Array<IParticleSystem>;
  37286. /**
  37287. * Gets the list of loaded skeletons
  37288. */
  37289. loadedSkeletons: Array<Skeleton>;
  37290. /**
  37291. * Callback called when the task is successful
  37292. */
  37293. onSuccess: (task: MeshAssetTask) => void;
  37294. /**
  37295. * Callback called when the task is successful
  37296. */
  37297. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37298. /**
  37299. * Creates a new MeshAssetTask
  37300. * @param name defines the name of the task
  37301. * @param meshesNames defines the list of mesh's names you want to load
  37302. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37303. * @param sceneFilename defines the filename of the scene to load from
  37304. */
  37305. constructor(
  37306. /**
  37307. * Defines the name of the task
  37308. */
  37309. name: string,
  37310. /**
  37311. * Defines the list of mesh's names you want to load
  37312. */
  37313. meshesNames: any,
  37314. /**
  37315. * Defines the root url to use as a base to load your meshes and associated resources
  37316. */
  37317. rootUrl: string,
  37318. /**
  37319. * Defines the filename of the scene to load from
  37320. */
  37321. sceneFilename: string);
  37322. /**
  37323. * Execute the current task
  37324. * @param scene defines the scene where you want your assets to be loaded
  37325. * @param onSuccess is a callback called when the task is successfully executed
  37326. * @param onError is a callback called if an error occurs
  37327. */
  37328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37329. }
  37330. /**
  37331. * Define a task used by AssetsManager to load text content
  37332. */
  37333. class TextFileAssetTask extends AbstractAssetTask {
  37334. /**
  37335. * Defines the name of the task
  37336. */
  37337. name: string;
  37338. /**
  37339. * Defines the location of the file to load
  37340. */
  37341. url: string;
  37342. /**
  37343. * Gets the loaded text string
  37344. */
  37345. text: string;
  37346. /**
  37347. * Callback called when the task is successful
  37348. */
  37349. onSuccess: (task: TextFileAssetTask) => void;
  37350. /**
  37351. * Callback called when the task is successful
  37352. */
  37353. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37354. /**
  37355. * Creates a new TextFileAssetTask object
  37356. * @param name defines the name of the task
  37357. * @param url defines the location of the file to load
  37358. */
  37359. constructor(
  37360. /**
  37361. * Defines the name of the task
  37362. */
  37363. name: string,
  37364. /**
  37365. * Defines the location of the file to load
  37366. */
  37367. url: string);
  37368. /**
  37369. * Execute the current task
  37370. * @param scene defines the scene where you want your assets to be loaded
  37371. * @param onSuccess is a callback called when the task is successfully executed
  37372. * @param onError is a callback called if an error occurs
  37373. */
  37374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37375. }
  37376. /**
  37377. * Define a task used by AssetsManager to load binary data
  37378. */
  37379. class BinaryFileAssetTask extends AbstractAssetTask {
  37380. /**
  37381. * Defines the name of the task
  37382. */
  37383. name: string;
  37384. /**
  37385. * Defines the location of the file to load
  37386. */
  37387. url: string;
  37388. /**
  37389. * Gets the lodaded data (as an array buffer)
  37390. */
  37391. data: ArrayBuffer;
  37392. /**
  37393. * Callback called when the task is successful
  37394. */
  37395. onSuccess: (task: BinaryFileAssetTask) => void;
  37396. /**
  37397. * Callback called when the task is successful
  37398. */
  37399. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37400. /**
  37401. * Creates a new BinaryFileAssetTask object
  37402. * @param name defines the name of the new task
  37403. * @param url defines the location of the file to load
  37404. */
  37405. constructor(
  37406. /**
  37407. * Defines the name of the task
  37408. */
  37409. name: string,
  37410. /**
  37411. * Defines the location of the file to load
  37412. */
  37413. url: string);
  37414. /**
  37415. * Execute the current task
  37416. * @param scene defines the scene where you want your assets to be loaded
  37417. * @param onSuccess is a callback called when the task is successfully executed
  37418. * @param onError is a callback called if an error occurs
  37419. */
  37420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37421. }
  37422. /**
  37423. * Define a task used by AssetsManager to load images
  37424. */
  37425. class ImageAssetTask extends AbstractAssetTask {
  37426. /**
  37427. * Defines the name of the task
  37428. */
  37429. name: string;
  37430. /**
  37431. * Defines the location of the image to load
  37432. */
  37433. url: string;
  37434. /**
  37435. * Gets the loaded images
  37436. */
  37437. image: HTMLImageElement;
  37438. /**
  37439. * Callback called when the task is successful
  37440. */
  37441. onSuccess: (task: ImageAssetTask) => void;
  37442. /**
  37443. * Callback called when the task is successful
  37444. */
  37445. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37446. /**
  37447. * Creates a new ImageAssetTask
  37448. * @param name defines the name of the task
  37449. * @param url defines the location of the image to load
  37450. */
  37451. constructor(
  37452. /**
  37453. * Defines the name of the task
  37454. */
  37455. name: string,
  37456. /**
  37457. * Defines the location of the image to load
  37458. */
  37459. url: string);
  37460. /**
  37461. * Execute the current task
  37462. * @param scene defines the scene where you want your assets to be loaded
  37463. * @param onSuccess is a callback called when the task is successfully executed
  37464. * @param onError is a callback called if an error occurs
  37465. */
  37466. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37467. }
  37468. /**
  37469. * Defines the interface used by texture loading tasks
  37470. */
  37471. interface ITextureAssetTask<TEX extends BaseTexture> {
  37472. /**
  37473. * Gets the loaded texture
  37474. */
  37475. texture: TEX;
  37476. }
  37477. /**
  37478. * Define a task used by AssetsManager to load 2D textures
  37479. */
  37480. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37481. /**
  37482. * Defines the name of the task
  37483. */
  37484. name: string;
  37485. /**
  37486. * Defines the location of the file to load
  37487. */
  37488. url: string;
  37489. /**
  37490. * Defines if mipmap should not be generated (default is false)
  37491. */
  37492. noMipmap?: boolean | undefined;
  37493. /**
  37494. * Defines if texture must be inverted on Y axis (default is false)
  37495. */
  37496. invertY?: boolean | undefined;
  37497. /**
  37498. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37499. */
  37500. samplingMode: number;
  37501. /**
  37502. * Gets the loaded texture
  37503. */
  37504. texture: Texture;
  37505. /**
  37506. * Callback called when the task is successful
  37507. */
  37508. onSuccess: (task: TextureAssetTask) => void;
  37509. /**
  37510. * Callback called when the task is successful
  37511. */
  37512. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37513. /**
  37514. * Creates a new TextureAssetTask object
  37515. * @param name defines the name of the task
  37516. * @param url defines the location of the file to load
  37517. * @param noMipmap defines if mipmap should not be generated (default is false)
  37518. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37519. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37520. */
  37521. constructor(
  37522. /**
  37523. * Defines the name of the task
  37524. */
  37525. name: string,
  37526. /**
  37527. * Defines the location of the file to load
  37528. */
  37529. url: string,
  37530. /**
  37531. * Defines if mipmap should not be generated (default is false)
  37532. */
  37533. noMipmap?: boolean | undefined,
  37534. /**
  37535. * Defines if texture must be inverted on Y axis (default is false)
  37536. */
  37537. invertY?: boolean | undefined,
  37538. /**
  37539. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37540. */
  37541. samplingMode?: number);
  37542. /**
  37543. * Execute the current task
  37544. * @param scene defines the scene where you want your assets to be loaded
  37545. * @param onSuccess is a callback called when the task is successfully executed
  37546. * @param onError is a callback called if an error occurs
  37547. */
  37548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37549. }
  37550. /**
  37551. * Define a task used by AssetsManager to load cube textures
  37552. */
  37553. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37554. /**
  37555. * Defines the name of the task
  37556. */
  37557. name: string;
  37558. /**
  37559. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37560. */
  37561. url: string;
  37562. /**
  37563. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37564. */
  37565. extensions?: string[] | undefined;
  37566. /**
  37567. * Defines if mipmaps should not be generated (default is false)
  37568. */
  37569. noMipmap?: boolean | undefined;
  37570. /**
  37571. * Defines the explicit list of files (undefined by default)
  37572. */
  37573. files?: string[] | undefined;
  37574. /**
  37575. * Gets the loaded texture
  37576. */
  37577. texture: CubeTexture;
  37578. /**
  37579. * Callback called when the task is successful
  37580. */
  37581. onSuccess: (task: CubeTextureAssetTask) => void;
  37582. /**
  37583. * Callback called when the task is successful
  37584. */
  37585. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37586. /**
  37587. * Creates a new CubeTextureAssetTask
  37588. * @param name defines the name of the task
  37589. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37590. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37592. * @param files defines the explicit list of files (undefined by default)
  37593. */
  37594. constructor(
  37595. /**
  37596. * Defines the name of the task
  37597. */
  37598. name: string,
  37599. /**
  37600. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37601. */
  37602. url: string,
  37603. /**
  37604. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37605. */
  37606. extensions?: string[] | undefined,
  37607. /**
  37608. * Defines if mipmaps should not be generated (default is false)
  37609. */
  37610. noMipmap?: boolean | undefined,
  37611. /**
  37612. * Defines the explicit list of files (undefined by default)
  37613. */
  37614. files?: string[] | undefined);
  37615. /**
  37616. * Execute the current task
  37617. * @param scene defines the scene where you want your assets to be loaded
  37618. * @param onSuccess is a callback called when the task is successfully executed
  37619. * @param onError is a callback called if an error occurs
  37620. */
  37621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37622. }
  37623. /**
  37624. * Define a task used by AssetsManager to load HDR cube textures
  37625. */
  37626. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37627. /**
  37628. * Defines the name of the task
  37629. */
  37630. name: string;
  37631. /**
  37632. * Defines the location of the file to load
  37633. */
  37634. url: string;
  37635. /**
  37636. * Defines the desired size (the more it increases the longer the generation will be)
  37637. */
  37638. size: number;
  37639. /**
  37640. * Defines if mipmaps should not be generated (default is false)
  37641. */
  37642. noMipmap: boolean;
  37643. /**
  37644. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37645. */
  37646. generateHarmonics: boolean;
  37647. /**
  37648. * 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)
  37649. */
  37650. gammaSpace: boolean;
  37651. /**
  37652. * Internal Use Only
  37653. */
  37654. reserved: boolean;
  37655. /**
  37656. * Gets the loaded texture
  37657. */
  37658. texture: HDRCubeTexture;
  37659. /**
  37660. * Callback called when the task is successful
  37661. */
  37662. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37663. /**
  37664. * Callback called when the task is successful
  37665. */
  37666. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37667. /**
  37668. * Creates a new HDRCubeTextureAssetTask object
  37669. * @param name defines the name of the task
  37670. * @param url defines the location of the file to load
  37671. * @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.
  37672. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37673. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37674. * @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)
  37675. * @param reserved Internal use only
  37676. */
  37677. constructor(
  37678. /**
  37679. * Defines the name of the task
  37680. */
  37681. name: string,
  37682. /**
  37683. * Defines the location of the file to load
  37684. */
  37685. url: string,
  37686. /**
  37687. * Defines the desired size (the more it increases the longer the generation will be)
  37688. */
  37689. size: number,
  37690. /**
  37691. * Defines if mipmaps should not be generated (default is false)
  37692. */
  37693. noMipmap?: boolean,
  37694. /**
  37695. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37696. */
  37697. generateHarmonics?: boolean,
  37698. /**
  37699. * 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)
  37700. */
  37701. gammaSpace?: boolean,
  37702. /**
  37703. * Internal Use Only
  37704. */
  37705. reserved?: boolean);
  37706. /**
  37707. * Execute the current task
  37708. * @param scene defines the scene where you want your assets to be loaded
  37709. * @param onSuccess is a callback called when the task is successfully executed
  37710. * @param onError is a callback called if an error occurs
  37711. */
  37712. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37713. }
  37714. /**
  37715. * This class can be used to easily import assets into a scene
  37716. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37717. */
  37718. class AssetsManager {
  37719. private _scene;
  37720. private _isLoading;
  37721. protected _tasks: AbstractAssetTask[];
  37722. protected _waitingTasksCount: number;
  37723. protected _totalTasksCount: number;
  37724. /**
  37725. * Callback called when all tasks are processed
  37726. */
  37727. onFinish: (tasks: AbstractAssetTask[]) => void;
  37728. /**
  37729. * Callback called when a task is successful
  37730. */
  37731. onTaskSuccess: (task: AbstractAssetTask) => void;
  37732. /**
  37733. * Callback called when a task had an error
  37734. */
  37735. onTaskError: (task: AbstractAssetTask) => void;
  37736. /**
  37737. * Callback called when a task is done (whatever the result is)
  37738. */
  37739. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37740. /**
  37741. * Observable called when all tasks are processed
  37742. */
  37743. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37744. /**
  37745. * Observable called when a task had an error
  37746. */
  37747. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37748. /**
  37749. * Observable called when a task is successful
  37750. */
  37751. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37752. /**
  37753. * Observable called when a task is done (whatever the result is)
  37754. */
  37755. onProgressObservable: Observable<IAssetsProgressEvent>;
  37756. /**
  37757. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37758. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37759. */
  37760. useDefaultLoadingScreen: boolean;
  37761. /**
  37762. * Creates a new AssetsManager
  37763. * @param scene defines the scene to work on
  37764. */
  37765. constructor(scene: Scene);
  37766. /**
  37767. * Add a MeshAssetTask to the list of active tasks
  37768. * @param taskName defines the name of the new task
  37769. * @param meshesNames defines the name of meshes to load
  37770. * @param rootUrl defines the root url to use to locate files
  37771. * @param sceneFilename defines the filename of the scene file
  37772. * @returns a new MeshAssetTask object
  37773. */
  37774. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37775. /**
  37776. * Add a TextFileAssetTask to the list of active tasks
  37777. * @param taskName defines the name of the new task
  37778. * @param url defines the url of the file to load
  37779. * @returns a new TextFileAssetTask object
  37780. */
  37781. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37782. /**
  37783. * Add a BinaryFileAssetTask to the list of active tasks
  37784. * @param taskName defines the name of the new task
  37785. * @param url defines the url of the file to load
  37786. * @returns a new BinaryFileAssetTask object
  37787. */
  37788. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37789. /**
  37790. * Add a ImageAssetTask to the list of active tasks
  37791. * @param taskName defines the name of the new task
  37792. * @param url defines the url of the file to load
  37793. * @returns a new ImageAssetTask object
  37794. */
  37795. addImageTask(taskName: string, url: string): ImageAssetTask;
  37796. /**
  37797. * Add a TextureAssetTask to the list of active tasks
  37798. * @param taskName defines the name of the new task
  37799. * @param url defines the url of the file to load
  37800. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37801. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37802. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37803. * @returns a new TextureAssetTask object
  37804. */
  37805. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37806. /**
  37807. * Add a CubeTextureAssetTask to the list of active tasks
  37808. * @param taskName defines the name of the new task
  37809. * @param url defines the url of the file to load
  37810. * @param extensions defines the extension to use to load the cube map (can be null)
  37811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37812. * @param files defines the list of files to load (can be null)
  37813. * @returns a new CubeTextureAssetTask object
  37814. */
  37815. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37816. /**
  37817. *
  37818. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37819. * @param taskName defines the name of the new task
  37820. * @param url defines the url of the file to load
  37821. * @param size defines the size you want for the cubemap (can be null)
  37822. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37823. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37824. * @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)
  37825. * @param reserved Internal use only
  37826. * @returns a new HDRCubeTextureAssetTask object
  37827. */
  37828. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37829. /**
  37830. * Remove a task from the assets manager.
  37831. * @param task the task to remove
  37832. */
  37833. removeTask(task: AbstractAssetTask): void;
  37834. private _decreaseWaitingTasksCount;
  37835. private _runTask;
  37836. /**
  37837. * Reset the AssetsManager and remove all tasks
  37838. * @return the current instance of the AssetsManager
  37839. */
  37840. reset(): AssetsManager;
  37841. /**
  37842. * Start the loading process
  37843. * @return the current instance of the AssetsManager
  37844. */
  37845. load(): AssetsManager;
  37846. }
  37847. }
  37848. declare module BABYLON {
  37849. /**
  37850. * Direct draw surface info
  37851. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37852. */
  37853. interface DDSInfo {
  37854. /**
  37855. * Width of the texture
  37856. */
  37857. width: number;
  37858. /**
  37859. * Width of the texture
  37860. */
  37861. height: number;
  37862. /**
  37863. * Number of Mipmaps for the texture
  37864. * @see https://en.wikipedia.org/wiki/Mipmap
  37865. */
  37866. mipmapCount: number;
  37867. /**
  37868. * If the textures format is a known fourCC format
  37869. * @see https://www.fourcc.org/
  37870. */
  37871. isFourCC: boolean;
  37872. /**
  37873. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37874. */
  37875. isRGB: boolean;
  37876. /**
  37877. * If the texture is a lumincance format
  37878. */
  37879. isLuminance: boolean;
  37880. /**
  37881. * If this is a cube texture
  37882. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37883. */
  37884. isCube: boolean;
  37885. /**
  37886. * If the texture is a compressed format eg. FOURCC_DXT1
  37887. */
  37888. isCompressed: boolean;
  37889. /**
  37890. * The dxgiFormat of the texture
  37891. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37892. */
  37893. dxgiFormat: number;
  37894. /**
  37895. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37896. */
  37897. textureType: number;
  37898. /**
  37899. * Sphericle polynomial created for the dds texture
  37900. */
  37901. sphericalPolynomial?: SphericalPolynomial;
  37902. }
  37903. /**
  37904. * Class used to provide DDS decompression tools
  37905. */
  37906. class DDSTools {
  37907. /**
  37908. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37909. */
  37910. static StoreLODInAlphaChannel: boolean;
  37911. /**
  37912. * Gets DDS information from an array buffer
  37913. * @param arrayBuffer defines the array buffer to read data from
  37914. * @returns the DDS information
  37915. */
  37916. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37917. private static _FloatView;
  37918. private static _Int32View;
  37919. private static _ToHalfFloat;
  37920. private static _FromHalfFloat;
  37921. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37922. private static _GetHalfFloatRGBAArrayBuffer;
  37923. private static _GetFloatRGBAArrayBuffer;
  37924. private static _GetFloatAsUIntRGBAArrayBuffer;
  37925. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37926. private static _GetRGBAArrayBuffer;
  37927. private static _ExtractLongWordOrder;
  37928. private static _GetRGBArrayBuffer;
  37929. private static _GetLuminanceArrayBuffer;
  37930. /**
  37931. * Uploads DDS Levels to a Babylon Texture
  37932. * @hidden
  37933. */
  37934. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37935. }
  37936. }
  37937. declare module BABYLON {
  37938. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37939. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37940. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37941. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37942. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37943. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37944. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37945. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37946. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37947. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37948. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37949. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37950. /**
  37951. * Decorator used to define property that can be serialized as reference to a camera
  37952. * @param sourceName defines the name of the property to decorate
  37953. */
  37954. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37955. /**
  37956. * Class used to help serialization objects
  37957. */
  37958. class SerializationHelper {
  37959. /**
  37960. * Static function used to serialized a specific entity
  37961. * @param entity defines the entity to serialize
  37962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37963. * @returns a JSON compatible object representing the serialization of the entity
  37964. */
  37965. static Serialize<T>(entity: T, serializationObject?: any): any;
  37966. /**
  37967. * Creates a new entity from a serialization data object
  37968. * @param creationFunction defines a function used to instanciated the new entity
  37969. * @param source defines the source serialization data
  37970. * @param scene defines the hosting scene
  37971. * @param rootUrl defines the root url for resources
  37972. * @returns a new entity
  37973. */
  37974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37975. /**
  37976. * Clones an object
  37977. * @param creationFunction defines the function used to instanciate the new object
  37978. * @param source defines the source object
  37979. * @returns the cloned object
  37980. */
  37981. static Clone<T>(creationFunction: () => T, source: T): T;
  37982. /**
  37983. * Instanciates a new object based on a source one (some data will be shared between both object)
  37984. * @param creationFunction defines the function used to instanciate the new object
  37985. * @param source defines the source object
  37986. * @returns the new object
  37987. */
  37988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37989. }
  37990. }
  37991. declare module BABYLON {
  37992. /**
  37993. * Wrapper class for promise with external resolve and reject.
  37994. */
  37995. class Deferred<T> {
  37996. /**
  37997. * The promise associated with this deferred object.
  37998. */
  37999. readonly promise: Promise<T>;
  38000. private _resolve;
  38001. private _reject;
  38002. /**
  38003. * The resolve method of the promise associated with this deferred object.
  38004. */
  38005. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38006. /**
  38007. * The reject method of the promise associated with this deferred object.
  38008. */
  38009. readonly reject: (reason?: any) => void;
  38010. /**
  38011. * Constructor for this deferred object.
  38012. */
  38013. constructor();
  38014. }
  38015. }
  38016. declare module BABYLON {
  38017. /**
  38018. * Raw texture data and descriptor sufficient for WebGL texture upload
  38019. */
  38020. interface EnvironmentTextureInfo {
  38021. /**
  38022. * Version of the environment map
  38023. */
  38024. version: number;
  38025. /**
  38026. * Width of image
  38027. */
  38028. width: number;
  38029. /**
  38030. * Irradiance information stored in the file.
  38031. */
  38032. irradiance: any;
  38033. /**
  38034. * Specular information stored in the file.
  38035. */
  38036. specular: any;
  38037. }
  38038. /**
  38039. * Sets of helpers addressing the serialization and deserialization of environment texture
  38040. * stored in a BabylonJS env file.
  38041. * Those files are usually stored as .env files.
  38042. */
  38043. class EnvironmentTextureTools {
  38044. /**
  38045. * Magic number identifying the env file.
  38046. */
  38047. private static _MagicBytes;
  38048. /**
  38049. * Gets the environment info from an env file.
  38050. * @param data The array buffer containing the .env bytes.
  38051. * @returns the environment file info (the json header) if successfully parsed.
  38052. */
  38053. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38054. /**
  38055. * Creates an environment texture from a loaded cube texture.
  38056. * @param texture defines the cube texture to convert in env file
  38057. * @return a promise containing the environment data if succesfull.
  38058. */
  38059. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38060. /**
  38061. * Creates a JSON representation of the spherical data.
  38062. * @param texture defines the texture containing the polynomials
  38063. * @return the JSON representation of the spherical info
  38064. */
  38065. private static _CreateEnvTextureIrradiance;
  38066. /**
  38067. * Uploads the texture info contained in the env file to the GPU.
  38068. * @param texture defines the internal texture to upload to
  38069. * @param arrayBuffer defines the buffer cotaining the data to load
  38070. * @param info defines the texture info retrieved through the GetEnvInfo method
  38071. * @returns a promise
  38072. */
  38073. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38074. /**
  38075. * Uploads the levels of image data to the GPU.
  38076. * @param texture defines the internal texture to upload to
  38077. * @param imageData defines the array buffer views of image data [mipmap][face]
  38078. * @returns a promise
  38079. */
  38080. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38081. /**
  38082. * Uploads spherical polynomials information to the texture.
  38083. * @param texture defines the texture we are trying to upload the information to
  38084. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38085. */
  38086. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38087. }
  38088. }
  38089. declare module BABYLON {
  38090. /**
  38091. * Class used to help managing file picking and drag'n'drop
  38092. */
  38093. class FilesInput {
  38094. /**
  38095. * List of files ready to be loaded
  38096. */
  38097. static FilesToLoad: {
  38098. [key: string]: File;
  38099. };
  38100. /**
  38101. * Callback called when a file is processed
  38102. */
  38103. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38104. private _engine;
  38105. private _currentScene;
  38106. private _sceneLoadedCallback;
  38107. private _progressCallback;
  38108. private _additionalRenderLoopLogicCallback;
  38109. private _textureLoadingCallback;
  38110. private _startingProcessingFilesCallback;
  38111. private _onReloadCallback;
  38112. private _errorCallback;
  38113. private _elementToMonitor;
  38114. private _sceneFileToLoad;
  38115. private _filesToLoad;
  38116. /**
  38117. * Creates a new FilesInput
  38118. * @param engine defines the rendering engine
  38119. * @param scene defines the hosting scene
  38120. * @param sceneLoadedCallback callback called when scene is loaded
  38121. * @param progressCallback callback called to track progress
  38122. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38123. * @param textureLoadingCallback callback called when a texture is loading
  38124. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38125. * @param onReloadCallback callback called when a reload is requested
  38126. * @param errorCallback callback call if an error occurs
  38127. */
  38128. 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);
  38129. private _dragEnterHandler;
  38130. private _dragOverHandler;
  38131. private _dropHandler;
  38132. /**
  38133. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38134. * @param elementToMonitor defines the DOM element to track
  38135. */
  38136. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38137. /**
  38138. * Release all associated resources
  38139. */
  38140. dispose(): void;
  38141. private renderFunction;
  38142. private drag;
  38143. private drop;
  38144. private _traverseFolder;
  38145. private _processFiles;
  38146. /**
  38147. * Load files from a drop event
  38148. * @param event defines the drop event to use as source
  38149. */
  38150. loadFiles(event: any): void;
  38151. private _processReload;
  38152. /**
  38153. * Reload the current scene from the loaded files
  38154. */
  38155. reload(): void;
  38156. }
  38157. }
  38158. declare module BABYLON {
  38159. /**
  38160. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38161. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38162. */
  38163. class KhronosTextureContainer {
  38164. /** contents of the KTX container file */
  38165. arrayBuffer: any;
  38166. private static HEADER_LEN;
  38167. private static COMPRESSED_2D;
  38168. private static COMPRESSED_3D;
  38169. private static TEX_2D;
  38170. private static TEX_3D;
  38171. /**
  38172. * Gets the openGL type
  38173. */
  38174. glType: number;
  38175. /**
  38176. * Gets the openGL type size
  38177. */
  38178. glTypeSize: number;
  38179. /**
  38180. * Gets the openGL format
  38181. */
  38182. glFormat: number;
  38183. /**
  38184. * Gets the openGL internal format
  38185. */
  38186. glInternalFormat: number;
  38187. /**
  38188. * Gets the base internal format
  38189. */
  38190. glBaseInternalFormat: number;
  38191. /**
  38192. * Gets image width in pixel
  38193. */
  38194. pixelWidth: number;
  38195. /**
  38196. * Gets image height in pixel
  38197. */
  38198. pixelHeight: number;
  38199. /**
  38200. * Gets image depth in pixels
  38201. */
  38202. pixelDepth: number;
  38203. /**
  38204. * Gets the number of array elements
  38205. */
  38206. numberOfArrayElements: number;
  38207. /**
  38208. * Gets the number of faces
  38209. */
  38210. numberOfFaces: number;
  38211. /**
  38212. * Gets the number of mipmap levels
  38213. */
  38214. numberOfMipmapLevels: number;
  38215. /**
  38216. * Gets the bytes of key value data
  38217. */
  38218. bytesOfKeyValueData: number;
  38219. /**
  38220. * Gets the load type
  38221. */
  38222. loadType: number;
  38223. /**
  38224. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38225. */
  38226. isInvalid: boolean;
  38227. /**
  38228. * Creates a new KhronosTextureContainer
  38229. * @param arrayBuffer contents of the KTX container file
  38230. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38231. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38232. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38233. */
  38234. constructor(
  38235. /** contents of the KTX container file */
  38236. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38237. /**
  38238. * Revert the endianness of a value.
  38239. * Not as fast hardware based, but will probably never need to use
  38240. * @param val defines the value to convert
  38241. * @returns the new value
  38242. */
  38243. switchEndianness(val: number): number;
  38244. /**
  38245. * Uploads KTX content to a Babylon Texture.
  38246. * It is assumed that the texture has already been created & is currently bound
  38247. * @hidden
  38248. */
  38249. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38250. private _upload2DCompressedLevels;
  38251. }
  38252. }
  38253. declare module BABYLON {
  38254. /**
  38255. * A class serves as a medium between the observable and its observers
  38256. */
  38257. class EventState {
  38258. /**
  38259. * Create a new EventState
  38260. * @param mask defines the mask associated with this state
  38261. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38262. * @param target defines the original target of the state
  38263. * @param currentTarget defines the current target of the state
  38264. */
  38265. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38266. /**
  38267. * Initialize the current event state
  38268. * @param mask defines the mask associated with this state
  38269. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38270. * @param target defines the original target of the state
  38271. * @param currentTarget defines the current target of the state
  38272. * @returns the current event state
  38273. */
  38274. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38275. /**
  38276. * An Observer can set this property to true to prevent subsequent observers of being notified
  38277. */
  38278. skipNextObservers: boolean;
  38279. /**
  38280. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38281. */
  38282. mask: number;
  38283. /**
  38284. * The object that originally notified the event
  38285. */
  38286. target?: any;
  38287. /**
  38288. * The current object in the bubbling phase
  38289. */
  38290. currentTarget?: any;
  38291. /**
  38292. * This will be populated with the return value of the last function that was executed.
  38293. * If it is the first function in the callback chain it will be the event data.
  38294. */
  38295. lastReturnValue?: any;
  38296. }
  38297. /**
  38298. * Represent an Observer registered to a given Observable object.
  38299. */
  38300. class Observer<T> {
  38301. /**
  38302. * Defines the callback to call when the observer is notified
  38303. */
  38304. callback: (eventData: T, eventState: EventState) => void;
  38305. /**
  38306. * Defines the mask of the observer (used to filter notifications)
  38307. */
  38308. mask: number;
  38309. /**
  38310. * Defines the current scope used to restore the JS context
  38311. */
  38312. scope: any;
  38313. /** @hidden */
  38314. _willBeUnregistered: boolean;
  38315. /**
  38316. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38317. */
  38318. unregisterOnNextCall: boolean;
  38319. /**
  38320. * Creates a new observer
  38321. * @param callback defines the callback to call when the observer is notified
  38322. * @param mask defines the mask of the observer (used to filter notifications)
  38323. * @param scope defines the current scope used to restore the JS context
  38324. */
  38325. constructor(
  38326. /**
  38327. * Defines the callback to call when the observer is notified
  38328. */
  38329. callback: (eventData: T, eventState: EventState) => void,
  38330. /**
  38331. * Defines the mask of the observer (used to filter notifications)
  38332. */
  38333. mask: number,
  38334. /**
  38335. * Defines the current scope used to restore the JS context
  38336. */
  38337. scope?: any);
  38338. }
  38339. /**
  38340. * Represent a list of observers registered to multiple Observables object.
  38341. */
  38342. class MultiObserver<T> {
  38343. private _observers;
  38344. private _observables;
  38345. /**
  38346. * Release associated resources
  38347. */
  38348. dispose(): void;
  38349. /**
  38350. * Raise a callback when one of the observable will notify
  38351. * @param observables defines a list of observables to watch
  38352. * @param callback defines the callback to call on notification
  38353. * @param mask defines the mask used to filter notifications
  38354. * @param scope defines the current scope used to restore the JS context
  38355. * @returns the new MultiObserver
  38356. */
  38357. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38358. }
  38359. /**
  38360. * The Observable class is a simple implementation of the Observable pattern.
  38361. *
  38362. * 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.
  38363. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38364. * 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).
  38365. * 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.
  38366. */
  38367. class Observable<T> {
  38368. private _observers;
  38369. private _eventState;
  38370. private _onObserverAdded;
  38371. /**
  38372. * Creates a new observable
  38373. * @param onObserverAdded defines a callback to call when a new observer is added
  38374. */
  38375. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38376. /**
  38377. * Create a new Observer with the specified callback
  38378. * @param callback the callback that will be executed for that Observer
  38379. * @param mask the mask used to filter observers
  38380. * @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.
  38381. * @param scope optional scope for the callback to be called from
  38382. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38383. * @returns the new observer created for the callback
  38384. */
  38385. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38386. /**
  38387. * Create a new Observer with the specified callback and unregisters after the next notification
  38388. * @param callback the callback that will be executed for that Observer
  38389. * @returns the new observer created for the callback
  38390. */
  38391. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38392. /**
  38393. * Remove an Observer from the Observable object
  38394. * @param observer the instance of the Observer to remove
  38395. * @returns false if it doesn't belong to this Observable
  38396. */
  38397. remove(observer: Nullable<Observer<T>>): boolean;
  38398. /**
  38399. * Remove a callback from the Observable object
  38400. * @param callback the callback to remove
  38401. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38402. * @returns false if it doesn't belong to this Observable
  38403. */
  38404. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38405. private _deferUnregister;
  38406. private _remove;
  38407. /**
  38408. * Notify all Observers by calling their respective callback with the given data
  38409. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38410. * @param eventData defines the data to send to all observers
  38411. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38412. * @param target defines the original target of the state
  38413. * @param currentTarget defines the current target of the state
  38414. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38415. */
  38416. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38417. /**
  38418. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38419. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38420. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38421. * and it is crucial that all callbacks will be executed.
  38422. * The order of the callbacks is kept, callbacks are not executed parallel.
  38423. *
  38424. * @param eventData The data to be sent to each callback
  38425. * @param mask is used to filter observers defaults to -1
  38426. * @param target defines the callback target (see EventState)
  38427. * @param currentTarget defines he current object in the bubbling phase
  38428. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38429. */
  38430. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38431. /**
  38432. * Notify a specific observer
  38433. * @param observer defines the observer to notify
  38434. * @param eventData defines the data to be sent to each callback
  38435. * @param mask is used to filter observers defaults to -1
  38436. */
  38437. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38438. /**
  38439. * Gets a boolean indicating if the observable has at least one observer
  38440. * @returns true is the Observable has at least one Observer registered
  38441. */
  38442. hasObservers(): boolean;
  38443. /**
  38444. * Clear the list of observers
  38445. */
  38446. clear(): void;
  38447. /**
  38448. * Clone the current observable
  38449. * @returns a new observable
  38450. */
  38451. clone(): Observable<T>;
  38452. /**
  38453. * Does this observable handles observer registered with a given mask
  38454. * @param mask defines the mask to be tested
  38455. * @return whether or not one observer registered with the given mask is handeled
  38456. **/
  38457. hasSpecificMask(mask?: number): boolean;
  38458. }
  38459. }
  38460. declare module BABYLON {
  38461. /**
  38462. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38463. */
  38464. class PerformanceMonitor {
  38465. private _enabled;
  38466. private _rollingFrameTime;
  38467. private _lastFrameTimeMs;
  38468. /**
  38469. * constructor
  38470. * @param frameSampleSize The number of samples required to saturate the sliding window
  38471. */
  38472. constructor(frameSampleSize?: number);
  38473. /**
  38474. * Samples current frame
  38475. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38476. */
  38477. sampleFrame(timeMs?: number): void;
  38478. /**
  38479. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38480. */
  38481. readonly averageFrameTime: number;
  38482. /**
  38483. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38484. */
  38485. readonly averageFrameTimeVariance: number;
  38486. /**
  38487. * Returns the frame time of the most recent frame
  38488. */
  38489. readonly instantaneousFrameTime: number;
  38490. /**
  38491. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38492. */
  38493. readonly averageFPS: number;
  38494. /**
  38495. * Returns the average framerate in frames per second using the most recent frame time
  38496. */
  38497. readonly instantaneousFPS: number;
  38498. /**
  38499. * Returns true if enough samples have been taken to completely fill the sliding window
  38500. */
  38501. readonly isSaturated: boolean;
  38502. /**
  38503. * Enables contributions to the sliding window sample set
  38504. */
  38505. enable(): void;
  38506. /**
  38507. * Disables contributions to the sliding window sample set
  38508. * Samples will not be interpolated over the disabled period
  38509. */
  38510. disable(): void;
  38511. /**
  38512. * Returns true if sampling is enabled
  38513. */
  38514. readonly isEnabled: boolean;
  38515. /**
  38516. * Resets performance monitor
  38517. */
  38518. reset(): void;
  38519. }
  38520. /**
  38521. * RollingAverage
  38522. *
  38523. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38524. */
  38525. class RollingAverage {
  38526. /**
  38527. * Current average
  38528. */
  38529. average: number;
  38530. /**
  38531. * Current variance
  38532. */
  38533. variance: number;
  38534. protected _samples: Array<number>;
  38535. protected _sampleCount: number;
  38536. protected _pos: number;
  38537. protected _m2: number;
  38538. /**
  38539. * constructor
  38540. * @param length The number of samples required to saturate the sliding window
  38541. */
  38542. constructor(length: number);
  38543. /**
  38544. * Adds a sample to the sample set
  38545. * @param v The sample value
  38546. */
  38547. add(v: number): void;
  38548. /**
  38549. * Returns previously added values or null if outside of history or outside the sliding window domain
  38550. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38551. * @return Value previously recorded with add() or null if outside of range
  38552. */
  38553. history(i: number): number;
  38554. /**
  38555. * Returns true if enough samples have been taken to completely fill the sliding window
  38556. * @return true if sample-set saturated
  38557. */
  38558. isSaturated(): boolean;
  38559. /**
  38560. * Resets the rolling average (equivalent to 0 samples taken so far)
  38561. */
  38562. reset(): void;
  38563. /**
  38564. * Wraps a value around the sample range boundaries
  38565. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38566. * @return Wrapped position in sample range
  38567. */
  38568. protected _wrapPosition(i: number): number;
  38569. }
  38570. }
  38571. declare module BABYLON {
  38572. /**
  38573. * Helper class that provides a small promise polyfill
  38574. */
  38575. class PromisePolyfill {
  38576. /**
  38577. * Static function used to check if the polyfill is required
  38578. * If this is the case then the function will inject the polyfill to window.Promise
  38579. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38580. */
  38581. static Apply(force?: boolean): void;
  38582. }
  38583. }
  38584. declare module BABYLON {
  38585. /**
  38586. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38588. */
  38589. class SceneOptimization {
  38590. /**
  38591. * Defines the priority of this optimization (0 by default which means first in the list)
  38592. */
  38593. priority: number;
  38594. /**
  38595. * Gets a string describing the action executed by the current optimization
  38596. * @returns description string
  38597. */
  38598. getDescription(): string;
  38599. /**
  38600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38601. * @param scene defines the current scene where to apply this optimization
  38602. * @param optimizer defines the current optimizer
  38603. * @returns true if everything that can be done was applied
  38604. */
  38605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38606. /**
  38607. * Creates the SceneOptimization object
  38608. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38609. * @param desc defines the description associated with the optimization
  38610. */
  38611. constructor(
  38612. /**
  38613. * Defines the priority of this optimization (0 by default which means first in the list)
  38614. */
  38615. priority?: number);
  38616. }
  38617. /**
  38618. * Defines an optimization used to reduce the size of render target textures
  38619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38620. */
  38621. class TextureOptimization extends SceneOptimization {
  38622. /**
  38623. * Defines the priority of this optimization (0 by default which means first in the list)
  38624. */
  38625. priority: number;
  38626. /**
  38627. * 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
  38628. */
  38629. maximumSize: number;
  38630. /**
  38631. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38632. */
  38633. step: number;
  38634. /**
  38635. * Gets a string describing the action executed by the current optimization
  38636. * @returns description string
  38637. */
  38638. getDescription(): string;
  38639. /**
  38640. * Creates the TextureOptimization object
  38641. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38642. * @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
  38643. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38644. */
  38645. constructor(
  38646. /**
  38647. * Defines the priority of this optimization (0 by default which means first in the list)
  38648. */
  38649. priority?: number,
  38650. /**
  38651. * 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
  38652. */
  38653. maximumSize?: number,
  38654. /**
  38655. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38656. */
  38657. step?: number);
  38658. /**
  38659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38660. * @param scene defines the current scene where to apply this optimization
  38661. * @param optimizer defines the current optimizer
  38662. * @returns true if everything that can be done was applied
  38663. */
  38664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38665. }
  38666. /**
  38667. * Defines an optimization used to increase or decrease the rendering resolution
  38668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38669. */
  38670. class HardwareScalingOptimization extends SceneOptimization {
  38671. /**
  38672. * Defines the priority of this optimization (0 by default which means first in the list)
  38673. */
  38674. priority: number;
  38675. /**
  38676. * Defines the maximum scale to use (2 by default)
  38677. */
  38678. maximumScale: number;
  38679. /**
  38680. * Defines the step to use between two passes (0.5 by default)
  38681. */
  38682. step: number;
  38683. private _currentScale;
  38684. private _directionOffset;
  38685. /**
  38686. * Gets a string describing the action executed by the current optimization
  38687. * @return description string
  38688. */
  38689. getDescription(): string;
  38690. /**
  38691. * Creates the HardwareScalingOptimization object
  38692. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38693. * @param maximumScale defines the maximum scale to use (2 by default)
  38694. * @param step defines the step to use between two passes (0.5 by default)
  38695. */
  38696. constructor(
  38697. /**
  38698. * Defines the priority of this optimization (0 by default which means first in the list)
  38699. */
  38700. priority?: number,
  38701. /**
  38702. * Defines the maximum scale to use (2 by default)
  38703. */
  38704. maximumScale?: number,
  38705. /**
  38706. * Defines the step to use between two passes (0.5 by default)
  38707. */
  38708. step?: number);
  38709. /**
  38710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38711. * @param scene defines the current scene where to apply this optimization
  38712. * @param optimizer defines the current optimizer
  38713. * @returns true if everything that can be done was applied
  38714. */
  38715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38716. }
  38717. /**
  38718. * Defines an optimization used to remove shadows
  38719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38720. */
  38721. class ShadowsOptimization extends SceneOptimization {
  38722. /**
  38723. * Gets a string describing the action executed by the current optimization
  38724. * @return description string
  38725. */
  38726. getDescription(): string;
  38727. /**
  38728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38729. * @param scene defines the current scene where to apply this optimization
  38730. * @param optimizer defines the current optimizer
  38731. * @returns true if everything that can be done was applied
  38732. */
  38733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38734. }
  38735. /**
  38736. * Defines an optimization used to turn post-processes off
  38737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38738. */
  38739. class PostProcessesOptimization extends SceneOptimization {
  38740. /**
  38741. * Gets a string describing the action executed by the current optimization
  38742. * @return description string
  38743. */
  38744. getDescription(): string;
  38745. /**
  38746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38747. * @param scene defines the current scene where to apply this optimization
  38748. * @param optimizer defines the current optimizer
  38749. * @returns true if everything that can be done was applied
  38750. */
  38751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38752. }
  38753. /**
  38754. * Defines an optimization used to turn lens flares off
  38755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38756. */
  38757. class LensFlaresOptimization extends SceneOptimization {
  38758. /**
  38759. * Gets a string describing the action executed by the current optimization
  38760. * @return description string
  38761. */
  38762. getDescription(): string;
  38763. /**
  38764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38765. * @param scene defines the current scene where to apply this optimization
  38766. * @param optimizer defines the current optimizer
  38767. * @returns true if everything that can be done was applied
  38768. */
  38769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38770. }
  38771. /**
  38772. * Defines an optimization based on user defined callback.
  38773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38774. */
  38775. class CustomOptimization extends SceneOptimization {
  38776. /**
  38777. * Callback called to apply the custom optimization.
  38778. */
  38779. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38780. /**
  38781. * Callback called to get custom description
  38782. */
  38783. onGetDescription: () => string;
  38784. /**
  38785. * Gets a string describing the action executed by the current optimization
  38786. * @returns description string
  38787. */
  38788. getDescription(): string;
  38789. /**
  38790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38791. * @param scene defines the current scene where to apply this optimization
  38792. * @param optimizer defines the current optimizer
  38793. * @returns true if everything that can be done was applied
  38794. */
  38795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38796. }
  38797. /**
  38798. * Defines an optimization used to turn particles off
  38799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38800. */
  38801. class ParticlesOptimization extends SceneOptimization {
  38802. /**
  38803. * Gets a string describing the action executed by the current optimization
  38804. * @return description string
  38805. */
  38806. getDescription(): string;
  38807. /**
  38808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38809. * @param scene defines the current scene where to apply this optimization
  38810. * @param optimizer defines the current optimizer
  38811. * @returns true if everything that can be done was applied
  38812. */
  38813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38814. }
  38815. /**
  38816. * Defines an optimization used to turn render targets off
  38817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38818. */
  38819. class RenderTargetsOptimization extends SceneOptimization {
  38820. /**
  38821. * Gets a string describing the action executed by the current optimization
  38822. * @return description string
  38823. */
  38824. getDescription(): string;
  38825. /**
  38826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38827. * @param scene defines the current scene where to apply this optimization
  38828. * @param optimizer defines the current optimizer
  38829. * @returns true if everything that can be done was applied
  38830. */
  38831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38832. }
  38833. /**
  38834. * Defines an optimization used to merge meshes with compatible materials
  38835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38836. */
  38837. class MergeMeshesOptimization extends SceneOptimization {
  38838. private static _UpdateSelectionTree;
  38839. /**
  38840. * Gets or sets a boolean which defines if optimization octree has to be updated
  38841. */
  38842. /**
  38843. * Gets or sets a boolean which defines if optimization octree has to be updated
  38844. */
  38845. static UpdateSelectionTree: boolean;
  38846. /**
  38847. * Gets a string describing the action executed by the current optimization
  38848. * @return description string
  38849. */
  38850. getDescription(): string;
  38851. private _canBeMerged;
  38852. /**
  38853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38854. * @param scene defines the current scene where to apply this optimization
  38855. * @param optimizer defines the current optimizer
  38856. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38857. * @returns true if everything that can be done was applied
  38858. */
  38859. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38860. }
  38861. /**
  38862. * Defines a list of options used by SceneOptimizer
  38863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38864. */
  38865. class SceneOptimizerOptions {
  38866. /**
  38867. * Defines the target frame rate to reach (60 by default)
  38868. */
  38869. targetFrameRate: number;
  38870. /**
  38871. * Defines the interval between two checkes (2000ms by default)
  38872. */
  38873. trackerDuration: number;
  38874. /**
  38875. * Gets the list of optimizations to apply
  38876. */
  38877. optimizations: SceneOptimization[];
  38878. /**
  38879. * Creates a new list of options used by SceneOptimizer
  38880. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38881. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38882. */
  38883. constructor(
  38884. /**
  38885. * Defines the target frame rate to reach (60 by default)
  38886. */
  38887. targetFrameRate?: number,
  38888. /**
  38889. * Defines the interval between two checkes (2000ms by default)
  38890. */
  38891. trackerDuration?: number);
  38892. /**
  38893. * Add a new optimization
  38894. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38895. * @returns the current SceneOptimizerOptions
  38896. */
  38897. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38898. /**
  38899. * Add a new custom optimization
  38900. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38901. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38902. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38903. * @returns the current SceneOptimizerOptions
  38904. */
  38905. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38906. /**
  38907. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38908. * @param targetFrameRate defines the target frame rate (60 by default)
  38909. * @returns a SceneOptimizerOptions object
  38910. */
  38911. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38912. /**
  38913. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38914. * @param targetFrameRate defines the target frame rate (60 by default)
  38915. * @returns a SceneOptimizerOptions object
  38916. */
  38917. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38918. /**
  38919. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38920. * @param targetFrameRate defines the target frame rate (60 by default)
  38921. * @returns a SceneOptimizerOptions object
  38922. */
  38923. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38924. }
  38925. /**
  38926. * Class used to run optimizations in order to reach a target frame rate
  38927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38928. */
  38929. class SceneOptimizer implements IDisposable {
  38930. private _isRunning;
  38931. private _options;
  38932. private _scene;
  38933. private _currentPriorityLevel;
  38934. private _targetFrameRate;
  38935. private _trackerDuration;
  38936. private _currentFrameRate;
  38937. private _sceneDisposeObserver;
  38938. private _improvementMode;
  38939. /**
  38940. * Defines an observable called when the optimizer reaches the target frame rate
  38941. */
  38942. onSuccessObservable: Observable<SceneOptimizer>;
  38943. /**
  38944. * Defines an observable called when the optimizer enables an optimization
  38945. */
  38946. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38947. /**
  38948. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38949. */
  38950. onFailureObservable: Observable<SceneOptimizer>;
  38951. /**
  38952. * Gets a boolean indicating if the optimizer is in improvement mode
  38953. */
  38954. readonly isInImprovementMode: boolean;
  38955. /**
  38956. * Gets the current priority level (0 at start)
  38957. */
  38958. readonly currentPriorityLevel: number;
  38959. /**
  38960. * Gets the current frame rate checked by the SceneOptimizer
  38961. */
  38962. readonly currentFrameRate: number;
  38963. /**
  38964. * Gets or sets the current target frame rate (60 by default)
  38965. */
  38966. /**
  38967. * Gets or sets the current target frame rate (60 by default)
  38968. */
  38969. targetFrameRate: number;
  38970. /**
  38971. * Gets or sets the current interval between two checks (every 2000ms by default)
  38972. */
  38973. /**
  38974. * Gets or sets the current interval between two checks (every 2000ms by default)
  38975. */
  38976. trackerDuration: number;
  38977. /**
  38978. * Gets the list of active optimizations
  38979. */
  38980. readonly optimizations: SceneOptimization[];
  38981. /**
  38982. * Creates a new SceneOptimizer
  38983. * @param scene defines the scene to work on
  38984. * @param options defines the options to use with the SceneOptimizer
  38985. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38986. * @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)
  38987. */
  38988. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38989. /**
  38990. * Stops the current optimizer
  38991. */
  38992. stop(): void;
  38993. /**
  38994. * Reset the optimizer to initial step (current priority level = 0)
  38995. */
  38996. reset(): void;
  38997. /**
  38998. * Start the optimizer. By default it will try to reach a specific framerate
  38999. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39000. */
  39001. start(): void;
  39002. private _checkCurrentState;
  39003. /**
  39004. * Release all resources
  39005. */
  39006. dispose(): void;
  39007. /**
  39008. * Helper function to create a SceneOptimizer with one single line of code
  39009. * @param scene defines the scene to work on
  39010. * @param options defines the options to use with the SceneOptimizer
  39011. * @param onSuccess defines a callback to call on success
  39012. * @param onFailure defines a callback to call on failure
  39013. * @returns the new SceneOptimizer object
  39014. */
  39015. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39016. }
  39017. }
  39018. declare module BABYLON {
  39019. /**
  39020. * Class used to serialize a scene into a string
  39021. */
  39022. class SceneSerializer {
  39023. /**
  39024. * Clear cache used by a previous serialization
  39025. */
  39026. static ClearCache(): void;
  39027. /**
  39028. * Serialize a scene into a JSON compatible object
  39029. * @param scene defines the scene to serialize
  39030. * @returns a JSON compatible object
  39031. */
  39032. static Serialize(scene: Scene): any;
  39033. /**
  39034. * Serialize a mesh into a JSON compatible object
  39035. * @param toSerialize defines the mesh to serialize
  39036. * @param withParents defines if parents must be serialized as well
  39037. * @param withChildren defines if children must be serialized as well
  39038. * @returns a JSON compatible object
  39039. */
  39040. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39041. }
  39042. }
  39043. declare module BABYLON {
  39044. /**
  39045. * Defines an array and its length.
  39046. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39047. */
  39048. interface ISmartArrayLike<T> {
  39049. /**
  39050. * The data of the array.
  39051. */
  39052. data: Array<T>;
  39053. /**
  39054. * The active length of the array.
  39055. */
  39056. length: number;
  39057. }
  39058. /**
  39059. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39060. */
  39061. class SmartArray<T> implements ISmartArrayLike<T> {
  39062. /**
  39063. * The full set of data from the array.
  39064. */
  39065. data: Array<T>;
  39066. /**
  39067. * The active length of the array.
  39068. */
  39069. length: number;
  39070. protected _id: number;
  39071. /**
  39072. * Instantiates a Smart Array.
  39073. * @param capacity defines the default capacity of the array.
  39074. */
  39075. constructor(capacity: number);
  39076. /**
  39077. * Pushes a value at the end of the active data.
  39078. * @param value defines the object to push in the array.
  39079. */
  39080. push(value: T): void;
  39081. /**
  39082. * Iterates over the active data and apply the lambda to them.
  39083. * @param func defines the action to apply on each value.
  39084. */
  39085. forEach(func: (content: T) => void): void;
  39086. /**
  39087. * Sorts the full sets of data.
  39088. * @param compareFn defines the comparison function to apply.
  39089. */
  39090. sort(compareFn: (a: T, b: T) => number): void;
  39091. /**
  39092. * Resets the active data to an empty array.
  39093. */
  39094. reset(): void;
  39095. /**
  39096. * Releases all the data from the array as well as the array.
  39097. */
  39098. dispose(): void;
  39099. /**
  39100. * Concats the active data with a given array.
  39101. * @param array defines the data to concatenate with.
  39102. */
  39103. concat(array: any): void;
  39104. /**
  39105. * Returns the position of a value in the active data.
  39106. * @param value defines the value to find the index for
  39107. * @returns the index if found in the active data otherwise -1
  39108. */
  39109. indexOf(value: T): number;
  39110. /**
  39111. * Returns whether an element is part of the active data.
  39112. * @param value defines the value to look for
  39113. * @returns true if found in the active data otherwise false
  39114. */
  39115. contains(value: T): boolean;
  39116. private static _GlobalId;
  39117. }
  39118. /**
  39119. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39120. * The data in this array can only be present once
  39121. */
  39122. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39123. private _duplicateId;
  39124. /**
  39125. * Pushes a value at the end of the active data.
  39126. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39127. * @param value defines the object to push in the array.
  39128. */
  39129. push(value: T): void;
  39130. /**
  39131. * Pushes a value at the end of the active data.
  39132. * If the data is already present, it won t be added again
  39133. * @param value defines the object to push in the array.
  39134. * @returns true if added false if it was already present
  39135. */
  39136. pushNoDuplicate(value: T): boolean;
  39137. /**
  39138. * Resets the active data to an empty array.
  39139. */
  39140. reset(): void;
  39141. /**
  39142. * Concats the active data with a given array.
  39143. * This ensures no dupplicate will be present in the result.
  39144. * @param array defines the data to concatenate with.
  39145. */
  39146. concatWithNoDuplicate(array: any): void;
  39147. }
  39148. }
  39149. declare module BABYLON {
  39150. /**
  39151. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39152. * The underlying implementation relies on an associative array to ensure the best performances.
  39153. * The value can be anything including 'null' but except 'undefined'
  39154. */
  39155. class StringDictionary<T> {
  39156. /**
  39157. * This will clear this dictionary and copy the content from the 'source' one.
  39158. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39159. * @param source the dictionary to take the content from and copy to this dictionary
  39160. */
  39161. copyFrom(source: StringDictionary<T>): void;
  39162. /**
  39163. * Get a value based from its key
  39164. * @param key the given key to get the matching value from
  39165. * @return the value if found, otherwise undefined is returned
  39166. */
  39167. get(key: string): T | undefined;
  39168. /**
  39169. * Get a value from its key or add it if it doesn't exist.
  39170. * This method will ensure you that a given key/data will be present in the dictionary.
  39171. * @param key the given key to get the matching value from
  39172. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39173. * The factory will only be invoked if there's no data for the given key.
  39174. * @return the value corresponding to the key.
  39175. */
  39176. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39177. /**
  39178. * Get a value from its key if present in the dictionary otherwise add it
  39179. * @param key the key to get the value from
  39180. * @param val if there's no such key/value pair in the dictionary add it with this value
  39181. * @return the value corresponding to the key
  39182. */
  39183. getOrAdd(key: string, val: T): T;
  39184. /**
  39185. * Check if there's a given key in the dictionary
  39186. * @param key the key to check for
  39187. * @return true if the key is present, false otherwise
  39188. */
  39189. contains(key: string): boolean;
  39190. /**
  39191. * Add a new key and its corresponding value
  39192. * @param key the key to add
  39193. * @param value the value corresponding to the key
  39194. * @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
  39195. */
  39196. add(key: string, value: T): boolean;
  39197. /**
  39198. * Update a specific value associated to a key
  39199. * @param key defines the key to use
  39200. * @param value defines the value to store
  39201. * @returns true if the value was updated (or false if the key was not found)
  39202. */
  39203. set(key: string, value: T): boolean;
  39204. /**
  39205. * Get the element of the given key and remove it from the dictionary
  39206. * @param key defines the key to search
  39207. * @returns the value associated with the key or null if not found
  39208. */
  39209. getAndRemove(key: string): Nullable<T>;
  39210. /**
  39211. * Remove a key/value from the dictionary.
  39212. * @param key the key to remove
  39213. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39214. */
  39215. remove(key: string): boolean;
  39216. /**
  39217. * Clear the whole content of the dictionary
  39218. */
  39219. clear(): void;
  39220. /**
  39221. * Gets the current count
  39222. */
  39223. readonly count: number;
  39224. /**
  39225. * Execute a callback on each key/val of the dictionary.
  39226. * Note that you can remove any element in this dictionary in the callback implementation
  39227. * @param callback the callback to execute on a given key/value pair
  39228. */
  39229. forEach(callback: (key: string, val: T) => void): void;
  39230. /**
  39231. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39232. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39233. * Note that you can remove any element in this dictionary in the callback implementation
  39234. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39235. * @returns the first item
  39236. */
  39237. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39238. private _count;
  39239. private _data;
  39240. }
  39241. }
  39242. declare module BABYLON {
  39243. /**
  39244. * Class used to store custom tags
  39245. */
  39246. class Tags {
  39247. /**
  39248. * Adds support for tags on the given object
  39249. * @param obj defines the object to use
  39250. */
  39251. static EnableFor(obj: any): void;
  39252. /**
  39253. * Removes tags support
  39254. * @param obj defines the object to use
  39255. */
  39256. static DisableFor(obj: any): void;
  39257. /**
  39258. * Gets a boolean indicating if the given object has tags
  39259. * @param obj defines the object to use
  39260. * @returns a boolean
  39261. */
  39262. static HasTags(obj: any): boolean;
  39263. /**
  39264. * Gets the tags available on a given object
  39265. * @param obj defines the object to use
  39266. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39267. * @returns the tags
  39268. */
  39269. static GetTags(obj: any, asString?: boolean): any;
  39270. /**
  39271. * Adds tags to an object
  39272. * @param obj defines the object to use
  39273. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39274. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39275. */
  39276. static AddTagsTo(obj: any, tagsString: string): void;
  39277. /**
  39278. * @hidden
  39279. */
  39280. static _AddTagTo(obj: any, tag: string): void;
  39281. /**
  39282. * Removes specific tags from a specific object
  39283. * @param obj defines the object to use
  39284. * @param tagsString defines the tags to remove
  39285. */
  39286. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39287. /**
  39288. * @hidden
  39289. */
  39290. static _RemoveTagFrom(obj: any, tag: string): void;
  39291. /**
  39292. * Defines if tags hosted on an object match a given query
  39293. * @param obj defines the object to use
  39294. * @param tagsQuery defines the tag query
  39295. * @returns a boolean
  39296. */
  39297. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39298. }
  39299. }
  39300. declare module BABYLON {
  39301. /**
  39302. * Class used to host texture specific utilities
  39303. */
  39304. class TextureTools {
  39305. /**
  39306. * Uses the GPU to create a copy texture rescaled at a given size
  39307. * @param texture Texture to copy from
  39308. * @param width defines the desired width
  39309. * @param height defines the desired height
  39310. * @param useBilinearMode defines if bilinear mode has to be used
  39311. * @return the generated texture
  39312. */
  39313. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39314. /**
  39315. * Gets an environment BRDF texture for a given scene
  39316. * @param scene defines the hosting scene
  39317. * @returns the environment BRDF texture
  39318. */
  39319. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39320. private static _environmentBRDFBase64Texture;
  39321. }
  39322. }
  39323. declare module BABYLON {
  39324. /**
  39325. * Based on jsTGALoader - Javascript loader for TGA file
  39326. * By Vincent Thibault
  39327. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39328. */
  39329. class TGATools {
  39330. private static _TYPE_INDEXED;
  39331. private static _TYPE_RGB;
  39332. private static _TYPE_GREY;
  39333. private static _TYPE_RLE_INDEXED;
  39334. private static _TYPE_RLE_RGB;
  39335. private static _TYPE_RLE_GREY;
  39336. private static _ORIGIN_MASK;
  39337. private static _ORIGIN_SHIFT;
  39338. private static _ORIGIN_BL;
  39339. private static _ORIGIN_BR;
  39340. private static _ORIGIN_UL;
  39341. private static _ORIGIN_UR;
  39342. /**
  39343. * Gets the header of a TGA file
  39344. * @param data defines the TGA data
  39345. * @returns the header
  39346. */
  39347. static GetTGAHeader(data: Uint8Array): any;
  39348. /**
  39349. * Uploads TGA content to a Babylon Texture
  39350. * @hidden
  39351. */
  39352. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39353. /** @hidden */
  39354. 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;
  39355. /** @hidden */
  39356. 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;
  39357. /** @hidden */
  39358. 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;
  39359. /** @hidden */
  39360. 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;
  39361. /** @hidden */
  39362. 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;
  39363. /** @hidden */
  39364. 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;
  39365. }
  39366. }
  39367. declare module BABYLON {
  39368. /**
  39369. * Interface for any object that can request an animation frame
  39370. */
  39371. interface ICustomAnimationFrameRequester {
  39372. /**
  39373. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39374. */
  39375. renderFunction?: Function;
  39376. /**
  39377. * Called to request the next frame to render to
  39378. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39379. */
  39380. requestAnimationFrame: Function;
  39381. /**
  39382. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39383. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39384. */
  39385. requestID?: number;
  39386. }
  39387. /**
  39388. * Interface containing an array of animations
  39389. */
  39390. interface IAnimatable {
  39391. /**
  39392. * Array of animations
  39393. */
  39394. animations: Array<Animation>;
  39395. }
  39396. /** Interface used by value gradients (color, factor, ...) */
  39397. interface IValueGradient {
  39398. /**
  39399. * Gets or sets the gradient value (between 0 and 1)
  39400. */
  39401. gradient: number;
  39402. }
  39403. /** Class used to store color4 gradient */
  39404. class ColorGradient implements IValueGradient {
  39405. /**
  39406. * Gets or sets the gradient value (between 0 and 1)
  39407. */
  39408. gradient: number;
  39409. /**
  39410. * Gets or sets first associated color
  39411. */
  39412. color1: Color4;
  39413. /**
  39414. * Gets or sets second associated color
  39415. */
  39416. color2?: Color4;
  39417. /**
  39418. * Will get a color picked randomly between color1 and color2.
  39419. * If color2 is undefined then color1 will be used
  39420. * @param result defines the target Color4 to store the result in
  39421. */
  39422. getColorToRef(result: Color4): void;
  39423. }
  39424. /** Class used to store color 3 gradient */
  39425. class Color3Gradient implements IValueGradient {
  39426. /**
  39427. * Gets or sets the gradient value (between 0 and 1)
  39428. */
  39429. gradient: number;
  39430. /**
  39431. * Gets or sets the associated color
  39432. */
  39433. color: Color3;
  39434. }
  39435. /** Class used to store factor gradient */
  39436. class FactorGradient implements IValueGradient {
  39437. /**
  39438. * Gets or sets the gradient value (between 0 and 1)
  39439. */
  39440. gradient: number;
  39441. /**
  39442. * Gets or sets first associated factor
  39443. */
  39444. factor1: number;
  39445. /**
  39446. * Gets or sets second associated factor
  39447. */
  39448. factor2?: number;
  39449. /**
  39450. * Will get a number picked randomly between factor1 and factor2.
  39451. * If factor2 is undefined then factor1 will be used
  39452. * @returns the picked number
  39453. */
  39454. getFactor(): number;
  39455. }
  39456. /**
  39457. * @ignore
  39458. * Application error to support additional information when loading a file
  39459. */
  39460. class LoadFileError extends Error {
  39461. /** defines the optional XHR request */
  39462. request?: XMLHttpRequest | undefined;
  39463. private static _setPrototypeOf;
  39464. /**
  39465. * Creates a new LoadFileError
  39466. * @param message defines the message of the error
  39467. * @param request defines the optional XHR request
  39468. */
  39469. constructor(message: string,
  39470. /** defines the optional XHR request */
  39471. request?: XMLHttpRequest | undefined);
  39472. }
  39473. /**
  39474. * Class used to define a retry strategy when error happens while loading assets
  39475. */
  39476. class RetryStrategy {
  39477. /**
  39478. * Function used to defines an exponential back off strategy
  39479. * @param maxRetries defines the maximum number of retries (3 by default)
  39480. * @param baseInterval defines the interval between retries
  39481. * @returns the strategy function to use
  39482. */
  39483. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39484. }
  39485. /**
  39486. * File request interface
  39487. */
  39488. interface IFileRequest {
  39489. /**
  39490. * Raised when the request is complete (success or error).
  39491. */
  39492. onCompleteObservable: Observable<IFileRequest>;
  39493. /**
  39494. * Aborts the request for a file.
  39495. */
  39496. abort: () => void;
  39497. }
  39498. /**
  39499. * Class containing a set of static utilities functions
  39500. */
  39501. class Tools {
  39502. /**
  39503. * Gets or sets the base URL to use to load assets
  39504. */
  39505. static BaseUrl: string;
  39506. /**
  39507. * Enable/Disable Custom HTTP Request Headers globally.
  39508. * default = false
  39509. * @see CustomRequestHeaders
  39510. */
  39511. static UseCustomRequestHeaders: boolean;
  39512. /**
  39513. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39514. * i.e. when loading files, where the server/service expects an Authorization header.
  39515. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39516. */
  39517. static CustomRequestHeaders: {
  39518. [key: string]: string;
  39519. };
  39520. /**
  39521. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39522. */
  39523. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39524. /**
  39525. * Default behaviour for cors in the application.
  39526. * It can be a string if the expected behavior is identical in the entire app.
  39527. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39528. */
  39529. static CorsBehavior: string | ((url: string | string[]) => string);
  39530. /**
  39531. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39532. * @ignorenaming
  39533. */
  39534. static UseFallbackTexture: boolean;
  39535. /**
  39536. * Use this object to register external classes like custom textures or material
  39537. * to allow the laoders to instantiate them
  39538. */
  39539. static RegisteredExternalClasses: {
  39540. [key: string]: Object;
  39541. };
  39542. /**
  39543. * Texture content used if a texture cannot loaded
  39544. * @ignorenaming
  39545. */
  39546. static fallbackTexture: string;
  39547. /**
  39548. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39549. * @param u defines the coordinate on X axis
  39550. * @param v defines the coordinate on Y axis
  39551. * @param width defines the width of the source data
  39552. * @param height defines the height of the source data
  39553. * @param pixels defines the source byte array
  39554. * @param color defines the output color
  39555. */
  39556. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39557. /**
  39558. * Interpolates between a and b via alpha
  39559. * @param a The lower value (returned when alpha = 0)
  39560. * @param b The upper value (returned when alpha = 1)
  39561. * @param alpha The interpolation-factor
  39562. * @return The mixed value
  39563. */
  39564. static Mix(a: number, b: number, alpha: number): number;
  39565. /**
  39566. * Tries to instantiate a new object from a given class name
  39567. * @param className defines the class name to instantiate
  39568. * @returns the new object or null if the system was not able to do the instantiation
  39569. */
  39570. static Instantiate(className: string): any;
  39571. /**
  39572. * Provides a slice function that will work even on IE
  39573. * @param data defines the array to slice
  39574. * @param start defines the start of the data (optional)
  39575. * @param end defines the end of the data (optional)
  39576. * @returns the new sliced array
  39577. */
  39578. static Slice<T>(data: T, start?: number, end?: number): T;
  39579. /**
  39580. * Polyfill for setImmediate
  39581. * @param action defines the action to execute after the current execution block
  39582. */
  39583. static SetImmediate(action: () => void): void;
  39584. /**
  39585. * Function indicating if a number is an exponent of 2
  39586. * @param value defines the value to test
  39587. * @returns true if the value is an exponent of 2
  39588. */
  39589. static IsExponentOfTwo(value: number): boolean;
  39590. private static _tmpFloatArray;
  39591. /**
  39592. * Returns the nearest 32-bit single precision float representation of a Number
  39593. * @param value A Number. If the parameter is of a different type, it will get converted
  39594. * to a number or to NaN if it cannot be converted
  39595. * @returns number
  39596. */
  39597. static FloatRound(value: number): number;
  39598. /**
  39599. * Find the next highest power of two.
  39600. * @param x Number to start search from.
  39601. * @return Next highest power of two.
  39602. */
  39603. static CeilingPOT(x: number): number;
  39604. /**
  39605. * Find the next lowest power of two.
  39606. * @param x Number to start search from.
  39607. * @return Next lowest power of two.
  39608. */
  39609. static FloorPOT(x: number): number;
  39610. /**
  39611. * Find the nearest power of two.
  39612. * @param x Number to start search from.
  39613. * @return Next nearest power of two.
  39614. */
  39615. static NearestPOT(x: number): number;
  39616. /**
  39617. * Get the closest exponent of two
  39618. * @param value defines the value to approximate
  39619. * @param max defines the maximum value to return
  39620. * @param mode defines how to define the closest value
  39621. * @returns closest exponent of two of the given value
  39622. */
  39623. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39624. /**
  39625. * Extracts the filename from a path
  39626. * @param path defines the path to use
  39627. * @returns the filename
  39628. */
  39629. static GetFilename(path: string): string;
  39630. /**
  39631. * Extracts the "folder" part of a path (everything before the filename).
  39632. * @param uri The URI to extract the info from
  39633. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39634. * @returns The "folder" part of the path
  39635. */
  39636. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39637. /**
  39638. * Extracts text content from a DOM element hierarchy
  39639. * @param element defines the root element
  39640. * @returns a string
  39641. */
  39642. static GetDOMTextContent(element: HTMLElement): string;
  39643. /**
  39644. * Convert an angle in radians to degrees
  39645. * @param angle defines the angle to convert
  39646. * @returns the angle in degrees
  39647. */
  39648. static ToDegrees(angle: number): number;
  39649. /**
  39650. * Convert an angle in degrees to radians
  39651. * @param angle defines the angle to convert
  39652. * @returns the angle in radians
  39653. */
  39654. static ToRadians(angle: number): number;
  39655. /**
  39656. * Encode a buffer to a base64 string
  39657. * @param buffer defines the buffer to encode
  39658. * @returns the encoded string
  39659. */
  39660. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39661. /**
  39662. * Extracts minimum and maximum values from a list of indexed positions
  39663. * @param positions defines the positions to use
  39664. * @param indices defines the indices to the positions
  39665. * @param indexStart defines the start index
  39666. * @param indexCount defines the end index
  39667. * @param bias defines bias value to add to the result
  39668. * @return minimum and maximum values
  39669. */
  39670. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39671. minimum: Vector3;
  39672. maximum: Vector3;
  39673. };
  39674. /**
  39675. * Extracts minimum and maximum values from a list of positions
  39676. * @param positions defines the positions to use
  39677. * @param start defines the start index in the positions array
  39678. * @param count defines the number of positions to handle
  39679. * @param bias defines bias value to add to the result
  39680. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39681. * @return minimum and maximum values
  39682. */
  39683. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39684. minimum: Vector3;
  39685. maximum: Vector3;
  39686. };
  39687. /**
  39688. * Returns an array if obj is not an array
  39689. * @param obj defines the object to evaluate as an array
  39690. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39691. * @returns either obj directly if obj is an array or a new array containing obj
  39692. */
  39693. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39694. /**
  39695. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39696. * @param size the number of element to construct and put in the array
  39697. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39698. * @returns a new array filled with new objects
  39699. */
  39700. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39701. /**
  39702. * Gets the pointer prefix to use
  39703. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39704. */
  39705. static GetPointerPrefix(): string;
  39706. /**
  39707. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39708. * @param func - the function to be called
  39709. * @param requester - the object that will request the next frame. Falls back to window.
  39710. * @returns frame number
  39711. */
  39712. static QueueNewFrame(func: () => void, requester?: any): number;
  39713. /**
  39714. * Ask the browser to promote the current element to fullscreen rendering mode
  39715. * @param element defines the DOM element to promote
  39716. */
  39717. static RequestFullscreen(element: HTMLElement): void;
  39718. /**
  39719. * Asks the browser to exit fullscreen mode
  39720. */
  39721. static ExitFullscreen(): void;
  39722. /**
  39723. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39724. * @param url define the url we are trying
  39725. * @param element define the dom element where to configure the cors policy
  39726. */
  39727. static SetCorsBehavior(url: string | string[], element: {
  39728. crossOrigin: string | null;
  39729. }): void;
  39730. /**
  39731. * Removes unwanted characters from an url
  39732. * @param url defines the url to clean
  39733. * @returns the cleaned url
  39734. */
  39735. static CleanUrl(url: string): string;
  39736. /**
  39737. * Gets or sets a function used to pre-process url before using them to load assets
  39738. */
  39739. static PreprocessUrl: (url: string) => string;
  39740. /**
  39741. * Loads an image as an HTMLImageElement.
  39742. * @param input url string, ArrayBuffer, or Blob to load
  39743. * @param onLoad callback called when the image successfully loads
  39744. * @param onError callback called when the image fails to load
  39745. * @param offlineProvider offline provider for caching
  39746. * @returns the HTMLImageElement of the loaded image
  39747. */
  39748. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39749. /**
  39750. * Loads a file
  39751. * @param url url string, ArrayBuffer, or Blob to load
  39752. * @param onSuccess callback called when the file successfully loads
  39753. * @param onProgress callback called while file is loading (if the server supports this mode)
  39754. * @param offlineProvider defines the offline provider for caching
  39755. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39756. * @param onError callback called when the file fails to load
  39757. * @returns a file request object
  39758. */
  39759. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  39760. /**
  39761. * Load a script (identified by an url). When the url returns, the
  39762. * content of this file is added into a new script element, attached to the DOM (body element)
  39763. * @param scriptUrl defines the url of the script to laod
  39764. * @param onSuccess defines the callback called when the script is loaded
  39765. * @param onError defines the callback to call if an error occurs
  39766. */
  39767. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39768. /**
  39769. * Loads a file from a blob
  39770. * @param fileToLoad defines the blob to use
  39771. * @param callback defines the callback to call when data is loaded
  39772. * @param progressCallback defines the callback to call during loading process
  39773. * @returns a file request object
  39774. */
  39775. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39776. /**
  39777. * Loads a file
  39778. * @param fileToLoad defines the file to load
  39779. * @param callback defines the callback to call when data is loaded
  39780. * @param progressCallBack defines the callback to call during loading process
  39781. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39782. * @returns a file request object
  39783. */
  39784. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39785. /**
  39786. * Creates a data url from a given string content
  39787. * @param content defines the content to convert
  39788. * @returns the new data url link
  39789. */
  39790. static FileAsURL(content: string): string;
  39791. /**
  39792. * Format the given number to a specific decimal format
  39793. * @param value defines the number to format
  39794. * @param decimals defines the number of decimals to use
  39795. * @returns the formatted string
  39796. */
  39797. static Format(value: number, decimals?: number): string;
  39798. /**
  39799. * Checks if a given vector is inside a specific range
  39800. * @param v defines the vector to test
  39801. * @param min defines the minimum range
  39802. * @param max defines the maximum range
  39803. */
  39804. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39805. /**
  39806. * Tries to copy an object by duplicating every property
  39807. * @param source defines the source object
  39808. * @param destination defines the target object
  39809. * @param doNotCopyList defines a list of properties to avoid
  39810. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39811. */
  39812. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39813. /**
  39814. * Gets a boolean indicating if the given object has no own property
  39815. * @param obj defines the object to test
  39816. * @returns true if object has no own property
  39817. */
  39818. static IsEmpty(obj: any): boolean;
  39819. /**
  39820. * Function used to register events at window level
  39821. * @param events defines the events to register
  39822. */
  39823. static RegisterTopRootEvents(events: {
  39824. name: string;
  39825. handler: Nullable<(e: FocusEvent) => any>;
  39826. }[]): void;
  39827. /**
  39828. * Function used to unregister events from window level
  39829. * @param events defines the events to unregister
  39830. */
  39831. static UnregisterTopRootEvents(events: {
  39832. name: string;
  39833. handler: Nullable<(e: FocusEvent) => any>;
  39834. }[]): void;
  39835. /**
  39836. * Dumps the current bound framebuffer
  39837. * @param width defines the rendering width
  39838. * @param height defines the rendering height
  39839. * @param engine defines the hosting engine
  39840. * @param successCallback defines the callback triggered once the data are available
  39841. * @param mimeType defines the mime type of the result
  39842. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39843. */
  39844. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39845. /**
  39846. * Converts the canvas data to blob.
  39847. * This acts as a polyfill for browsers not supporting the to blob function.
  39848. * @param canvas Defines the canvas to extract the data from
  39849. * @param successCallback Defines the callback triggered once the data are available
  39850. * @param mimeType Defines the mime type of the result
  39851. */
  39852. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39853. /**
  39854. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39855. * @param successCallback defines the callback triggered once the data are available
  39856. * @param mimeType defines the mime type of the result
  39857. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39858. */
  39859. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39860. /**
  39861. * Downloads a blob in the browser
  39862. * @param blob defines the blob to download
  39863. * @param fileName defines the name of the downloaded file
  39864. */
  39865. static Download(blob: Blob, fileName: string): void;
  39866. /**
  39867. * Captures a screenshot of the current rendering
  39868. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39869. * @param engine defines the rendering engine
  39870. * @param camera defines the source camera
  39871. * @param size This parameter can be set to a single number or to an object with the
  39872. * following (optional) properties: precision, width, height. If a single number is passed,
  39873. * it will be used for both width and height. If an object is passed, the screenshot size
  39874. * will be derived from the parameters. The precision property is a multiplier allowing
  39875. * rendering at a higher or lower resolution
  39876. * @param successCallback defines the callback receives a single parameter which contains the
  39877. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39878. * src parameter of an <img> to display it
  39879. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39880. * Check your browser for supported MIME types
  39881. */
  39882. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39883. /**
  39884. * Generates an image screenshot from the specified camera.
  39885. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39886. * @param engine The engine to use for rendering
  39887. * @param camera The camera to use for rendering
  39888. * @param size This parameter can be set to a single number or to an object with the
  39889. * following (optional) properties: precision, width, height. If a single number is passed,
  39890. * it will be used for both width and height. If an object is passed, the screenshot size
  39891. * will be derived from the parameters. The precision property is a multiplier allowing
  39892. * rendering at a higher or lower resolution
  39893. * @param successCallback The callback receives a single parameter which contains the
  39894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39895. * src parameter of an <img> to display it
  39896. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39897. * Check your browser for supported MIME types
  39898. * @param samples Texture samples (default: 1)
  39899. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39900. * @param fileName A name for for the downloaded file.
  39901. */
  39902. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39903. /**
  39904. * Validates if xhr data is correct
  39905. * @param xhr defines the request to validate
  39906. * @param dataType defines the expected data type
  39907. * @returns true if data is correct
  39908. */
  39909. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39910. /**
  39911. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39912. * Be aware Math.random() could cause collisions, but:
  39913. * "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"
  39914. * @returns a pseudo random id
  39915. */
  39916. static RandomId(): string;
  39917. /**
  39918. * Test if the given uri is a base64 string
  39919. * @param uri The uri to test
  39920. * @return True if the uri is a base64 string or false otherwise
  39921. */
  39922. static IsBase64(uri: string): boolean;
  39923. /**
  39924. * Decode the given base64 uri.
  39925. * @param uri The uri to decode
  39926. * @return The decoded base64 data.
  39927. */
  39928. static DecodeBase64(uri: string): ArrayBuffer;
  39929. /**
  39930. * No log
  39931. */
  39932. static readonly NoneLogLevel: number;
  39933. /**
  39934. * Only message logs
  39935. */
  39936. static readonly MessageLogLevel: number;
  39937. /**
  39938. * Only warning logs
  39939. */
  39940. static readonly WarningLogLevel: number;
  39941. /**
  39942. * Only error logs
  39943. */
  39944. static readonly ErrorLogLevel: number;
  39945. /**
  39946. * All logs
  39947. */
  39948. static readonly AllLogLevel: number;
  39949. private static _LogCache;
  39950. /**
  39951. * Gets a value indicating the number of loading errors
  39952. * @ignorenaming
  39953. */
  39954. static errorsCount: number;
  39955. /**
  39956. * Callback called when a new log is added
  39957. */
  39958. static OnNewCacheEntry: (entry: string) => void;
  39959. private static _AddLogEntry;
  39960. private static _FormatMessage;
  39961. private static _LogDisabled;
  39962. private static _LogEnabled;
  39963. private static _WarnDisabled;
  39964. private static _WarnEnabled;
  39965. private static _ErrorDisabled;
  39966. private static _ErrorEnabled;
  39967. /**
  39968. * Log a message to the console
  39969. */
  39970. static Log: (message: string) => void;
  39971. /**
  39972. * Write a warning message to the console
  39973. */
  39974. static Warn: (message: string) => void;
  39975. /**
  39976. * Write an error message to the console
  39977. */
  39978. static Error: (message: string) => void;
  39979. /**
  39980. * Gets current log cache (list of logs)
  39981. */
  39982. static readonly LogCache: string;
  39983. /**
  39984. * Clears the log cache
  39985. */
  39986. static ClearLogCache(): void;
  39987. /**
  39988. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39989. */
  39990. static LogLevels: number;
  39991. /**
  39992. * Checks if the loaded document was accessed via `file:`-Protocol.
  39993. * @returns boolean
  39994. */
  39995. static IsFileURL(): boolean;
  39996. /**
  39997. * Checks if the window object exists
  39998. * @returns true if the window object exists
  39999. */
  40000. static IsWindowObjectExist(): boolean;
  40001. /**
  40002. * No performance log
  40003. */
  40004. static readonly PerformanceNoneLogLevel: number;
  40005. /**
  40006. * Use user marks to log performance
  40007. */
  40008. static readonly PerformanceUserMarkLogLevel: number;
  40009. /**
  40010. * Log performance to the console
  40011. */
  40012. static readonly PerformanceConsoleLogLevel: number;
  40013. private static _performance;
  40014. /**
  40015. * Sets the current performance log level
  40016. */
  40017. static PerformanceLogLevel: number;
  40018. private static _StartPerformanceCounterDisabled;
  40019. private static _EndPerformanceCounterDisabled;
  40020. private static _StartUserMark;
  40021. private static _EndUserMark;
  40022. private static _StartPerformanceConsole;
  40023. private static _EndPerformanceConsole;
  40024. /**
  40025. * Injects the @see CustomRequestHeaders into the given request
  40026. * @param request the request that should be used for injection
  40027. */
  40028. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40029. /**
  40030. * Starts a performance counter
  40031. */
  40032. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40033. /**
  40034. * Ends a specific performance coutner
  40035. */
  40036. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40037. /**
  40038. * Gets either window.performance.now() if supported or Date.now() else
  40039. */
  40040. static readonly Now: number;
  40041. /**
  40042. * This method will return the name of the class used to create the instance of the given object.
  40043. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40044. * @param object the object to get the class name from
  40045. * @param isType defines if the object is actually a type
  40046. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40047. */
  40048. static GetClassName(object: any, isType?: boolean): string;
  40049. /**
  40050. * Gets the first element of an array satisfying a given predicate
  40051. * @param array defines the array to browse
  40052. * @param predicate defines the predicate to use
  40053. * @returns null if not found or the element
  40054. */
  40055. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40056. /**
  40057. * This method will return the name of the full name of the class, including its owning module (if any).
  40058. * 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).
  40059. * @param object the object to get the class name from
  40060. * @param isType defines if the object is actually a type
  40061. * @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.
  40062. * @ignorenaming
  40063. */
  40064. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40065. /**
  40066. * Returns a promise that resolves after the given amount of time.
  40067. * @param delay Number of milliseconds to delay
  40068. * @returns Promise that resolves after the given amount of time
  40069. */
  40070. static DelayAsync(delay: number): Promise<void>;
  40071. /**
  40072. * Gets the current gradient from an array of IValueGradient
  40073. * @param ratio defines the current ratio to get
  40074. * @param gradients defines the array of IValueGradient
  40075. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40076. */
  40077. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40078. }
  40079. /**
  40080. * This class is used to track a performance counter which is number based.
  40081. * The user has access to many properties which give statistics of different nature.
  40082. *
  40083. * The implementer can track two kinds of Performance Counter: time and count.
  40084. * 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.
  40085. * 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.
  40086. */
  40087. class PerfCounter {
  40088. /**
  40089. * Gets or sets a global boolean to turn on and off all the counters
  40090. */
  40091. static Enabled: boolean;
  40092. /**
  40093. * Returns the smallest value ever
  40094. */
  40095. readonly min: number;
  40096. /**
  40097. * Returns the biggest value ever
  40098. */
  40099. readonly max: number;
  40100. /**
  40101. * Returns the average value since the performance counter is running
  40102. */
  40103. readonly average: number;
  40104. /**
  40105. * Returns the average value of the last second the counter was monitored
  40106. */
  40107. readonly lastSecAverage: number;
  40108. /**
  40109. * Returns the current value
  40110. */
  40111. readonly current: number;
  40112. /**
  40113. * Gets the accumulated total
  40114. */
  40115. readonly total: number;
  40116. /**
  40117. * Gets the total value count
  40118. */
  40119. readonly count: number;
  40120. /**
  40121. * Creates a new counter
  40122. */
  40123. constructor();
  40124. /**
  40125. * Call this method to start monitoring a new frame.
  40126. * 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.
  40127. */
  40128. fetchNewFrame(): void;
  40129. /**
  40130. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40131. * @param newCount the count value to add to the monitored count
  40132. * @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.
  40133. */
  40134. addCount(newCount: number, fetchResult: boolean): void;
  40135. /**
  40136. * Start monitoring this performance counter
  40137. */
  40138. beginMonitoring(): void;
  40139. /**
  40140. * Compute the time lapsed since the previous beginMonitoring() call.
  40141. * @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
  40142. */
  40143. endMonitoring(newFrame?: boolean): void;
  40144. private _fetchResult;
  40145. private _startMonitoringTime;
  40146. private _min;
  40147. private _max;
  40148. private _average;
  40149. private _current;
  40150. private _totalValueCount;
  40151. private _totalAccumulated;
  40152. private _lastSecAverage;
  40153. private _lastSecAccumulated;
  40154. private _lastSecTime;
  40155. private _lastSecValueCount;
  40156. }
  40157. /**
  40158. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40159. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40160. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40161. * @param name The name of the class, case should be preserved
  40162. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40163. */
  40164. function className(name: string, module?: string): (target: Object) => void;
  40165. /**
  40166. * An implementation of a loop for asynchronous functions.
  40167. */
  40168. class AsyncLoop {
  40169. /**
  40170. * Defines the number of iterations for the loop
  40171. */
  40172. iterations: number;
  40173. /**
  40174. * Defines the current index of the loop.
  40175. */
  40176. index: number;
  40177. private _done;
  40178. private _fn;
  40179. private _successCallback;
  40180. /**
  40181. * Constructor.
  40182. * @param iterations the number of iterations.
  40183. * @param func the function to run each iteration
  40184. * @param successCallback the callback that will be called upon succesful execution
  40185. * @param offset starting offset.
  40186. */
  40187. constructor(
  40188. /**
  40189. * Defines the number of iterations for the loop
  40190. */
  40191. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40192. /**
  40193. * Execute the next iteration. Must be called after the last iteration was finished.
  40194. */
  40195. executeNext(): void;
  40196. /**
  40197. * Break the loop and run the success callback.
  40198. */
  40199. breakLoop(): void;
  40200. /**
  40201. * Create and run an async loop.
  40202. * @param iterations the number of iterations.
  40203. * @param fn the function to run each iteration
  40204. * @param successCallback the callback that will be called upon succesful execution
  40205. * @param offset starting offset.
  40206. * @returns the created async loop object
  40207. */
  40208. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40209. /**
  40210. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40211. * @param iterations total number of iterations
  40212. * @param syncedIterations number of synchronous iterations in each async iteration.
  40213. * @param fn the function to call each iteration.
  40214. * @param callback a success call back that will be called when iterating stops.
  40215. * @param breakFunction a break condition (optional)
  40216. * @param timeout timeout settings for the setTimeout function. default - 0.
  40217. * @returns the created async loop object
  40218. */
  40219. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40220. }
  40221. }
  40222. interface HTMLCanvasElement {
  40223. /** Track wether a record is in progress */
  40224. isRecording: boolean;
  40225. /** Capture Stream method defined by some browsers */
  40226. captureStream(fps?: number): MediaStream;
  40227. }
  40228. interface MediaRecorder {
  40229. /** Starts recording */
  40230. start(timeSlice: number): void;
  40231. /** Stops recording */
  40232. stop(): void;
  40233. /** Event raised when an error arised. */
  40234. onerror: (event: ErrorEvent) => void;
  40235. /** Event raised when the recording stops. */
  40236. onstop: (event: Event) => void;
  40237. /** Event raised when a new chunk of data is available and should be tracked. */
  40238. ondataavailable: (event: Event) => void;
  40239. }
  40240. interface MediaRecorderOptions {
  40241. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40242. mimeType?: string;
  40243. /** The chosen bitrate for the audio component of the media. */
  40244. audioBitsPerSecond?: number;
  40245. /** The chosen bitrate for the video component of the media. */
  40246. videoBitsPerSecond?: number;
  40247. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  40248. bitsPerSecond?: number;
  40249. }
  40250. interface MediaRecorderConstructor {
  40251. /**
  40252. * A reference to the prototype.
  40253. */
  40254. readonly prototype: MediaRecorder;
  40255. /**
  40256. * Creates a new MediaRecorder.
  40257. * @param stream Defines the stream to record.
  40258. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40259. */
  40260. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40261. }
  40262. /**
  40263. * MediaRecoreder object available in some browsers.
  40264. */
  40265. declare var MediaRecorder: MediaRecorderConstructor;
  40266. declare module BABYLON {
  40267. /**
  40268. * This represents the different options avilable for the video capture.
  40269. */
  40270. interface VideoRecorderOptions {
  40271. /** Defines the mime type of the video */
  40272. mimeType: string;
  40273. /** Defines the video the video should be recorded at */
  40274. fps: number;
  40275. /** Defines the chunk size for the recording data */
  40276. recordChunckSize: number;
  40277. }
  40278. /**
  40279. * This can helps recording videos from BabylonJS.
  40280. * This is based on the available WebRTC functionalities of the browser.
  40281. *
  40282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40283. */
  40284. class VideoRecorder {
  40285. private static readonly _defaultOptions;
  40286. /**
  40287. * Returns wehther or not the VideoRecorder is available in your browser.
  40288. * @param engine Defines the Babylon Engine to check the support for
  40289. * @returns true if supported otherwise false
  40290. */
  40291. static IsSupported(engine: Engine): boolean;
  40292. private readonly _options;
  40293. private _canvas;
  40294. private _mediaRecorder;
  40295. private _recordedChunks;
  40296. private _fileName;
  40297. private _resolve;
  40298. private _reject;
  40299. /**
  40300. * True wether a recording is already in progress.
  40301. */
  40302. readonly isRecording: boolean;
  40303. /**
  40304. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40305. * a video file.
  40306. * @param engine Defines the BabylonJS Engine you wish to record
  40307. * @param options Defines options that can be used to customized the capture
  40308. */
  40309. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40310. /**
  40311. * Stops the current recording before the default capture timeout passed in the startRecording
  40312. * functions.
  40313. */
  40314. stopRecording(): void;
  40315. /**
  40316. * Starts recording the canvas for a max duration specified in parameters.
  40317. * @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.
  40318. * @param maxDuration Defines the maximum recording time in seconds.
  40319. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40320. * @return a promise callback at the end of the recording with the video data in Blob.
  40321. */
  40322. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40323. /**
  40324. * Releases internal resources used during the recording.
  40325. */
  40326. dispose(): void;
  40327. private _handleDataAvailable;
  40328. private _handleError;
  40329. private _handleStop;
  40330. }
  40331. }
  40332. declare module BABYLON {
  40333. /**
  40334. * Defines the potential axis of a Joystick
  40335. */
  40336. enum JoystickAxis {
  40337. /** X axis */
  40338. X = 0,
  40339. /** Y axis */
  40340. Y = 1,
  40341. /** Z axis */
  40342. Z = 2
  40343. }
  40344. /**
  40345. * Class used to define virtual joystick (used in touch mode)
  40346. */
  40347. class VirtualJoystick {
  40348. /**
  40349. * Gets or sets a boolean indicating that left and right values must be inverted
  40350. */
  40351. reverseLeftRight: boolean;
  40352. /**
  40353. * Gets or sets a boolean indicating that up and down values must be inverted
  40354. */
  40355. reverseUpDown: boolean;
  40356. /**
  40357. * Gets the offset value for the position (ie. the change of the position value)
  40358. */
  40359. deltaPosition: Vector3;
  40360. /**
  40361. * Gets a boolean indicating if the virtual joystick was pressed
  40362. */
  40363. pressed: boolean;
  40364. /**
  40365. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40366. */
  40367. static Canvas: Nullable<HTMLCanvasElement>;
  40368. private static _globalJoystickIndex;
  40369. private static vjCanvasContext;
  40370. private static vjCanvasWidth;
  40371. private static vjCanvasHeight;
  40372. private static halfWidth;
  40373. private _action;
  40374. private _axisTargetedByLeftAndRight;
  40375. private _axisTargetedByUpAndDown;
  40376. private _joystickSensibility;
  40377. private _inversedSensibility;
  40378. private _joystickPointerID;
  40379. private _joystickColor;
  40380. private _joystickPointerPos;
  40381. private _joystickPreviousPointerPos;
  40382. private _joystickPointerStartPos;
  40383. private _deltaJoystickVector;
  40384. private _leftJoystick;
  40385. private _touches;
  40386. private _onPointerDownHandlerRef;
  40387. private _onPointerMoveHandlerRef;
  40388. private _onPointerUpHandlerRef;
  40389. private _onResize;
  40390. /**
  40391. * Creates a new virtual joystick
  40392. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40393. */
  40394. constructor(leftJoystick?: boolean);
  40395. /**
  40396. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40397. * @param newJoystickSensibility defines the new sensibility
  40398. */
  40399. setJoystickSensibility(newJoystickSensibility: number): void;
  40400. private _onPointerDown;
  40401. private _onPointerMove;
  40402. private _onPointerUp;
  40403. /**
  40404. * Change the color of the virtual joystick
  40405. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40406. */
  40407. setJoystickColor(newColor: string): void;
  40408. /**
  40409. * Defines a callback to call when the joystick is touched
  40410. * @param action defines the callback
  40411. */
  40412. setActionOnTouch(action: () => any): void;
  40413. /**
  40414. * Defines which axis you'd like to control for left & right
  40415. * @param axis defines the axis to use
  40416. */
  40417. setAxisForLeftRight(axis: JoystickAxis): void;
  40418. /**
  40419. * Defines which axis you'd like to control for up & down
  40420. * @param axis defines the axis to use
  40421. */
  40422. setAxisForUpDown(axis: JoystickAxis): void;
  40423. private _drawVirtualJoystick;
  40424. /**
  40425. * Release internal HTML canvas
  40426. */
  40427. releaseCanvas(): void;
  40428. }
  40429. }
  40430. declare module BABYLON {
  40431. /**
  40432. * Helper class to push actions to a pool of workers.
  40433. */
  40434. class WorkerPool implements IDisposable {
  40435. private _workerInfos;
  40436. private _pendingActions;
  40437. /**
  40438. * Constructor
  40439. * @param workers Array of workers to use for actions
  40440. */
  40441. constructor(workers: Array<Worker>);
  40442. /**
  40443. * Terminates all workers and clears any pending actions.
  40444. */
  40445. dispose(): void;
  40446. /**
  40447. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40448. * pended until a worker has completed its action.
  40449. * @param action The action to perform. Call onComplete when the action is complete.
  40450. */
  40451. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40452. private _execute;
  40453. }
  40454. }
  40455. declare module BABYLON {
  40456. /**
  40457. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40458. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40459. */
  40460. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40461. /**
  40462. * Gets the name of the behavior.
  40463. */
  40464. readonly name: string;
  40465. private _zoomStopsAnimation;
  40466. private _idleRotationSpeed;
  40467. private _idleRotationWaitTime;
  40468. private _idleRotationSpinupTime;
  40469. /**
  40470. * Sets the flag that indicates if user zooming should stop animation.
  40471. */
  40472. /**
  40473. * Gets the flag that indicates if user zooming should stop animation.
  40474. */
  40475. zoomStopsAnimation: boolean;
  40476. /**
  40477. * Sets the default speed at which the camera rotates around the model.
  40478. */
  40479. /**
  40480. * Gets the default speed at which the camera rotates around the model.
  40481. */
  40482. idleRotationSpeed: number;
  40483. /**
  40484. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40485. */
  40486. /**
  40487. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40488. */
  40489. idleRotationWaitTime: number;
  40490. /**
  40491. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40492. */
  40493. /**
  40494. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40495. */
  40496. idleRotationSpinupTime: number;
  40497. /**
  40498. * Gets a value indicating if the camera is currently rotating because of this behavior
  40499. */
  40500. readonly rotationInProgress: boolean;
  40501. private _onPrePointerObservableObserver;
  40502. private _onAfterCheckInputsObserver;
  40503. private _attachedCamera;
  40504. private _isPointerDown;
  40505. private _lastFrameTime;
  40506. private _lastInteractionTime;
  40507. private _cameraRotationSpeed;
  40508. /**
  40509. * Initializes the behavior.
  40510. */
  40511. init(): void;
  40512. /**
  40513. * Attaches the behavior to its arc rotate camera.
  40514. * @param camera Defines the camera to attach the behavior to
  40515. */
  40516. attach(camera: ArcRotateCamera): void;
  40517. /**
  40518. * Detaches the behavior from its current arc rotate camera.
  40519. */
  40520. detach(): void;
  40521. /**
  40522. * Returns true if user is scrolling.
  40523. * @return true if user is scrolling.
  40524. */
  40525. private _userIsZooming;
  40526. private _lastFrameRadius;
  40527. private _shouldAnimationStopForInteraction;
  40528. /**
  40529. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40530. */
  40531. private _applyUserInteraction;
  40532. private _userIsMoving;
  40533. }
  40534. }
  40535. declare module BABYLON {
  40536. /**
  40537. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40538. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40539. */
  40540. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40541. /**
  40542. * Gets the name of the behavior.
  40543. */
  40544. readonly name: string;
  40545. /**
  40546. * The easing function used by animations
  40547. */
  40548. static EasingFunction: BackEase;
  40549. /**
  40550. * The easing mode used by animations
  40551. */
  40552. static EasingMode: number;
  40553. /**
  40554. * The duration of the animation, in milliseconds
  40555. */
  40556. transitionDuration: number;
  40557. /**
  40558. * Length of the distance animated by the transition when lower radius is reached
  40559. */
  40560. lowerRadiusTransitionRange: number;
  40561. /**
  40562. * Length of the distance animated by the transition when upper radius is reached
  40563. */
  40564. upperRadiusTransitionRange: number;
  40565. private _autoTransitionRange;
  40566. /**
  40567. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40568. */
  40569. /**
  40570. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40571. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40572. */
  40573. autoTransitionRange: boolean;
  40574. private _attachedCamera;
  40575. private _onAfterCheckInputsObserver;
  40576. private _onMeshTargetChangedObserver;
  40577. /**
  40578. * Initializes the behavior.
  40579. */
  40580. init(): void;
  40581. /**
  40582. * Attaches the behavior to its arc rotate camera.
  40583. * @param camera Defines the camera to attach the behavior to
  40584. */
  40585. attach(camera: ArcRotateCamera): void;
  40586. /**
  40587. * Detaches the behavior from its current arc rotate camera.
  40588. */
  40589. detach(): void;
  40590. private _radiusIsAnimating;
  40591. private _radiusBounceTransition;
  40592. private _animatables;
  40593. private _cachedWheelPrecision;
  40594. /**
  40595. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40596. * @param radiusLimit The limit to check against.
  40597. * @return Bool to indicate if at limit.
  40598. */
  40599. private _isRadiusAtLimit;
  40600. /**
  40601. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40602. * @param radiusDelta The delta by which to animate to. Can be negative.
  40603. */
  40604. private _applyBoundRadiusAnimation;
  40605. /**
  40606. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40607. */
  40608. protected _clearAnimationLocks(): void;
  40609. /**
  40610. * Stops and removes all animations that have been applied to the camera
  40611. */
  40612. stopAllAnimations(): void;
  40613. }
  40614. }
  40615. declare module BABYLON {
  40616. /**
  40617. * The framing behavior (BABYLON.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.
  40618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40619. */
  40620. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40621. /**
  40622. * Gets the name of the behavior.
  40623. */
  40624. readonly name: string;
  40625. private _mode;
  40626. private _radiusScale;
  40627. private _positionScale;
  40628. private _defaultElevation;
  40629. private _elevationReturnTime;
  40630. private _elevationReturnWaitTime;
  40631. private _zoomStopsAnimation;
  40632. private _framingTime;
  40633. /**
  40634. * The easing function used by animations
  40635. */
  40636. static EasingFunction: ExponentialEase;
  40637. /**
  40638. * The easing mode used by animations
  40639. */
  40640. static EasingMode: number;
  40641. /**
  40642. * Sets the current mode used by the behavior
  40643. */
  40644. /**
  40645. * Gets current mode used by the behavior.
  40646. */
  40647. mode: number;
  40648. /**
  40649. * Sets the scale applied to the radius (1 by default)
  40650. */
  40651. /**
  40652. * Gets the scale applied to the radius
  40653. */
  40654. radiusScale: number;
  40655. /**
  40656. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40657. */
  40658. /**
  40659. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40660. */
  40661. positionScale: number;
  40662. /**
  40663. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40664. * behaviour is triggered, in radians.
  40665. */
  40666. /**
  40667. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40668. * behaviour is triggered, in radians.
  40669. */
  40670. defaultElevation: number;
  40671. /**
  40672. * Sets the time (in milliseconds) taken to return to the default beta position.
  40673. * Negative value indicates camera should not return to default.
  40674. */
  40675. /**
  40676. * Gets the time (in milliseconds) taken to return to the default beta position.
  40677. * Negative value indicates camera should not return to default.
  40678. */
  40679. elevationReturnTime: number;
  40680. /**
  40681. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40682. */
  40683. /**
  40684. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40685. */
  40686. elevationReturnWaitTime: number;
  40687. /**
  40688. * Sets the flag that indicates if user zooming should stop animation.
  40689. */
  40690. /**
  40691. * Gets the flag that indicates if user zooming should stop animation.
  40692. */
  40693. zoomStopsAnimation: boolean;
  40694. /**
  40695. * Sets the transition time when framing the mesh, in milliseconds
  40696. */
  40697. /**
  40698. * Gets the transition time when framing the mesh, in milliseconds
  40699. */
  40700. framingTime: number;
  40701. /**
  40702. * Define if the behavior should automatically change the configured
  40703. * camera limits and sensibilities.
  40704. */
  40705. autoCorrectCameraLimitsAndSensibility: boolean;
  40706. private _onPrePointerObservableObserver;
  40707. private _onAfterCheckInputsObserver;
  40708. private _onMeshTargetChangedObserver;
  40709. private _attachedCamera;
  40710. private _isPointerDown;
  40711. private _lastInteractionTime;
  40712. /**
  40713. * Initializes the behavior.
  40714. */
  40715. init(): void;
  40716. /**
  40717. * Attaches the behavior to its arc rotate camera.
  40718. * @param camera Defines the camera to attach the behavior to
  40719. */
  40720. attach(camera: ArcRotateCamera): void;
  40721. /**
  40722. * Detaches the behavior from its current arc rotate camera.
  40723. */
  40724. detach(): void;
  40725. private _animatables;
  40726. private _betaIsAnimating;
  40727. private _betaTransition;
  40728. private _radiusTransition;
  40729. private _vectorTransition;
  40730. /**
  40731. * Targets the given mesh and updates zoom level accordingly.
  40732. * @param mesh The mesh to target.
  40733. * @param radius Optional. If a cached radius position already exists, overrides default.
  40734. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40735. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40736. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40737. */
  40738. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40739. /**
  40740. * Targets the given mesh with its children and updates zoom level accordingly.
  40741. * @param mesh The mesh to target.
  40742. * @param radius Optional. If a cached radius position already exists, overrides default.
  40743. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40744. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40745. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40746. */
  40747. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40748. /**
  40749. * Targets the given meshes with their children and updates zoom level accordingly.
  40750. * @param meshes The mesh to target.
  40751. * @param radius Optional. If a cached radius position already exists, overrides default.
  40752. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40753. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40754. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40755. */
  40756. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40757. /**
  40758. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40759. * @param minimumWorld Determines the smaller position of the bounding box extend
  40760. * @param maximumWorld Determines the bigger position of the bounding box extend
  40761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40763. */
  40764. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40765. /**
  40766. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40767. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40768. * frustum width.
  40769. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40770. * to fully enclose the mesh in the viewing frustum.
  40771. */
  40772. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40773. /**
  40774. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40775. * is automatically returned to its default position (expected to be above ground plane).
  40776. */
  40777. private _maintainCameraAboveGround;
  40778. /**
  40779. * Returns the frustum slope based on the canvas ratio and camera FOV
  40780. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40781. */
  40782. private _getFrustumSlope;
  40783. /**
  40784. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40785. */
  40786. private _clearAnimationLocks;
  40787. /**
  40788. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40789. */
  40790. private _applyUserInteraction;
  40791. /**
  40792. * Stops and removes all animations that have been applied to the camera
  40793. */
  40794. stopAllAnimations(): void;
  40795. /**
  40796. * Gets a value indicating if the user is moving the camera
  40797. */
  40798. readonly isUserIsMoving: boolean;
  40799. /**
  40800. * The camera can move all the way towards the mesh.
  40801. */
  40802. static IgnoreBoundsSizeMode: number;
  40803. /**
  40804. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40805. */
  40806. static FitFrustumSidesMode: number;
  40807. }
  40808. }
  40809. declare module BABYLON {
  40810. /**
  40811. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40812. */
  40813. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40814. private ui;
  40815. /**
  40816. * The name of the behavior
  40817. */
  40818. name: string;
  40819. /**
  40820. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40821. */
  40822. distanceAwayFromFace: number;
  40823. /**
  40824. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40825. */
  40826. distanceAwayFromBottomOfFace: number;
  40827. private _faceVectors;
  40828. private _target;
  40829. private _scene;
  40830. private _onRenderObserver;
  40831. private _tmpMatrix;
  40832. private _tmpVector;
  40833. /**
  40834. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40835. * @param ui The transform node that should be attched to the mesh
  40836. */
  40837. constructor(ui: BABYLON.TransformNode);
  40838. /**
  40839. * Initializes the behavior
  40840. */
  40841. init(): void;
  40842. private _closestFace;
  40843. private _zeroVector;
  40844. private _lookAtTmpMatrix;
  40845. private _lookAtToRef;
  40846. /**
  40847. * Attaches the AttachToBoxBehavior to the passed in mesh
  40848. * @param target The mesh that the specified node will be attached to
  40849. */
  40850. attach(target: BABYLON.Mesh): void;
  40851. /**
  40852. * Detaches the behavior from the mesh
  40853. */
  40854. detach(): void;
  40855. }
  40856. }
  40857. declare module BABYLON {
  40858. /**
  40859. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40860. */
  40861. class FadeInOutBehavior implements Behavior<Mesh> {
  40862. /**
  40863. * Time in milliseconds to delay before fading in (Default: 0)
  40864. */
  40865. delay: number;
  40866. /**
  40867. * Time in milliseconds for the mesh to fade in (Default: 300)
  40868. */
  40869. fadeInTime: number;
  40870. private _millisecondsPerFrame;
  40871. private _hovered;
  40872. private _hoverValue;
  40873. private _ownerNode;
  40874. /**
  40875. * Instatiates the FadeInOutBehavior
  40876. */
  40877. constructor();
  40878. /**
  40879. * The name of the behavior
  40880. */
  40881. readonly name: string;
  40882. /**
  40883. * Initializes the behavior
  40884. */
  40885. init(): void;
  40886. /**
  40887. * Attaches the fade behavior on the passed in mesh
  40888. * @param ownerNode The mesh that will be faded in/out once attached
  40889. */
  40890. attach(ownerNode: Mesh): void;
  40891. /**
  40892. * Detaches the behavior from the mesh
  40893. */
  40894. detach(): void;
  40895. /**
  40896. * Triggers the mesh to begin fading in or out
  40897. * @param value if the object should fade in or out (true to fade in)
  40898. */
  40899. fadeIn(value: boolean): void;
  40900. private _update;
  40901. private _setAllVisibility;
  40902. }
  40903. }
  40904. declare module BABYLON {
  40905. /**
  40906. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40907. */
  40908. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40909. private _dragBehaviorA;
  40910. private _dragBehaviorB;
  40911. private _startDistance;
  40912. private _initialScale;
  40913. private _targetScale;
  40914. private _ownerNode;
  40915. private _sceneRenderObserver;
  40916. /**
  40917. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40918. */
  40919. constructor();
  40920. /**
  40921. * The name of the behavior
  40922. */
  40923. readonly name: string;
  40924. /**
  40925. * Initializes the behavior
  40926. */
  40927. init(): void;
  40928. private _getCurrentDistance;
  40929. /**
  40930. * Attaches the scale behavior the passed in mesh
  40931. * @param ownerNode The mesh that will be scaled around once attached
  40932. */
  40933. attach(ownerNode: Mesh): void;
  40934. /**
  40935. * Detaches the behavior from the mesh
  40936. */
  40937. detach(): void;
  40938. }
  40939. }
  40940. declare module BABYLON {
  40941. /**
  40942. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40943. */
  40944. class PointerDragBehavior implements Behavior<AbstractMesh> {
  40945. private static _AnyMouseID;
  40946. private _attachedNode;
  40947. private _dragPlane;
  40948. private _scene;
  40949. private _pointerObserver;
  40950. private _beforeRenderObserver;
  40951. private static _planeScene;
  40952. /**
  40953. * 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)
  40954. */
  40955. maxDragAngle: number;
  40956. /**
  40957. * @hidden
  40958. */
  40959. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40960. /**
  40961. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40962. */
  40963. currentDraggingPointerID: number;
  40964. /**
  40965. * The last position where the pointer hit the drag plane in world space
  40966. */
  40967. lastDragPosition: Vector3;
  40968. /**
  40969. * If the behavior is currently in a dragging state
  40970. */
  40971. dragging: boolean;
  40972. /**
  40973. * 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)
  40974. */
  40975. dragDeltaRatio: number;
  40976. /**
  40977. * If the drag plane orientation should be updated during the dragging (Default: true)
  40978. */
  40979. updateDragPlane: boolean;
  40980. private _debugMode;
  40981. private _moving;
  40982. /**
  40983. * Fires each time the attached mesh is dragged with the pointer
  40984. * * delta between last drag position and current drag position in world space
  40985. * * dragDistance along the drag axis
  40986. * * dragPlaneNormal normal of the current drag plane used during the drag
  40987. * * dragPlanePoint in world space where the drag intersects the drag plane
  40988. */
  40989. onDragObservable: Observable<{
  40990. delta: Vector3;
  40991. dragPlanePoint: Vector3;
  40992. dragPlaneNormal: Vector3;
  40993. dragDistance: number;
  40994. pointerId: number;
  40995. }>;
  40996. /**
  40997. * Fires each time a drag begins (eg. mouse down on mesh)
  40998. */
  40999. onDragStartObservable: Observable<{
  41000. dragPlanePoint: Vector3;
  41001. pointerId: number;
  41002. }>;
  41003. /**
  41004. * Fires each time a drag ends (eg. mouse release after drag)
  41005. */
  41006. onDragEndObservable: Observable<{
  41007. dragPlanePoint: Vector3;
  41008. pointerId: number;
  41009. }>;
  41010. /**
  41011. * If the attached mesh should be moved when dragged
  41012. */
  41013. moveAttached: boolean;
  41014. /**
  41015. * If the drag behavior will react to drag events (Default: true)
  41016. */
  41017. enabled: boolean;
  41018. /**
  41019. * If camera controls should be detached during the drag
  41020. */
  41021. detachCameraControls: boolean;
  41022. /**
  41023. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41024. */
  41025. useObjectOrienationForDragging: boolean;
  41026. private _options;
  41027. /**
  41028. * Creates a pointer drag behavior that can be attached to a mesh
  41029. * @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)
  41030. */
  41031. constructor(options?: {
  41032. dragAxis?: Vector3;
  41033. dragPlaneNormal?: Vector3;
  41034. });
  41035. /**
  41036. * The name of the behavior
  41037. */
  41038. readonly name: string;
  41039. /**
  41040. * Initializes the behavior
  41041. */
  41042. init(): void;
  41043. private _tmpVector;
  41044. private _alternatePickedPoint;
  41045. private _worldDragAxis;
  41046. private _targetPosition;
  41047. private _attachedElement;
  41048. /**
  41049. * Attaches the drag behavior the passed in mesh
  41050. * @param ownerNode The mesh that will be dragged around once attached
  41051. */
  41052. attach(ownerNode: AbstractMesh): void;
  41053. /**
  41054. * Force relase the drag action by code.
  41055. */
  41056. releaseDrag(): void;
  41057. private _startDragRay;
  41058. private _lastPointerRay;
  41059. /**
  41060. * Simulates the start of a pointer drag event on the behavior
  41061. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41062. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41063. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41064. */
  41065. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41066. private _startDrag;
  41067. private _dragDelta;
  41068. private _moveDrag;
  41069. private _pickWithRayOnDragPlane;
  41070. private _pointA;
  41071. private _pointB;
  41072. private _pointC;
  41073. private _lineA;
  41074. private _lineB;
  41075. private _localAxis;
  41076. private _lookAt;
  41077. private _updateDragPlanePosition;
  41078. /**
  41079. * Detaches the behavior from the mesh
  41080. */
  41081. detach(): void;
  41082. }
  41083. }
  41084. declare module BABYLON {
  41085. /**
  41086. * 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
  41087. */
  41088. class SixDofDragBehavior implements Behavior<Mesh> {
  41089. private static _virtualScene;
  41090. private _ownerNode;
  41091. private _sceneRenderObserver;
  41092. private _scene;
  41093. private _targetPosition;
  41094. private _virtualOriginMesh;
  41095. private _virtualDragMesh;
  41096. private _pointerObserver;
  41097. private _moving;
  41098. private _startingOrientation;
  41099. /**
  41100. * 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)
  41101. */
  41102. private zDragFactor;
  41103. /**
  41104. * If the behavior is currently in a dragging state
  41105. */
  41106. dragging: boolean;
  41107. /**
  41108. * 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)
  41109. */
  41110. dragDeltaRatio: number;
  41111. /**
  41112. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41113. */
  41114. currentDraggingPointerID: number;
  41115. /**
  41116. * If camera controls should be detached during the drag
  41117. */
  41118. detachCameraControls: boolean;
  41119. /**
  41120. * Fires each time a drag starts
  41121. */
  41122. onDragStartObservable: Observable<{}>;
  41123. /**
  41124. * Fires each time a drag ends (eg. mouse release after drag)
  41125. */
  41126. onDragEndObservable: Observable<{}>;
  41127. /**
  41128. * 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
  41129. */
  41130. constructor();
  41131. /**
  41132. * The name of the behavior
  41133. */
  41134. readonly name: string;
  41135. /**
  41136. * Initializes the behavior
  41137. */
  41138. init(): void;
  41139. /**
  41140. * Attaches the scale behavior the passed in mesh
  41141. * @param ownerNode The mesh that will be scaled around once attached
  41142. */
  41143. attach(ownerNode: Mesh): void;
  41144. /**
  41145. * Detaches the behavior from the mesh
  41146. */
  41147. detach(): void;
  41148. }
  41149. }
  41150. declare module BABYLON {
  41151. /**
  41152. * Manage the gamepad inputs to control an arc rotate camera.
  41153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41154. */
  41155. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41156. /**
  41157. * Defines the camera the input is attached to.
  41158. */
  41159. camera: ArcRotateCamera;
  41160. /**
  41161. * Defines the gamepad the input is gathering event from.
  41162. */
  41163. gamepad: Nullable<Gamepad>;
  41164. /**
  41165. * Defines the gamepad rotation sensiblity.
  41166. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41167. */
  41168. gamepadRotationSensibility: number;
  41169. /**
  41170. * Defines the gamepad move sensiblity.
  41171. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41172. */
  41173. gamepadMoveSensibility: number;
  41174. private _onGamepadConnectedObserver;
  41175. private _onGamepadDisconnectedObserver;
  41176. /**
  41177. * Attach the input controls to a specific dom element to get the input from.
  41178. * @param element Defines the element the controls should be listened from
  41179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41180. */
  41181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41182. /**
  41183. * Detach the current controls from the specified dom element.
  41184. * @param element Defines the element to stop listening the inputs from
  41185. */
  41186. detachControl(element: Nullable<HTMLElement>): void;
  41187. /**
  41188. * Update the current camera state depending on the inputs that have been used this frame.
  41189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41190. */
  41191. checkInputs(): void;
  41192. /**
  41193. * Gets the class name of the current intput.
  41194. * @returns the class name
  41195. */
  41196. getClassName(): string;
  41197. /**
  41198. * Get the friendly name associated with the input class.
  41199. * @returns the input friendly name
  41200. */
  41201. getSimpleName(): string;
  41202. }
  41203. }
  41204. declare module BABYLON {
  41205. /**
  41206. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41208. */
  41209. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41210. /**
  41211. * Defines the camera the input is attached to.
  41212. */
  41213. camera: ArcRotateCamera;
  41214. /**
  41215. * Defines the list of key codes associated with the up action (increase alpha)
  41216. */
  41217. keysUp: number[];
  41218. /**
  41219. * Defines the list of key codes associated with the down action (decrease alpha)
  41220. */
  41221. keysDown: number[];
  41222. /**
  41223. * Defines the list of key codes associated with the left action (increase beta)
  41224. */
  41225. keysLeft: number[];
  41226. /**
  41227. * Defines the list of key codes associated with the right action (decrease beta)
  41228. */
  41229. keysRight: number[];
  41230. /**
  41231. * Defines the list of key codes associated with the reset action.
  41232. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41233. */
  41234. keysReset: number[];
  41235. /**
  41236. * Defines the panning sensibility of the inputs.
  41237. * (How fast is the camera paning)
  41238. */
  41239. panningSensibility: number;
  41240. /**
  41241. * Defines the zooming sensibility of the inputs.
  41242. * (How fast is the camera zooming)
  41243. */
  41244. zoomingSensibility: number;
  41245. /**
  41246. * Defines wether maintaining the alt key down switch the movement mode from
  41247. * orientation to zoom.
  41248. */
  41249. useAltToZoom: boolean;
  41250. /**
  41251. * Rotation speed of the camera
  41252. */
  41253. angularSpeed: number;
  41254. private _keys;
  41255. private _ctrlPressed;
  41256. private _altPressed;
  41257. private _onCanvasBlurObserver;
  41258. private _onKeyboardObserver;
  41259. private _engine;
  41260. private _scene;
  41261. /**
  41262. * Attach the input controls to a specific dom element to get the input from.
  41263. * @param element Defines the element the controls should be listened from
  41264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41265. */
  41266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41267. /**
  41268. * Detach the current controls from the specified dom element.
  41269. * @param element Defines the element to stop listening the inputs from
  41270. */
  41271. detachControl(element: Nullable<HTMLElement>): void;
  41272. /**
  41273. * Update the current camera state depending on the inputs that have been used this frame.
  41274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41275. */
  41276. checkInputs(): void;
  41277. /**
  41278. * Gets the class name of the current intput.
  41279. * @returns the class name
  41280. */
  41281. getClassName(): string;
  41282. /**
  41283. * Get the friendly name associated with the input class.
  41284. * @returns the input friendly name
  41285. */
  41286. getSimpleName(): string;
  41287. }
  41288. }
  41289. declare module BABYLON {
  41290. /**
  41291. * Manage the mouse wheel inputs to control an arc rotate camera.
  41292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41293. */
  41294. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41295. /**
  41296. * Defines the camera the input is attached to.
  41297. */
  41298. camera: ArcRotateCamera;
  41299. /**
  41300. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41301. */
  41302. wheelPrecision: number;
  41303. /**
  41304. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41305. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41306. */
  41307. wheelDeltaPercentage: number;
  41308. private _wheel;
  41309. private _observer;
  41310. /**
  41311. * Attach the input controls to a specific dom element to get the input from.
  41312. * @param element Defines the element the controls should be listened from
  41313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41314. */
  41315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41316. /**
  41317. * Detach the current controls from the specified dom element.
  41318. * @param element Defines the element to stop listening the inputs from
  41319. */
  41320. detachControl(element: Nullable<HTMLElement>): void;
  41321. /**
  41322. * Gets the class name of the current intput.
  41323. * @returns the class name
  41324. */
  41325. getClassName(): string;
  41326. /**
  41327. * Get the friendly name associated with the input class.
  41328. * @returns the input friendly name
  41329. */
  41330. getSimpleName(): string;
  41331. }
  41332. }
  41333. declare module BABYLON {
  41334. /**
  41335. * Manage the pointers inputs to control an arc rotate camera.
  41336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41337. */
  41338. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41339. /**
  41340. * Defines the camera the input is attached to.
  41341. */
  41342. camera: ArcRotateCamera;
  41343. /**
  41344. * Defines the buttons associated with the input to handle camera move.
  41345. */
  41346. buttons: number[];
  41347. /**
  41348. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41349. */
  41350. angularSensibilityX: number;
  41351. /**
  41352. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41353. */
  41354. angularSensibilityY: number;
  41355. /**
  41356. * Defines the pointer pinch precision or how fast is the camera zooming.
  41357. */
  41358. pinchPrecision: number;
  41359. /**
  41360. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41361. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41362. */
  41363. pinchDeltaPercentage: number;
  41364. /**
  41365. * Defines the pointer panning sensibility or how fast is the camera moving.
  41366. */
  41367. panningSensibility: number;
  41368. /**
  41369. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41370. */
  41371. multiTouchPanning: boolean;
  41372. /**
  41373. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41374. */
  41375. multiTouchPanAndZoom: boolean;
  41376. /**
  41377. * Revers pinch action direction.
  41378. */
  41379. pinchInwards: boolean;
  41380. private _isPanClick;
  41381. private _pointerInput;
  41382. private _observer;
  41383. private _onMouseMove;
  41384. private _onGestureStart;
  41385. private _onGesture;
  41386. private _MSGestureHandler;
  41387. private _onLostFocus;
  41388. private _onContextMenu;
  41389. /**
  41390. * Attach the input controls to a specific dom element to get the input from.
  41391. * @param element Defines the element the controls should be listened from
  41392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41393. */
  41394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41395. /**
  41396. * Detach the current controls from the specified dom element.
  41397. * @param element Defines the element to stop listening the inputs from
  41398. */
  41399. detachControl(element: Nullable<HTMLElement>): void;
  41400. /**
  41401. * Gets the class name of the current intput.
  41402. * @returns the class name
  41403. */
  41404. getClassName(): string;
  41405. /**
  41406. * Get the friendly name associated with the input class.
  41407. * @returns the input friendly name
  41408. */
  41409. getSimpleName(): string;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41416. */
  41417. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41418. /**
  41419. * Defines the camera the input is attached to.
  41420. */
  41421. camera: ArcRotateCamera;
  41422. /**
  41423. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41424. */
  41425. alphaCorrection: number;
  41426. /**
  41427. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41428. */
  41429. gammaCorrection: number;
  41430. private _alpha;
  41431. private _gamma;
  41432. private _dirty;
  41433. private _deviceOrientationHandler;
  41434. /**
  41435. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41436. */
  41437. constructor();
  41438. /**
  41439. * Attach the input controls to a specific dom element to get the input from.
  41440. * @param element Defines the element the controls should be listened from
  41441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41442. */
  41443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41444. /** @hidden */
  41445. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41446. /**
  41447. * Update the current camera state depending on the inputs that have been used this frame.
  41448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41449. */
  41450. checkInputs(): void;
  41451. /**
  41452. * Detach the current controls from the specified dom element.
  41453. * @param element Defines the element to stop listening the inputs from
  41454. */
  41455. detachControl(element: Nullable<HTMLElement>): void;
  41456. /**
  41457. * Gets the class name of the current intput.
  41458. * @returns the class name
  41459. */
  41460. getClassName(): string;
  41461. /**
  41462. * Get the friendly name associated with the input class.
  41463. * @returns the input friendly name
  41464. */
  41465. getSimpleName(): string;
  41466. }
  41467. }
  41468. declare module BABYLON {
  41469. /**
  41470. * Listen to keyboard events to control the camera.
  41471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41472. */
  41473. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41474. /**
  41475. * Defines the camera the input is attached to.
  41476. */
  41477. camera: FlyCamera;
  41478. /**
  41479. * The list of keyboard keys used to control the forward move of the camera.
  41480. */
  41481. keysForward: number[];
  41482. /**
  41483. * The list of keyboard keys used to control the backward move of the camera.
  41484. */
  41485. keysBackward: number[];
  41486. /**
  41487. * The list of keyboard keys used to control the forward move of the camera.
  41488. */
  41489. keysUp: number[];
  41490. /**
  41491. * The list of keyboard keys used to control the backward move of the camera.
  41492. */
  41493. keysDown: number[];
  41494. /**
  41495. * The list of keyboard keys used to control the right strafe move of the camera.
  41496. */
  41497. keysRight: number[];
  41498. /**
  41499. * The list of keyboard keys used to control the left strafe move of the camera.
  41500. */
  41501. keysLeft: number[];
  41502. private _keys;
  41503. private _onCanvasBlurObserver;
  41504. private _onKeyboardObserver;
  41505. private _engine;
  41506. private _scene;
  41507. /**
  41508. * Attach the input controls to a specific dom element to get the input from.
  41509. * @param element Defines the element the controls should be listened from
  41510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41511. */
  41512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41513. /**
  41514. * Detach the current controls from the specified dom element.
  41515. * @param element Defines the element to stop listening the inputs from
  41516. */
  41517. detachControl(element: Nullable<HTMLElement>): void;
  41518. /**
  41519. * Gets the class name of the current intput.
  41520. * @returns the class name
  41521. */
  41522. getClassName(): string;
  41523. /** @hidden */
  41524. _onLostFocus(e: FocusEvent): void;
  41525. /**
  41526. * Get the friendly name associated with the input class.
  41527. * @returns the input friendly name
  41528. */
  41529. getSimpleName(): string;
  41530. /**
  41531. * Update the current camera state depending on the inputs that have been used this frame.
  41532. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41533. */
  41534. checkInputs(): void;
  41535. }
  41536. }
  41537. declare module BABYLON {
  41538. /**
  41539. * Listen to mouse events to control the camera.
  41540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41541. */
  41542. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41543. /**
  41544. * Defines the camera the input is attached to.
  41545. */
  41546. camera: FlyCamera;
  41547. /**
  41548. * Defines if touch is enabled. (Default is true.)
  41549. */
  41550. touchEnabled: boolean;
  41551. /**
  41552. * Defines the buttons associated with the input to handle camera rotation.
  41553. */
  41554. buttons: number[];
  41555. /**
  41556. * Assign buttons for Yaw control.
  41557. */
  41558. buttonsYaw: number[];
  41559. /**
  41560. * Assign buttons for Pitch control.
  41561. */
  41562. buttonsPitch: number[];
  41563. /**
  41564. * Assign buttons for Roll control.
  41565. */
  41566. buttonsRoll: number[];
  41567. /**
  41568. * Detect if any button is being pressed while mouse is moved.
  41569. * -1 = Mouse locked.
  41570. * 0 = Left button.
  41571. * 1 = Middle Button.
  41572. * 2 = Right Button.
  41573. */
  41574. activeButton: number;
  41575. /**
  41576. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41577. * Higher values reduce its sensitivity.
  41578. */
  41579. angularSensibility: number;
  41580. private _mousemoveCallback;
  41581. private _observer;
  41582. private _rollObserver;
  41583. private previousPosition;
  41584. private noPreventDefault;
  41585. private element;
  41586. /**
  41587. * Listen to mouse events to control the camera.
  41588. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41590. */
  41591. constructor(touchEnabled?: boolean);
  41592. /**
  41593. * Attach the mouse control to the HTML DOM element.
  41594. * @param element Defines the element that listens to the input events.
  41595. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41596. */
  41597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41598. /**
  41599. * Detach the current controls from the specified dom element.
  41600. * @param element Defines the element to stop listening the inputs from
  41601. */
  41602. detachControl(element: Nullable<HTMLElement>): void;
  41603. /**
  41604. * Gets the class name of the current input.
  41605. * @returns the class name.
  41606. */
  41607. getClassName(): string;
  41608. /**
  41609. * Get the friendly name associated with the input class.
  41610. * @returns the input's friendly name.
  41611. */
  41612. getSimpleName(): string;
  41613. private _pointerInput;
  41614. private _onMouseMove;
  41615. /**
  41616. * Rotate camera by mouse offset.
  41617. */
  41618. private rotateCamera;
  41619. }
  41620. }
  41621. declare module BABYLON {
  41622. /**
  41623. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41624. * Screen rotation is taken into account.
  41625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41626. */
  41627. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41628. private _camera;
  41629. private _screenOrientationAngle;
  41630. private _constantTranform;
  41631. private _screenQuaternion;
  41632. private _alpha;
  41633. private _beta;
  41634. private _gamma;
  41635. /**
  41636. * Instantiates a new input
  41637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41638. */
  41639. constructor();
  41640. /**
  41641. * Define the camera controlled by the input.
  41642. */
  41643. camera: FreeCamera;
  41644. /**
  41645. * Attach the input controls to a specific dom element to get the input from.
  41646. * @param element Defines the element the controls should be listened from
  41647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41648. */
  41649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41650. private _orientationChanged;
  41651. private _deviceOrientation;
  41652. /**
  41653. * Detach the current controls from the specified dom element.
  41654. * @param element Defines the element to stop listening the inputs from
  41655. */
  41656. detachControl(element: Nullable<HTMLElement>): void;
  41657. /**
  41658. * Update the current camera state depending on the inputs that have been used this frame.
  41659. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41660. */
  41661. checkInputs(): void;
  41662. /**
  41663. * Gets the class name of the current intput.
  41664. * @returns the class name
  41665. */
  41666. getClassName(): string;
  41667. /**
  41668. * Get the friendly name associated with the input class.
  41669. * @returns the input friendly name
  41670. */
  41671. getSimpleName(): string;
  41672. }
  41673. }
  41674. declare module BABYLON {
  41675. /**
  41676. * Manage the gamepad inputs to control a free camera.
  41677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41678. */
  41679. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41680. /**
  41681. * Define the camera the input is attached to.
  41682. */
  41683. camera: FreeCamera;
  41684. /**
  41685. * Define the Gamepad controlling the input
  41686. */
  41687. gamepad: Nullable<Gamepad>;
  41688. /**
  41689. * Defines the gamepad rotation sensiblity.
  41690. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41691. */
  41692. gamepadAngularSensibility: number;
  41693. /**
  41694. * Defines the gamepad move sensiblity.
  41695. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41696. */
  41697. gamepadMoveSensibility: number;
  41698. private _onGamepadConnectedObserver;
  41699. private _onGamepadDisconnectedObserver;
  41700. private _cameraTransform;
  41701. private _deltaTransform;
  41702. private _vector3;
  41703. private _vector2;
  41704. /**
  41705. * Attach the input controls to a specific dom element to get the input from.
  41706. * @param element Defines the element the controls should be listened from
  41707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41708. */
  41709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41710. /**
  41711. * Detach the current controls from the specified dom element.
  41712. * @param element Defines the element to stop listening the inputs from
  41713. */
  41714. detachControl(element: Nullable<HTMLElement>): void;
  41715. /**
  41716. * Update the current camera state depending on the inputs that have been used this frame.
  41717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41718. */
  41719. checkInputs(): void;
  41720. /**
  41721. * Gets the class name of the current intput.
  41722. * @returns the class name
  41723. */
  41724. getClassName(): string;
  41725. /**
  41726. * Get the friendly name associated with the input class.
  41727. * @returns the input friendly name
  41728. */
  41729. getSimpleName(): string;
  41730. }
  41731. }
  41732. declare module BABYLON {
  41733. /**
  41734. * Manage the keyboard inputs to control the movement of a free camera.
  41735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41736. */
  41737. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41738. /**
  41739. * Defines the camera the input is attached to.
  41740. */
  41741. camera: FreeCamera;
  41742. /**
  41743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41744. */
  41745. keysUp: number[];
  41746. /**
  41747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41748. */
  41749. keysDown: number[];
  41750. /**
  41751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41752. */
  41753. keysLeft: number[];
  41754. /**
  41755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41756. */
  41757. keysRight: number[];
  41758. private _keys;
  41759. private _onCanvasBlurObserver;
  41760. private _onKeyboardObserver;
  41761. private _engine;
  41762. private _scene;
  41763. /**
  41764. * Attach the input controls to a specific dom element to get the input from.
  41765. * @param element Defines the element the controls should be listened from
  41766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41767. */
  41768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41769. /**
  41770. * Detach the current controls from the specified dom element.
  41771. * @param element Defines the element to stop listening the inputs from
  41772. */
  41773. detachControl(element: Nullable<HTMLElement>): void;
  41774. /**
  41775. * Update the current camera state depending on the inputs that have been used this frame.
  41776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41777. */
  41778. checkInputs(): void;
  41779. /**
  41780. * Gets the class name of the current intput.
  41781. * @returns the class name
  41782. */
  41783. getClassName(): string;
  41784. /** @hidden */
  41785. _onLostFocus(e: FocusEvent): void;
  41786. /**
  41787. * Get the friendly name associated with the input class.
  41788. * @returns the input friendly name
  41789. */
  41790. getSimpleName(): string;
  41791. }
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * Manage the mouse inputs to control the movement of a free camera.
  41796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41797. */
  41798. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41799. /**
  41800. * Define if touch is enabled in the mouse input
  41801. */
  41802. touchEnabled: boolean;
  41803. /**
  41804. * Defines the camera the input is attached to.
  41805. */
  41806. camera: FreeCamera;
  41807. /**
  41808. * Defines the buttons associated with the input to handle camera move.
  41809. */
  41810. buttons: number[];
  41811. /**
  41812. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41813. */
  41814. angularSensibility: number;
  41815. private _pointerInput;
  41816. private _onMouseMove;
  41817. private _observer;
  41818. private previousPosition;
  41819. /**
  41820. * Manage the mouse inputs to control the movement of a free camera.
  41821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41822. * @param touchEnabled Defines if touch is enabled or not
  41823. */
  41824. constructor(
  41825. /**
  41826. * Define if touch is enabled in the mouse input
  41827. */
  41828. touchEnabled?: boolean);
  41829. /**
  41830. * Attach the input controls to a specific dom element to get the input from.
  41831. * @param element Defines the element the controls should be listened from
  41832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41833. */
  41834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41835. /**
  41836. * Detach the current controls from the specified dom element.
  41837. * @param element Defines the element to stop listening the inputs from
  41838. */
  41839. detachControl(element: Nullable<HTMLElement>): void;
  41840. /**
  41841. * Gets the class name of the current intput.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. /**
  41846. * Get the friendly name associated with the input class.
  41847. * @returns the input friendly name
  41848. */
  41849. getSimpleName(): string;
  41850. }
  41851. }
  41852. declare module BABYLON {
  41853. /**
  41854. * Manage the touch inputs to control the movement of a free camera.
  41855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41856. */
  41857. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41858. /**
  41859. * Defines the camera the input is attached to.
  41860. */
  41861. camera: FreeCamera;
  41862. /**
  41863. * Defines the touch sensibility for rotation.
  41864. * The higher the faster.
  41865. */
  41866. touchAngularSensibility: number;
  41867. /**
  41868. * Defines the touch sensibility for move.
  41869. * The higher the faster.
  41870. */
  41871. touchMoveSensibility: number;
  41872. private _offsetX;
  41873. private _offsetY;
  41874. private _pointerPressed;
  41875. private _pointerInput;
  41876. private _observer;
  41877. private _onLostFocus;
  41878. /**
  41879. * Attach the input controls to a specific dom element to get the input from.
  41880. * @param element Defines the element the controls should be listened from
  41881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41882. */
  41883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41884. /**
  41885. * Detach the current controls from the specified dom element.
  41886. * @param element Defines the element to stop listening the inputs from
  41887. */
  41888. detachControl(element: Nullable<HTMLElement>): void;
  41889. /**
  41890. * Update the current camera state depending on the inputs that have been used this frame.
  41891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41892. */
  41893. checkInputs(): void;
  41894. /**
  41895. * Gets the class name of the current intput.
  41896. * @returns the class name
  41897. */
  41898. getClassName(): string;
  41899. /**
  41900. * Get the friendly name associated with the input class.
  41901. * @returns the input friendly name
  41902. */
  41903. getSimpleName(): string;
  41904. }
  41905. }
  41906. declare module BABYLON {
  41907. /**
  41908. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41910. */
  41911. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41912. /**
  41913. * Defines the camera the input is attached to.
  41914. */
  41915. camera: FreeCamera;
  41916. private _leftjoystick;
  41917. private _rightjoystick;
  41918. /**
  41919. * Gets the left stick of the virtual joystick.
  41920. * @returns The virtual Joystick
  41921. */
  41922. getLeftJoystick(): VirtualJoystick;
  41923. /**
  41924. * Gets the right stick of the virtual joystick.
  41925. * @returns The virtual Joystick
  41926. */
  41927. getRightJoystick(): VirtualJoystick;
  41928. /**
  41929. * Update the current camera state depending on the inputs that have been used this frame.
  41930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41931. */
  41932. checkInputs(): void;
  41933. /**
  41934. * Attach the input controls to a specific dom element to get the input from.
  41935. * @param element Defines the element the controls should be listened from
  41936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41937. */
  41938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41939. /**
  41940. * Detach the current controls from the specified dom element.
  41941. * @param element Defines the element to stop listening the inputs from
  41942. */
  41943. detachControl(element: Nullable<HTMLElement>): void;
  41944. /**
  41945. * Gets the class name of the current intput.
  41946. * @returns the class name
  41947. */
  41948. getClassName(): string;
  41949. /**
  41950. * Get the friendly name associated with the input class.
  41951. * @returns the input friendly name
  41952. */
  41953. getSimpleName(): string;
  41954. }
  41955. }
  41956. declare module BABYLON {
  41957. /**
  41958. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41959. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41960. */
  41961. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41962. /**
  41963. * Creates a new AnaglyphArcRotateCamera
  41964. * @param name defines camera name
  41965. * @param alpha defines alpha angle (in radians)
  41966. * @param beta defines beta angle (in radians)
  41967. * @param radius defines radius
  41968. * @param target defines camera target
  41969. * @param interaxialDistance defines distance between each color axis
  41970. * @param scene defines the hosting scene
  41971. */
  41972. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41973. /**
  41974. * Gets camera class name
  41975. * @returns AnaglyphArcRotateCamera
  41976. */
  41977. getClassName(): string;
  41978. }
  41979. }
  41980. declare module BABYLON {
  41981. /**
  41982. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41983. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41984. */
  41985. class AnaglyphFreeCamera extends FreeCamera {
  41986. /**
  41987. * Creates a new AnaglyphFreeCamera
  41988. * @param name defines camera name
  41989. * @param position defines initial position
  41990. * @param interaxialDistance defines distance between each color axis
  41991. * @param scene defines the hosting scene
  41992. */
  41993. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41994. /**
  41995. * Gets camera class name
  41996. * @returns AnaglyphFreeCamera
  41997. */
  41998. getClassName(): string;
  41999. }
  42000. }
  42001. declare module BABYLON {
  42002. /**
  42003. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42004. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42005. */
  42006. class AnaglyphGamepadCamera extends GamepadCamera {
  42007. /**
  42008. * Creates a new AnaglyphGamepadCamera
  42009. * @param name defines camera name
  42010. * @param position defines initial position
  42011. * @param interaxialDistance defines distance between each color axis
  42012. * @param scene defines the hosting scene
  42013. */
  42014. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42015. /**
  42016. * Gets camera class name
  42017. * @returns AnaglyphGamepadCamera
  42018. */
  42019. getClassName(): string;
  42020. }
  42021. }
  42022. declare module BABYLON {
  42023. /**
  42024. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42025. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42026. */
  42027. class AnaglyphUniversalCamera extends UniversalCamera {
  42028. /**
  42029. * Creates a new AnaglyphUniversalCamera
  42030. * @param name defines camera name
  42031. * @param position defines initial position
  42032. * @param interaxialDistance defines distance between each color axis
  42033. * @param scene defines the hosting scene
  42034. */
  42035. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42036. /**
  42037. * Gets camera class name
  42038. * @returns AnaglyphUniversalCamera
  42039. */
  42040. getClassName(): string;
  42041. }
  42042. }
  42043. declare module BABYLON {
  42044. /**
  42045. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42046. * @see http://doc.babylonjs.com/features/cameras
  42047. */
  42048. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42049. /**
  42050. * Creates a new StereoscopicArcRotateCamera
  42051. * @param name defines camera name
  42052. * @param alpha defines alpha angle (in radians)
  42053. * @param beta defines beta angle (in radians)
  42054. * @param radius defines radius
  42055. * @param target defines camera target
  42056. * @param interaxialDistance defines distance between each color axis
  42057. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42058. * @param scene defines the hosting scene
  42059. */
  42060. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42061. /**
  42062. * Gets camera class name
  42063. * @returns StereoscopicArcRotateCamera
  42064. */
  42065. getClassName(): string;
  42066. }
  42067. }
  42068. declare module BABYLON {
  42069. /**
  42070. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42071. * @see http://doc.babylonjs.com/features/cameras
  42072. */
  42073. class StereoscopicFreeCamera extends FreeCamera {
  42074. /**
  42075. * Creates a new StereoscopicFreeCamera
  42076. * @param name defines camera name
  42077. * @param position defines initial position
  42078. * @param interaxialDistance defines distance between each color axis
  42079. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42080. * @param scene defines the hosting scene
  42081. */
  42082. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42083. /**
  42084. * Gets camera class name
  42085. * @returns StereoscopicFreeCamera
  42086. */
  42087. getClassName(): string;
  42088. }
  42089. }
  42090. declare module BABYLON {
  42091. /**
  42092. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42093. * @see http://doc.babylonjs.com/features/cameras
  42094. */
  42095. class StereoscopicGamepadCamera extends GamepadCamera {
  42096. /**
  42097. * Creates a new StereoscopicGamepadCamera
  42098. * @param name defines camera name
  42099. * @param position defines initial position
  42100. * @param interaxialDistance defines distance between each color axis
  42101. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42102. * @param scene defines the hosting scene
  42103. */
  42104. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42105. /**
  42106. * Gets camera class name
  42107. * @returns StereoscopicGamepadCamera
  42108. */
  42109. getClassName(): string;
  42110. }
  42111. }
  42112. declare module BABYLON {
  42113. /**
  42114. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42115. * @see http://doc.babylonjs.com/features/cameras
  42116. */
  42117. class StereoscopicUniversalCamera extends UniversalCamera {
  42118. /**
  42119. * Creates a new StereoscopicUniversalCamera
  42120. * @param name defines camera name
  42121. * @param position defines initial position
  42122. * @param interaxialDistance defines distance between each color axis
  42123. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42124. * @param scene defines the hosting scene
  42125. */
  42126. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42127. /**
  42128. * Gets camera class name
  42129. * @returns StereoscopicUniversalCamera
  42130. */
  42131. getClassName(): string;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * This represents all the required metrics to create a VR camera.
  42137. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42138. */
  42139. class VRCameraMetrics {
  42140. /**
  42141. * Define the horizontal resolution off the screen.
  42142. */
  42143. hResolution: number;
  42144. /**
  42145. * Define the vertical resolution off the screen.
  42146. */
  42147. vResolution: number;
  42148. /**
  42149. * Define the horizontal screen size.
  42150. */
  42151. hScreenSize: number;
  42152. /**
  42153. * Define the vertical screen size.
  42154. */
  42155. vScreenSize: number;
  42156. /**
  42157. * Define the vertical screen center position.
  42158. */
  42159. vScreenCenter: number;
  42160. /**
  42161. * Define the distance of the eyes to the screen.
  42162. */
  42163. eyeToScreenDistance: number;
  42164. /**
  42165. * Define the distance between both lenses
  42166. */
  42167. lensSeparationDistance: number;
  42168. /**
  42169. * Define the distance between both viewer's eyes.
  42170. */
  42171. interpupillaryDistance: number;
  42172. /**
  42173. * Define the distortion factor of the VR postprocess.
  42174. * Please, touch with care.
  42175. */
  42176. distortionK: number[];
  42177. /**
  42178. * Define the chromatic aberration correction factors for the VR post process.
  42179. */
  42180. chromaAbCorrection: number[];
  42181. /**
  42182. * Define the scale factor of the post process.
  42183. * The smaller the better but the slower.
  42184. */
  42185. postProcessScaleFactor: number;
  42186. /**
  42187. * Define an offset for the lens center.
  42188. */
  42189. lensCenterOffset: number;
  42190. /**
  42191. * Define if the current vr camera should compensate the distortion of the lense or not.
  42192. */
  42193. compensateDistortion: boolean;
  42194. /**
  42195. * Gets the rendering aspect ratio based on the provided resolutions.
  42196. */
  42197. readonly aspectRatio: number;
  42198. /**
  42199. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42200. */
  42201. readonly aspectRatioFov: number;
  42202. /**
  42203. * @hidden
  42204. */
  42205. readonly leftHMatrix: Matrix;
  42206. /**
  42207. * @hidden
  42208. */
  42209. readonly rightHMatrix: Matrix;
  42210. /**
  42211. * @hidden
  42212. */
  42213. readonly leftPreViewMatrix: Matrix;
  42214. /**
  42215. * @hidden
  42216. */
  42217. readonly rightPreViewMatrix: Matrix;
  42218. /**
  42219. * Get the default VRMetrics based on the most generic setup.
  42220. * @returns the default vr metrics
  42221. */
  42222. static GetDefault(): VRCameraMetrics;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42228. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42229. */
  42230. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42231. /**
  42232. * Creates a new VRDeviceOrientationArcRotateCamera
  42233. * @param name defines camera name
  42234. * @param alpha defines the camera rotation along the logitudinal axis
  42235. * @param beta defines the camera rotation along the latitudinal axis
  42236. * @param radius defines the camera distance from its target
  42237. * @param target defines the camera target
  42238. * @param scene defines the scene the camera belongs to
  42239. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42240. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42241. */
  42242. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42243. /**
  42244. * Gets camera class name
  42245. * @returns VRDeviceOrientationArcRotateCamera
  42246. */
  42247. getClassName(): string;
  42248. }
  42249. }
  42250. declare module BABYLON {
  42251. /**
  42252. * Camera used to simulate VR rendering (based on FreeCamera)
  42253. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42254. */
  42255. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42256. /**
  42257. * Creates a new VRDeviceOrientationFreeCamera
  42258. * @param name defines camera name
  42259. * @param position defines the start position of the camera
  42260. * @param scene defines the scene the camera belongs to
  42261. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42262. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42263. */
  42264. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42265. /**
  42266. * Gets camera class name
  42267. * @returns VRDeviceOrientationFreeCamera
  42268. */
  42269. getClassName(): string;
  42270. }
  42271. }
  42272. declare module BABYLON {
  42273. /**
  42274. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42275. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42276. */
  42277. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42278. /**
  42279. * Creates a new VRDeviceOrientationGamepadCamera
  42280. * @param name defines camera name
  42281. * @param position defines the start position of the camera
  42282. * @param scene defines the scene the camera belongs to
  42283. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42284. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42285. */
  42286. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42287. /**
  42288. * Gets camera class name
  42289. * @returns VRDeviceOrientationGamepadCamera
  42290. */
  42291. getClassName(): string;
  42292. }
  42293. }
  42294. declare module BABYLON {
  42295. /**
  42296. * Options to modify the vr teleportation behavior.
  42297. */
  42298. interface VRTeleportationOptions {
  42299. /**
  42300. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42301. */
  42302. floorMeshName?: string;
  42303. /**
  42304. * A list of meshes to be used as the teleportation floor. (default: empty)
  42305. */
  42306. floorMeshes?: Mesh[];
  42307. }
  42308. /**
  42309. * Options to modify the vr experience helper's behavior.
  42310. */
  42311. interface VRExperienceHelperOptions extends WebVROptions {
  42312. /**
  42313. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42314. */
  42315. createDeviceOrientationCamera?: boolean;
  42316. /**
  42317. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42318. */
  42319. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42320. /**
  42321. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42322. */
  42323. laserToggle?: boolean;
  42324. /**
  42325. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42326. */
  42327. floorMeshes?: Mesh[];
  42328. }
  42329. /**
  42330. * Helps to quickly add VR support to an existing scene.
  42331. * See http://doc.babylonjs.com/how_to/webvr_helper
  42332. */
  42333. class VRExperienceHelper {
  42334. /** Options to modify the vr experience helper's behavior. */
  42335. webVROptions: VRExperienceHelperOptions;
  42336. private _scene;
  42337. private _position;
  42338. private _btnVR;
  42339. private _btnVRDisplayed;
  42340. private _webVRsupported;
  42341. private _webVRready;
  42342. private _webVRrequesting;
  42343. private _webVRpresenting;
  42344. private _hasEnteredVR;
  42345. private _fullscreenVRpresenting;
  42346. private _canvas;
  42347. private _webVRCamera;
  42348. private _vrDeviceOrientationCamera;
  42349. private _deviceOrientationCamera;
  42350. private _existingCamera;
  42351. private _onKeyDown;
  42352. private _onVrDisplayPresentChange;
  42353. private _onVRDisplayChanged;
  42354. private _onVRRequestPresentStart;
  42355. private _onVRRequestPresentComplete;
  42356. /**
  42357. * Observable raised when entering VR.
  42358. */
  42359. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42360. /**
  42361. * Observable raised when exiting VR.
  42362. */
  42363. onExitingVRObservable: Observable<VRExperienceHelper>;
  42364. /**
  42365. * Observable raised when controller mesh is loaded.
  42366. */
  42367. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42368. /** Return this.onEnteringVRObservable
  42369. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42370. */
  42371. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42372. /** Return this.onExitingVRObservable
  42373. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42374. */
  42375. readonly onExitingVR: Observable<VRExperienceHelper>;
  42376. /** Return this.onControllerMeshLoadedObservable
  42377. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42378. */
  42379. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42380. private _rayLength;
  42381. private _useCustomVRButton;
  42382. private _teleportationRequested;
  42383. private _teleportActive;
  42384. private _floorMeshName;
  42385. private _floorMeshesCollection;
  42386. private _rotationAllowed;
  42387. private _teleportBackwardsVector;
  42388. private _teleportationTarget;
  42389. private _isDefaultTeleportationTarget;
  42390. private _postProcessMove;
  42391. private _teleportationFillColor;
  42392. private _teleportationBorderColor;
  42393. private _rotationAngle;
  42394. private _haloCenter;
  42395. private _cameraGazer;
  42396. private _padSensibilityUp;
  42397. private _padSensibilityDown;
  42398. private _leftController;
  42399. private _rightController;
  42400. /**
  42401. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42402. */
  42403. onNewMeshSelected: Observable<AbstractMesh>;
  42404. /**
  42405. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42406. */
  42407. onNewMeshPicked: Observable<PickingInfo>;
  42408. private _circleEase;
  42409. /**
  42410. * Observable raised before camera teleportation
  42411. */
  42412. onBeforeCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised after camera teleportation
  42415. */
  42416. onAfterCameraTeleport: Observable<Vector3>;
  42417. /**
  42418. * Observable raised when current selected mesh gets unselected
  42419. */
  42420. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42421. private _raySelectionPredicate;
  42422. /**
  42423. * To be optionaly changed by user to define custom ray selection
  42424. */
  42425. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42428. */
  42429. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42430. /**
  42431. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42432. */
  42433. teleportationEnabled: boolean;
  42434. private _defaultHeight;
  42435. private _teleportationInitialized;
  42436. private _interactionsEnabled;
  42437. private _interactionsRequested;
  42438. private _displayGaze;
  42439. private _displayLaserPointer;
  42440. /**
  42441. * The mesh used to display where the user is going to teleport.
  42442. */
  42443. /**
  42444. * Sets the mesh to be used to display where the user is going to teleport.
  42445. */
  42446. teleportationTarget: Mesh;
  42447. /**
  42448. * 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
  42449. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42450. * See http://doc.babylonjs.com/resources/baking_transformations
  42451. */
  42452. gazeTrackerMesh: Mesh;
  42453. /**
  42454. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42455. */
  42456. updateGazeTrackerScale: boolean;
  42457. /**
  42458. * The gaze tracking mesh corresponding to the left controller
  42459. */
  42460. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the right controller
  42463. */
  42464. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * If the ray of the gaze should be displayed.
  42467. */
  42468. /**
  42469. * Sets if the ray of the gaze should be displayed.
  42470. */
  42471. displayGaze: boolean;
  42472. /**
  42473. * If the ray of the LaserPointer should be displayed.
  42474. */
  42475. /**
  42476. * Sets if the ray of the LaserPointer should be displayed.
  42477. */
  42478. displayLaserPointer: boolean;
  42479. /**
  42480. * The deviceOrientationCamera used as the camera when not in VR.
  42481. */
  42482. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42483. /**
  42484. * Based on the current WebVR support, returns the current VR camera used.
  42485. */
  42486. readonly currentVRCamera: Nullable<Camera>;
  42487. /**
  42488. * The webVRCamera which is used when in VR.
  42489. */
  42490. readonly webVRCamera: WebVRFreeCamera;
  42491. /**
  42492. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42493. */
  42494. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42495. private readonly _teleportationRequestInitiated;
  42496. /**
  42497. * Instantiates a VRExperienceHelper.
  42498. * Helps to quickly add VR support to an existing scene.
  42499. * @param scene The scene the VRExperienceHelper belongs to.
  42500. * @param webVROptions Options to modify the vr experience helper's behavior.
  42501. */
  42502. constructor(scene: Scene,
  42503. /** Options to modify the vr experience helper's behavior. */
  42504. webVROptions?: VRExperienceHelperOptions);
  42505. private _onDefaultMeshLoaded;
  42506. private _onResize;
  42507. private _onFullscreenChange;
  42508. /**
  42509. * Gets a value indicating if we are currently in VR mode.
  42510. */
  42511. readonly isInVRMode: boolean;
  42512. private onVrDisplayPresentChange;
  42513. private onVRDisplayChanged;
  42514. private moveButtonToBottomRight;
  42515. private displayVRButton;
  42516. private updateButtonVisibility;
  42517. private _cachedAngularSensibility;
  42518. /**
  42519. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42520. * Otherwise, will use the fullscreen API.
  42521. */
  42522. enterVR(): void;
  42523. /**
  42524. * Attempt to exit VR, or fullscreen.
  42525. */
  42526. exitVR(): void;
  42527. /**
  42528. * The position of the vr experience helper.
  42529. */
  42530. /**
  42531. * Sets the position of the vr experience helper.
  42532. */
  42533. position: Vector3;
  42534. /**
  42535. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42536. */
  42537. enableInteractions(): void;
  42538. private readonly _noControllerIsActive;
  42539. private beforeRender;
  42540. private _isTeleportationFloor;
  42541. /**
  42542. * Adds a floor mesh to be used for teleportation.
  42543. * @param floorMesh the mesh to be used for teleportation.
  42544. */
  42545. addFloorMesh(floorMesh: Mesh): void;
  42546. /**
  42547. * Removes a floor mesh from being used for teleportation.
  42548. * @param floorMesh the mesh to be removed.
  42549. */
  42550. removeFloorMesh(floorMesh: Mesh): void;
  42551. /**
  42552. * Enables interactions and teleportation using the VR controllers and gaze.
  42553. * @param vrTeleportationOptions options to modify teleportation behavior.
  42554. */
  42555. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42556. private _onNewGamepadConnected;
  42557. private _tryEnableInteractionOnController;
  42558. private _onNewGamepadDisconnected;
  42559. private _enableInteractionOnController;
  42560. private _checkTeleportWithRay;
  42561. private _checkRotate;
  42562. private _checkTeleportBackwards;
  42563. private _enableTeleportationOnController;
  42564. private _createTeleportationCircles;
  42565. private _displayTeleportationTarget;
  42566. private _hideTeleportationTarget;
  42567. private _rotateCamera;
  42568. private _moveTeleportationSelectorTo;
  42569. private _workingVector;
  42570. private _workingQuaternion;
  42571. private _workingMatrix;
  42572. /**
  42573. * Teleports the users feet to the desired location
  42574. * @param location The location where the user's feet should be placed
  42575. */
  42576. teleportCamera(location: Vector3): void;
  42577. private _convertNormalToDirectionOfRay;
  42578. private _castRayAndSelectObject;
  42579. private _notifySelectedMeshUnselected;
  42580. /**
  42581. * Sets the color of the laser ray from the vr controllers.
  42582. * @param color new color for the ray.
  42583. */
  42584. changeLaserColor(color: Color3): void;
  42585. /**
  42586. * Sets the color of the ray from the vr headsets gaze.
  42587. * @param color new color for the ray.
  42588. */
  42589. changeGazeColor(color: Color3): void;
  42590. /**
  42591. * Exits VR and disposes of the vr experience helper
  42592. */
  42593. dispose(): void;
  42594. /**
  42595. * Gets the name of the VRExperienceHelper class
  42596. * @returns "VRExperienceHelper"
  42597. */
  42598. getClassName(): string;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42604. * IMPORTANT!! The data is right-hand data.
  42605. * @export
  42606. * @interface DevicePose
  42607. */
  42608. interface DevicePose {
  42609. /**
  42610. * The position of the device, values in array are [x,y,z].
  42611. */
  42612. readonly position: Nullable<Float32Array>;
  42613. /**
  42614. * The linearVelocity of the device, values in array are [x,y,z].
  42615. */
  42616. readonly linearVelocity: Nullable<Float32Array>;
  42617. /**
  42618. * The linearAcceleration of the device, values in array are [x,y,z].
  42619. */
  42620. readonly linearAcceleration: Nullable<Float32Array>;
  42621. /**
  42622. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42623. */
  42624. readonly orientation: Nullable<Float32Array>;
  42625. /**
  42626. * The angularVelocity of the device, values in array are [x,y,z].
  42627. */
  42628. readonly angularVelocity: Nullable<Float32Array>;
  42629. /**
  42630. * The angularAcceleration of the device, values in array are [x,y,z].
  42631. */
  42632. readonly angularAcceleration: Nullable<Float32Array>;
  42633. }
  42634. /**
  42635. * Interface representing a pose controlled object in Babylon.
  42636. * A pose controlled object has both regular pose values as well as pose values
  42637. * from an external device such as a VR head mounted display
  42638. */
  42639. interface PoseControlled {
  42640. /**
  42641. * The position of the object in babylon space.
  42642. */
  42643. position: Vector3;
  42644. /**
  42645. * The rotation quaternion of the object in babylon space.
  42646. */
  42647. rotationQuaternion: Quaternion;
  42648. /**
  42649. * The position of the device in babylon space.
  42650. */
  42651. devicePosition?: Vector3;
  42652. /**
  42653. * The rotation quaternion of the device in babylon space.
  42654. */
  42655. deviceRotationQuaternion: Quaternion;
  42656. /**
  42657. * The raw pose coming from the device.
  42658. */
  42659. rawPose: Nullable<DevicePose>;
  42660. /**
  42661. * The scale of the device to be used when translating from device space to babylon space.
  42662. */
  42663. deviceScaleFactor: number;
  42664. /**
  42665. * Updates the poseControlled values based on the input device pose.
  42666. * @param poseData the pose data to update the object with
  42667. */
  42668. updateFromDevice(poseData: DevicePose): void;
  42669. }
  42670. /**
  42671. * Set of options to customize the webVRCamera
  42672. */
  42673. interface WebVROptions {
  42674. /**
  42675. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42676. */
  42677. trackPosition?: boolean;
  42678. /**
  42679. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42680. */
  42681. positionScale?: number;
  42682. /**
  42683. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42684. */
  42685. displayName?: string;
  42686. /**
  42687. * Should the native controller meshes be initialized. (default: true)
  42688. */
  42689. controllerMeshes?: boolean;
  42690. /**
  42691. * Creating a default HemiLight only on controllers. (default: true)
  42692. */
  42693. defaultLightingOnControllers?: boolean;
  42694. /**
  42695. * If you don't want to use the default VR button of the helper. (default: false)
  42696. */
  42697. useCustomVRButton?: boolean;
  42698. /**
  42699. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42700. */
  42701. customVRButton?: HTMLButtonElement;
  42702. /**
  42703. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42704. */
  42705. rayLength?: number;
  42706. /**
  42707. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42708. */
  42709. defaultHeight?: number;
  42710. }
  42711. /**
  42712. * This represents a WebVR camera.
  42713. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42714. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42715. */
  42716. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42717. private webVROptions;
  42718. /**
  42719. * @hidden
  42720. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42721. */
  42722. _vrDevice: any;
  42723. /**
  42724. * The rawPose of the vrDevice.
  42725. */
  42726. rawPose: Nullable<DevicePose>;
  42727. private _onVREnabled;
  42728. private _specsVersion;
  42729. private _attached;
  42730. private _frameData;
  42731. protected _descendants: Array<Node>;
  42732. private _deviceRoomPosition;
  42733. /** @hidden */
  42734. _deviceRoomRotationQuaternion: Quaternion;
  42735. private _standingMatrix;
  42736. /**
  42737. * Represents device position in babylon space.
  42738. */
  42739. devicePosition: Vector3;
  42740. /**
  42741. * Represents device rotation in babylon space.
  42742. */
  42743. deviceRotationQuaternion: Quaternion;
  42744. /**
  42745. * The scale of the device to be used when translating from device space to babylon space.
  42746. */
  42747. deviceScaleFactor: number;
  42748. private _deviceToWorld;
  42749. private _worldToDevice;
  42750. /**
  42751. * References to the webVR controllers for the vrDevice.
  42752. */
  42753. controllers: Array<WebVRController>;
  42754. /**
  42755. * Emits an event when a controller is attached.
  42756. */
  42757. onControllersAttachedObservable: Observable<WebVRController[]>;
  42758. /**
  42759. * Emits an event when a controller's mesh has been loaded;
  42760. */
  42761. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42762. /**
  42763. * Emits an event when the HMD's pose has been updated.
  42764. */
  42765. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42766. private _poseSet;
  42767. /**
  42768. * If the rig cameras be used as parent instead of this camera.
  42769. */
  42770. rigParenting: boolean;
  42771. private _lightOnControllers;
  42772. private _defaultHeight?;
  42773. /**
  42774. * Instantiates a WebVRFreeCamera.
  42775. * @param name The name of the WebVRFreeCamera
  42776. * @param position The starting anchor position for the camera
  42777. * @param scene The scene the camera belongs to
  42778. * @param webVROptions a set of customizable options for the webVRCamera
  42779. */
  42780. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42781. /**
  42782. * Gets the device distance from the ground in meters.
  42783. * @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.
  42784. */
  42785. deviceDistanceToRoomGround(): number;
  42786. /**
  42787. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42788. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42789. */
  42790. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42791. /**
  42792. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42793. * @returns A promise with a boolean set to if the standing matrix is supported.
  42794. */
  42795. useStandingMatrixAsync(): Promise<boolean>;
  42796. /**
  42797. * Disposes the camera
  42798. */
  42799. dispose(): void;
  42800. /**
  42801. * Gets a vrController by name.
  42802. * @param name The name of the controller to retreive
  42803. * @returns the controller matching the name specified or null if not found
  42804. */
  42805. getControllerByName(name: string): Nullable<WebVRController>;
  42806. private _leftController;
  42807. /**
  42808. * The controller corrisponding to the users left hand.
  42809. */
  42810. readonly leftController: Nullable<WebVRController>;
  42811. private _rightController;
  42812. /**
  42813. * The controller corrisponding to the users right hand.
  42814. */
  42815. readonly rightController: Nullable<WebVRController>;
  42816. /**
  42817. * Casts a ray forward from the vrCamera's gaze.
  42818. * @param length Length of the ray (default: 100)
  42819. * @returns the ray corrisponding to the gaze
  42820. */
  42821. getForwardRay(length?: number): Ray;
  42822. /**
  42823. * @hidden
  42824. * Updates the camera based on device's frame data
  42825. */
  42826. _checkInputs(): void;
  42827. /**
  42828. * Updates the poseControlled values based on the input device pose.
  42829. * @param poseData Pose coming from the device
  42830. */
  42831. updateFromDevice(poseData: DevicePose): void;
  42832. private _htmlElementAttached;
  42833. private _detachIfAttached;
  42834. /**
  42835. * WebVR's attach control will start broadcasting frames to the device.
  42836. * Note that in certain browsers (chrome for example) this function must be called
  42837. * within a user-interaction callback. Example:
  42838. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42839. *
  42840. * @param element html element to attach the vrDevice to
  42841. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42842. */
  42843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42844. /**
  42845. * Detaches the camera from the html element and disables VR
  42846. *
  42847. * @param element html element to detach from
  42848. */
  42849. detachControl(element: HTMLElement): void;
  42850. /**
  42851. * @returns the name of this class
  42852. */
  42853. getClassName(): string;
  42854. /**
  42855. * Calls resetPose on the vrDisplay
  42856. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42857. */
  42858. resetToCurrentRotation(): void;
  42859. /**
  42860. * @hidden
  42861. * Updates the rig cameras (left and right eye)
  42862. */
  42863. _updateRigCameras(): void;
  42864. private _workingVector;
  42865. private _oneVector;
  42866. private _workingMatrix;
  42867. private updateCacheCalled;
  42868. private _correctPositionIfNotTrackPosition;
  42869. /**
  42870. * @hidden
  42871. * Updates the cached values of the camera
  42872. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42873. */
  42874. _updateCache(ignoreParentClass?: boolean): void;
  42875. /**
  42876. * @hidden
  42877. * Get current device position in babylon world
  42878. */
  42879. _computeDevicePosition(): void;
  42880. /**
  42881. * Updates the current device position and rotation in the babylon world
  42882. */
  42883. update(): void;
  42884. /**
  42885. * @hidden
  42886. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42887. * @returns an identity matrix
  42888. */
  42889. _getViewMatrix(): Matrix;
  42890. private _tmpMatrix;
  42891. /**
  42892. * This function is called by the two RIG cameras.
  42893. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42894. */
  42895. protected _getWebVRViewMatrix(): Matrix;
  42896. protected _getWebVRProjectionMatrix(): Matrix;
  42897. private _onGamepadConnectedObserver;
  42898. private _onGamepadDisconnectedObserver;
  42899. private _updateCacheWhenTrackingDisabledObserver;
  42900. /**
  42901. * Initializes the controllers and their meshes
  42902. */
  42903. initControllers(): void;
  42904. }
  42905. }
  42906. declare module BABYLON {
  42907. /**
  42908. * WebXR Camera which holds the views for the xrSession
  42909. * @see https://doc.babylonjs.com/how_to/webxr
  42910. */
  42911. class WebXRCamera extends FreeCamera {
  42912. private static _TmpMatrix;
  42913. /**
  42914. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42915. * @param name the name of the camera
  42916. * @param scene the scene to add the camera to
  42917. */
  42918. constructor(name: string, scene: BABYLON.Scene);
  42919. private _updateNumberOfRigCameras;
  42920. /** @hidden */
  42921. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42922. /**
  42923. * Updates the cameras position from the current pose information of the XR session
  42924. * @param xrSessionManager the session containing pose information
  42925. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42926. */
  42927. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42928. }
  42929. }
  42930. declare module BABYLON {
  42931. /**
  42932. * Button which can be used to enter a different mode of XR
  42933. */
  42934. class WebXREnterExitUIButton {
  42935. /** button element */
  42936. element: HTMLElement;
  42937. /** XR initialization options for the button */
  42938. initializationOptions: XRSessionCreationOptions;
  42939. /**
  42940. * Creates a WebXREnterExitUIButton
  42941. * @param element button element
  42942. * @param initializationOptions XR initialization options for the button
  42943. */
  42944. constructor(
  42945. /** button element */
  42946. element: HTMLElement,
  42947. /** XR initialization options for the button */
  42948. initializationOptions: XRSessionCreationOptions);
  42949. /**
  42950. * Overwritable function which can be used to update the button's visuals when the state changes
  42951. * @param activeButton the current active button in the UI
  42952. */
  42953. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42954. }
  42955. /**
  42956. * Options to create the webXR UI
  42957. */
  42958. class WebXREnterExitUIOptions {
  42959. /**
  42960. * Context to enter xr with
  42961. */
  42962. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42963. /**
  42964. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42965. */
  42966. customButtons?: Array<WebXREnterExitUIButton>;
  42967. }
  42968. /**
  42969. * UI to allow the user to enter/exit XR mode
  42970. */
  42971. class WebXREnterExitUI implements IDisposable {
  42972. private scene;
  42973. private _overlay;
  42974. private _buttons;
  42975. private _activeButton;
  42976. /**
  42977. * Fired every time the active button is changed.
  42978. *
  42979. * When xr is entered via a button that launches xr that button will be the callback parameter
  42980. *
  42981. * When exiting xr the callback parameter will be null)
  42982. */
  42983. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42984. /**
  42985. * Creates UI to allow the user to enter/exit XR mode
  42986. * @param scene the scene to add the ui to
  42987. * @param helper the xr experience helper to enter/exit xr with
  42988. * @param options options to configure the UI
  42989. * @returns the created ui
  42990. */
  42991. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42992. private constructor();
  42993. private _updateButtons;
  42994. /**
  42995. * Disposes of the object
  42996. */
  42997. dispose(): void;
  42998. }
  42999. }
  43000. declare module BABYLON {
  43001. /**
  43002. * States of the webXR experience
  43003. */
  43004. enum WebXRState {
  43005. /**
  43006. * Transitioning to being in XR mode
  43007. */
  43008. ENTERING_XR = 0,
  43009. /**
  43010. * Transitioning to non XR mode
  43011. */
  43012. EXITING_XR = 1,
  43013. /**
  43014. * In XR mode and presenting
  43015. */
  43016. IN_XR = 2,
  43017. /**
  43018. * Not entered XR mode
  43019. */
  43020. NOT_IN_XR = 3
  43021. }
  43022. /**
  43023. * Helper class used to enable XR
  43024. * @see https://doc.babylonjs.com/how_to/webxr
  43025. */
  43026. class WebXRExperienceHelper implements IDisposable {
  43027. private scene;
  43028. /**
  43029. * 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
  43030. */
  43031. container: AbstractMesh;
  43032. /**
  43033. * Camera used to render xr content
  43034. */
  43035. camera: WebXRCamera;
  43036. /**
  43037. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43038. */
  43039. state: WebXRState;
  43040. private _setState;
  43041. private static _TmpVector;
  43042. /**
  43043. * Fires when the state of the experience helper has changed
  43044. */
  43045. onStateChangedObservable: Observable<WebXRState>;
  43046. /** @hidden */
  43047. _sessionManager: WebXRSessionManager;
  43048. private _nonVRCamera;
  43049. private _originalSceneAutoClear;
  43050. private _supported;
  43051. /**
  43052. * Creates the experience helper
  43053. * @param scene the scene to attach the experience helper to
  43054. * @returns a promise for the experience helper
  43055. */
  43056. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43057. /**
  43058. * Creates a WebXRExperienceHelper
  43059. * @param scene The scene the helper should be created in
  43060. */
  43061. private constructor();
  43062. /**
  43063. * Exits XR mode and returns the scene to its original state
  43064. * @returns promise that resolves after xr mode has exited
  43065. */
  43066. exitXRAsync(): Promise<void>;
  43067. /**
  43068. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43069. * @param sessionCreationOptions options for the XR session
  43070. * @param frameOfReference frame of reference of the XR session
  43071. * @returns promise that resolves after xr mode has entered
  43072. */
  43073. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43074. /**
  43075. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43076. * @param ray ray to cast into the environment
  43077. * @returns Promise which resolves with a collision point in the environment if it exists
  43078. */
  43079. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43080. /**
  43081. * Updates the global position of the camera by moving the camera's container
  43082. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43083. * @param position The desired global position of the camera
  43084. */
  43085. setPositionOfCameraUsingContainer(position: Vector3): void;
  43086. /**
  43087. * Rotates the xr camera by rotating the camera's container around the camera's position
  43088. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43089. * @param rotation the desired quaternion rotation to apply to the camera
  43090. */
  43091. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43092. /**
  43093. * Checks if the creation options are supported by the xr session
  43094. * @param options creation options
  43095. * @returns true if supported
  43096. */
  43097. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43098. /**
  43099. * Disposes of the experience helper
  43100. */
  43101. dispose(): void;
  43102. }
  43103. }
  43104. declare module BABYLON {
  43105. /**
  43106. * Represents an XR input
  43107. */
  43108. class WebXRController {
  43109. /**
  43110. * 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
  43111. */
  43112. grip?: BABYLON.AbstractMesh;
  43113. /**
  43114. * Pointer which can be used to select objects or attach a visible laser to
  43115. */
  43116. pointer: BABYLON.AbstractMesh;
  43117. /**
  43118. * Creates the controller
  43119. * @see https://doc.babylonjs.com/how_to/webxr
  43120. * @param scene the scene which the controller should be associated to
  43121. */
  43122. constructor(scene: BABYLON.Scene);
  43123. /**
  43124. * Disposes of the object
  43125. */
  43126. dispose(): void;
  43127. }
  43128. /**
  43129. * XR input used to track XR inputs such as controllers/rays
  43130. */
  43131. class WebXRInput implements IDisposable {
  43132. private helper;
  43133. /**
  43134. * XR controllers being tracked
  43135. */
  43136. controllers: Array<WebXRController>;
  43137. private _tmpMatrix;
  43138. private _frameObserver;
  43139. /**
  43140. * Initializes the WebXRInput
  43141. * @param helper experience helper which the input should be created for
  43142. */
  43143. constructor(helper: WebXRExperienceHelper);
  43144. /**
  43145. * Disposes of the object
  43146. */
  43147. dispose(): void;
  43148. }
  43149. }
  43150. declare module BABYLON {
  43151. /**
  43152. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43153. */
  43154. class WebXRManagedOutputCanvas implements IDisposable {
  43155. private _canvas;
  43156. /**
  43157. * xrpresent context of the canvas which can be used to display/mirror xr content
  43158. */
  43159. canvasContext: Nullable<WebGLRenderingContext>;
  43160. /**
  43161. * Initializes the canvas to be added/removed upon entering/exiting xr
  43162. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43163. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43164. */
  43165. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43166. /**
  43167. * Disposes of the object
  43168. */
  43169. dispose(): void;
  43170. private _setManagedOutputCanvas;
  43171. private _addCanvas;
  43172. private _removeCanvas;
  43173. }
  43174. }
  43175. declare module BABYLON {
  43176. /**
  43177. * Manages an XRSession
  43178. * @see https://doc.babylonjs.com/how_to/webxr
  43179. */
  43180. class WebXRSessionManager implements IDisposable {
  43181. private scene;
  43182. /**
  43183. * Fires every time a new xrFrame arrives which can be used to update the camera
  43184. */
  43185. onXRFrameObservable: Observable<any>;
  43186. /**
  43187. * Fires when the xr session is ended either by the device or manually done
  43188. */
  43189. onXRSessionEnded: Observable<any>;
  43190. /** @hidden */
  43191. _xrSession: XRSession;
  43192. /** @hidden */
  43193. _frameOfReference: XRFrameOfReference;
  43194. /** @hidden */
  43195. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43196. /** @hidden */
  43197. _currentXRFrame: Nullable<XRFrame>;
  43198. private _xrNavigator;
  43199. private _xrDevice;
  43200. private _tmpMatrix;
  43201. /**
  43202. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43203. * @param scene The scene which the session should be created for
  43204. */
  43205. constructor(scene: BABYLON.Scene);
  43206. /**
  43207. * Initializes the manager
  43208. * After initialization enterXR can be called to start an XR session
  43209. * @returns Promise which resolves after it is initialized
  43210. */
  43211. initializeAsync(): Promise<void>;
  43212. /**
  43213. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43214. * @param sessionCreationOptions xr options to create the session with
  43215. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43216. * @returns Promise which resolves after it enters XR
  43217. */
  43218. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43219. /**
  43220. * Stops the xrSession and restores the renderloop
  43221. * @returns Promise which resolves after it exits XR
  43222. */
  43223. exitXRAsync(): Promise<void>;
  43224. /**
  43225. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43226. * @param ray ray to cast into the environment
  43227. * @returns Promise which resolves with a collision point in the environment if it exists
  43228. */
  43229. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43230. /**
  43231. * Checks if a session would be supported for the creation options specified
  43232. * @param options creation options to check if they are supported
  43233. * @returns true if supported
  43234. */
  43235. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43236. /**
  43237. * @hidden
  43238. * Converts the render layer of xrSession to a render target
  43239. * @param session session to create render target for
  43240. * @param scene scene the new render target should be created for
  43241. */
  43242. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43243. /**
  43244. * Disposes of the session manager
  43245. */
  43246. dispose(): void;
  43247. }
  43248. }
  43249. declare module BABYLON {
  43250. /**
  43251. * Contains an array of blocks representing the octree
  43252. */
  43253. interface IOctreeContainer<T> {
  43254. /**
  43255. * Blocks within the octree
  43256. */
  43257. blocks: Array<OctreeBlock<T>>;
  43258. }
  43259. /**
  43260. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43261. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43262. */
  43263. class Octree<T> {
  43264. /** 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.) */
  43265. maxDepth: number;
  43266. /**
  43267. * Blocks within the octree containing objects
  43268. */
  43269. blocks: Array<OctreeBlock<T>>;
  43270. /**
  43271. * Content stored in the octree
  43272. */
  43273. dynamicContent: T[];
  43274. private _maxBlockCapacity;
  43275. private _selectionContent;
  43276. private _creationFunc;
  43277. /**
  43278. * Creates a octree
  43279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43280. * @param creationFunc function to be used to instatiate the octree
  43281. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43282. * @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.)
  43283. */
  43284. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43285. /** 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.) */
  43286. maxDepth?: number);
  43287. /**
  43288. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43289. * @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);
  43290. * @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);
  43291. * @param entries meshes to be added to the octree blocks
  43292. */
  43293. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43294. /**
  43295. * Adds a mesh to the octree
  43296. * @param entry Mesh to add to the octree
  43297. */
  43298. addMesh(entry: T): void;
  43299. /**
  43300. * Selects an array of meshes within the frustum
  43301. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43302. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43303. * @returns array of meshes within the frustum
  43304. */
  43305. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43306. /**
  43307. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43308. * @param sphereCenter defines the bounding sphere center
  43309. * @param sphereRadius defines the bounding sphere radius
  43310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43311. * @returns an array of objects that intersect the sphere
  43312. */
  43313. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43314. /**
  43315. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43316. * @param ray defines the ray to test with
  43317. * @returns array of intersected objects
  43318. */
  43319. intersectsRay(ray: Ray): SmartArray<T>;
  43320. /**
  43321. * @hidden
  43322. */
  43323. 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;
  43324. /**
  43325. * Adds a mesh into the octree block if it intersects the block
  43326. */
  43327. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43328. /**
  43329. * Adds a submesh into the octree block if it intersects the block
  43330. */
  43331. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43332. }
  43333. }
  43334. declare module BABYLON {
  43335. /**
  43336. * Class used to store a cell in an octree
  43337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43338. */
  43339. class OctreeBlock<T> {
  43340. /**
  43341. * Gets the content of the current block
  43342. */
  43343. entries: T[];
  43344. /**
  43345. * Gets the list of block children
  43346. */
  43347. blocks: Array<OctreeBlock<T>>;
  43348. private _depth;
  43349. private _maxDepth;
  43350. private _capacity;
  43351. private _minPoint;
  43352. private _maxPoint;
  43353. private _boundingVectors;
  43354. private _creationFunc;
  43355. /**
  43356. * Creates a new block
  43357. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43358. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43359. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43360. * @param depth defines the current depth of this block in the octree
  43361. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43362. * @param creationFunc defines a callback to call when an element is added to the block
  43363. */
  43364. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43365. /**
  43366. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43367. */
  43368. readonly capacity: number;
  43369. /**
  43370. * Gets the minimum vector (in world space) of the block's bounding box
  43371. */
  43372. readonly minPoint: Vector3;
  43373. /**
  43374. * Gets the maximum vector (in world space) of the block's bounding box
  43375. */
  43376. readonly maxPoint: Vector3;
  43377. /**
  43378. * Add a new element to this block
  43379. * @param entry defines the element to add
  43380. */
  43381. addEntry(entry: T): void;
  43382. /**
  43383. * Add an array of elements to this block
  43384. * @param entries defines the array of elements to add
  43385. */
  43386. addEntries(entries: T[]): void;
  43387. /**
  43388. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43389. * @param frustumPlanes defines the frustum planes to test
  43390. * @param selection defines the array to store current content if selection is positive
  43391. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43392. */
  43393. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43394. /**
  43395. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43396. * @param sphereCenter defines the bounding sphere center
  43397. * @param sphereRadius defines the bounding sphere radius
  43398. * @param selection defines the array to store current content if selection is positive
  43399. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43400. */
  43401. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43402. /**
  43403. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43404. * @param ray defines the ray to test with
  43405. * @param selection defines the array to store current content if selection is positive
  43406. */
  43407. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43408. /**
  43409. * Subdivide the content into child blocks (this block will then be empty)
  43410. */
  43411. createInnerBlocks(): void;
  43412. }
  43413. }
  43414. declare module BABYLON {
  43415. interface Scene {
  43416. /**
  43417. * @hidden
  43418. * Backing Filed
  43419. */
  43420. _selectionOctree: Octree<AbstractMesh>;
  43421. /**
  43422. * Gets the octree used to boost mesh selection (picking)
  43423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43424. */
  43425. selectionOctree: Octree<AbstractMesh>;
  43426. /**
  43427. * Creates or updates the octree used to boost selection (picking)
  43428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43429. * @param maxCapacity defines the maximum capacity per leaf
  43430. * @param maxDepth defines the maximum depth of the octree
  43431. * @returns an octree of AbstractMesh
  43432. */
  43433. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43434. }
  43435. interface AbstractMesh {
  43436. /**
  43437. * @hidden
  43438. * Backing Field
  43439. */
  43440. _submeshesOctree: Octree<SubMesh>;
  43441. /**
  43442. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43443. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43444. * @param maxCapacity defines the maximum size of each block (64 by default)
  43445. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43446. * @returns the new octree
  43447. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43448. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43449. */
  43450. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43451. }
  43452. /**
  43453. * Defines the octree scene component responsible to manage any octrees
  43454. * in a given scene.
  43455. */
  43456. class OctreeSceneComponent {
  43457. /**
  43458. * The component name helpfull to identify the component in the list of scene components.
  43459. */
  43460. readonly name: string;
  43461. /**
  43462. * The scene the component belongs to.
  43463. */
  43464. scene: Scene;
  43465. /**
  43466. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43467. */
  43468. readonly checksIsEnabled: boolean;
  43469. /**
  43470. * Creates a new instance of the component for the given scene
  43471. * @param scene Defines the scene to register the component in
  43472. */
  43473. constructor(scene: Scene);
  43474. /**
  43475. * Registers the component in a given scene
  43476. */
  43477. register(): void;
  43478. /**
  43479. * Return the list of active meshes
  43480. * @returns the list of active meshes
  43481. */
  43482. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43483. /**
  43484. * Return the list of active sub meshes
  43485. * @param mesh The mesh to get the candidates sub meshes from
  43486. * @returns the list of active sub meshes
  43487. */
  43488. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43489. private _tempRay;
  43490. /**
  43491. * Return the list of sub meshes intersecting with a given local ray
  43492. * @param mesh defines the mesh to find the submesh for
  43493. * @param localRay defines the ray in local space
  43494. * @returns the list of intersecting sub meshes
  43495. */
  43496. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43497. /**
  43498. * Return the list of sub meshes colliding with a collider
  43499. * @param mesh defines the mesh to find the submesh for
  43500. * @param collider defines the collider to evaluate the collision against
  43501. * @returns the list of colliding sub meshes
  43502. */
  43503. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43504. /**
  43505. * Rebuilds the elements related to this component in case of
  43506. * context lost for instance.
  43507. */
  43508. rebuild(): void;
  43509. /**
  43510. * Disposes the component and the associated ressources.
  43511. */
  43512. dispose(): void;
  43513. }
  43514. }
  43515. declare module BABYLON {
  43516. /** @hidden */
  43517. class _OcclusionDataStorage {
  43518. /** @hidden */
  43519. occlusionInternalRetryCounter: number;
  43520. /** @hidden */
  43521. isOcclusionQueryInProgress: boolean;
  43522. /** @hidden */
  43523. isOccluded: boolean;
  43524. /** @hidden */
  43525. occlusionRetryCount: number;
  43526. /** @hidden */
  43527. occlusionType: number;
  43528. /** @hidden */
  43529. occlusionQueryAlgorithmType: number;
  43530. }
  43531. interface Engine {
  43532. /**
  43533. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43534. * @return the new query
  43535. */
  43536. createQuery(): WebGLQuery;
  43537. /**
  43538. * Delete and release a webGL query
  43539. * @param query defines the query to delete
  43540. * @return the current engine
  43541. */
  43542. deleteQuery(query: WebGLQuery): Engine;
  43543. /**
  43544. * Check if a given query has resolved and got its value
  43545. * @param query defines the query to check
  43546. * @returns true if the query got its value
  43547. */
  43548. isQueryResultAvailable(query: WebGLQuery): boolean;
  43549. /**
  43550. * Gets the value of a given query
  43551. * @param query defines the query to check
  43552. * @returns the value of the query
  43553. */
  43554. getQueryResult(query: WebGLQuery): number;
  43555. /**
  43556. * Initiates an occlusion query
  43557. * @param algorithmType defines the algorithm to use
  43558. * @param query defines the query to use
  43559. * @returns the current engine
  43560. * @see http://doc.babylonjs.com/features/occlusionquery
  43561. */
  43562. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43563. /**
  43564. * Ends an occlusion query
  43565. * @see http://doc.babylonjs.com/features/occlusionquery
  43566. * @param algorithmType defines the algorithm to use
  43567. * @returns the current engine
  43568. */
  43569. endOcclusionQuery(algorithmType: number): Engine;
  43570. /**
  43571. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43572. * Please note that only one query can be issued at a time
  43573. * @returns a time token used to track the time span
  43574. */
  43575. startTimeQuery(): Nullable<_TimeToken>;
  43576. /**
  43577. * Ends a time query
  43578. * @param token defines the token used to measure the time span
  43579. * @returns the time spent (in ns)
  43580. */
  43581. endTimeQuery(token: _TimeToken): int;
  43582. /** @hidden */
  43583. _currentNonTimestampToken: Nullable<_TimeToken>;
  43584. /** @hidden */
  43585. _createTimeQuery(): WebGLQuery;
  43586. /** @hidden */
  43587. _deleteTimeQuery(query: WebGLQuery): void;
  43588. /** @hidden */
  43589. _getGlAlgorithmType(algorithmType: number): number;
  43590. /** @hidden */
  43591. _getTimeQueryResult(query: WebGLQuery): any;
  43592. /** @hidden */
  43593. _getTimeQueryAvailability(query: WebGLQuery): any;
  43594. }
  43595. interface AbstractMesh {
  43596. /**
  43597. * Backing filed
  43598. * @hidden
  43599. */
  43600. __occlusionDataStorage: _OcclusionDataStorage;
  43601. /**
  43602. * Access property
  43603. * @hidden
  43604. */
  43605. _occlusionDataStorage: _OcclusionDataStorage;
  43606. /**
  43607. * 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.
  43608. * The default value is -1 which means don't break the query and wait till the result
  43609. * @see http://doc.babylonjs.com/features/occlusionquery
  43610. */
  43611. occlusionRetryCount: number;
  43612. /**
  43613. * 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:
  43614. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43615. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43616. * * 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.
  43617. * @see http://doc.babylonjs.com/features/occlusionquery
  43618. */
  43619. occlusionType: number;
  43620. /**
  43621. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43622. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43623. * * 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.
  43624. * @see http://doc.babylonjs.com/features/occlusionquery
  43625. */
  43626. occlusionQueryAlgorithmType: number;
  43627. /**
  43628. * 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
  43629. * @see http://doc.babylonjs.com/features/occlusionquery
  43630. */
  43631. isOccluded: boolean;
  43632. /**
  43633. * Flag to check the progress status of the query
  43634. * @see http://doc.babylonjs.com/features/occlusionquery
  43635. */
  43636. isOcclusionQueryInProgress: boolean;
  43637. }
  43638. }
  43639. declare module BABYLON {
  43640. interface Engine {
  43641. /**
  43642. * Creates a webGL transform feedback object
  43643. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43644. * @returns the webGL transform feedback object
  43645. */
  43646. createTransformFeedback(): WebGLTransformFeedback;
  43647. /**
  43648. * Delete a webGL transform feedback object
  43649. * @param value defines the webGL transform feedback object to delete
  43650. */
  43651. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43652. /**
  43653. * Bind a webGL transform feedback object to the webgl context
  43654. * @param value defines the webGL transform feedback object to bind
  43655. */
  43656. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43657. /**
  43658. * Begins a transform feedback operation
  43659. * @param usePoints defines if points or triangles must be used
  43660. */
  43661. beginTransformFeedback(usePoints: boolean): void;
  43662. /**
  43663. * Ends a transform feedback operation
  43664. */
  43665. endTransformFeedback(): void;
  43666. /**
  43667. * Specify the varyings to use with transform feedback
  43668. * @param program defines the associated webGL program
  43669. * @param value defines the list of strings representing the varying names
  43670. */
  43671. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43672. /**
  43673. * Bind a webGL buffer for a transform feedback operation
  43674. * @param value defines the webGL buffer to bind
  43675. */
  43676. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43677. }
  43678. }
  43679. declare module BABYLON {
  43680. /**
  43681. * Google Daydream controller
  43682. */
  43683. class DaydreamController extends WebVRController {
  43684. /**
  43685. * Base Url for the controller model.
  43686. */
  43687. static MODEL_BASE_URL: string;
  43688. /**
  43689. * File name for the controller model.
  43690. */
  43691. static MODEL_FILENAME: string;
  43692. /**
  43693. * Gamepad Id prefix used to identify Daydream Controller.
  43694. */
  43695. static readonly GAMEPAD_ID_PREFIX: string;
  43696. /**
  43697. * Creates a new DaydreamController from a gamepad
  43698. * @param vrGamepad the gamepad that the controller should be created from
  43699. */
  43700. constructor(vrGamepad: any);
  43701. /**
  43702. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43703. * @param scene scene in which to add meshes
  43704. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43705. */
  43706. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43707. /**
  43708. * Called once for each button that changed state since the last frame
  43709. * @param buttonIdx Which button index changed
  43710. * @param state New state of the button
  43711. * @param changes Which properties on the state changed since last frame
  43712. */
  43713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43714. }
  43715. }
  43716. declare module BABYLON {
  43717. /**
  43718. * Gear VR Controller
  43719. */
  43720. class GearVRController extends WebVRController {
  43721. /**
  43722. * Base Url for the controller model.
  43723. */
  43724. static MODEL_BASE_URL: string;
  43725. /**
  43726. * File name for the controller model.
  43727. */
  43728. static MODEL_FILENAME: string;
  43729. /**
  43730. * Gamepad Id prefix used to identify this controller.
  43731. */
  43732. static readonly GAMEPAD_ID_PREFIX: string;
  43733. private readonly _buttonIndexToObservableNameMap;
  43734. /**
  43735. * Creates a new GearVRController from a gamepad
  43736. * @param vrGamepad the gamepad that the controller should be created from
  43737. */
  43738. constructor(vrGamepad: any);
  43739. /**
  43740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43741. * @param scene scene in which to add meshes
  43742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43743. */
  43744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43745. /**
  43746. * Called once for each button that changed state since the last frame
  43747. * @param buttonIdx Which button index changed
  43748. * @param state New state of the button
  43749. * @param changes Which properties on the state changed since last frame
  43750. */
  43751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43752. }
  43753. }
  43754. declare module BABYLON {
  43755. /**
  43756. * Generic Controller
  43757. */
  43758. class GenericController extends WebVRController {
  43759. /**
  43760. * Base Url for the controller model.
  43761. */
  43762. static readonly MODEL_BASE_URL: string;
  43763. /**
  43764. * File name for the controller model.
  43765. */
  43766. static readonly MODEL_FILENAME: string;
  43767. /**
  43768. * Creates a new GenericController from a gamepad
  43769. * @param vrGamepad the gamepad that the controller should be created from
  43770. */
  43771. constructor(vrGamepad: any);
  43772. /**
  43773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43774. * @param scene scene in which to add meshes
  43775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43776. */
  43777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43778. /**
  43779. * Called once for each button that changed state since the last frame
  43780. * @param buttonIdx Which button index changed
  43781. * @param state New state of the button
  43782. * @param changes Which properties on the state changed since last frame
  43783. */
  43784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43785. }
  43786. }
  43787. declare module BABYLON {
  43788. /**
  43789. * Oculus Touch Controller
  43790. */
  43791. class OculusTouchController extends WebVRController {
  43792. /**
  43793. * Base Url for the controller model.
  43794. */
  43795. static MODEL_BASE_URL: string;
  43796. /**
  43797. * File name for the left controller model.
  43798. */
  43799. static MODEL_LEFT_FILENAME: string;
  43800. /**
  43801. * File name for the right controller model.
  43802. */
  43803. static MODEL_RIGHT_FILENAME: string;
  43804. /**
  43805. * Fired when the secondary trigger on this controller is modified
  43806. */
  43807. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43808. /**
  43809. * Fired when the thumb rest on this controller is modified
  43810. */
  43811. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43812. /**
  43813. * Creates a new OculusTouchController from a gamepad
  43814. * @param vrGamepad the gamepad that the controller should be created from
  43815. */
  43816. constructor(vrGamepad: any);
  43817. /**
  43818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43819. * @param scene scene in which to add meshes
  43820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43821. */
  43822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43823. /**
  43824. * Fired when the A button on this controller is modified
  43825. */
  43826. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43827. /**
  43828. * Fired when the B button on this controller is modified
  43829. */
  43830. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43831. /**
  43832. * Fired when the X button on this controller is modified
  43833. */
  43834. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43835. /**
  43836. * Fired when the Y button on this controller is modified
  43837. */
  43838. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43839. /**
  43840. * Called once for each button that changed state since the last frame
  43841. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43842. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43843. * 2) secondary trigger (same)
  43844. * 3) A (right) X (left), touch, pressed = value
  43845. * 4) B / Y
  43846. * 5) thumb rest
  43847. * @param buttonIdx Which button index changed
  43848. * @param state New state of the button
  43849. * @param changes Which properties on the state changed since last frame
  43850. */
  43851. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43852. }
  43853. }
  43854. declare module BABYLON {
  43855. /**
  43856. * Defines the types of pose enabled controllers that are supported
  43857. */
  43858. enum PoseEnabledControllerType {
  43859. /**
  43860. * HTC Vive
  43861. */
  43862. VIVE = 0,
  43863. /**
  43864. * Oculus Rift
  43865. */
  43866. OCULUS = 1,
  43867. /**
  43868. * Windows mixed reality
  43869. */
  43870. WINDOWS = 2,
  43871. /**
  43872. * Samsung gear VR
  43873. */
  43874. GEAR_VR = 3,
  43875. /**
  43876. * Google Daydream
  43877. */
  43878. DAYDREAM = 4,
  43879. /**
  43880. * Generic
  43881. */
  43882. GENERIC = 5
  43883. }
  43884. /**
  43885. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43886. */
  43887. interface MutableGamepadButton {
  43888. /**
  43889. * Value of the button/trigger
  43890. */
  43891. value: number;
  43892. /**
  43893. * If the button/trigger is currently touched
  43894. */
  43895. touched: boolean;
  43896. /**
  43897. * If the button/trigger is currently pressed
  43898. */
  43899. pressed: boolean;
  43900. }
  43901. /**
  43902. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43903. * @hidden
  43904. */
  43905. interface ExtendedGamepadButton extends GamepadButton {
  43906. /**
  43907. * If the button/trigger is currently pressed
  43908. */
  43909. readonly pressed: boolean;
  43910. /**
  43911. * If the button/trigger is currently touched
  43912. */
  43913. readonly touched: boolean;
  43914. /**
  43915. * Value of the button/trigger
  43916. */
  43917. readonly value: number;
  43918. }
  43919. /**
  43920. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43921. */
  43922. class PoseEnabledControllerHelper {
  43923. /**
  43924. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43925. * @param vrGamepad the gamepad to initialized
  43926. * @returns a vr controller of the type the gamepad identified as
  43927. */
  43928. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43929. }
  43930. /**
  43931. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43932. */
  43933. class PoseEnabledController extends Gamepad implements PoseControlled {
  43934. private _deviceRoomPosition;
  43935. private _deviceRoomRotationQuaternion;
  43936. /**
  43937. * The device position in babylon space
  43938. */
  43939. devicePosition: Vector3;
  43940. /**
  43941. * The device rotation in babylon space
  43942. */
  43943. deviceRotationQuaternion: Quaternion;
  43944. /**
  43945. * The scale factor of the device in babylon space
  43946. */
  43947. deviceScaleFactor: number;
  43948. /**
  43949. * (Likely devicePosition should be used instead) The device position in its room space
  43950. */
  43951. position: Vector3;
  43952. /**
  43953. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43954. */
  43955. rotationQuaternion: Quaternion;
  43956. /**
  43957. * The type of controller (Eg. Windows mixed reality)
  43958. */
  43959. controllerType: PoseEnabledControllerType;
  43960. protected _calculatedPosition: Vector3;
  43961. private _calculatedRotation;
  43962. /**
  43963. * The raw pose from the device
  43964. */
  43965. rawPose: DevicePose;
  43966. private _trackPosition;
  43967. private _maxRotationDistFromHeadset;
  43968. private _draggedRoomRotation;
  43969. /**
  43970. * @hidden
  43971. */
  43972. _disableTrackPosition(fixedPosition: Vector3): void;
  43973. /**
  43974. * Internal, the mesh attached to the controller
  43975. * @hidden
  43976. */
  43977. _mesh: Nullable<AbstractMesh>;
  43978. private _poseControlledCamera;
  43979. private _leftHandSystemQuaternion;
  43980. /**
  43981. * Internal, matrix used to convert room space to babylon space
  43982. * @hidden
  43983. */
  43984. _deviceToWorld: Matrix;
  43985. /**
  43986. * Node to be used when casting a ray from the controller
  43987. * @hidden
  43988. */
  43989. _pointingPoseNode: Nullable<TransformNode>;
  43990. /**
  43991. * Name of the child mesh that can be used to cast a ray from the controller
  43992. */
  43993. static readonly POINTING_POSE: string;
  43994. /**
  43995. * Creates a new PoseEnabledController from a gamepad
  43996. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43997. */
  43998. constructor(browserGamepad: any);
  43999. private _workingMatrix;
  44000. /**
  44001. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44002. */
  44003. update(): void;
  44004. /**
  44005. * Updates only the pose device and mesh without doing any button event checking
  44006. */
  44007. protected _updatePoseAndMesh(): void;
  44008. /**
  44009. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44010. * @param poseData raw pose fromthe device
  44011. */
  44012. updateFromDevice(poseData: DevicePose): void;
  44013. /**
  44014. * @hidden
  44015. */
  44016. _meshAttachedObservable: Observable<AbstractMesh>;
  44017. /**
  44018. * Attaches a mesh to the controller
  44019. * @param mesh the mesh to be attached
  44020. */
  44021. attachToMesh(mesh: AbstractMesh): void;
  44022. /**
  44023. * Attaches the controllers mesh to a camera
  44024. * @param camera the camera the mesh should be attached to
  44025. */
  44026. attachToPoseControlledCamera(camera: TargetCamera): void;
  44027. /**
  44028. * Disposes of the controller
  44029. */
  44030. dispose(): void;
  44031. /**
  44032. * The mesh that is attached to the controller
  44033. */
  44034. readonly mesh: Nullable<AbstractMesh>;
  44035. /**
  44036. * Gets the ray of the controller in the direction the controller is pointing
  44037. * @param length the length the resulting ray should be
  44038. * @returns a ray in the direction the controller is pointing
  44039. */
  44040. getForwardRay(length?: number): Ray;
  44041. }
  44042. }
  44043. declare module BABYLON {
  44044. /**
  44045. * Vive Controller
  44046. */
  44047. class ViveController extends WebVRController {
  44048. /**
  44049. * Base Url for the controller model.
  44050. */
  44051. static MODEL_BASE_URL: string;
  44052. /**
  44053. * File name for the controller model.
  44054. */
  44055. static MODEL_FILENAME: string;
  44056. /**
  44057. * Creates a new ViveController from a gamepad
  44058. * @param vrGamepad the gamepad that the controller should be created from
  44059. */
  44060. constructor(vrGamepad: any);
  44061. /**
  44062. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44063. * @param scene scene in which to add meshes
  44064. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44065. */
  44066. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44067. /**
  44068. * Fired when the left button on this controller is modified
  44069. */
  44070. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44071. /**
  44072. * Fired when the right button on this controller is modified
  44073. */
  44074. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44075. /**
  44076. * Fired when the menu button on this controller is modified
  44077. */
  44078. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44079. /**
  44080. * Called once for each button that changed state since the last frame
  44081. * Vive mapping:
  44082. * 0: touchpad
  44083. * 1: trigger
  44084. * 2: left AND right buttons
  44085. * 3: menu button
  44086. * @param buttonIdx Which button index changed
  44087. * @param state New state of the button
  44088. * @param changes Which properties on the state changed since last frame
  44089. */
  44090. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44091. }
  44092. }
  44093. declare module BABYLON {
  44094. /**
  44095. * Defines the WebVRController object that represents controllers tracked in 3D space
  44096. */
  44097. abstract class WebVRController extends PoseEnabledController {
  44098. /**
  44099. * Internal, the default controller model for the controller
  44100. */
  44101. protected _defaultModel: AbstractMesh;
  44102. /**
  44103. * Fired when the trigger state has changed
  44104. */
  44105. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44106. /**
  44107. * Fired when the main button state has changed
  44108. */
  44109. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44110. /**
  44111. * Fired when the secondary button state has changed
  44112. */
  44113. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44114. /**
  44115. * Fired when the pad state has changed
  44116. */
  44117. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44118. /**
  44119. * Fired when controllers stick values have changed
  44120. */
  44121. onPadValuesChangedObservable: Observable<StickValues>;
  44122. /**
  44123. * Array of button availible on the controller
  44124. */
  44125. protected _buttons: Array<MutableGamepadButton>;
  44126. private _onButtonStateChange;
  44127. /**
  44128. * Fired when a controller button's state has changed
  44129. * @param callback the callback containing the button that was modified
  44130. */
  44131. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44132. /**
  44133. * X and Y axis corrisponding to the controllers joystick
  44134. */
  44135. pad: StickValues;
  44136. /**
  44137. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44138. */
  44139. hand: string;
  44140. /**
  44141. * The default controller model for the controller
  44142. */
  44143. readonly defaultModel: AbstractMesh;
  44144. /**
  44145. * Creates a new WebVRController from a gamepad
  44146. * @param vrGamepad the gamepad that the WebVRController should be created from
  44147. */
  44148. constructor(vrGamepad: any);
  44149. /**
  44150. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44151. */
  44152. update(): void;
  44153. /**
  44154. * Function to be called when a button is modified
  44155. */
  44156. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44157. /**
  44158. * Loads a mesh and attaches it to the controller
  44159. * @param scene the scene the mesh should be added to
  44160. * @param meshLoaded callback for when the mesh has been loaded
  44161. */
  44162. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44163. private _setButtonValue;
  44164. private _changes;
  44165. private _checkChanges;
  44166. /**
  44167. * Disposes of th webVRCOntroller
  44168. */
  44169. dispose(): void;
  44170. }
  44171. }
  44172. declare module BABYLON {
  44173. /**
  44174. * Defines the WindowsMotionController object that the state of the windows motion controller
  44175. */
  44176. class WindowsMotionController extends WebVRController {
  44177. /**
  44178. * The base url used to load the left and right controller models
  44179. */
  44180. static MODEL_BASE_URL: string;
  44181. /**
  44182. * The name of the left controller model file
  44183. */
  44184. static MODEL_LEFT_FILENAME: string;
  44185. /**
  44186. * The name of the right controller model file
  44187. */
  44188. static MODEL_RIGHT_FILENAME: string;
  44189. /**
  44190. * The controller name prefix for this controller type
  44191. */
  44192. static readonly GAMEPAD_ID_PREFIX: string;
  44193. /**
  44194. * The controller id pattern for this controller type
  44195. */
  44196. private static readonly GAMEPAD_ID_PATTERN;
  44197. private _loadedMeshInfo;
  44198. private readonly _mapping;
  44199. /**
  44200. * Fired when the trackpad on this controller is clicked
  44201. */
  44202. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44203. /**
  44204. * Fired when the trackpad on this controller is modified
  44205. */
  44206. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44207. /**
  44208. * The current x and y values of this controller's trackpad
  44209. */
  44210. trackpad: StickValues;
  44211. /**
  44212. * Creates a new WindowsMotionController from a gamepad
  44213. * @param vrGamepad the gamepad that the controller should be created from
  44214. */
  44215. constructor(vrGamepad: any);
  44216. /**
  44217. * Fired when the trigger on this controller is modified
  44218. */
  44219. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44220. /**
  44221. * Fired when the menu button on this controller is modified
  44222. */
  44223. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44224. /**
  44225. * Fired when the grip button on this controller is modified
  44226. */
  44227. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44228. /**
  44229. * Fired when the thumbstick button on this controller is modified
  44230. */
  44231. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44232. /**
  44233. * Fired when the touchpad button on this controller is modified
  44234. */
  44235. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44236. /**
  44237. * Fired when the touchpad values on this controller are modified
  44238. */
  44239. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44240. private _updateTrackpad;
  44241. /**
  44242. * Called once per frame by the engine.
  44243. */
  44244. update(): void;
  44245. /**
  44246. * Called once for each button that changed state since the last frame
  44247. * @param buttonIdx Which button index changed
  44248. * @param state New state of the button
  44249. * @param changes Which properties on the state changed since last frame
  44250. */
  44251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44252. /**
  44253. * Moves the buttons on the controller mesh based on their current state
  44254. * @param buttonName the name of the button to move
  44255. * @param buttonValue the value of the button which determines the buttons new position
  44256. */
  44257. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44258. /**
  44259. * Moves the axis on the controller mesh based on its current state
  44260. * @param axis the index of the axis
  44261. * @param axisValue the value of the axis which determines the meshes new position
  44262. * @hidden
  44263. */
  44264. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44265. /**
  44266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44267. * @param scene scene in which to add meshes
  44268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44269. */
  44270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44271. /**
  44272. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44273. * can be transformed by button presses and axes values, based on this._mapping.
  44274. *
  44275. * @param scene scene in which the meshes exist
  44276. * @param meshes list of meshes that make up the controller model to process
  44277. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44278. */
  44279. private processModel;
  44280. private createMeshInfo;
  44281. /**
  44282. * Gets the ray of the controller in the direction the controller is pointing
  44283. * @param length the length the resulting ray should be
  44284. * @returns a ray in the direction the controller is pointing
  44285. */
  44286. getForwardRay(length?: number): Ray;
  44287. /**
  44288. * Disposes of the controller
  44289. */
  44290. dispose(): void;
  44291. }
  44292. }
  44293. declare module BABYLON {
  44294. /**
  44295. * Interface to implement to create a shadow generator compatible with BJS.
  44296. */
  44297. interface IShadowGenerator {
  44298. /**
  44299. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44300. * @returns The render target texture if present otherwise, null
  44301. */
  44302. getShadowMap(): Nullable<RenderTargetTexture>;
  44303. /**
  44304. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44305. * @returns The render target texture if the shadow map is present otherwise, null
  44306. */
  44307. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44308. /**
  44309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44310. * @param subMesh The submesh we want to render in the shadow map
  44311. * @param useInstances Defines wether will draw in the map using instances
  44312. * @returns true if ready otherwise, false
  44313. */
  44314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44315. /**
  44316. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44317. * @param defines Defines of the material we want to update
  44318. * @param lightIndex Index of the light in the enabled light list of the material
  44319. */
  44320. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44321. /**
  44322. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44323. * defined in the generator but impacting the effect).
  44324. * It implies the unifroms available on the materials are the standard BJS ones.
  44325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44326. * @param effect The effect we are binfing the information for
  44327. */
  44328. bindShadowLight(lightIndex: string, effect: Effect): void;
  44329. /**
  44330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44331. * (eq to shadow prjection matrix * light transform matrix)
  44332. * @returns The transform matrix used to create the shadow map
  44333. */
  44334. getTransformMatrix(): Matrix;
  44335. /**
  44336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44337. * Cube and 2D textures for instance.
  44338. */
  44339. recreateShadowMap(): void;
  44340. /**
  44341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44342. * @param onCompiled Callback triggered at the and of the effects compilation
  44343. * @param options Sets of optional options forcing the compilation with different modes
  44344. */
  44345. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44346. useInstances: boolean;
  44347. }>): void;
  44348. /**
  44349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44350. * @param options Sets of optional options forcing the compilation with different modes
  44351. * @returns A promise that resolves when the compilation completes
  44352. */
  44353. forceCompilationAsync(options?: Partial<{
  44354. useInstances: boolean;
  44355. }>): Promise<void>;
  44356. /**
  44357. * Serializes the shadow generator setup to a json object.
  44358. * @returns The serialized JSON object
  44359. */
  44360. serialize(): any;
  44361. /**
  44362. * Disposes the Shadow map and related Textures and effects.
  44363. */
  44364. dispose(): void;
  44365. }
  44366. /**
  44367. * Default implementation IShadowGenerator.
  44368. * This is the main object responsible of generating shadows in the framework.
  44369. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44370. */
  44371. class ShadowGenerator implements IShadowGenerator {
  44372. /**
  44373. * Shadow generator mode None: no filtering applied.
  44374. */
  44375. static readonly FILTER_NONE: number;
  44376. /**
  44377. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44379. */
  44380. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44381. /**
  44382. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44383. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44384. */
  44385. static readonly FILTER_POISSONSAMPLING: number;
  44386. /**
  44387. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44389. */
  44390. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44391. /**
  44392. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44393. * edge artifacts on steep falloff.
  44394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44395. */
  44396. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44397. /**
  44398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44399. * edge artifacts on steep falloff.
  44400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44401. */
  44402. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44403. /**
  44404. * Shadow generator mode PCF: Percentage Closer Filtering
  44405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44406. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44407. */
  44408. static readonly FILTER_PCF: number;
  44409. /**
  44410. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44412. * Contact Hardening
  44413. */
  44414. static readonly FILTER_PCSS: number;
  44415. /**
  44416. * Reserved for PCF and PCSS
  44417. * Highest Quality.
  44418. *
  44419. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44420. *
  44421. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44422. */
  44423. static readonly QUALITY_HIGH: number;
  44424. /**
  44425. * Reserved for PCF and PCSS
  44426. * Good tradeoff for quality/perf cross devices
  44427. *
  44428. * Execute PCF on a 3*3 kernel.
  44429. *
  44430. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44431. */
  44432. static readonly QUALITY_MEDIUM: number;
  44433. /**
  44434. * Reserved for PCF and PCSS
  44435. * The lowest quality but the fastest.
  44436. *
  44437. * Execute PCF on a 1*1 kernel.
  44438. *
  44439. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44440. */
  44441. static readonly QUALITY_LOW: number;
  44442. private _bias;
  44443. /**
  44444. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44445. */
  44446. /**
  44447. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44448. */
  44449. bias: number;
  44450. private _normalBias;
  44451. /**
  44452. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44453. */
  44454. /**
  44455. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44456. */
  44457. normalBias: number;
  44458. private _blurBoxOffset;
  44459. /**
  44460. * Gets the blur box offset: offset applied during the blur pass.
  44461. * Only useful if useKernelBlur = false
  44462. */
  44463. /**
  44464. * Sets the blur box offset: offset applied during the blur pass.
  44465. * Only useful if useKernelBlur = false
  44466. */
  44467. blurBoxOffset: number;
  44468. private _blurScale;
  44469. /**
  44470. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44471. * 2 means half of the size.
  44472. */
  44473. /**
  44474. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44475. * 2 means half of the size.
  44476. */
  44477. blurScale: number;
  44478. private _blurKernel;
  44479. /**
  44480. * Gets the blur kernel: kernel size of the blur pass.
  44481. * Only useful if useKernelBlur = true
  44482. */
  44483. /**
  44484. * Sets the blur kernel: kernel size of the blur pass.
  44485. * Only useful if useKernelBlur = true
  44486. */
  44487. blurKernel: number;
  44488. private _useKernelBlur;
  44489. /**
  44490. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44492. */
  44493. /**
  44494. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44495. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44496. */
  44497. useKernelBlur: boolean;
  44498. private _depthScale;
  44499. /**
  44500. * Gets the depth scale used in ESM mode.
  44501. */
  44502. /**
  44503. * Sets the depth scale used in ESM mode.
  44504. * This can override the scale stored on the light.
  44505. */
  44506. depthScale: number;
  44507. private _filter;
  44508. /**
  44509. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44510. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44511. */
  44512. /**
  44513. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44514. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44515. */
  44516. filter: number;
  44517. /**
  44518. * Gets if the current filter is set to Poisson Sampling.
  44519. */
  44520. /**
  44521. * Sets the current filter to Poisson Sampling.
  44522. */
  44523. usePoissonSampling: boolean;
  44524. /**
  44525. * Gets if the current filter is set to ESM.
  44526. */
  44527. /**
  44528. * Sets the current filter is to ESM.
  44529. */
  44530. useExponentialShadowMap: boolean;
  44531. /**
  44532. * Gets if the current filter is set to filtered ESM.
  44533. */
  44534. /**
  44535. * Gets if the current filter is set to filtered ESM.
  44536. */
  44537. useBlurExponentialShadowMap: boolean;
  44538. /**
  44539. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44540. * exponential to prevent steep falloff artifacts).
  44541. */
  44542. /**
  44543. * Sets the current filter to "close ESM" (using the inverse of the
  44544. * exponential to prevent steep falloff artifacts).
  44545. */
  44546. useCloseExponentialShadowMap: boolean;
  44547. /**
  44548. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44549. * exponential to prevent steep falloff artifacts).
  44550. */
  44551. /**
  44552. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44553. * exponential to prevent steep falloff artifacts).
  44554. */
  44555. useBlurCloseExponentialShadowMap: boolean;
  44556. /**
  44557. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44558. */
  44559. /**
  44560. * Sets the current filter to "PCF" (percentage closer filtering).
  44561. */
  44562. usePercentageCloserFiltering: boolean;
  44563. private _filteringQuality;
  44564. /**
  44565. * Gets the PCF or PCSS Quality.
  44566. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44567. */
  44568. /**
  44569. * Sets the PCF or PCSS Quality.
  44570. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44571. */
  44572. filteringQuality: number;
  44573. /**
  44574. * Gets if the current filter is set to "PCSS" (contact hardening).
  44575. */
  44576. /**
  44577. * Sets the current filter to "PCSS" (contact hardening).
  44578. */
  44579. useContactHardeningShadow: boolean;
  44580. private _contactHardeningLightSizeUVRatio;
  44581. /**
  44582. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44583. * Using a ratio helps keeping shape stability independently of the map size.
  44584. *
  44585. * It does not account for the light projection as it was having too much
  44586. * instability during the light setup or during light position changes.
  44587. *
  44588. * Only valid if useContactHardeningShadow is true.
  44589. */
  44590. /**
  44591. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44592. * Using a ratio helps keeping shape stability independently of the map size.
  44593. *
  44594. * It does not account for the light projection as it was having too much
  44595. * instability during the light setup or during light position changes.
  44596. *
  44597. * Only valid if useContactHardeningShadow is true.
  44598. */
  44599. contactHardeningLightSizeUVRatio: number;
  44600. private _darkness;
  44601. /**
  44602. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44603. * 0 means strongest and 1 would means no shadow.
  44604. * @returns the darkness.
  44605. */
  44606. getDarkness(): number;
  44607. /**
  44608. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44609. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44610. * @returns the shadow generator allowing fluent coding.
  44611. */
  44612. setDarkness(darkness: number): ShadowGenerator;
  44613. private _transparencyShadow;
  44614. /**
  44615. * Sets the ability to have transparent shadow (boolean).
  44616. * @param transparent True if transparent else False
  44617. * @returns the shadow generator allowing fluent coding
  44618. */
  44619. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44620. private _shadowMap;
  44621. private _shadowMap2;
  44622. /**
  44623. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44624. * @returns The render target texture if present otherwise, null
  44625. */
  44626. getShadowMap(): Nullable<RenderTargetTexture>;
  44627. /**
  44628. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44629. * @returns The render target texture if the shadow map is present otherwise, null
  44630. */
  44631. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44632. /**
  44633. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44634. * @param mesh Mesh to add
  44635. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44636. * @returns the Shadow Generator itself
  44637. */
  44638. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44639. /**
  44640. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44641. * @param mesh Mesh to remove
  44642. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44643. * @returns the Shadow Generator itself
  44644. */
  44645. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44646. /**
  44647. * Controls the extent to which the shadows fade out at the edge of the frustum
  44648. * Used only by directionals and spots
  44649. */
  44650. frustumEdgeFalloff: number;
  44651. private _light;
  44652. /**
  44653. * Returns the associated light object.
  44654. * @returns the light generating the shadow
  44655. */
  44656. getLight(): IShadowLight;
  44657. /**
  44658. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44659. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44660. * It might on the other hand introduce peter panning.
  44661. */
  44662. forceBackFacesOnly: boolean;
  44663. private _scene;
  44664. private _lightDirection;
  44665. private _effect;
  44666. private _viewMatrix;
  44667. private _projectionMatrix;
  44668. private _transformMatrix;
  44669. private _cachedPosition;
  44670. private _cachedDirection;
  44671. private _cachedDefines;
  44672. private _currentRenderID;
  44673. private _boxBlurPostprocess;
  44674. private _kernelBlurXPostprocess;
  44675. private _kernelBlurYPostprocess;
  44676. private _blurPostProcesses;
  44677. private _mapSize;
  44678. private _currentFaceIndex;
  44679. private _currentFaceIndexCache;
  44680. private _textureType;
  44681. private _defaultTextureMatrix;
  44682. /**
  44683. * Creates a ShadowGenerator object.
  44684. * A ShadowGenerator is the required tool to use the shadows.
  44685. * Each light casting shadows needs to use its own ShadowGenerator.
  44686. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44687. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44688. * @param light The light object generating the shadows.
  44689. * @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.
  44690. */
  44691. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44692. private _initializeGenerator;
  44693. private _initializeShadowMap;
  44694. private _initializeBlurRTTAndPostProcesses;
  44695. private _renderForShadowMap;
  44696. private _renderSubMeshForShadowMap;
  44697. private _applyFilterValues;
  44698. /**
  44699. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44700. * @param onCompiled Callback triggered at the and of the effects compilation
  44701. * @param options Sets of optional options forcing the compilation with different modes
  44702. */
  44703. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44704. useInstances: boolean;
  44705. }>): void;
  44706. /**
  44707. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44708. * @param options Sets of optional options forcing the compilation with different modes
  44709. * @returns A promise that resolves when the compilation completes
  44710. */
  44711. forceCompilationAsync(options?: Partial<{
  44712. useInstances: boolean;
  44713. }>): Promise<void>;
  44714. /**
  44715. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44716. * @param subMesh The submesh we want to render in the shadow map
  44717. * @param useInstances Defines wether will draw in the map using instances
  44718. * @returns true if ready otherwise, false
  44719. */
  44720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44721. /**
  44722. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44723. * @param defines Defines of the material we want to update
  44724. * @param lightIndex Index of the light in the enabled light list of the material
  44725. */
  44726. prepareDefines(defines: any, lightIndex: number): void;
  44727. /**
  44728. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44729. * defined in the generator but impacting the effect).
  44730. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44731. * @param effect The effect we are binfing the information for
  44732. */
  44733. bindShadowLight(lightIndex: string, effect: Effect): void;
  44734. /**
  44735. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44736. * (eq to shadow prjection matrix * light transform matrix)
  44737. * @returns The transform matrix used to create the shadow map
  44738. */
  44739. getTransformMatrix(): Matrix;
  44740. /**
  44741. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44742. * Cube and 2D textures for instance.
  44743. */
  44744. recreateShadowMap(): void;
  44745. private _disposeBlurPostProcesses;
  44746. private _disposeRTTandPostProcesses;
  44747. /**
  44748. * Disposes the ShadowGenerator.
  44749. * Returns nothing.
  44750. */
  44751. dispose(): void;
  44752. /**
  44753. * Serializes the shadow generator setup to a json object.
  44754. * @returns The serialized JSON object
  44755. */
  44756. serialize(): any;
  44757. /**
  44758. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44759. * @param parsedShadowGenerator The JSON object to parse
  44760. * @param scene The scene to create the shadow map for
  44761. * @returns The parsed shadow generator
  44762. */
  44763. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44764. }
  44765. }
  44766. declare module BABYLON {
  44767. /**
  44768. * Defines the shadow generator component responsible to manage any shadow generators
  44769. * in a given scene.
  44770. */
  44771. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44772. /**
  44773. * The component name helpfull to identify the component in the list of scene components.
  44774. */
  44775. readonly name: string;
  44776. /**
  44777. * The scene the component belongs to.
  44778. */
  44779. scene: Scene;
  44780. /**
  44781. * Creates a new instance of the component for the given scene
  44782. * @param scene Defines the scene to register the component in
  44783. */
  44784. constructor(scene: Scene);
  44785. /**
  44786. * Registers the component in a given scene
  44787. */
  44788. register(): void;
  44789. /**
  44790. * Rebuilds the elements related to this component in case of
  44791. * context lost for instance.
  44792. */
  44793. rebuild(): void;
  44794. /**
  44795. * Serializes the component data to the specified json object
  44796. * @param serializationObject The object to serialize to
  44797. */
  44798. serialize(serializationObject: any): void;
  44799. /**
  44800. * Adds all the element from the container to the scene
  44801. * @param container the container holding the elements
  44802. */
  44803. addFromContainer(container: AbstractScene): void;
  44804. /**
  44805. * Removes all the elements in the container from the scene
  44806. * @param container contains the elements to remove
  44807. */
  44808. removeFromContainer(container: AbstractScene): void;
  44809. /**
  44810. * Rebuilds the elements related to this component in case of
  44811. * context lost for instance.
  44812. */
  44813. dispose(): void;
  44814. private _gatherRenderTargets;
  44815. }
  44816. }
  44817. declare module BABYLON {
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * Background material used to create an efficient environement around your scene.
  44822. */
  44823. class BackgroundMaterial extends PushMaterial {
  44824. /**
  44825. * Standard reflectance value at parallel view angle.
  44826. */
  44827. static StandardReflectance0: number;
  44828. /**
  44829. * Standard reflectance value at grazing angle.
  44830. */
  44831. static StandardReflectance90: number;
  44832. protected _primaryColor: Color3;
  44833. /**
  44834. * Key light Color (multiply against the environement texture)
  44835. */
  44836. primaryColor: Color3;
  44837. protected __perceptualColor: Nullable<Color3>;
  44838. /**
  44839. * Experimental Internal Use Only.
  44840. *
  44841. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44842. * This acts as a helper to set the primary color to a more "human friendly" value.
  44843. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44844. * output color as close as possible from the chosen value.
  44845. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44846. * part of lighting setup.)
  44847. */
  44848. _perceptualColor: Nullable<Color3>;
  44849. protected _primaryColorShadowLevel: float;
  44850. /**
  44851. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44852. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44853. */
  44854. primaryColorShadowLevel: float;
  44855. protected _primaryColorHighlightLevel: float;
  44856. /**
  44857. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44858. * The primary color is used at the level chosen to define what the white area would look.
  44859. */
  44860. primaryColorHighlightLevel: float;
  44861. protected _reflectionTexture: Nullable<BaseTexture>;
  44862. /**
  44863. * Reflection Texture used in the material.
  44864. * Should be author in a specific way for the best result (refer to the documentation).
  44865. */
  44866. reflectionTexture: Nullable<BaseTexture>;
  44867. protected _reflectionBlur: float;
  44868. /**
  44869. * Reflection Texture level of blur.
  44870. *
  44871. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44872. * texture twice.
  44873. */
  44874. reflectionBlur: float;
  44875. protected _diffuseTexture: Nullable<BaseTexture>;
  44876. /**
  44877. * Diffuse Texture used in the material.
  44878. * Should be author in a specific way for the best result (refer to the documentation).
  44879. */
  44880. diffuseTexture: Nullable<BaseTexture>;
  44881. protected _shadowLights: Nullable<IShadowLight[]>;
  44882. /**
  44883. * Specify the list of lights casting shadow on the material.
  44884. * All scene shadow lights will be included if null.
  44885. */
  44886. shadowLights: Nullable<IShadowLight[]>;
  44887. protected _shadowLevel: float;
  44888. /**
  44889. * Helps adjusting the shadow to a softer level if required.
  44890. * 0 means black shadows and 1 means no shadows.
  44891. */
  44892. shadowLevel: float;
  44893. protected _sceneCenter: Vector3;
  44894. /**
  44895. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44896. * It is usually zero but might be interesting to modify according to your setup.
  44897. */
  44898. sceneCenter: Vector3;
  44899. protected _opacityFresnel: boolean;
  44900. /**
  44901. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44902. * This helps ensuring a nice transition when the camera goes under the ground.
  44903. */
  44904. opacityFresnel: boolean;
  44905. protected _reflectionFresnel: boolean;
  44906. /**
  44907. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44908. * This helps adding a mirror texture on the ground.
  44909. */
  44910. reflectionFresnel: boolean;
  44911. protected _reflectionFalloffDistance: number;
  44912. /**
  44913. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44914. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44915. */
  44916. reflectionFalloffDistance: number;
  44917. protected _reflectionAmount: number;
  44918. /**
  44919. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44920. */
  44921. reflectionAmount: number;
  44922. protected _reflectionReflectance0: number;
  44923. /**
  44924. * This specifies the weight of the reflection at grazing angle.
  44925. */
  44926. reflectionReflectance0: number;
  44927. protected _reflectionReflectance90: number;
  44928. /**
  44929. * This specifies the weight of the reflection at a perpendicular point of view.
  44930. */
  44931. reflectionReflectance90: number;
  44932. /**
  44933. * Sets the reflection reflectance fresnel values according to the default standard
  44934. * empirically know to work well :-)
  44935. */
  44936. reflectionStandardFresnelWeight: number;
  44937. protected _useRGBColor: boolean;
  44938. /**
  44939. * Helps to directly use the maps channels instead of their level.
  44940. */
  44941. useRGBColor: boolean;
  44942. protected _enableNoise: boolean;
  44943. /**
  44944. * This helps reducing the banding effect that could occur on the background.
  44945. */
  44946. enableNoise: boolean;
  44947. /**
  44948. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44949. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44950. * Recommended to be keep at 1.0 except for special cases.
  44951. */
  44952. fovMultiplier: number;
  44953. private _fovMultiplier;
  44954. /**
  44955. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44956. */
  44957. useEquirectangularFOV: boolean;
  44958. private _maxSimultaneousLights;
  44959. /**
  44960. * Number of Simultaneous lights allowed on the material.
  44961. */
  44962. maxSimultaneousLights: int;
  44963. /**
  44964. * Default configuration related to image processing available in the Background Material.
  44965. */
  44966. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44967. /**
  44968. * Keep track of the image processing observer to allow dispose and replace.
  44969. */
  44970. private _imageProcessingObserver;
  44971. /**
  44972. * Attaches a new image processing configuration to the PBR Material.
  44973. * @param configuration (if null the scene configuration will be use)
  44974. */
  44975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44976. /**
  44977. * Gets the image processing configuration used either in this material.
  44978. */
  44979. /**
  44980. * Sets the Default image processing configuration used either in the this material.
  44981. *
  44982. * If sets to null, the scene one is in use.
  44983. */
  44984. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44985. /**
  44986. * Gets wether the color curves effect is enabled.
  44987. */
  44988. /**
  44989. * Sets wether the color curves effect is enabled.
  44990. */
  44991. cameraColorCurvesEnabled: boolean;
  44992. /**
  44993. * Gets wether the color grading effect is enabled.
  44994. */
  44995. /**
  44996. * Gets wether the color grading effect is enabled.
  44997. */
  44998. cameraColorGradingEnabled: boolean;
  44999. /**
  45000. * Gets wether tonemapping is enabled or not.
  45001. */
  45002. /**
  45003. * Sets wether tonemapping is enabled or not
  45004. */
  45005. cameraToneMappingEnabled: boolean;
  45006. /**
  45007. * The camera exposure used on this material.
  45008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45009. * This corresponds to a photographic exposure.
  45010. */
  45011. /**
  45012. * The camera exposure used on this material.
  45013. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45014. * This corresponds to a photographic exposure.
  45015. */
  45016. cameraExposure: float;
  45017. /**
  45018. * Gets The camera contrast used on this material.
  45019. */
  45020. /**
  45021. * Sets The camera contrast used on this material.
  45022. */
  45023. cameraContrast: float;
  45024. /**
  45025. * Gets the Color Grading 2D Lookup Texture.
  45026. */
  45027. /**
  45028. * Sets the Color Grading 2D Lookup Texture.
  45029. */
  45030. cameraColorGradingTexture: Nullable<BaseTexture>;
  45031. /**
  45032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45034. * 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;
  45035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45036. */
  45037. /**
  45038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45040. * 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;
  45041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45042. */
  45043. cameraColorCurves: Nullable<ColorCurves>;
  45044. /**
  45045. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45046. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45047. */
  45048. switchToBGR: boolean;
  45049. private _renderTargets;
  45050. private _reflectionControls;
  45051. private _white;
  45052. private _primaryShadowColor;
  45053. private _primaryHighlightColor;
  45054. /**
  45055. * Instantiates a Background Material in the given scene
  45056. * @param name The friendly name of the material
  45057. * @param scene The scene to add the material to
  45058. */
  45059. constructor(name: string, scene: Scene);
  45060. /**
  45061. * Gets a boolean indicating that current material needs to register RTT
  45062. */
  45063. readonly hasRenderTargetTextures: boolean;
  45064. /**
  45065. * The entire material has been created in order to prevent overdraw.
  45066. * @returns false
  45067. */
  45068. needAlphaTesting(): boolean;
  45069. /**
  45070. * The entire material has been created in order to prevent overdraw.
  45071. * @returns true if blending is enable
  45072. */
  45073. needAlphaBlending(): boolean;
  45074. /**
  45075. * Checks wether the material is ready to be rendered for a given mesh.
  45076. * @param mesh The mesh to render
  45077. * @param subMesh The submesh to check against
  45078. * @param useInstances Specify wether or not the material is used with instances
  45079. * @returns true if all the dependencies are ready (Textures, Effects...)
  45080. */
  45081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45082. /**
  45083. * Compute the primary color according to the chosen perceptual color.
  45084. */
  45085. private _computePrimaryColorFromPerceptualColor;
  45086. /**
  45087. * Compute the highlights and shadow colors according to their chosen levels.
  45088. */
  45089. private _computePrimaryColors;
  45090. /**
  45091. * Build the uniform buffer used in the material.
  45092. */
  45093. buildUniformLayout(): void;
  45094. /**
  45095. * Unbind the material.
  45096. */
  45097. unbind(): void;
  45098. /**
  45099. * Bind only the world matrix to the material.
  45100. * @param world The world matrix to bind.
  45101. */
  45102. bindOnlyWorldMatrix(world: Matrix): void;
  45103. /**
  45104. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45105. * @param world The world matrix to bind.
  45106. * @param subMesh The submesh to bind for.
  45107. */
  45108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45109. /**
  45110. * Dispose the material.
  45111. * @param forceDisposeEffect Force disposal of the associated effect.
  45112. * @param forceDisposeTextures Force disposal of the associated textures.
  45113. */
  45114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45115. /**
  45116. * Clones the material.
  45117. * @param name The cloned name.
  45118. * @returns The cloned material.
  45119. */
  45120. clone(name: string): BackgroundMaterial;
  45121. /**
  45122. * Serializes the current material to its JSON representation.
  45123. * @returns The JSON representation.
  45124. */
  45125. serialize(): any;
  45126. /**
  45127. * Gets the class name of the material
  45128. * @returns "BackgroundMaterial"
  45129. */
  45130. getClassName(): string;
  45131. /**
  45132. * Parse a JSON input to create back a background material.
  45133. * @param source The JSON data to parse
  45134. * @param scene The scene to create the parsed material in
  45135. * @param rootUrl The root url of the assets the material depends upon
  45136. * @returns the instantiated BackgroundMaterial.
  45137. */
  45138. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45139. }
  45140. }
  45141. declare module BABYLON {
  45142. /**
  45143. * The Physically based material base class of BJS.
  45144. *
  45145. * This offers the main features of a standard PBR material.
  45146. * For more information, please refer to the documentation :
  45147. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45148. */
  45149. abstract class PBRBaseMaterial extends PushMaterial {
  45150. /**
  45151. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45152. */
  45153. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45154. /**
  45155. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45156. * to enhance interoperability with other engines.
  45157. */
  45158. static readonly LIGHTFALLOFF_GLTF: number;
  45159. /**
  45160. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45161. * to enhance interoperability with other materials.
  45162. */
  45163. static readonly LIGHTFALLOFF_STANDARD: number;
  45164. /**
  45165. * Intensity of the direct lights e.g. the four lights available in your scene.
  45166. * This impacts both the direct diffuse and specular highlights.
  45167. */
  45168. protected _directIntensity: number;
  45169. /**
  45170. * Intensity of the emissive part of the material.
  45171. * This helps controlling the emissive effect without modifying the emissive color.
  45172. */
  45173. protected _emissiveIntensity: number;
  45174. /**
  45175. * Intensity of the environment e.g. how much the environment will light the object
  45176. * either through harmonics for rough material or through the refelction for shiny ones.
  45177. */
  45178. protected _environmentIntensity: number;
  45179. /**
  45180. * This is a special control allowing the reduction of the specular highlights coming from the
  45181. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45182. */
  45183. protected _specularIntensity: number;
  45184. /**
  45185. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45186. */
  45187. private _lightingInfos;
  45188. /**
  45189. * Debug Control allowing disabling the bump map on this material.
  45190. */
  45191. protected _disableBumpMap: boolean;
  45192. /**
  45193. * AKA Diffuse Texture in standard nomenclature.
  45194. */
  45195. protected _albedoTexture: BaseTexture;
  45196. /**
  45197. * AKA Occlusion Texture in other nomenclature.
  45198. */
  45199. protected _ambientTexture: BaseTexture;
  45200. /**
  45201. * AKA Occlusion Texture Intensity in other nomenclature.
  45202. */
  45203. protected _ambientTextureStrength: number;
  45204. /**
  45205. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45206. * 1 means it completely occludes it
  45207. * 0 mean it has no impact
  45208. */
  45209. protected _ambientTextureImpactOnAnalyticalLights: number;
  45210. /**
  45211. * Stores the alpha values in a texture.
  45212. */
  45213. protected _opacityTexture: BaseTexture;
  45214. /**
  45215. * Stores the reflection values in a texture.
  45216. */
  45217. protected _reflectionTexture: BaseTexture;
  45218. /**
  45219. * Stores the refraction values in a texture.
  45220. */
  45221. protected _refractionTexture: BaseTexture;
  45222. /**
  45223. * Stores the emissive values in a texture.
  45224. */
  45225. protected _emissiveTexture: BaseTexture;
  45226. /**
  45227. * AKA Specular texture in other nomenclature.
  45228. */
  45229. protected _reflectivityTexture: BaseTexture;
  45230. /**
  45231. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45232. */
  45233. protected _metallicTexture: BaseTexture;
  45234. /**
  45235. * Specifies the metallic scalar of the metallic/roughness workflow.
  45236. * Can also be used to scale the metalness values of the metallic texture.
  45237. */
  45238. protected _metallic: Nullable<number>;
  45239. /**
  45240. * Specifies the roughness scalar of the metallic/roughness workflow.
  45241. * Can also be used to scale the roughness values of the metallic texture.
  45242. */
  45243. protected _roughness: Nullable<number>;
  45244. /**
  45245. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45246. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45247. */
  45248. protected _microSurfaceTexture: BaseTexture;
  45249. /**
  45250. * Stores surface normal data used to displace a mesh in a texture.
  45251. */
  45252. protected _bumpTexture: BaseTexture;
  45253. /**
  45254. * Stores the pre-calculated light information of a mesh in a texture.
  45255. */
  45256. protected _lightmapTexture: BaseTexture;
  45257. /**
  45258. * The color of a material in ambient lighting.
  45259. */
  45260. protected _ambientColor: Color3;
  45261. /**
  45262. * AKA Diffuse Color in other nomenclature.
  45263. */
  45264. protected _albedoColor: Color3;
  45265. /**
  45266. * AKA Specular Color in other nomenclature.
  45267. */
  45268. protected _reflectivityColor: Color3;
  45269. /**
  45270. * The color applied when light is reflected from a material.
  45271. */
  45272. protected _reflectionColor: Color3;
  45273. /**
  45274. * The color applied when light is emitted from a material.
  45275. */
  45276. protected _emissiveColor: Color3;
  45277. /**
  45278. * AKA Glossiness in other nomenclature.
  45279. */
  45280. protected _microSurface: number;
  45281. /**
  45282. * source material index of refraction (IOR)' / 'destination material IOR.
  45283. */
  45284. protected _indexOfRefraction: number;
  45285. /**
  45286. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45287. */
  45288. protected _invertRefractionY: boolean;
  45289. /**
  45290. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45291. * Materials half opaque for instance using refraction could benefit from this control.
  45292. */
  45293. protected _linkRefractionWithTransparency: boolean;
  45294. /**
  45295. * Specifies that the material will use the light map as a show map.
  45296. */
  45297. protected _useLightmapAsShadowmap: boolean;
  45298. /**
  45299. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45300. * makes the reflect vector face the model (under horizon).
  45301. */
  45302. protected _useHorizonOcclusion: boolean;
  45303. /**
  45304. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45305. * too much the area relying on ambient texture to define their ambient occlusion.
  45306. */
  45307. protected _useRadianceOcclusion: boolean;
  45308. /**
  45309. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45310. */
  45311. protected _useAlphaFromAlbedoTexture: boolean;
  45312. /**
  45313. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45314. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45315. */
  45316. protected _useSpecularOverAlpha: boolean;
  45317. /**
  45318. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45319. */
  45320. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45321. /**
  45322. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45323. */
  45324. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45325. /**
  45326. * Specifies if the metallic texture contains the roughness information in its green channel.
  45327. */
  45328. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45329. /**
  45330. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45331. */
  45332. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45333. /**
  45334. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45335. */
  45336. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45337. /**
  45338. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45339. */
  45340. protected _useAmbientInGrayScale: boolean;
  45341. /**
  45342. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45343. * The material will try to infer what glossiness each pixel should be.
  45344. */
  45345. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45346. /**
  45347. * Defines the falloff type used in this material.
  45348. * It by default is Physical.
  45349. */
  45350. protected _lightFalloff: number;
  45351. /**
  45352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45354. */
  45355. protected _useRadianceOverAlpha: boolean;
  45356. /**
  45357. * Allows using an object space normal map (instead of tangent space).
  45358. */
  45359. protected _useObjectSpaceNormalMap: boolean;
  45360. /**
  45361. * Allows using the bump map in parallax mode.
  45362. */
  45363. protected _useParallax: boolean;
  45364. /**
  45365. * Allows using the bump map in parallax occlusion mode.
  45366. */
  45367. protected _useParallaxOcclusion: boolean;
  45368. /**
  45369. * Controls the scale bias of the parallax mode.
  45370. */
  45371. protected _parallaxScaleBias: number;
  45372. /**
  45373. * If sets to true, disables all the lights affecting the material.
  45374. */
  45375. protected _disableLighting: boolean;
  45376. /**
  45377. * Number of Simultaneous lights allowed on the material.
  45378. */
  45379. protected _maxSimultaneousLights: number;
  45380. /**
  45381. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45382. */
  45383. protected _invertNormalMapX: boolean;
  45384. /**
  45385. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45386. */
  45387. protected _invertNormalMapY: boolean;
  45388. /**
  45389. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45390. */
  45391. protected _twoSidedLighting: boolean;
  45392. /**
  45393. * Defines the alpha limits in alpha test mode.
  45394. */
  45395. protected _alphaCutOff: number;
  45396. /**
  45397. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45398. */
  45399. protected _forceAlphaTest: boolean;
  45400. /**
  45401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45403. */
  45404. protected _useAlphaFresnel: boolean;
  45405. /**
  45406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45408. */
  45409. protected _useLinearAlphaFresnel: boolean;
  45410. /**
  45411. * The transparency mode of the material.
  45412. */
  45413. protected _transparencyMode: Nullable<number>;
  45414. /**
  45415. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45416. * from cos thetav and roughness:
  45417. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45418. */
  45419. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45420. /**
  45421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45422. */
  45423. protected _forceIrradianceInFragment: boolean;
  45424. /**
  45425. * Force normal to face away from face.
  45426. */
  45427. protected _forceNormalForward: boolean;
  45428. /**
  45429. * Enables specular anti aliasing in the PBR shader.
  45430. * It will both interacts on the Geometry for analytical and IBL lighting.
  45431. * It also prefilter the roughness map based on the bump values.
  45432. */
  45433. protected _enableSpecularAntiAliasing: boolean;
  45434. /**
  45435. * Default configuration related to image processing available in the PBR Material.
  45436. */
  45437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45438. /**
  45439. * Keep track of the image processing observer to allow dispose and replace.
  45440. */
  45441. private _imageProcessingObserver;
  45442. /**
  45443. * Attaches a new image processing configuration to the PBR Material.
  45444. * @param configuration
  45445. */
  45446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45447. /**
  45448. * Stores the available render targets.
  45449. */
  45450. private _renderTargets;
  45451. /**
  45452. * Sets the global ambient color for the material used in lighting calculations.
  45453. */
  45454. private _globalAmbientColor;
  45455. /**
  45456. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45457. */
  45458. private _useLogarithmicDepth;
  45459. /**
  45460. * If set to true, no lighting calculations will be applied.
  45461. */
  45462. private _unlit;
  45463. /**
  45464. * Instantiates a new PBRMaterial instance.
  45465. *
  45466. * @param name The material name
  45467. * @param scene The scene the material will be use in.
  45468. */
  45469. constructor(name: string, scene: Scene);
  45470. /**
  45471. * Gets a boolean indicating that current material needs to register RTT
  45472. */
  45473. readonly hasRenderTargetTextures: boolean;
  45474. /**
  45475. * Gets the name of the material class.
  45476. */
  45477. getClassName(): string;
  45478. /**
  45479. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45480. */
  45481. /**
  45482. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45483. */
  45484. useLogarithmicDepth: boolean;
  45485. /**
  45486. * Gets the current transparency mode.
  45487. */
  45488. /**
  45489. * Sets the transparency mode of the material.
  45490. *
  45491. * | Value | Type | Description |
  45492. * | ----- | ----------------------------------- | ----------- |
  45493. * | 0 | OPAQUE | |
  45494. * | 1 | ALPHATEST | |
  45495. * | 2 | ALPHABLEND | |
  45496. * | 3 | ALPHATESTANDBLEND | |
  45497. *
  45498. */
  45499. transparencyMode: Nullable<number>;
  45500. /**
  45501. * Returns true if alpha blending should be disabled.
  45502. */
  45503. private readonly _disableAlphaBlending;
  45504. /**
  45505. * Specifies whether or not this material should be rendered in alpha blend mode.
  45506. */
  45507. needAlphaBlending(): boolean;
  45508. /**
  45509. * Specifies if the mesh will require alpha blending.
  45510. * @param mesh - BJS mesh.
  45511. */
  45512. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45513. /**
  45514. * Specifies whether or not this material should be rendered in alpha test mode.
  45515. */
  45516. needAlphaTesting(): boolean;
  45517. /**
  45518. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45519. */
  45520. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45521. /**
  45522. * Gets the texture used for the alpha test.
  45523. */
  45524. getAlphaTestTexture(): BaseTexture;
  45525. /**
  45526. * Stores the reflectivity values based on metallic roughness workflow.
  45527. */
  45528. private static _scaledReflectivity;
  45529. /**
  45530. * Specifies that the submesh is ready to be used.
  45531. * @param mesh - BJS mesh.
  45532. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45533. * @param useInstances - Specifies that instances should be used.
  45534. * @returns - boolean indicating that the submesh is ready or not.
  45535. */
  45536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45537. /**
  45538. * Specifies if the material uses metallic roughness workflow.
  45539. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45540. */
  45541. isMetallicWorkflow(): boolean;
  45542. private _prepareEffect;
  45543. private _prepareDefines;
  45544. /**
  45545. * Force shader compilation
  45546. */
  45547. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45548. clipPlane: boolean;
  45549. }>): void;
  45550. /**
  45551. * Initializes the uniform buffer layout for the shader.
  45552. */
  45553. buildUniformLayout(): void;
  45554. /**
  45555. * Unbinds the textures.
  45556. */
  45557. unbind(): void;
  45558. /**
  45559. * Binds the submesh data.
  45560. * @param world - The world matrix.
  45561. * @param mesh - The BJS mesh.
  45562. * @param subMesh - A submesh of the BJS mesh.
  45563. */
  45564. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45565. /**
  45566. * Returns the animatable textures.
  45567. * @returns - Array of animatable textures.
  45568. */
  45569. getAnimatables(): IAnimatable[];
  45570. /**
  45571. * Returns the texture used for reflections.
  45572. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45573. */
  45574. private _getReflectionTexture;
  45575. /**
  45576. * Returns the texture used for refraction or null if none is used.
  45577. * @returns - Refection texture if present. If no refraction texture and refraction
  45578. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45579. */
  45580. private _getRefractionTexture;
  45581. /**
  45582. * Disposes the resources of the material.
  45583. * @param forceDisposeEffect - Forces the disposal of effects.
  45584. * @param forceDisposeTextures - Forces the disposal of all textures.
  45585. */
  45586. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45587. }
  45588. }
  45589. declare module BABYLON {
  45590. /**
  45591. * The Physically based simple base material of BJS.
  45592. *
  45593. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45594. * It is used as the base class for both the specGloss and metalRough conventions.
  45595. */
  45596. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45597. /**
  45598. * Number of Simultaneous lights allowed on the material.
  45599. */
  45600. maxSimultaneousLights: number;
  45601. /**
  45602. * If sets to true, disables all the lights affecting the material.
  45603. */
  45604. disableLighting: boolean;
  45605. /**
  45606. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45607. */
  45608. environmentTexture: BaseTexture;
  45609. /**
  45610. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45611. */
  45612. invertNormalMapX: boolean;
  45613. /**
  45614. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45615. */
  45616. invertNormalMapY: boolean;
  45617. /**
  45618. * Normal map used in the model.
  45619. */
  45620. normalTexture: BaseTexture;
  45621. /**
  45622. * Emissivie color used to self-illuminate the model.
  45623. */
  45624. emissiveColor: Color3;
  45625. /**
  45626. * Emissivie texture used to self-illuminate the model.
  45627. */
  45628. emissiveTexture: BaseTexture;
  45629. /**
  45630. * Occlusion Channel Strenght.
  45631. */
  45632. occlusionStrength: number;
  45633. /**
  45634. * Occlusion Texture of the material (adding extra occlusion effects).
  45635. */
  45636. occlusionTexture: BaseTexture;
  45637. /**
  45638. * Defines the alpha limits in alpha test mode.
  45639. */
  45640. alphaCutOff: number;
  45641. /**
  45642. * Gets the current double sided mode.
  45643. */
  45644. /**
  45645. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45646. */
  45647. doubleSided: boolean;
  45648. /**
  45649. * Stores the pre-calculated light information of a mesh in a texture.
  45650. */
  45651. lightmapTexture: BaseTexture;
  45652. /**
  45653. * If true, the light map contains occlusion information instead of lighting info.
  45654. */
  45655. useLightmapAsShadowmap: boolean;
  45656. /**
  45657. * Return the active textures of the material.
  45658. */
  45659. getActiveTextures(): BaseTexture[];
  45660. hasTexture(texture: BaseTexture): boolean;
  45661. /**
  45662. * Instantiates a new PBRMaterial instance.
  45663. *
  45664. * @param name The material name
  45665. * @param scene The scene the material will be use in.
  45666. */
  45667. constructor(name: string, scene: Scene);
  45668. getClassName(): string;
  45669. }
  45670. }
  45671. declare module BABYLON {
  45672. /**
  45673. * The Physically based material of BJS.
  45674. *
  45675. * This offers the main features of a standard PBR material.
  45676. * For more information, please refer to the documentation :
  45677. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45678. */
  45679. class PBRMaterial extends PBRBaseMaterial {
  45680. /**
  45681. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45682. */
  45683. static readonly PBRMATERIAL_OPAQUE: number;
  45684. /**
  45685. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45686. */
  45687. static readonly PBRMATERIAL_ALPHATEST: number;
  45688. /**
  45689. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45690. */
  45691. static readonly PBRMATERIAL_ALPHABLEND: number;
  45692. /**
  45693. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45694. * They are also discarded below the alpha cutoff threshold to improve performances.
  45695. */
  45696. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45697. /**
  45698. * Defines the default value of how much AO map is occluding the analytical lights
  45699. * (point spot...).
  45700. */
  45701. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45702. /**
  45703. * Intensity of the direct lights e.g. the four lights available in your scene.
  45704. * This impacts both the direct diffuse and specular highlights.
  45705. */
  45706. directIntensity: number;
  45707. /**
  45708. * Intensity of the emissive part of the material.
  45709. * This helps controlling the emissive effect without modifying the emissive color.
  45710. */
  45711. emissiveIntensity: number;
  45712. /**
  45713. * Intensity of the environment e.g. how much the environment will light the object
  45714. * either through harmonics for rough material or through the refelction for shiny ones.
  45715. */
  45716. environmentIntensity: number;
  45717. /**
  45718. * This is a special control allowing the reduction of the specular highlights coming from the
  45719. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45720. */
  45721. specularIntensity: number;
  45722. /**
  45723. * Debug Control allowing disabling the bump map on this material.
  45724. */
  45725. disableBumpMap: boolean;
  45726. /**
  45727. * AKA Diffuse Texture in standard nomenclature.
  45728. */
  45729. albedoTexture: BaseTexture;
  45730. /**
  45731. * AKA Occlusion Texture in other nomenclature.
  45732. */
  45733. ambientTexture: BaseTexture;
  45734. /**
  45735. * AKA Occlusion Texture Intensity in other nomenclature.
  45736. */
  45737. ambientTextureStrength: number;
  45738. /**
  45739. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45740. * 1 means it completely occludes it
  45741. * 0 mean it has no impact
  45742. */
  45743. ambientTextureImpactOnAnalyticalLights: number;
  45744. /**
  45745. * Stores the alpha values in a texture.
  45746. */
  45747. opacityTexture: BaseTexture;
  45748. /**
  45749. * Stores the reflection values in a texture.
  45750. */
  45751. reflectionTexture: Nullable<BaseTexture>;
  45752. /**
  45753. * Stores the emissive values in a texture.
  45754. */
  45755. emissiveTexture: BaseTexture;
  45756. /**
  45757. * AKA Specular texture in other nomenclature.
  45758. */
  45759. reflectivityTexture: BaseTexture;
  45760. /**
  45761. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45762. */
  45763. metallicTexture: BaseTexture;
  45764. /**
  45765. * Specifies the metallic scalar of the metallic/roughness workflow.
  45766. * Can also be used to scale the metalness values of the metallic texture.
  45767. */
  45768. metallic: Nullable<number>;
  45769. /**
  45770. * Specifies the roughness scalar of the metallic/roughness workflow.
  45771. * Can also be used to scale the roughness values of the metallic texture.
  45772. */
  45773. roughness: Nullable<number>;
  45774. /**
  45775. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45776. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45777. */
  45778. microSurfaceTexture: BaseTexture;
  45779. /**
  45780. * Stores surface normal data used to displace a mesh in a texture.
  45781. */
  45782. bumpTexture: BaseTexture;
  45783. /**
  45784. * Stores the pre-calculated light information of a mesh in a texture.
  45785. */
  45786. lightmapTexture: BaseTexture;
  45787. /**
  45788. * Stores the refracted light information in a texture.
  45789. */
  45790. refractionTexture: BaseTexture;
  45791. /**
  45792. * The color of a material in ambient lighting.
  45793. */
  45794. ambientColor: Color3;
  45795. /**
  45796. * AKA Diffuse Color in other nomenclature.
  45797. */
  45798. albedoColor: Color3;
  45799. /**
  45800. * AKA Specular Color in other nomenclature.
  45801. */
  45802. reflectivityColor: Color3;
  45803. /**
  45804. * The color reflected from the material.
  45805. */
  45806. reflectionColor: Color3;
  45807. /**
  45808. * The color emitted from the material.
  45809. */
  45810. emissiveColor: Color3;
  45811. /**
  45812. * AKA Glossiness in other nomenclature.
  45813. */
  45814. microSurface: number;
  45815. /**
  45816. * source material index of refraction (IOR)' / 'destination material IOR.
  45817. */
  45818. indexOfRefraction: number;
  45819. /**
  45820. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45821. */
  45822. invertRefractionY: boolean;
  45823. /**
  45824. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45825. * Materials half opaque for instance using refraction could benefit from this control.
  45826. */
  45827. linkRefractionWithTransparency: boolean;
  45828. /**
  45829. * If true, the light map contains occlusion information instead of lighting info.
  45830. */
  45831. useLightmapAsShadowmap: boolean;
  45832. /**
  45833. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45834. */
  45835. useAlphaFromAlbedoTexture: boolean;
  45836. /**
  45837. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45838. */
  45839. forceAlphaTest: boolean;
  45840. /**
  45841. * Defines the alpha limits in alpha test mode.
  45842. */
  45843. alphaCutOff: number;
  45844. /**
  45845. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45846. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45847. */
  45848. useSpecularOverAlpha: boolean;
  45849. /**
  45850. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45851. */
  45852. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45853. /**
  45854. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45855. */
  45856. useRoughnessFromMetallicTextureAlpha: boolean;
  45857. /**
  45858. * Specifies if the metallic texture contains the roughness information in its green channel.
  45859. */
  45860. useRoughnessFromMetallicTextureGreen: boolean;
  45861. /**
  45862. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45863. */
  45864. useMetallnessFromMetallicTextureBlue: boolean;
  45865. /**
  45866. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45867. */
  45868. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45869. /**
  45870. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45871. */
  45872. useAmbientInGrayScale: boolean;
  45873. /**
  45874. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45875. * The material will try to infer what glossiness each pixel should be.
  45876. */
  45877. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45878. /**
  45879. * BJS is using an harcoded light falloff based on a manually sets up range.
  45880. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45881. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45882. */
  45883. /**
  45884. * BJS is using an harcoded light falloff based on a manually sets up range.
  45885. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45886. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45887. */
  45888. usePhysicalLightFalloff: boolean;
  45889. /**
  45890. * In order to support the falloff compatibility with gltf, a special mode has been added
  45891. * to reproduce the gltf light falloff.
  45892. */
  45893. /**
  45894. * In order to support the falloff compatibility with gltf, a special mode has been added
  45895. * to reproduce the gltf light falloff.
  45896. */
  45897. useGLTFLightFalloff: boolean;
  45898. /**
  45899. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45900. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45901. */
  45902. useRadianceOverAlpha: boolean;
  45903. /**
  45904. * Allows using an object space normal map (instead of tangent space).
  45905. */
  45906. useObjectSpaceNormalMap: boolean;
  45907. /**
  45908. * Allows using the bump map in parallax mode.
  45909. */
  45910. useParallax: boolean;
  45911. /**
  45912. * Allows using the bump map in parallax occlusion mode.
  45913. */
  45914. useParallaxOcclusion: boolean;
  45915. /**
  45916. * Controls the scale bias of the parallax mode.
  45917. */
  45918. parallaxScaleBias: number;
  45919. /**
  45920. * If sets to true, disables all the lights affecting the material.
  45921. */
  45922. disableLighting: boolean;
  45923. /**
  45924. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45925. */
  45926. forceIrradianceInFragment: boolean;
  45927. /**
  45928. * Number of Simultaneous lights allowed on the material.
  45929. */
  45930. maxSimultaneousLights: number;
  45931. /**
  45932. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45933. */
  45934. invertNormalMapX: boolean;
  45935. /**
  45936. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45937. */
  45938. invertNormalMapY: boolean;
  45939. /**
  45940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45941. */
  45942. twoSidedLighting: boolean;
  45943. /**
  45944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45945. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45946. */
  45947. useAlphaFresnel: boolean;
  45948. /**
  45949. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45950. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45951. */
  45952. useLinearAlphaFresnel: boolean;
  45953. /**
  45954. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45955. * And/Or occlude the blended part.
  45956. */
  45957. environmentBRDFTexture: Nullable<BaseTexture>;
  45958. /**
  45959. * Force normal to face away from face.
  45960. */
  45961. forceNormalForward: boolean;
  45962. /**
  45963. * Enables specular anti aliasing in the PBR shader.
  45964. * It will both interacts on the Geometry for analytical and IBL lighting.
  45965. * It also prefilter the roughness map based on the bump values.
  45966. */
  45967. enableSpecularAntiAliasing: boolean;
  45968. /**
  45969. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45970. * makes the reflect vector face the model (under horizon).
  45971. */
  45972. useHorizonOcclusion: boolean;
  45973. /**
  45974. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45975. * too much the area relying on ambient texture to define their ambient occlusion.
  45976. */
  45977. useRadianceOcclusion: boolean;
  45978. /**
  45979. * If set to true, no lighting calculations will be applied.
  45980. */
  45981. unlit: boolean;
  45982. /**
  45983. * Gets the image processing configuration used either in this material.
  45984. */
  45985. /**
  45986. * Sets the Default image processing configuration used either in the this material.
  45987. *
  45988. * If sets to null, the scene one is in use.
  45989. */
  45990. imageProcessingConfiguration: ImageProcessingConfiguration;
  45991. /**
  45992. * Gets wether the color curves effect is enabled.
  45993. */
  45994. /**
  45995. * Sets wether the color curves effect is enabled.
  45996. */
  45997. cameraColorCurvesEnabled: boolean;
  45998. /**
  45999. * Gets wether the color grading effect is enabled.
  46000. */
  46001. /**
  46002. * Gets wether the color grading effect is enabled.
  46003. */
  46004. cameraColorGradingEnabled: boolean;
  46005. /**
  46006. * Gets wether tonemapping is enabled or not.
  46007. */
  46008. /**
  46009. * Sets wether tonemapping is enabled or not
  46010. */
  46011. cameraToneMappingEnabled: boolean;
  46012. /**
  46013. * The camera exposure used on this material.
  46014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46015. * This corresponds to a photographic exposure.
  46016. */
  46017. /**
  46018. * The camera exposure used on this material.
  46019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46020. * This corresponds to a photographic exposure.
  46021. */
  46022. cameraExposure: number;
  46023. /**
  46024. * Gets The camera contrast used on this material.
  46025. */
  46026. /**
  46027. * Sets The camera contrast used on this material.
  46028. */
  46029. cameraContrast: number;
  46030. /**
  46031. * Gets the Color Grading 2D Lookup Texture.
  46032. */
  46033. /**
  46034. * Sets the Color Grading 2D Lookup Texture.
  46035. */
  46036. cameraColorGradingTexture: Nullable<BaseTexture>;
  46037. /**
  46038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46040. * 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;
  46041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46042. */
  46043. /**
  46044. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46045. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46046. * 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;
  46047. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46048. */
  46049. cameraColorCurves: Nullable<ColorCurves>;
  46050. /**
  46051. * Instantiates a new PBRMaterial instance.
  46052. *
  46053. * @param name The material name
  46054. * @param scene The scene the material will be use in.
  46055. */
  46056. constructor(name: string, scene: Scene);
  46057. /**
  46058. * Returns the name of this material class.
  46059. */
  46060. getClassName(): string;
  46061. /**
  46062. * Returns an array of the actively used textures.
  46063. * @returns - Array of BaseTextures
  46064. */
  46065. getActiveTextures(): BaseTexture[];
  46066. /**
  46067. * Checks to see if a texture is used in the material.
  46068. * @param texture - Base texture to use.
  46069. * @returns - Boolean specifying if a texture is used in the material.
  46070. */
  46071. hasTexture(texture: BaseTexture): boolean;
  46072. /**
  46073. * Makes a duplicate of the current material.
  46074. * @param name - name to use for the new material.
  46075. */
  46076. clone(name: string): PBRMaterial;
  46077. /**
  46078. * Serializes this PBR Material.
  46079. * @returns - An object with the serialized material.
  46080. */
  46081. serialize(): any;
  46082. /**
  46083. * Parses a PBR Material from a serialized object.
  46084. * @param source - Serialized object.
  46085. * @param scene - BJS scene instance.
  46086. * @param rootUrl - url for the scene object
  46087. * @returns - PBRMaterial
  46088. */
  46089. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46090. }
  46091. }
  46092. declare module BABYLON {
  46093. /**
  46094. * The PBR material of BJS following the metal roughness convention.
  46095. *
  46096. * This fits to the PBR convention in the GLTF definition:
  46097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46098. */
  46099. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46100. /**
  46101. * The base color has two different interpretations depending on the value of metalness.
  46102. * When the material is a metal, the base color is the specific measured reflectance value
  46103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46104. * of the material.
  46105. */
  46106. baseColor: Color3;
  46107. /**
  46108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46109. * well as opacity information in the alpha channel.
  46110. */
  46111. baseTexture: BaseTexture;
  46112. /**
  46113. * Specifies the metallic scalar value of the material.
  46114. * Can also be used to scale the metalness values of the metallic texture.
  46115. */
  46116. metallic: number;
  46117. /**
  46118. * Specifies the roughness scalar value of the material.
  46119. * Can also be used to scale the roughness values of the metallic texture.
  46120. */
  46121. roughness: number;
  46122. /**
  46123. * Texture containing both the metallic value in the B channel and the
  46124. * roughness value in the G channel to keep better precision.
  46125. */
  46126. metallicRoughnessTexture: BaseTexture;
  46127. /**
  46128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46129. *
  46130. * @param name The material name
  46131. * @param scene The scene the material will be use in.
  46132. */
  46133. constructor(name: string, scene: Scene);
  46134. /**
  46135. * Return the currrent class name of the material.
  46136. */
  46137. getClassName(): string;
  46138. /**
  46139. * Return the active textures of the material.
  46140. */
  46141. getActiveTextures(): BaseTexture[];
  46142. /**
  46143. * Checks to see if a texture is used in the material.
  46144. * @param texture - Base texture to use.
  46145. * @returns - Boolean specifying if a texture is used in the material.
  46146. */
  46147. hasTexture(texture: BaseTexture): boolean;
  46148. /**
  46149. * Makes a duplicate of the current material.
  46150. * @param name - name to use for the new material.
  46151. */
  46152. clone(name: string): PBRMetallicRoughnessMaterial;
  46153. /**
  46154. * Serialize the material to a parsable JSON object.
  46155. */
  46156. serialize(): any;
  46157. /**
  46158. * Parses a JSON object correponding to the serialize function.
  46159. */
  46160. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * The PBR material of BJS following the specular glossiness convention.
  46166. *
  46167. * This fits to the PBR convention in the GLTF definition:
  46168. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46169. */
  46170. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46171. /**
  46172. * Specifies the diffuse color of the material.
  46173. */
  46174. diffuseColor: Color3;
  46175. /**
  46176. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46177. * channel.
  46178. */
  46179. diffuseTexture: BaseTexture;
  46180. /**
  46181. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46182. */
  46183. specularColor: Color3;
  46184. /**
  46185. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46186. */
  46187. glossiness: number;
  46188. /**
  46189. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46190. */
  46191. specularGlossinessTexture: BaseTexture;
  46192. /**
  46193. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46194. *
  46195. * @param name The material name
  46196. * @param scene The scene the material will be use in.
  46197. */
  46198. constructor(name: string, scene: Scene);
  46199. /**
  46200. * Return the currrent class name of the material.
  46201. */
  46202. getClassName(): string;
  46203. /**
  46204. * Return the active textures of the material.
  46205. */
  46206. getActiveTextures(): BaseTexture[];
  46207. /**
  46208. * Checks to see if a texture is used in the material.
  46209. * @param texture - Base texture to use.
  46210. * @returns - Boolean specifying if a texture is used in the material.
  46211. */
  46212. hasTexture(texture: BaseTexture): boolean;
  46213. /**
  46214. * Makes a duplicate of the current material.
  46215. * @param name - name to use for the new material.
  46216. */
  46217. clone(name: string): PBRSpecularGlossinessMaterial;
  46218. /**
  46219. * Serialize the material to a parsable JSON object.
  46220. */
  46221. serialize(): any;
  46222. /**
  46223. * Parses a JSON object correponding to the serialize function.
  46224. */
  46225. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46226. }
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * Base class of all the textures in babylon.
  46231. * It groups all the common properties the materials, post process, lights... might need
  46232. * in order to make a correct use of the texture.
  46233. */
  46234. class BaseTexture {
  46235. /**
  46236. * Default anisotropic filtering level for the application.
  46237. * It is set to 4 as a good tradeoff between perf and quality.
  46238. */
  46239. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46240. /**
  46241. * Gets or sets the unique id of the texture
  46242. */
  46243. uniqueId: number;
  46244. /**
  46245. * Define the name of the texture.
  46246. */
  46247. name: string;
  46248. /**
  46249. * Gets or sets an object used to store user defined information.
  46250. */
  46251. metadata: any;
  46252. private _hasAlpha;
  46253. /**
  46254. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46255. */
  46256. hasAlpha: boolean;
  46257. /**
  46258. * Defines if the alpha value should be determined via the rgb values.
  46259. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46260. */
  46261. getAlphaFromRGB: boolean;
  46262. /**
  46263. * Intensity or strength of the texture.
  46264. * It is commonly used by materials to fine tune the intensity of the texture
  46265. */
  46266. level: number;
  46267. /**
  46268. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46269. * This is part of the texture as textures usually maps to one uv set.
  46270. */
  46271. coordinatesIndex: number;
  46272. private _coordinatesMode;
  46273. /**
  46274. * How a texture is mapped.
  46275. *
  46276. * | Value | Type | Description |
  46277. * | ----- | ----------------------------------- | ----------- |
  46278. * | 0 | EXPLICIT_MODE | |
  46279. * | 1 | SPHERICAL_MODE | |
  46280. * | 2 | PLANAR_MODE | |
  46281. * | 3 | CUBIC_MODE | |
  46282. * | 4 | PROJECTION_MODE | |
  46283. * | 5 | SKYBOX_MODE | |
  46284. * | 6 | INVCUBIC_MODE | |
  46285. * | 7 | EQUIRECTANGULAR_MODE | |
  46286. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46287. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46288. */
  46289. coordinatesMode: number;
  46290. /**
  46291. * | Value | Type | Description |
  46292. * | ----- | ------------------ | ----------- |
  46293. * | 0 | CLAMP_ADDRESSMODE | |
  46294. * | 1 | WRAP_ADDRESSMODE | |
  46295. * | 2 | MIRROR_ADDRESSMODE | |
  46296. */
  46297. wrapU: number;
  46298. /**
  46299. * | Value | Type | Description |
  46300. * | ----- | ------------------ | ----------- |
  46301. * | 0 | CLAMP_ADDRESSMODE | |
  46302. * | 1 | WRAP_ADDRESSMODE | |
  46303. * | 2 | MIRROR_ADDRESSMODE | |
  46304. */
  46305. wrapV: number;
  46306. /**
  46307. * | Value | Type | Description |
  46308. * | ----- | ------------------ | ----------- |
  46309. * | 0 | CLAMP_ADDRESSMODE | |
  46310. * | 1 | WRAP_ADDRESSMODE | |
  46311. * | 2 | MIRROR_ADDRESSMODE | |
  46312. */
  46313. wrapR: number;
  46314. /**
  46315. * With compliant hardware and browser (supporting anisotropic filtering)
  46316. * this defines the level of anisotropic filtering in the texture.
  46317. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46318. */
  46319. anisotropicFilteringLevel: number;
  46320. /**
  46321. * Define if the texture is a cube texture or if false a 2d texture.
  46322. */
  46323. isCube: boolean;
  46324. /**
  46325. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46326. */
  46327. is3D: boolean;
  46328. /**
  46329. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46330. * HDR texture are usually stored in linear space.
  46331. * This only impacts the PBR and Background materials
  46332. */
  46333. gammaSpace: boolean;
  46334. /**
  46335. * Gets whether or not the texture contains RGBD data.
  46336. */
  46337. readonly isRGBD: boolean;
  46338. /**
  46339. * Is Z inverted in the texture (useful in a cube texture).
  46340. */
  46341. invertZ: boolean;
  46342. /**
  46343. * @hidden
  46344. */
  46345. lodLevelInAlpha: boolean;
  46346. /**
  46347. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46348. */
  46349. lodGenerationOffset: number;
  46350. /**
  46351. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46352. */
  46353. lodGenerationScale: number;
  46354. /**
  46355. * Define if the texture is a render target.
  46356. */
  46357. isRenderTarget: boolean;
  46358. /**
  46359. * Define the unique id of the texture in the scene.
  46360. */
  46361. readonly uid: string;
  46362. /**
  46363. * Return a string representation of the texture.
  46364. * @returns the texture as a string
  46365. */
  46366. toString(): string;
  46367. /**
  46368. * Get the class name of the texture.
  46369. * @returns "BaseTexture"
  46370. */
  46371. getClassName(): string;
  46372. /**
  46373. * Define the list of animation attached to the texture.
  46374. */
  46375. animations: Animation[];
  46376. /**
  46377. * An event triggered when the texture is disposed.
  46378. */
  46379. onDisposeObservable: Observable<BaseTexture>;
  46380. private _onDisposeObserver;
  46381. /**
  46382. * Callback triggered when the texture has been disposed.
  46383. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46384. */
  46385. onDispose: () => void;
  46386. /**
  46387. * Define the current state of the loading sequence when in delayed load mode.
  46388. */
  46389. delayLoadState: number;
  46390. private _scene;
  46391. /** @hidden */
  46392. _texture: Nullable<InternalTexture>;
  46393. private _uid;
  46394. /**
  46395. * Define if the texture is preventinga material to render or not.
  46396. * If not and the texture is not ready, the engine will use a default black texture instead.
  46397. */
  46398. readonly isBlocking: boolean;
  46399. /**
  46400. * Instantiates a new BaseTexture.
  46401. * Base class of all the textures in babylon.
  46402. * It groups all the common properties the materials, post process, lights... might need
  46403. * in order to make a correct use of the texture.
  46404. * @param scene Define the scene the texture blongs to
  46405. */
  46406. constructor(scene: Nullable<Scene>);
  46407. /**
  46408. * Get the scene the texture belongs to.
  46409. * @returns the scene or null if undefined
  46410. */
  46411. getScene(): Nullable<Scene>;
  46412. /**
  46413. * Get the texture transform matrix used to offset tile the texture for istance.
  46414. * @returns the transformation matrix
  46415. */
  46416. getTextureMatrix(): Matrix;
  46417. /**
  46418. * Get the texture reflection matrix used to rotate/transform the reflection.
  46419. * @returns the reflection matrix
  46420. */
  46421. getReflectionTextureMatrix(): Matrix;
  46422. /**
  46423. * Get the underlying lower level texture from Babylon.
  46424. * @returns the insternal texture
  46425. */
  46426. getInternalTexture(): Nullable<InternalTexture>;
  46427. /**
  46428. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46429. * @returns true if ready or not blocking
  46430. */
  46431. isReadyOrNotBlocking(): boolean;
  46432. /**
  46433. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46434. * @returns true if fully ready
  46435. */
  46436. isReady(): boolean;
  46437. private _cachedSize;
  46438. /**
  46439. * Get the size of the texture.
  46440. * @returns the texture size.
  46441. */
  46442. getSize(): ISize;
  46443. /**
  46444. * Get the base size of the texture.
  46445. * It can be different from the size if the texture has been resized for POT for instance
  46446. * @returns the base size
  46447. */
  46448. getBaseSize(): ISize;
  46449. /**
  46450. * Scales the texture if is `canRescale()`
  46451. * @param ratio the resize factor we want to use to rescale
  46452. */
  46453. scale(ratio: number): void;
  46454. /**
  46455. * Get if the texture can rescale.
  46456. */
  46457. readonly canRescale: boolean;
  46458. /** @hidden */
  46459. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46460. /** @hidden */
  46461. _rebuild(): void;
  46462. /**
  46463. * Triggers the load sequence in delayed load mode.
  46464. */
  46465. delayLoad(): void;
  46466. /**
  46467. * Clones the texture.
  46468. * @returns the cloned texture
  46469. */
  46470. clone(): Nullable<BaseTexture>;
  46471. /**
  46472. * Get the texture underlying type (INT, FLOAT...)
  46473. */
  46474. readonly textureType: number;
  46475. /**
  46476. * Get the texture underlying format (RGB, RGBA...)
  46477. */
  46478. readonly textureFormat: number;
  46479. /**
  46480. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46481. * This will returns an RGBA array buffer containing either in values (0-255) or
  46482. * float values (0-1) depending of the underlying buffer type.
  46483. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46484. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46485. * @param buffer defines a user defined buffer to fill with data (can be null)
  46486. * @returns The Array buffer containing the pixels data.
  46487. */
  46488. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46489. /**
  46490. * Release and destroy the underlying lower level texture aka internalTexture.
  46491. */
  46492. releaseInternalTexture(): void;
  46493. /**
  46494. * Get the polynomial representation of the texture data.
  46495. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46496. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46497. */
  46498. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46499. /** @hidden */
  46500. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46501. /** @hidden */
  46502. readonly _lodTextureMid: Nullable<BaseTexture>;
  46503. /** @hidden */
  46504. readonly _lodTextureLow: Nullable<BaseTexture>;
  46505. /**
  46506. * Dispose the texture and release its associated resources.
  46507. */
  46508. dispose(): void;
  46509. /**
  46510. * Serialize the texture into a JSON representation that can be parsed later on.
  46511. * @returns the JSON representation of the texture
  46512. */
  46513. serialize(): any;
  46514. /**
  46515. * Helper function to be called back once a list of texture contains only ready textures.
  46516. * @param textures Define the list of textures to wait for
  46517. * @param callback Define the callback triggered once the entire list will be ready
  46518. */
  46519. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46520. }
  46521. }
  46522. declare module BABYLON {
  46523. /**
  46524. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46525. * It can help converting any input color in a desired output one. This can then be used to create effects
  46526. * from sepia, black and white to sixties or futuristic rendering...
  46527. *
  46528. * The only supported format is currently 3dl.
  46529. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46530. */
  46531. class ColorGradingTexture extends BaseTexture {
  46532. /**
  46533. * The current texture matrix. (will always be identity in color grading texture)
  46534. */
  46535. private _textureMatrix;
  46536. /**
  46537. * The texture URL.
  46538. */
  46539. url: string;
  46540. /**
  46541. * Empty line regex stored for GC.
  46542. */
  46543. private static _noneEmptyLineRegex;
  46544. private _engine;
  46545. /**
  46546. * Instantiates a ColorGradingTexture from the following parameters.
  46547. *
  46548. * @param url The location of the color gradind data (currently only supporting 3dl)
  46549. * @param scene The scene the texture will be used in
  46550. */
  46551. constructor(url: string, scene: Scene);
  46552. /**
  46553. * Returns the texture matrix used in most of the material.
  46554. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46555. */
  46556. getTextureMatrix(): Matrix;
  46557. /**
  46558. * Occurs when the file being loaded is a .3dl LUT file.
  46559. */
  46560. private load3dlTexture;
  46561. /**
  46562. * Starts the loading process of the texture.
  46563. */
  46564. private loadTexture;
  46565. /**
  46566. * Clones the color gradind texture.
  46567. */
  46568. clone(): ColorGradingTexture;
  46569. /**
  46570. * Called during delayed load for textures.
  46571. */
  46572. delayLoad(): void;
  46573. /**
  46574. * Parses a color grading texture serialized by Babylon.
  46575. * @param parsedTexture The texture information being parsedTexture
  46576. * @param scene The scene to load the texture in
  46577. * @param rootUrl The root url of the data assets to load
  46578. * @return A color gradind texture
  46579. */
  46580. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46581. /**
  46582. * Serializes the LUT texture to json format.
  46583. */
  46584. serialize(): any;
  46585. }
  46586. }
  46587. declare module BABYLON {
  46588. /**
  46589. * Class for creating a cube texture
  46590. */
  46591. class CubeTexture extends BaseTexture {
  46592. /**
  46593. * The url of the texture
  46594. */
  46595. url: string;
  46596. /**
  46597. * Gets or sets the center of the bounding box associated with the cube texture.
  46598. * It must define where the camera used to render the texture was set
  46599. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46600. */
  46601. boundingBoxPosition: Vector3;
  46602. private _boundingBoxSize;
  46603. /**
  46604. * Gets or sets the size of the bounding box associated with the cube texture
  46605. * When defined, the cubemap will switch to local mode
  46606. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46607. * @example https://www.babylonjs-playground.com/#RNASML
  46608. */
  46609. /**
  46610. * Returns the bounding box size
  46611. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46612. */
  46613. boundingBoxSize: Vector3;
  46614. protected _rotationY: number;
  46615. /**
  46616. * Sets texture matrix rotation angle around Y axis in radians.
  46617. */
  46618. /**
  46619. * Gets texture matrix rotation angle around Y axis radians.
  46620. */
  46621. rotationY: number;
  46622. private _noMipmap;
  46623. private _files;
  46624. private _extensions;
  46625. private _textureMatrix;
  46626. private _format;
  46627. private _createPolynomials;
  46628. /** @hidden */
  46629. readonly _prefiltered: boolean;
  46630. /**
  46631. * Creates a cube texture from an array of image urls
  46632. * @param files defines an array of image urls
  46633. * @param scene defines the hosting scene
  46634. * @param noMipmap specifies if mip maps are not used
  46635. * @returns a cube texture
  46636. */
  46637. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46638. /**
  46639. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46640. * @param url defines the url of the prefiltered texture
  46641. * @param scene defines the scene the texture is attached to
  46642. * @param forcedExtension defines the extension of the file if different from the url
  46643. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46644. * @return the prefiltered texture
  46645. */
  46646. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46647. /**
  46648. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46649. * as prefiltered data.
  46650. * @param rootUrl defines the url of the texture or the root name of the six images
  46651. * @param scene defines the scene the texture is attached to
  46652. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46653. * @param noMipmap defines if mipmaps should be created or not
  46654. * @param files defines the six files to load for the different faces
  46655. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46656. * @param onError defines a callback triggered in case of error during load
  46657. * @param format defines the internal format to use for the texture once loaded
  46658. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46659. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46660. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46663. * @return the cube texture
  46664. */
  46665. 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);
  46666. /**
  46667. * Delays loading of the cube texture
  46668. */
  46669. delayLoad(): void;
  46670. /**
  46671. * Returns the reflection texture matrix
  46672. * @returns the reflection texture matrix
  46673. */
  46674. getReflectionTextureMatrix(): Matrix;
  46675. /**
  46676. * Sets the reflection texture matrix
  46677. * @param value Reflection texture matrix
  46678. */
  46679. setReflectionTextureMatrix(value: Matrix): void;
  46680. /**
  46681. * Parses text to create a cube texture
  46682. * @param parsedTexture define the serialized text to read from
  46683. * @param scene defines the hosting scene
  46684. * @param rootUrl defines the root url of the cube texture
  46685. * @returns a cube texture
  46686. */
  46687. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46688. /**
  46689. * Makes a clone, or deep copy, of the cube texture
  46690. * @returns a new cube texture
  46691. */
  46692. clone(): CubeTexture;
  46693. }
  46694. }
  46695. declare module BABYLON {
  46696. /**
  46697. * A class extending Texture allowing drawing on a texture
  46698. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46699. */
  46700. class DynamicTexture extends Texture {
  46701. private _generateMipMaps;
  46702. private _canvas;
  46703. private _context;
  46704. private _engine;
  46705. /**
  46706. * Creates a DynamicTexture
  46707. * @param name defines the name of the texture
  46708. * @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
  46709. * @param scene defines the scene where you want the texture
  46710. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46711. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46712. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46713. */
  46714. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46715. /**
  46716. * Get the current class name of the texture useful for serialization or dynamic coding.
  46717. * @returns "DynamicTexture"
  46718. */
  46719. getClassName(): string;
  46720. /**
  46721. * Gets the current state of canRescale
  46722. */
  46723. readonly canRescale: boolean;
  46724. private _recreate;
  46725. /**
  46726. * Scales the texture
  46727. * @param ratio the scale factor to apply to both width and height
  46728. */
  46729. scale(ratio: number): void;
  46730. /**
  46731. * Resizes the texture
  46732. * @param width the new width
  46733. * @param height the new height
  46734. */
  46735. scaleTo(width: number, height: number): void;
  46736. /**
  46737. * Gets the context of the canvas used by the texture
  46738. * @returns the canvas context of the dynamic texture
  46739. */
  46740. getContext(): CanvasRenderingContext2D;
  46741. /**
  46742. * Clears the texture
  46743. */
  46744. clear(): void;
  46745. /**
  46746. * Updates the texture
  46747. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46748. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46749. */
  46750. update(invertY?: boolean, premulAlpha?: boolean): void;
  46751. /**
  46752. * Draws text onto the texture
  46753. * @param text defines the text to be drawn
  46754. * @param x defines the placement of the text from the left
  46755. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46756. * @param font defines the font to be used with font-style, font-size, font-name
  46757. * @param color defines the color used for the text
  46758. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46759. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46760. * @param update defines whether texture is immediately update (default is true)
  46761. */
  46762. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46763. /**
  46764. * Clones the texture
  46765. * @returns the clone of the texture.
  46766. */
  46767. clone(): DynamicTexture;
  46768. /**
  46769. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46770. * @returns a serialized dynamic texture object
  46771. */
  46772. serialize(): any;
  46773. /** @hidden */
  46774. _rebuild(): void;
  46775. }
  46776. }
  46777. declare module BABYLON {
  46778. /**
  46779. * This represents a texture coming from an HDR input.
  46780. *
  46781. * The only supported format is currently panorama picture stored in RGBE format.
  46782. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46783. */
  46784. class HDRCubeTexture extends BaseTexture {
  46785. private static _facesMapping;
  46786. private _generateHarmonics;
  46787. private _noMipmap;
  46788. private _textureMatrix;
  46789. private _size;
  46790. private _onLoad;
  46791. private _onError;
  46792. /**
  46793. * The texture URL.
  46794. */
  46795. url: string;
  46796. /**
  46797. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46798. */
  46799. coordinatesMode: number;
  46800. protected _isBlocking: boolean;
  46801. /**
  46802. * Sets wether or not the texture is blocking during loading.
  46803. */
  46804. /**
  46805. * Gets wether or not the texture is blocking during loading.
  46806. */
  46807. isBlocking: boolean;
  46808. protected _rotationY: number;
  46809. /**
  46810. * Sets texture matrix rotation angle around Y axis in radians.
  46811. */
  46812. /**
  46813. * Gets texture matrix rotation angle around Y axis radians.
  46814. */
  46815. rotationY: number;
  46816. /**
  46817. * Gets or sets the center of the bounding box associated with the cube texture
  46818. * It must define where the camera used to render the texture was set
  46819. */
  46820. boundingBoxPosition: Vector3;
  46821. private _boundingBoxSize;
  46822. /**
  46823. * Gets or sets the size of the bounding box associated with the cube texture
  46824. * When defined, the cubemap will switch to local mode
  46825. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46826. * @example https://www.babylonjs-playground.com/#RNASML
  46827. */
  46828. boundingBoxSize: Vector3;
  46829. /**
  46830. * Instantiates an HDRTexture from the following parameters.
  46831. *
  46832. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46833. * @param scene The scene the texture will be used in
  46834. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46835. * @param noMipmap Forces to not generate the mipmap if true
  46836. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46837. * @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)
  46838. * @param reserved Reserved flag for internal use.
  46839. */
  46840. 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>);
  46841. /**
  46842. * Occurs when the file is raw .hdr file.
  46843. */
  46844. private loadTexture;
  46845. clone(): HDRCubeTexture;
  46846. delayLoad(): void;
  46847. /**
  46848. * Get the texture reflection matrix used to rotate/transform the reflection.
  46849. * @returns the reflection matrix
  46850. */
  46851. getReflectionTextureMatrix(): Matrix;
  46852. /**
  46853. * Set the texture reflection matrix used to rotate/transform the reflection.
  46854. * @param value Define the reflection matrix to set
  46855. */
  46856. setReflectionTextureMatrix(value: Matrix): void;
  46857. /**
  46858. * Parses a JSON representation of an HDR Texture in order to create the texture
  46859. * @param parsedTexture Define the JSON representation
  46860. * @param scene Define the scene the texture should be created in
  46861. * @param rootUrl Define the root url in case we need to load relative dependencies
  46862. * @returns the newly created texture after parsing
  46863. */
  46864. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46865. serialize(): any;
  46866. }
  46867. }
  46868. declare module BABYLON {
  46869. /**
  46870. * Class used to store data associated with WebGL texture data for the engine
  46871. * This class should not be used directly
  46872. */
  46873. class InternalTexture implements IInternalTextureTracker {
  46874. /**
  46875. * The source of the texture data is unknown
  46876. */
  46877. static DATASOURCE_UNKNOWN: number;
  46878. /**
  46879. * Texture data comes from an URL
  46880. */
  46881. static DATASOURCE_URL: number;
  46882. /**
  46883. * Texture data is only used for temporary storage
  46884. */
  46885. static DATASOURCE_TEMP: number;
  46886. /**
  46887. * Texture data comes from raw data (ArrayBuffer)
  46888. */
  46889. static DATASOURCE_RAW: number;
  46890. /**
  46891. * Texture content is dynamic (video or dynamic texture)
  46892. */
  46893. static DATASOURCE_DYNAMIC: number;
  46894. /**
  46895. * Texture content is generated by rendering to it
  46896. */
  46897. static DATASOURCE_RENDERTARGET: number;
  46898. /**
  46899. * Texture content is part of a multi render target process
  46900. */
  46901. static DATASOURCE_MULTIRENDERTARGET: number;
  46902. /**
  46903. * Texture data comes from a cube data file
  46904. */
  46905. static DATASOURCE_CUBE: number;
  46906. /**
  46907. * Texture data comes from a raw cube data
  46908. */
  46909. static DATASOURCE_CUBERAW: number;
  46910. /**
  46911. * Texture data come from a prefiltered cube data file
  46912. */
  46913. static DATASOURCE_CUBEPREFILTERED: number;
  46914. /**
  46915. * Texture content is raw 3D data
  46916. */
  46917. static DATASOURCE_RAW3D: number;
  46918. /**
  46919. * Texture content is a depth texture
  46920. */
  46921. static DATASOURCE_DEPTHTEXTURE: number;
  46922. /**
  46923. * Texture data comes from a raw cube data encoded with RGBD
  46924. */
  46925. static DATASOURCE_CUBERAW_RGBD: number;
  46926. /**
  46927. * Defines if the texture is ready
  46928. */
  46929. isReady: boolean;
  46930. /**
  46931. * Defines if the texture is a cube texture
  46932. */
  46933. isCube: boolean;
  46934. /**
  46935. * Defines if the texture contains 3D data
  46936. */
  46937. is3D: boolean;
  46938. /**
  46939. * Gets the URL used to load this texture
  46940. */
  46941. url: string;
  46942. /**
  46943. * Gets the sampling mode of the texture
  46944. */
  46945. samplingMode: number;
  46946. /**
  46947. * Gets a boolean indicating if the texture needs mipmaps generation
  46948. */
  46949. generateMipMaps: boolean;
  46950. /**
  46951. * Gets the number of samples used by the texture (WebGL2+ only)
  46952. */
  46953. samples: number;
  46954. /**
  46955. * Gets the type of the texture (int, float...)
  46956. */
  46957. type: number;
  46958. /**
  46959. * Gets the format of the texture (RGB, RGBA...)
  46960. */
  46961. format: number;
  46962. /**
  46963. * Observable called when the texture is loaded
  46964. */
  46965. onLoadedObservable: Observable<InternalTexture>;
  46966. /**
  46967. * Gets the width of the texture
  46968. */
  46969. width: number;
  46970. /**
  46971. * Gets the height of the texture
  46972. */
  46973. height: number;
  46974. /**
  46975. * Gets the depth of the texture
  46976. */
  46977. depth: number;
  46978. /**
  46979. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46980. */
  46981. baseWidth: number;
  46982. /**
  46983. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46984. */
  46985. baseHeight: number;
  46986. /**
  46987. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46988. */
  46989. baseDepth: number;
  46990. /**
  46991. * Gets a boolean indicating if the texture is inverted on Y axis
  46992. */
  46993. invertY: boolean;
  46994. /**
  46995. * Gets or set the previous tracker in the list
  46996. */
  46997. previous: Nullable<IInternalTextureTracker>;
  46998. /**
  46999. * Gets or set the next tracker in the list
  47000. */
  47001. next: Nullable<IInternalTextureTracker>;
  47002. /** @hidden */
  47003. _initialSlot: number;
  47004. /** @hidden */
  47005. _designatedSlot: number;
  47006. /** @hidden */
  47007. _dataSource: number;
  47008. /** @hidden */
  47009. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47010. /** @hidden */
  47011. _bufferView: Nullable<ArrayBufferView>;
  47012. /** @hidden */
  47013. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47014. /** @hidden */
  47015. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47016. /** @hidden */
  47017. _size: number;
  47018. /** @hidden */
  47019. _extension: string;
  47020. /** @hidden */
  47021. _files: Nullable<string[]>;
  47022. /** @hidden */
  47023. _workingCanvas: HTMLCanvasElement;
  47024. /** @hidden */
  47025. _workingContext: CanvasRenderingContext2D;
  47026. /** @hidden */
  47027. _framebuffer: Nullable<WebGLFramebuffer>;
  47028. /** @hidden */
  47029. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47030. /** @hidden */
  47031. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47032. /** @hidden */
  47033. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47034. /** @hidden */
  47035. _attachments: Nullable<number[]>;
  47036. /** @hidden */
  47037. _cachedCoordinatesMode: Nullable<number>;
  47038. /** @hidden */
  47039. _cachedWrapU: Nullable<number>;
  47040. /** @hidden */
  47041. _cachedWrapV: Nullable<number>;
  47042. /** @hidden */
  47043. _cachedWrapR: Nullable<number>;
  47044. /** @hidden */
  47045. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47046. /** @hidden */
  47047. _isDisabled: boolean;
  47048. /** @hidden */
  47049. _compression: Nullable<string>;
  47050. /** @hidden */
  47051. _generateStencilBuffer: boolean;
  47052. /** @hidden */
  47053. _generateDepthBuffer: boolean;
  47054. /** @hidden */
  47055. _comparisonFunction: number;
  47056. /** @hidden */
  47057. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47058. /** @hidden */
  47059. _lodGenerationScale: number;
  47060. /** @hidden */
  47061. _lodGenerationOffset: number;
  47062. /** @hidden */
  47063. _lodTextureHigh: BaseTexture;
  47064. /** @hidden */
  47065. _lodTextureMid: BaseTexture;
  47066. /** @hidden */
  47067. _lodTextureLow: BaseTexture;
  47068. /** @hidden */
  47069. _isRGBD: boolean;
  47070. /** @hidden */
  47071. _webGLTexture: Nullable<WebGLTexture>;
  47072. /** @hidden */
  47073. _references: number;
  47074. private _engine;
  47075. /**
  47076. * Gets the Engine the texture belongs to.
  47077. * @returns The babylon engine
  47078. */
  47079. getEngine(): Engine;
  47080. /**
  47081. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47082. */
  47083. readonly dataSource: number;
  47084. /**
  47085. * Creates a new InternalTexture
  47086. * @param engine defines the engine to use
  47087. * @param dataSource defines the type of data that will be used
  47088. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47089. */
  47090. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47091. /**
  47092. * Increments the number of references (ie. the number of Texture that point to it)
  47093. */
  47094. incrementReferences(): void;
  47095. /**
  47096. * Change the size of the texture (not the size of the content)
  47097. * @param width defines the new width
  47098. * @param height defines the new height
  47099. * @param depth defines the new depth (1 by default)
  47100. */
  47101. updateSize(width: int, height: int, depth?: int): void;
  47102. /** @hidden */
  47103. _rebuild(): void;
  47104. /** @hidden */
  47105. _swapAndDie(target: InternalTexture): void;
  47106. /**
  47107. * Dispose the current allocated resources
  47108. */
  47109. dispose(): void;
  47110. }
  47111. }
  47112. declare module BABYLON {
  47113. /**
  47114. * This represents the required contract to create a new type of texture loader.
  47115. */
  47116. interface IInternalTextureLoader {
  47117. /**
  47118. * Defines wether the loader supports cascade loading the different faces.
  47119. */
  47120. supportCascades: boolean;
  47121. /**
  47122. * This returns if the loader support the current file information.
  47123. * @param extension defines the file extension of the file being loaded
  47124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47125. * @param fallback defines the fallback internal texture if any
  47126. * @param isBase64 defines whether the texture is encoded as a base64
  47127. * @param isBuffer defines whether the texture data are stored as a buffer
  47128. * @returns true if the loader can load the specified file
  47129. */
  47130. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47131. /**
  47132. * Transform the url before loading if required.
  47133. * @param rootUrl the url of the texture
  47134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47135. * @returns the transformed texture
  47136. */
  47137. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47138. /**
  47139. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47140. * @param rootUrl the url of the texture
  47141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47142. * @returns the fallback texture
  47143. */
  47144. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47145. /**
  47146. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47147. * @param data contains the texture data
  47148. * @param texture defines the BabylonJS internal texture
  47149. * @param createPolynomials will be true if polynomials have been requested
  47150. * @param onLoad defines the callback to trigger once the texture is ready
  47151. * @param onError defines the callback to trigger in case of error
  47152. */
  47153. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47154. /**
  47155. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47156. * @param data contains the texture data
  47157. * @param texture defines the BabylonJS internal texture
  47158. * @param callback defines the method to call once ready to upload
  47159. */
  47160. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47161. }
  47162. }
  47163. declare module BABYLON {
  47164. /**
  47165. * Internal interface used to track InternalTexture already bound to the GL context
  47166. */
  47167. interface IInternalTextureTracker {
  47168. /**
  47169. * Gets or set the previous tracker in the list
  47170. */
  47171. previous: Nullable<IInternalTextureTracker>;
  47172. /**
  47173. * Gets or set the next tracker in the list
  47174. */
  47175. next: Nullable<IInternalTextureTracker>;
  47176. }
  47177. /**
  47178. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47179. */
  47180. class DummyInternalTextureTracker {
  47181. /**
  47182. * Gets or set the previous tracker in the list
  47183. */
  47184. previous: Nullable<IInternalTextureTracker>;
  47185. /**
  47186. * Gets or set the next tracker in the list
  47187. */
  47188. next: Nullable<IInternalTextureTracker>;
  47189. }
  47190. }
  47191. declare module BABYLON {
  47192. /**
  47193. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47194. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47195. * You can then easily use it as a reflectionTexture on a flat surface.
  47196. * In case the surface is not a plane, please consider relying on reflection probes.
  47197. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47198. */
  47199. class MirrorTexture extends RenderTargetTexture {
  47200. private scene;
  47201. /**
  47202. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47203. * It is possible to directly set the mirrorPlane by directly using a BABYLON.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.
  47204. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47205. */
  47206. mirrorPlane: Plane;
  47207. /**
  47208. * Define the blur ratio used to blur the reflection if needed.
  47209. */
  47210. blurRatio: number;
  47211. /**
  47212. * Define the adaptive blur kernel used to blur the reflection if needed.
  47213. * This will autocompute the closest best match for the `blurKernel`
  47214. */
  47215. adaptiveBlurKernel: number;
  47216. /**
  47217. * Define the blur kernel used to blur the reflection if needed.
  47218. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47219. */
  47220. blurKernel: number;
  47221. /**
  47222. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47223. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47224. */
  47225. blurKernelX: number;
  47226. /**
  47227. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47228. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47229. */
  47230. blurKernelY: number;
  47231. private _autoComputeBlurKernel;
  47232. protected _onRatioRescale(): void;
  47233. private _updateGammaSpace;
  47234. private _imageProcessingConfigChangeObserver;
  47235. private _transformMatrix;
  47236. private _mirrorMatrix;
  47237. private _savedViewMatrix;
  47238. private _blurX;
  47239. private _blurY;
  47240. private _adaptiveBlurKernel;
  47241. private _blurKernelX;
  47242. private _blurKernelY;
  47243. private _blurRatio;
  47244. /**
  47245. * Instantiates a Mirror Texture.
  47246. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47247. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47248. * You can then easily use it as a reflectionTexture on a flat surface.
  47249. * In case the surface is not a plane, please consider relying on reflection probes.
  47250. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47251. * @param name
  47252. * @param size
  47253. * @param scene
  47254. * @param generateMipMaps
  47255. * @param type
  47256. * @param samplingMode
  47257. * @param generateDepthBuffer
  47258. */
  47259. constructor(name: string, size: number | {
  47260. width: number;
  47261. height: number;
  47262. } | {
  47263. ratio: number;
  47264. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47265. private _preparePostProcesses;
  47266. /**
  47267. * Clone the mirror texture.
  47268. * @returns the cloned texture
  47269. */
  47270. clone(): MirrorTexture;
  47271. /**
  47272. * Serialize the texture to a JSON representation you could use in Parse later on
  47273. * @returns the serialized JSON representation
  47274. */
  47275. serialize(): any;
  47276. /**
  47277. * Dispose the texture and release its associated resources.
  47278. */
  47279. dispose(): void;
  47280. }
  47281. }
  47282. declare module BABYLON {
  47283. /**
  47284. * Creation options of the multi render target texture.
  47285. */
  47286. interface IMultiRenderTargetOptions {
  47287. /**
  47288. * Define if the texture needs to create mip maps after render.
  47289. */
  47290. generateMipMaps?: boolean;
  47291. /**
  47292. * Define the types of all the draw buffers we want to create
  47293. */
  47294. types?: number[];
  47295. /**
  47296. * Define the sampling modes of all the draw buffers we want to create
  47297. */
  47298. samplingModes?: number[];
  47299. /**
  47300. * Define if a depth buffer is required
  47301. */
  47302. generateDepthBuffer?: boolean;
  47303. /**
  47304. * Define if a stencil buffer is required
  47305. */
  47306. generateStencilBuffer?: boolean;
  47307. /**
  47308. * Define if a depth texture is required instead of a depth buffer
  47309. */
  47310. generateDepthTexture?: boolean;
  47311. /**
  47312. * Define the number of desired draw buffers
  47313. */
  47314. textureCount?: number;
  47315. /**
  47316. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47317. */
  47318. doNotChangeAspectRatio?: boolean;
  47319. /**
  47320. * Define the default type of the buffers we are creating
  47321. */
  47322. defaultType?: number;
  47323. }
  47324. /**
  47325. * A multi render target, like a render target provides the ability to render to a texture.
  47326. * Unlike the render target, it can render to several draw buffers in one draw.
  47327. * This is specially interesting in deferred rendering or for any effects requiring more than
  47328. * just one color from a single pass.
  47329. */
  47330. class MultiRenderTarget extends RenderTargetTexture {
  47331. private _internalTextures;
  47332. private _textures;
  47333. private _multiRenderTargetOptions;
  47334. /**
  47335. * Get if draw buffers are currently supported by the used hardware and browser.
  47336. */
  47337. readonly isSupported: boolean;
  47338. /**
  47339. * Get the list of textures generated by the multi render target.
  47340. */
  47341. readonly textures: Texture[];
  47342. /**
  47343. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47344. */
  47345. readonly depthTexture: Texture;
  47346. /**
  47347. * Set the wrapping mode on U of all the textures we are rendering to.
  47348. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47349. */
  47350. wrapU: number;
  47351. /**
  47352. * Set the wrapping mode on V of all the textures we are rendering to.
  47353. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47354. */
  47355. wrapV: number;
  47356. /**
  47357. * Instantiate a new multi render target texture.
  47358. * A multi render target, like a render target provides the ability to render to a texture.
  47359. * Unlike the render target, it can render to several draw buffers in one draw.
  47360. * This is specially interesting in deferred rendering or for any effects requiring more than
  47361. * just one color from a single pass.
  47362. * @param name Define the name of the texture
  47363. * @param size Define the size of the buffers to render to
  47364. * @param count Define the number of target we are rendering into
  47365. * @param scene Define the scene the texture belongs to
  47366. * @param options Define the options used to create the multi render target
  47367. */
  47368. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47369. /** @hidden */
  47370. _rebuild(): void;
  47371. private _createInternalTextures;
  47372. private _createTextures;
  47373. /**
  47374. * Define the number of samples used if MSAA is enabled.
  47375. */
  47376. samples: number;
  47377. /**
  47378. * Resize all the textures in the multi render target.
  47379. * Be carrefull as it will recreate all the data in the new texture.
  47380. * @param size Define the new size
  47381. */
  47382. resize(size: any): void;
  47383. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47384. /**
  47385. * Dispose the render targets and their associated resources
  47386. */
  47387. dispose(): void;
  47388. /**
  47389. * Release all the underlying texture used as draw buffers.
  47390. */
  47391. releaseInternalTextures(): void;
  47392. }
  47393. }
  47394. declare module BABYLON {
  47395. /**
  47396. * Raw cube texture where the raw buffers are passed in
  47397. */
  47398. class RawCubeTexture extends CubeTexture {
  47399. /**
  47400. * Creates a cube texture where the raw buffers are passed in.
  47401. * @param scene defines the scene the texture is attached to
  47402. * @param data defines the array of data to use to create each face
  47403. * @param size defines the size of the textures
  47404. * @param format defines the format of the data
  47405. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47406. * @param generateMipMaps defines if the engine should generate the mip levels
  47407. * @param invertY defines if data must be stored with Y axis inverted
  47408. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47409. * @param compression defines the compression used (null by default)
  47410. */
  47411. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47412. /**
  47413. * Updates the raw cube texture.
  47414. * @param data defines the data to store
  47415. * @param format defines the data format
  47416. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47417. * @param invertY defines if data must be stored with Y axis inverted
  47418. * @param compression defines the compression used (null by default)
  47419. * @param level defines which level of the texture to update
  47420. */
  47421. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47422. /**
  47423. * Updates a raw cube texture with RGBD encoded data.
  47424. * @param data defines the array of data [mipmap][face] to use to create each face
  47425. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47426. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47427. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47428. * @returns a promsie that resolves when the operation is complete
  47429. */
  47430. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47431. /**
  47432. * Clones the raw cube texture.
  47433. * @return a new cube texture
  47434. */
  47435. clone(): CubeTexture;
  47436. /** @hidden */
  47437. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47438. }
  47439. }
  47440. declare module BABYLON {
  47441. /**
  47442. * Raw texture can help creating a texture directly from an array of data.
  47443. * This can be super useful if you either get the data from an uncompressed source or
  47444. * if you wish to create your texture pixel by pixel.
  47445. */
  47446. class RawTexture extends Texture {
  47447. /**
  47448. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47449. */
  47450. format: number;
  47451. private _engine;
  47452. /**
  47453. * Instantiates a new RawTexture.
  47454. * Raw texture can help creating a texture directly from an array of data.
  47455. * This can be super useful if you either get the data from an uncompressed source or
  47456. * if you wish to create your texture pixel by pixel.
  47457. * @param data define the array of data to use to create the texture
  47458. * @param width define the width of the texture
  47459. * @param height define the height of the texture
  47460. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47461. * @param scene define the scene the texture belongs to
  47462. * @param generateMipMaps define whether mip maps should be generated or not
  47463. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47464. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47465. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47466. */
  47467. constructor(data: ArrayBufferView, width: number, height: number,
  47468. /**
  47469. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47470. */
  47471. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47472. /**
  47473. * Updates the texture underlying data.
  47474. * @param data Define the new data of the texture
  47475. */
  47476. update(data: ArrayBufferView): void;
  47477. /**
  47478. * Creates a luminance texture from some data.
  47479. * @param data Define the texture data
  47480. * @param width Define the width of the texture
  47481. * @param height Define the height of the texture
  47482. * @param scene Define the scene the texture belongs to
  47483. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47486. * @returns the luminance texture
  47487. */
  47488. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47489. /**
  47490. * Creates a luminance alpha texture from some data.
  47491. * @param data Define the texture data
  47492. * @param width Define the width of the texture
  47493. * @param height Define the height of the texture
  47494. * @param scene Define the scene the texture belongs to
  47495. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47496. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47497. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47498. * @returns the luminance alpha texture
  47499. */
  47500. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47501. /**
  47502. * Creates an alpha texture from some data.
  47503. * @param data Define the texture data
  47504. * @param width Define the width of the texture
  47505. * @param height Define the height of the texture
  47506. * @param scene Define the scene the texture belongs to
  47507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47510. * @returns the alpha texture
  47511. */
  47512. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47513. /**
  47514. * Creates a RGB texture from some data.
  47515. * @param data Define the texture data
  47516. * @param width Define the width of the texture
  47517. * @param height Define the height of the texture
  47518. * @param scene Define the scene the texture belongs to
  47519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47522. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47523. * @returns the RGB alpha texture
  47524. */
  47525. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47526. /**
  47527. * Creates a RGBA texture from some data.
  47528. * @param data Define the texture data
  47529. * @param width Define the width of the texture
  47530. * @param height Define the height of the texture
  47531. * @param scene Define the scene the texture belongs to
  47532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47535. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47536. * @returns the RGBA texture
  47537. */
  47538. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47539. /**
  47540. * Creates a R texture from some data.
  47541. * @param data Define the texture data
  47542. * @param width Define the width of the texture
  47543. * @param height Define the height of the texture
  47544. * @param scene Define the scene the texture belongs to
  47545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47549. * @returns the R texture
  47550. */
  47551. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47552. }
  47553. }
  47554. declare module BABYLON {
  47555. /**
  47556. * Class used to store 3D textures containing user data
  47557. */
  47558. class RawTexture3D extends Texture {
  47559. /** Gets or sets the texture format to use */
  47560. format: number;
  47561. private _engine;
  47562. /**
  47563. * Create a new RawTexture3D
  47564. * @param data defines the data of the texture
  47565. * @param width defines the width of the texture
  47566. * @param height defines the height of the texture
  47567. * @param depth defines the depth of the texture
  47568. * @param format defines the texture format to use
  47569. * @param scene defines the hosting scene
  47570. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47571. * @param invertY defines if texture must be stored with Y axis inverted
  47572. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47573. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47574. */
  47575. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47576. /** Gets or sets the texture format to use */
  47577. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47578. /**
  47579. * Update the texture with new data
  47580. * @param data defines the data to store in the texture
  47581. */
  47582. update(data: ArrayBufferView): void;
  47583. }
  47584. }
  47585. declare module BABYLON {
  47586. /**
  47587. * Creates a refraction texture used by refraction channel of the standard material.
  47588. * It is like a mirror but to see through a material.
  47589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47590. */
  47591. class RefractionTexture extends RenderTargetTexture {
  47592. /**
  47593. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47594. * It is possible to directly set the refractionPlane by directly using a BABYLON.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.
  47595. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47596. */
  47597. refractionPlane: Plane;
  47598. /**
  47599. * Define how deep under the surface we should see.
  47600. */
  47601. depth: number;
  47602. /**
  47603. * Creates a refraction texture used by refraction channel of the standard material.
  47604. * It is like a mirror but to see through a material.
  47605. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47606. * @param name Define the texture name
  47607. * @param size Define the size of the underlying texture
  47608. * @param scene Define the scene the refraction belongs to
  47609. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47610. */
  47611. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47612. /**
  47613. * Clone the refraction texture.
  47614. * @returns the cloned texture
  47615. */
  47616. clone(): RefractionTexture;
  47617. /**
  47618. * Serialize the texture to a JSON representation you could use in Parse later on
  47619. * @returns the serialized JSON representation
  47620. */
  47621. serialize(): any;
  47622. }
  47623. }
  47624. declare module BABYLON {
  47625. /**
  47626. * This Helps creating a texture that will be created from a camera in your scene.
  47627. * It is basically a dynamic texture that could be used to create special effects for instance.
  47628. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47629. */
  47630. class RenderTargetTexture extends Texture {
  47631. isCube: boolean;
  47632. /**
  47633. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47634. */
  47635. static readonly REFRESHRATE_RENDER_ONCE: number;
  47636. /**
  47637. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47638. */
  47639. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47640. /**
  47641. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47642. * the central point of your effect and can save a lot of performances.
  47643. */
  47644. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47645. /**
  47646. * Use this predicate to dynamically define the list of mesh you want to render.
  47647. * If set, the renderList property will be overwritten.
  47648. */
  47649. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47650. private _renderList;
  47651. /**
  47652. * Use this list to define the list of mesh you want to render.
  47653. */
  47654. renderList: Nullable<Array<AbstractMesh>>;
  47655. private _hookArray;
  47656. /**
  47657. * Define if particles should be rendered in your texture.
  47658. */
  47659. renderParticles: boolean;
  47660. /**
  47661. * Define if sprites should be rendered in your texture.
  47662. */
  47663. renderSprites: boolean;
  47664. /**
  47665. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47666. */
  47667. coordinatesMode: number;
  47668. /**
  47669. * Define the camera used to render the texture.
  47670. */
  47671. activeCamera: Nullable<Camera>;
  47672. /**
  47673. * Override the render function of the texture with your own one.
  47674. */
  47675. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47676. /**
  47677. * Define if camera post processes should be use while rendering the texture.
  47678. */
  47679. useCameraPostProcesses: boolean;
  47680. /**
  47681. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47682. */
  47683. ignoreCameraViewport: boolean;
  47684. private _postProcessManager;
  47685. private _postProcesses;
  47686. private _resizeObserver;
  47687. /**
  47688. * An event triggered when the texture is unbind.
  47689. */
  47690. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47691. /**
  47692. * An event triggered when the texture is unbind.
  47693. */
  47694. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47695. private _onAfterUnbindObserver;
  47696. /**
  47697. * Set a after unbind callback in the texture.
  47698. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47699. */
  47700. onAfterUnbind: () => void;
  47701. /**
  47702. * An event triggered before rendering the texture
  47703. */
  47704. onBeforeRenderObservable: Observable<number>;
  47705. private _onBeforeRenderObserver;
  47706. /**
  47707. * Set a before render callback in the texture.
  47708. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47709. */
  47710. onBeforeRender: (faceIndex: number) => void;
  47711. /**
  47712. * An event triggered after rendering the texture
  47713. */
  47714. onAfterRenderObservable: Observable<number>;
  47715. private _onAfterRenderObserver;
  47716. /**
  47717. * Set a after render callback in the texture.
  47718. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47719. */
  47720. onAfterRender: (faceIndex: number) => void;
  47721. /**
  47722. * An event triggered after the texture clear
  47723. */
  47724. onClearObservable: Observable<Engine>;
  47725. private _onClearObserver;
  47726. /**
  47727. * Set a clear callback in the texture.
  47728. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47729. */
  47730. onClear: (Engine: Engine) => void;
  47731. /**
  47732. * Define the clear color of the Render Target if it should be different from the scene.
  47733. */
  47734. clearColor: Color4;
  47735. protected _size: number | {
  47736. width: number;
  47737. height: number;
  47738. };
  47739. protected _initialSizeParameter: number | {
  47740. width: number;
  47741. height: number;
  47742. } | {
  47743. ratio: number;
  47744. };
  47745. protected _sizeRatio: Nullable<number>;
  47746. /** @hidden */
  47747. _generateMipMaps: boolean;
  47748. protected _renderingManager: RenderingManager;
  47749. /** @hidden */
  47750. _waitingRenderList: string[];
  47751. protected _doNotChangeAspectRatio: boolean;
  47752. protected _currentRefreshId: number;
  47753. protected _refreshRate: number;
  47754. protected _textureMatrix: Matrix;
  47755. protected _samples: number;
  47756. protected _renderTargetOptions: RenderTargetCreationOptions;
  47757. /**
  47758. * Gets render target creation options that were used.
  47759. */
  47760. readonly renderTargetOptions: RenderTargetCreationOptions;
  47761. protected _engine: Engine;
  47762. protected _onRatioRescale(): void;
  47763. /**
  47764. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47765. * It must define where the camera used to render the texture is set
  47766. */
  47767. boundingBoxPosition: Vector3;
  47768. private _boundingBoxSize;
  47769. /**
  47770. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47771. * When defined, the cubemap will switch to local mode
  47772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47773. * @example https://www.babylonjs-playground.com/#RNASML
  47774. */
  47775. boundingBoxSize: Vector3;
  47776. /**
  47777. * In case the RTT has been created with a depth texture, get the associated
  47778. * depth texture.
  47779. * Otherwise, return null.
  47780. */
  47781. depthStencilTexture: Nullable<InternalTexture>;
  47782. /**
  47783. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47784. * or used a shadow, depth texture...
  47785. * @param name The friendly name of the texture
  47786. * @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)
  47787. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47788. * @param generateMipMaps True if mip maps need to be generated after render.
  47789. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47790. * @param type The type of the buffer in the RTT (int, half float, float...)
  47791. * @param isCube True if a cube texture needs to be created
  47792. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47793. * @param generateDepthBuffer True to generate a depth buffer
  47794. * @param generateStencilBuffer True to generate a stencil buffer
  47795. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47796. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47797. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47798. */
  47799. constructor(name: string, size: number | {
  47800. width: number;
  47801. height: number;
  47802. } | {
  47803. ratio: number;
  47804. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47805. /**
  47806. * Creates a depth stencil texture.
  47807. * This is only available in WebGL 2 or with the depth texture extension available.
  47808. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47809. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47810. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47811. */
  47812. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47813. private _processSizeParameter;
  47814. /**
  47815. * Define the number of samples to use in case of MSAA.
  47816. * It defaults to one meaning no MSAA has been enabled.
  47817. */
  47818. samples: number;
  47819. /**
  47820. * Resets the refresh counter of the texture and start bak from scratch.
  47821. * Could be useful to regenerate the texture if it is setup to render only once.
  47822. */
  47823. resetRefreshCounter(): void;
  47824. /**
  47825. * Define the refresh rate of the texture or the rendering frequency.
  47826. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47827. */
  47828. refreshRate: number;
  47829. /**
  47830. * Adds a post process to the render target rendering passes.
  47831. * @param postProcess define the post process to add
  47832. */
  47833. addPostProcess(postProcess: PostProcess): void;
  47834. /**
  47835. * Clear all the post processes attached to the render target
  47836. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47837. */
  47838. clearPostProcesses(dispose?: boolean): void;
  47839. /**
  47840. * Remove one of the post process from the list of attached post processes to the texture
  47841. * @param postProcess define the post process to remove from the list
  47842. */
  47843. removePostProcess(postProcess: PostProcess): void;
  47844. /** @hidden */
  47845. _shouldRender(): boolean;
  47846. /**
  47847. * Gets the actual render size of the texture.
  47848. * @returns the width of the render size
  47849. */
  47850. getRenderSize(): number;
  47851. /**
  47852. * Gets the actual render width of the texture.
  47853. * @returns the width of the render size
  47854. */
  47855. getRenderWidth(): number;
  47856. /**
  47857. * Gets the actual render height of the texture.
  47858. * @returns the height of the render size
  47859. */
  47860. getRenderHeight(): number;
  47861. /**
  47862. * Get if the texture can be rescaled or not.
  47863. */
  47864. readonly canRescale: boolean;
  47865. /**
  47866. * Resize the texture using a ratio.
  47867. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47868. */
  47869. scale(ratio: number): void;
  47870. /**
  47871. * Get the texture reflection matrix used to rotate/transform the reflection.
  47872. * @returns the reflection matrix
  47873. */
  47874. getReflectionTextureMatrix(): Matrix;
  47875. /**
  47876. * Resize the texture to a new desired size.
  47877. * Be carrefull as it will recreate all the data in the new texture.
  47878. * @param size Define the new size. It can be:
  47879. * - a number for squared texture,
  47880. * - an object containing { width: number, height: number }
  47881. * - or an object containing a ratio { ratio: number }
  47882. */
  47883. resize(size: number | {
  47884. width: number;
  47885. height: number;
  47886. } | {
  47887. ratio: number;
  47888. }): void;
  47889. /**
  47890. * Renders all the objects from the render list into the texture.
  47891. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47892. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47893. */
  47894. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47895. private _bestReflectionRenderTargetDimension;
  47896. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47897. private renderToTarget;
  47898. /**
  47899. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47900. * This allowed control for front to back rendering or reversly depending of the special needs.
  47901. *
  47902. * @param renderingGroupId The rendering group id corresponding to its index
  47903. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47904. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47905. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47906. */
  47907. 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;
  47908. /**
  47909. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47910. *
  47911. * @param renderingGroupId The rendering group id corresponding to its index
  47912. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47913. */
  47914. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47915. /**
  47916. * Clones the texture.
  47917. * @returns the cloned texture
  47918. */
  47919. clone(): RenderTargetTexture;
  47920. /**
  47921. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47922. * @returns The JSON representation of the texture
  47923. */
  47924. serialize(): any;
  47925. /**
  47926. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47927. */
  47928. disposeFramebufferObjects(): void;
  47929. /**
  47930. * Dispose the texture and release its associated resources.
  47931. */
  47932. dispose(): void;
  47933. /** @hidden */
  47934. _rebuild(): void;
  47935. /**
  47936. * Clear the info related to rendering groups preventing retention point in material dispose.
  47937. */
  47938. freeRenderingGroups(): void;
  47939. }
  47940. }
  47941. declare module BABYLON {
  47942. /**
  47943. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47944. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47945. */
  47946. class Texture extends BaseTexture {
  47947. /** nearest is mag = nearest and min = nearest and mip = linear */
  47948. static readonly NEAREST_SAMPLINGMODE: number;
  47949. /** nearest is mag = nearest and min = nearest and mip = linear */
  47950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47952. static readonly BILINEAR_SAMPLINGMODE: number;
  47953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47955. /** Trilinear is mag = linear and min = linear and mip = linear */
  47956. static readonly TRILINEAR_SAMPLINGMODE: number;
  47957. /** Trilinear is mag = linear and min = linear and mip = linear */
  47958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47959. /** mag = nearest and min = nearest and mip = nearest */
  47960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47961. /** mag = nearest and min = linear and mip = nearest */
  47962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47963. /** mag = nearest and min = linear and mip = linear */
  47964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47965. /** mag = nearest and min = linear and mip = none */
  47966. static readonly NEAREST_LINEAR: number;
  47967. /** mag = nearest and min = nearest and mip = none */
  47968. static readonly NEAREST_NEAREST: number;
  47969. /** mag = linear and min = nearest and mip = nearest */
  47970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47971. /** mag = linear and min = nearest and mip = linear */
  47972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47973. /** mag = linear and min = linear and mip = none */
  47974. static readonly LINEAR_LINEAR: number;
  47975. /** mag = linear and min = nearest and mip = none */
  47976. static readonly LINEAR_NEAREST: number;
  47977. /** Explicit coordinates mode */
  47978. static readonly EXPLICIT_MODE: number;
  47979. /** Spherical coordinates mode */
  47980. static readonly SPHERICAL_MODE: number;
  47981. /** Planar coordinates mode */
  47982. static readonly PLANAR_MODE: number;
  47983. /** Cubic coordinates mode */
  47984. static readonly CUBIC_MODE: number;
  47985. /** Projection coordinates mode */
  47986. static readonly PROJECTION_MODE: number;
  47987. /** Inverse Cubic coordinates mode */
  47988. static readonly SKYBOX_MODE: number;
  47989. /** Inverse Cubic coordinates mode */
  47990. static readonly INVCUBIC_MODE: number;
  47991. /** Equirectangular coordinates mode */
  47992. static readonly EQUIRECTANGULAR_MODE: number;
  47993. /** Equirectangular Fixed coordinates mode */
  47994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47995. /** Equirectangular Fixed Mirrored coordinates mode */
  47996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47997. /** Texture is not repeating outside of 0..1 UVs */
  47998. static readonly CLAMP_ADDRESSMODE: number;
  47999. /** Texture is repeating outside of 0..1 UVs */
  48000. static readonly WRAP_ADDRESSMODE: number;
  48001. /** Texture is repeating and mirrored */
  48002. static readonly MIRROR_ADDRESSMODE: number;
  48003. /**
  48004. * 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
  48005. */
  48006. static UseSerializedUrlIfAny: boolean;
  48007. /**
  48008. * Define the url of the texture.
  48009. */
  48010. url: Nullable<string>;
  48011. /**
  48012. * Define an offset on the texture to offset the u coordinates of the UVs
  48013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48014. */
  48015. uOffset: number;
  48016. /**
  48017. * Define an offset on the texture to offset the v coordinates of the UVs
  48018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48019. */
  48020. vOffset: number;
  48021. /**
  48022. * Define an offset on the texture to scale the u coordinates of the UVs
  48023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48024. */
  48025. uScale: number;
  48026. /**
  48027. * Define an offset on the texture to scale the v coordinates of the UVs
  48028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48029. */
  48030. vScale: number;
  48031. /**
  48032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48033. * @see http://doc.babylonjs.com/how_to/more_materials
  48034. */
  48035. uAng: number;
  48036. /**
  48037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48038. * @see http://doc.babylonjs.com/how_to/more_materials
  48039. */
  48040. vAng: number;
  48041. /**
  48042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48043. * @see http://doc.babylonjs.com/how_to/more_materials
  48044. */
  48045. wAng: number;
  48046. /**
  48047. * Defines the center of rotation (U)
  48048. */
  48049. uRotationCenter: number;
  48050. /**
  48051. * Defines the center of rotation (V)
  48052. */
  48053. vRotationCenter: number;
  48054. /**
  48055. * Defines the center of rotation (W)
  48056. */
  48057. wRotationCenter: number;
  48058. /**
  48059. * Are mip maps generated for this texture or not.
  48060. */
  48061. readonly noMipmap: boolean;
  48062. private _noMipmap;
  48063. /** @hidden */
  48064. _invertY: boolean;
  48065. private _rowGenerationMatrix;
  48066. private _cachedTextureMatrix;
  48067. private _projectionModeMatrix;
  48068. private _t0;
  48069. private _t1;
  48070. private _t2;
  48071. private _cachedUOffset;
  48072. private _cachedVOffset;
  48073. private _cachedUScale;
  48074. private _cachedVScale;
  48075. private _cachedUAng;
  48076. private _cachedVAng;
  48077. private _cachedWAng;
  48078. private _cachedProjectionMatrixId;
  48079. private _cachedCoordinatesMode;
  48080. /** @hidden */
  48081. _samplingMode: number;
  48082. /** @hidden */
  48083. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48084. private _deleteBuffer;
  48085. protected _format: Nullable<number>;
  48086. private _delayedOnLoad;
  48087. private _delayedOnError;
  48088. /**
  48089. * Observable triggered once the texture has been loaded.
  48090. */
  48091. onLoadObservable: Observable<Texture>;
  48092. protected _isBlocking: boolean;
  48093. /**
  48094. * Is the texture preventing material to render while loading.
  48095. * If false, a default texture will be used instead of the loading one during the preparation step.
  48096. */
  48097. isBlocking: boolean;
  48098. /**
  48099. * Get the current sampling mode associated with the texture.
  48100. */
  48101. readonly samplingMode: number;
  48102. /**
  48103. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48104. */
  48105. readonly invertY: boolean;
  48106. /**
  48107. * Instantiates a new texture.
  48108. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48109. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48110. * @param url define the url of the picture to load as a texture
  48111. * @param scene define the scene the texture will belong to
  48112. * @param noMipmap define if the texture will require mip maps or not
  48113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48115. * @param onLoad define a callback triggered when the texture has been loaded
  48116. * @param onError define a callback triggered when an error occurred during the loading session
  48117. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48118. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48119. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48120. */
  48121. 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);
  48122. /**
  48123. * Update the url (and optional buffer) of this texture if url was null during construction.
  48124. * @param url the url of the texture
  48125. * @param buffer the buffer of the texture (defaults to null)
  48126. */
  48127. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  48128. /**
  48129. * Finish the loading sequence of a texture flagged as delayed load.
  48130. * @hidden
  48131. */
  48132. delayLoad(): void;
  48133. /**
  48134. * Update the sampling mode of the texture.
  48135. * Default is Trilinear mode.
  48136. *
  48137. * | Value | Type | Description |
  48138. * | ----- | ------------------ | ----------- |
  48139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  48140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  48141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  48142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  48143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  48144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  48145. * | 7 | NEAREST_LINEAR | |
  48146. * | 8 | NEAREST_NEAREST | |
  48147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  48148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  48149. * | 11 | LINEAR_LINEAR | |
  48150. * | 12 | LINEAR_NEAREST | |
  48151. *
  48152. * > _mag_: magnification filter (close to the viewer)
  48153. * > _min_: minification filter (far from the viewer)
  48154. * > _mip_: filter used between mip map levels
  48155. *@param samplingMode Define the new sampling mode of the texture
  48156. */
  48157. updateSamplingMode(samplingMode: number): void;
  48158. private _prepareRowForTextureGeneration;
  48159. /**
  48160. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48161. * @returns the transform matrix of the texture.
  48162. */
  48163. getTextureMatrix(): Matrix;
  48164. /**
  48165. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48166. * @returns The reflection texture transform
  48167. */
  48168. getReflectionTextureMatrix(): Matrix;
  48169. /**
  48170. * Clones the texture.
  48171. * @returns the cloned texture
  48172. */
  48173. clone(): Texture;
  48174. /**
  48175. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48176. * @returns The JSON representation of the texture
  48177. */
  48178. serialize(): any;
  48179. /**
  48180. * Get the current class name of the texture useful for serialization or dynamic coding.
  48181. * @returns "Texture"
  48182. */
  48183. getClassName(): string;
  48184. /**
  48185. * Dispose the texture and release its associated resources.
  48186. */
  48187. dispose(): void;
  48188. /**
  48189. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48190. * @param parsedTexture Define the JSON representation of the texture
  48191. * @param scene Define the scene the parsed texture should be instantiated in
  48192. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48193. * @returns The parsed texture if successful
  48194. */
  48195. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48196. /**
  48197. * Creates a texture from its base 64 representation.
  48198. * @param data Define the base64 payload without the data: prefix
  48199. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48200. * @param scene Define the scene the texture should belong to
  48201. * @param noMipmap Forces the texture to not create mip map information if true
  48202. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48203. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48204. * @param onLoad define a callback triggered when the texture has been loaded
  48205. * @param onError define a callback triggered when an error occurred during the loading session
  48206. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48207. * @returns the created texture
  48208. */
  48209. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48210. /**
  48211. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48212. * @param data Define the base64 payload without the data: prefix
  48213. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48214. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48215. * @param scene Define the scene the texture should belong to
  48216. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48217. * @param noMipmap Forces the texture to not create mip map information if true
  48218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48220. * @param onLoad define a callback triggered when the texture has been loaded
  48221. * @param onError define a callback triggered when an error occurred during the loading session
  48222. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48223. * @returns the created texture
  48224. */
  48225. 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;
  48226. }
  48227. }
  48228. declare module BABYLON {
  48229. /**
  48230. * Settings for finer control over video usage
  48231. */
  48232. interface VideoTextureSettings {
  48233. /**
  48234. * Applies `autoplay` to video, if specified
  48235. */
  48236. autoPlay?: boolean;
  48237. /**
  48238. * Applies `loop` to video, if specified
  48239. */
  48240. loop?: boolean;
  48241. /**
  48242. * Automatically updates internal texture from video at every frame in the render loop
  48243. */
  48244. autoUpdateTexture: boolean;
  48245. /**
  48246. * Image src displayed during the video loading or until the user interacts with the video.
  48247. */
  48248. poster?: string;
  48249. }
  48250. /**
  48251. * If you want to display a video in your scene, this is the special texture for that.
  48252. * This special texture works similar to other textures, with the exception of a few parameters.
  48253. * @see https://doc.babylonjs.com/how_to/video_texture
  48254. */
  48255. class VideoTexture extends Texture {
  48256. /**
  48257. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48258. */
  48259. readonly autoUpdateTexture: boolean;
  48260. /**
  48261. * The video instance used by the texture internally
  48262. */
  48263. readonly video: HTMLVideoElement;
  48264. private _onUserActionRequestedObservable;
  48265. /**
  48266. * Event triggerd when a dom action is required by the user to play the video.
  48267. * This happens due to recent changes in browser policies preventing video to auto start.
  48268. */
  48269. readonly onUserActionRequestedObservable: Observable<Texture>;
  48270. private _generateMipMaps;
  48271. private _engine;
  48272. private _stillImageCaptured;
  48273. private _displayingPosterTexture;
  48274. private _settings;
  48275. private _createInternalTextureOnEvent;
  48276. /**
  48277. * Creates a video texture.
  48278. * If you want to display a video in your scene, this is the special texture for that.
  48279. * This special texture works similar to other textures, with the exception of a few parameters.
  48280. * @see https://doc.babylonjs.com/how_to/video_texture
  48281. * @param name optional name, will detect from video source, if not defined
  48282. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48283. * @param scene is obviously the current scene.
  48284. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48285. * @param invertY is false by default but can be used to invert video on Y axis
  48286. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48287. * @param settings allows finer control over video usage
  48288. */
  48289. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48290. private _getName;
  48291. private _getVideo;
  48292. private _createInternalTexture;
  48293. private reset;
  48294. /**
  48295. * @hidden Internal method to initiate `update`.
  48296. */
  48297. _rebuild(): void;
  48298. /**
  48299. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48300. */
  48301. update(): void;
  48302. /**
  48303. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48304. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48305. */
  48306. updateTexture(isVisible: boolean): void;
  48307. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48308. /**
  48309. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48310. * @param url New url.
  48311. */
  48312. updateURL(url: string): void;
  48313. /**
  48314. * Dispose the texture and release its associated resources.
  48315. */
  48316. dispose(): void;
  48317. /**
  48318. * Creates a video texture straight from your WebCam video feed.
  48319. * @param scene Define the scene the texture should be created in
  48320. * @param onReady Define a callback to triggered once the texture will be ready
  48321. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48322. */
  48323. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48324. minWidth: number;
  48325. maxWidth: number;
  48326. minHeight: number;
  48327. maxHeight: number;
  48328. deviceId: string;
  48329. }): void;
  48330. }
  48331. }
  48332. declare var DracoDecoderModule: any;
  48333. declare var WebAssembly: any;
  48334. declare module BABYLON {
  48335. /**
  48336. * Configuration for Draco compression
  48337. */
  48338. interface IDracoCompressionConfiguration {
  48339. /**
  48340. * Configuration for the decoder.
  48341. */
  48342. decoder?: {
  48343. /**
  48344. * The url to the WebAssembly module.
  48345. */
  48346. wasmUrl?: string;
  48347. /**
  48348. * The url to the WebAssembly binary.
  48349. */
  48350. wasmBinaryUrl?: string;
  48351. /**
  48352. * The url to the fallback JavaScript module.
  48353. */
  48354. fallbackUrl?: string;
  48355. };
  48356. }
  48357. /**
  48358. * Draco compression (https://google.github.io/draco/)
  48359. *
  48360. * This class wraps the Draco module.
  48361. *
  48362. * **Encoder**
  48363. *
  48364. * The encoder is not currently implemented.
  48365. *
  48366. * **Decoder**
  48367. *
  48368. * 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.
  48369. *
  48370. * To update the configuration, use the following code:
  48371. * ```javascript
  48372. * BABYLON.DracoCompression.Configuration = {
  48373. * decoder: {
  48374. * wasmUrl: "<url to the WebAssembly library>",
  48375. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48376. * fallbackUrl: "<url to the fallback JavaScript library>",
  48377. * }
  48378. * };
  48379. * ```
  48380. *
  48381. * 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.
  48382. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48383. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48384. *
  48385. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48386. * ```javascript
  48387. * var dracoCompression = new BABYLON.DracoCompression();
  48388. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48389. * [BABYLON.VertexBuffer.PositionKind]: 0
  48390. * });
  48391. * ```
  48392. *
  48393. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48394. */
  48395. class DracoCompression implements IDisposable {
  48396. private static _DecoderModulePromise;
  48397. /**
  48398. * The configuration. Defaults to the following urls:
  48399. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48400. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48401. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48402. */
  48403. static Configuration: IDracoCompressionConfiguration;
  48404. /**
  48405. * Returns true if the decoder is available.
  48406. */
  48407. static readonly DecoderAvailable: boolean;
  48408. /**
  48409. * Constructor
  48410. */
  48411. constructor();
  48412. /**
  48413. * Stop all async operations and release resources.
  48414. */
  48415. dispose(): void;
  48416. /**
  48417. * Decode Draco compressed mesh data to vertex data.
  48418. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48419. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48420. * @returns A promise that resolves with the decoded vertex data
  48421. */
  48422. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48423. [kind: string]: number;
  48424. }): Promise<VertexData>;
  48425. private static _GetDecoderModule;
  48426. private static _LoadScriptAsync;
  48427. private static _LoadFileAsync;
  48428. }
  48429. }
  48430. declare module BABYLON {
  48431. /**
  48432. * Particle emitter emitting particles from the inside of a box.
  48433. * It emits the particles randomly between 2 given directions.
  48434. */
  48435. class BoxParticleEmitter implements IParticleEmitterType {
  48436. /**
  48437. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48438. */
  48439. direction1: Vector3;
  48440. /**
  48441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48442. */
  48443. direction2: Vector3;
  48444. /**
  48445. * 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.
  48446. */
  48447. minEmitBox: Vector3;
  48448. /**
  48449. * 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.
  48450. */
  48451. maxEmitBox: Vector3;
  48452. /**
  48453. * Creates a new instance BoxParticleEmitter
  48454. */
  48455. constructor();
  48456. /**
  48457. * Called by the particle System when the direction is computed for the created particle.
  48458. * @param worldMatrix is the world matrix of the particle system
  48459. * @param directionToUpdate is the direction vector to update with the result
  48460. * @param particle is the particle we are computed the direction for
  48461. */
  48462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48463. /**
  48464. * Called by the particle System when the position is computed for the created particle.
  48465. * @param worldMatrix is the world matrix of the particle system
  48466. * @param positionToUpdate is the position vector to update with the result
  48467. * @param particle is the particle we are computed the position for
  48468. */
  48469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48470. /**
  48471. * Clones the current emitter and returns a copy of it
  48472. * @returns the new emitter
  48473. */
  48474. clone(): BoxParticleEmitter;
  48475. /**
  48476. * Called by the GPUParticleSystem to setup the update shader
  48477. * @param effect defines the update shader
  48478. */
  48479. applyToShader(effect: Effect): void;
  48480. /**
  48481. * Returns a string to use to update the GPU particles update shader
  48482. * @returns a string containng the defines string
  48483. */
  48484. getEffectDefines(): string;
  48485. /**
  48486. * Returns the string "BoxParticleEmitter"
  48487. * @returns a string containing the class name
  48488. */
  48489. getClassName(): string;
  48490. /**
  48491. * Serializes the particle system to a JSON object.
  48492. * @returns the JSON object
  48493. */
  48494. serialize(): any;
  48495. /**
  48496. * Parse properties from a JSON object
  48497. * @param serializationObject defines the JSON object
  48498. */
  48499. parse(serializationObject: any): void;
  48500. }
  48501. }
  48502. declare module BABYLON {
  48503. /**
  48504. * Particle emitter emitting particles from the inside of a cone.
  48505. * It emits the particles alongside the cone volume from the base to the particle.
  48506. * The emission direction might be randomized.
  48507. */
  48508. class ConeParticleEmitter implements IParticleEmitterType {
  48509. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48510. directionRandomizer: number;
  48511. private _radius;
  48512. private _angle;
  48513. private _height;
  48514. /**
  48515. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48516. */
  48517. radiusRange: number;
  48518. /**
  48519. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48520. */
  48521. heightRange: number;
  48522. /**
  48523. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48524. */
  48525. emitFromSpawnPointOnly: boolean;
  48526. /**
  48527. * Gets or sets the radius of the emission cone
  48528. */
  48529. radius: number;
  48530. /**
  48531. * Gets or sets the angle of the emission cone
  48532. */
  48533. angle: number;
  48534. private _buildHeight;
  48535. /**
  48536. * Creates a new instance ConeParticleEmitter
  48537. * @param radius the radius of the emission cone (1 by default)
  48538. * @param angles the cone base angle (PI by default)
  48539. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48540. */
  48541. constructor(radius?: number, angle?: number,
  48542. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48543. directionRandomizer?: number);
  48544. /**
  48545. * Called by the particle System when the direction is computed for the created particle.
  48546. * @param worldMatrix is the world matrix of the particle system
  48547. * @param directionToUpdate is the direction vector to update with the result
  48548. * @param particle is the particle we are computed the direction for
  48549. */
  48550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48551. /**
  48552. * Called by the particle System when the position is computed for the created particle.
  48553. * @param worldMatrix is the world matrix of the particle system
  48554. * @param positionToUpdate is the position vector to update with the result
  48555. * @param particle is the particle we are computed the position for
  48556. */
  48557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48558. /**
  48559. * Clones the current emitter and returns a copy of it
  48560. * @returns the new emitter
  48561. */
  48562. clone(): ConeParticleEmitter;
  48563. /**
  48564. * Called by the GPUParticleSystem to setup the update shader
  48565. * @param effect defines the update shader
  48566. */
  48567. applyToShader(effect: Effect): void;
  48568. /**
  48569. * Returns a string to use to update the GPU particles update shader
  48570. * @returns a string containng the defines string
  48571. */
  48572. getEffectDefines(): string;
  48573. /**
  48574. * Returns the string "ConeParticleEmitter"
  48575. * @returns a string containing the class name
  48576. */
  48577. getClassName(): string;
  48578. /**
  48579. * Serializes the particle system to a JSON object.
  48580. * @returns the JSON object
  48581. */
  48582. serialize(): any;
  48583. /**
  48584. * Parse properties from a JSON object
  48585. * @param serializationObject defines the JSON object
  48586. */
  48587. parse(serializationObject: any): void;
  48588. }
  48589. }
  48590. declare module BABYLON {
  48591. /**
  48592. * Particle emitter emitting particles from the inside of a cylinder.
  48593. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48594. */
  48595. class CylinderParticleEmitter implements IParticleEmitterType {
  48596. /**
  48597. * The radius of the emission cylinder.
  48598. */
  48599. radius: number;
  48600. /**
  48601. * The height of the emission cylinder.
  48602. */
  48603. height: number;
  48604. /**
  48605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48606. */
  48607. radiusRange: number;
  48608. /**
  48609. * How much to randomize the particle direction [0-1].
  48610. */
  48611. directionRandomizer: number;
  48612. /**
  48613. * Creates a new instance CylinderParticleEmitter
  48614. * @param radius the radius of the emission cylinder (1 by default)
  48615. * @param height the height of the emission cylinder (1 by default)
  48616. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48617. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48618. */
  48619. constructor(
  48620. /**
  48621. * The radius of the emission cylinder.
  48622. */
  48623. radius?: number,
  48624. /**
  48625. * The height of the emission cylinder.
  48626. */
  48627. height?: number,
  48628. /**
  48629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48630. */
  48631. radiusRange?: number,
  48632. /**
  48633. * How much to randomize the particle direction [0-1].
  48634. */
  48635. directionRandomizer?: number);
  48636. /**
  48637. * Called by the particle System when the direction is computed for the created particle.
  48638. * @param worldMatrix is the world matrix of the particle system
  48639. * @param directionToUpdate is the direction vector to update with the result
  48640. * @param particle is the particle we are computed the direction for
  48641. */
  48642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48643. /**
  48644. * Called by the particle System when the position is computed for the created particle.
  48645. * @param worldMatrix is the world matrix of the particle system
  48646. * @param positionToUpdate is the position vector to update with the result
  48647. * @param particle is the particle we are computed the position for
  48648. */
  48649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48650. /**
  48651. * Clones the current emitter and returns a copy of it
  48652. * @returns the new emitter
  48653. */
  48654. clone(): CylinderParticleEmitter;
  48655. /**
  48656. * Called by the GPUParticleSystem to setup the update shader
  48657. * @param effect defines the update shader
  48658. */
  48659. applyToShader(effect: Effect): void;
  48660. /**
  48661. * Returns a string to use to update the GPU particles update shader
  48662. * @returns a string containng the defines string
  48663. */
  48664. getEffectDefines(): string;
  48665. /**
  48666. * Returns the string "CylinderParticleEmitter"
  48667. * @returns a string containing the class name
  48668. */
  48669. getClassName(): string;
  48670. /**
  48671. * Serializes the particle system to a JSON object.
  48672. * @returns the JSON object
  48673. */
  48674. serialize(): any;
  48675. /**
  48676. * Parse properties from a JSON object
  48677. * @param serializationObject defines the JSON object
  48678. */
  48679. parse(serializationObject: any): void;
  48680. }
  48681. /**
  48682. * Particle emitter emitting particles from the inside of a cylinder.
  48683. * It emits the particles randomly between two vectors.
  48684. */
  48685. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48686. /**
  48687. * The min limit of the emission direction.
  48688. */
  48689. direction1: Vector3;
  48690. /**
  48691. * The max limit of the emission direction.
  48692. */
  48693. direction2: Vector3;
  48694. /**
  48695. * Creates a new instance CylinderDirectedParticleEmitter
  48696. * @param radius the radius of the emission cylinder (1 by default)
  48697. * @param height the height of the emission cylinder (1 by default)
  48698. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48699. * @param direction1 the min limit of the emission direction (up vector by default)
  48700. * @param direction2 the max limit of the emission direction (up vector by default)
  48701. */
  48702. constructor(radius?: number, height?: number, radiusRange?: number,
  48703. /**
  48704. * The min limit of the emission direction.
  48705. */
  48706. direction1?: Vector3,
  48707. /**
  48708. * The max limit of the emission direction.
  48709. */
  48710. direction2?: Vector3);
  48711. /**
  48712. * Called by the particle System when the direction is computed for the created particle.
  48713. * @param worldMatrix is the world matrix of the particle system
  48714. * @param directionToUpdate is the direction vector to update with the result
  48715. * @param particle is the particle we are computed the direction for
  48716. */
  48717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48718. /**
  48719. * Clones the current emitter and returns a copy of it
  48720. * @returns the new emitter
  48721. */
  48722. clone(): CylinderDirectedParticleEmitter;
  48723. /**
  48724. * Called by the GPUParticleSystem to setup the update shader
  48725. * @param effect defines the update shader
  48726. */
  48727. applyToShader(effect: Effect): void;
  48728. /**
  48729. * Returns a string to use to update the GPU particles update shader
  48730. * @returns a string containng the defines string
  48731. */
  48732. getEffectDefines(): string;
  48733. /**
  48734. * Returns the string "CylinderDirectedParticleEmitter"
  48735. * @returns a string containing the class name
  48736. */
  48737. getClassName(): string;
  48738. /**
  48739. * Serializes the particle system to a JSON object.
  48740. * @returns the JSON object
  48741. */
  48742. serialize(): any;
  48743. /**
  48744. * Parse properties from a JSON object
  48745. * @param serializationObject defines the JSON object
  48746. */
  48747. parse(serializationObject: any): void;
  48748. }
  48749. }
  48750. declare module BABYLON {
  48751. /**
  48752. * Particle emitter emitting particles from the inside of a hemisphere.
  48753. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48754. */
  48755. class HemisphericParticleEmitter implements IParticleEmitterType {
  48756. /**
  48757. * The radius of the emission hemisphere.
  48758. */
  48759. radius: number;
  48760. /**
  48761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48762. */
  48763. radiusRange: number;
  48764. /**
  48765. * How much to randomize the particle direction [0-1].
  48766. */
  48767. directionRandomizer: number;
  48768. /**
  48769. * Creates a new instance HemisphericParticleEmitter
  48770. * @param radius the radius of the emission hemisphere (1 by default)
  48771. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48773. */
  48774. constructor(
  48775. /**
  48776. * The radius of the emission hemisphere.
  48777. */
  48778. radius?: number,
  48779. /**
  48780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48781. */
  48782. radiusRange?: number,
  48783. /**
  48784. * How much to randomize the particle direction [0-1].
  48785. */
  48786. directionRandomizer?: number);
  48787. /**
  48788. * Called by the particle System when the direction is computed for the created particle.
  48789. * @param worldMatrix is the world matrix of the particle system
  48790. * @param directionToUpdate is the direction vector to update with the result
  48791. * @param particle is the particle we are computed the direction for
  48792. */
  48793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48794. /**
  48795. * Called by the particle System when the position is computed for the created particle.
  48796. * @param worldMatrix is the world matrix of the particle system
  48797. * @param positionToUpdate is the position vector to update with the result
  48798. * @param particle is the particle we are computed the position for
  48799. */
  48800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48801. /**
  48802. * Clones the current emitter and returns a copy of it
  48803. * @returns the new emitter
  48804. */
  48805. clone(): HemisphericParticleEmitter;
  48806. /**
  48807. * Called by the GPUParticleSystem to setup the update shader
  48808. * @param effect defines the update shader
  48809. */
  48810. applyToShader(effect: Effect): void;
  48811. /**
  48812. * Returns a string to use to update the GPU particles update shader
  48813. * @returns a string containng the defines string
  48814. */
  48815. getEffectDefines(): string;
  48816. /**
  48817. * Returns the string "HemisphericParticleEmitter"
  48818. * @returns a string containing the class name
  48819. */
  48820. getClassName(): string;
  48821. /**
  48822. * Serializes the particle system to a JSON object.
  48823. * @returns the JSON object
  48824. */
  48825. serialize(): any;
  48826. /**
  48827. * Parse properties from a JSON object
  48828. * @param serializationObject defines the JSON object
  48829. */
  48830. parse(serializationObject: any): void;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * Particle emitter represents a volume emitting particles.
  48836. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48837. */
  48838. interface IParticleEmitterType {
  48839. /**
  48840. * Called by the particle System when the direction is computed for the created particle.
  48841. * @param worldMatrix is the world matrix of the particle system
  48842. * @param directionToUpdate is the direction vector to update with the result
  48843. * @param particle is the particle we are computed the direction for
  48844. */
  48845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48846. /**
  48847. * Called by the particle System when the position is computed for the created particle.
  48848. * @param worldMatrix is the world matrix of the particle system
  48849. * @param positionToUpdate is the position vector to update with the result
  48850. * @param particle is the particle we are computed the position for
  48851. */
  48852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48853. /**
  48854. * Clones the current emitter and returns a copy of it
  48855. * @returns the new emitter
  48856. */
  48857. clone(): IParticleEmitterType;
  48858. /**
  48859. * Called by the GPUParticleSystem to setup the update shader
  48860. * @param effect defines the update shader
  48861. */
  48862. applyToShader(effect: Effect): void;
  48863. /**
  48864. * Returns a string to use to update the GPU particles update shader
  48865. * @returns the effect defines string
  48866. */
  48867. getEffectDefines(): string;
  48868. /**
  48869. * Returns a string representing the class name
  48870. * @returns a string containing the class name
  48871. */
  48872. getClassName(): string;
  48873. /**
  48874. * Serializes the particle system to a JSON object.
  48875. * @returns the JSON object
  48876. */
  48877. serialize(): any;
  48878. /**
  48879. * Parse properties from a JSON object
  48880. * @param serializationObject defines the JSON object
  48881. */
  48882. parse(serializationObject: any): void;
  48883. }
  48884. }
  48885. declare module BABYLON {
  48886. /**
  48887. * Particle emitter emitting particles from a point.
  48888. * It emits the particles randomly between 2 given directions.
  48889. */
  48890. class PointParticleEmitter implements IParticleEmitterType {
  48891. /**
  48892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48893. */
  48894. direction1: Vector3;
  48895. /**
  48896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48897. */
  48898. direction2: Vector3;
  48899. /**
  48900. * Creates a new instance PointParticleEmitter
  48901. */
  48902. constructor();
  48903. /**
  48904. * Called by the particle System when the direction is computed for the created particle.
  48905. * @param worldMatrix is the world matrix of the particle system
  48906. * @param directionToUpdate is the direction vector to update with the result
  48907. * @param particle is the particle we are computed the direction for
  48908. */
  48909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48910. /**
  48911. * Called by the particle System when the position is computed for the created particle.
  48912. * @param worldMatrix is the world matrix of the particle system
  48913. * @param positionToUpdate is the position vector to update with the result
  48914. * @param particle is the particle we are computed the position for
  48915. */
  48916. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48917. /**
  48918. * Clones the current emitter and returns a copy of it
  48919. * @returns the new emitter
  48920. */
  48921. clone(): PointParticleEmitter;
  48922. /**
  48923. * Called by the GPUParticleSystem to setup the update shader
  48924. * @param effect defines the update shader
  48925. */
  48926. applyToShader(effect: Effect): void;
  48927. /**
  48928. * Returns a string to use to update the GPU particles update shader
  48929. * @returns a string containng the defines string
  48930. */
  48931. getEffectDefines(): string;
  48932. /**
  48933. * Returns the string "PointParticleEmitter"
  48934. * @returns a string containing the class name
  48935. */
  48936. getClassName(): string;
  48937. /**
  48938. * Serializes the particle system to a JSON object.
  48939. * @returns the JSON object
  48940. */
  48941. serialize(): any;
  48942. /**
  48943. * Parse properties from a JSON object
  48944. * @param serializationObject defines the JSON object
  48945. */
  48946. parse(serializationObject: any): void;
  48947. }
  48948. }
  48949. declare module BABYLON {
  48950. /**
  48951. * Particle emitter emitting particles from the inside of a sphere.
  48952. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48953. */
  48954. class SphereParticleEmitter implements IParticleEmitterType {
  48955. /**
  48956. * The radius of the emission sphere.
  48957. */
  48958. radius: number;
  48959. /**
  48960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48961. */
  48962. radiusRange: number;
  48963. /**
  48964. * How much to randomize the particle direction [0-1].
  48965. */
  48966. directionRandomizer: number;
  48967. /**
  48968. * Creates a new instance SphereParticleEmitter
  48969. * @param radius the radius of the emission sphere (1 by default)
  48970. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48972. */
  48973. constructor(
  48974. /**
  48975. * The radius of the emission sphere.
  48976. */
  48977. radius?: number,
  48978. /**
  48979. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48980. */
  48981. radiusRange?: number,
  48982. /**
  48983. * How much to randomize the particle direction [0-1].
  48984. */
  48985. directionRandomizer?: number);
  48986. /**
  48987. * Called by the particle System when the direction is computed for the created particle.
  48988. * @param worldMatrix is the world matrix of the particle system
  48989. * @param directionToUpdate is the direction vector to update with the result
  48990. * @param particle is the particle we are computed the direction for
  48991. */
  48992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48993. /**
  48994. * Called by the particle System when the position is computed for the created particle.
  48995. * @param worldMatrix is the world matrix of the particle system
  48996. * @param positionToUpdate is the position vector to update with the result
  48997. * @param particle is the particle we are computed the position for
  48998. */
  48999. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49000. /**
  49001. * Clones the current emitter and returns a copy of it
  49002. * @returns the new emitter
  49003. */
  49004. clone(): SphereParticleEmitter;
  49005. /**
  49006. * Called by the GPUParticleSystem to setup the update shader
  49007. * @param effect defines the update shader
  49008. */
  49009. applyToShader(effect: Effect): void;
  49010. /**
  49011. * Returns a string to use to update the GPU particles update shader
  49012. * @returns a string containng the defines string
  49013. */
  49014. getEffectDefines(): string;
  49015. /**
  49016. * Returns the string "SphereParticleEmitter"
  49017. * @returns a string containing the class name
  49018. */
  49019. getClassName(): string;
  49020. /**
  49021. * Serializes the particle system to a JSON object.
  49022. * @returns the JSON object
  49023. */
  49024. serialize(): any;
  49025. /**
  49026. * Parse properties from a JSON object
  49027. * @param serializationObject defines the JSON object
  49028. */
  49029. parse(serializationObject: any): void;
  49030. }
  49031. /**
  49032. * Particle emitter emitting particles from the inside of a sphere.
  49033. * It emits the particles randomly between two vectors.
  49034. */
  49035. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49036. /**
  49037. * The min limit of the emission direction.
  49038. */
  49039. direction1: Vector3;
  49040. /**
  49041. * The max limit of the emission direction.
  49042. */
  49043. direction2: Vector3;
  49044. /**
  49045. * Creates a new instance SphereDirectedParticleEmitter
  49046. * @param radius the radius of the emission sphere (1 by default)
  49047. * @param direction1 the min limit of the emission direction (up vector by default)
  49048. * @param direction2 the max limit of the emission direction (up vector by default)
  49049. */
  49050. constructor(radius?: number,
  49051. /**
  49052. * The min limit of the emission direction.
  49053. */
  49054. direction1?: Vector3,
  49055. /**
  49056. * The max limit of the emission direction.
  49057. */
  49058. direction2?: Vector3);
  49059. /**
  49060. * Called by the particle System when the direction is computed for the created particle.
  49061. * @param worldMatrix is the world matrix of the particle system
  49062. * @param directionToUpdate is the direction vector to update with the result
  49063. * @param particle is the particle we are computed the direction for
  49064. */
  49065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49066. /**
  49067. * Clones the current emitter and returns a copy of it
  49068. * @returns the new emitter
  49069. */
  49070. clone(): SphereDirectedParticleEmitter;
  49071. /**
  49072. * Called by the GPUParticleSystem to setup the update shader
  49073. * @param effect defines the update shader
  49074. */
  49075. applyToShader(effect: Effect): void;
  49076. /**
  49077. * Returns a string to use to update the GPU particles update shader
  49078. * @returns a string containng the defines string
  49079. */
  49080. getEffectDefines(): string;
  49081. /**
  49082. * Returns the string "SphereDirectedParticleEmitter"
  49083. * @returns a string containing the class name
  49084. */
  49085. getClassName(): string;
  49086. /**
  49087. * Serializes the particle system to a JSON object.
  49088. * @returns the JSON object
  49089. */
  49090. serialize(): any;
  49091. /**
  49092. * Parse properties from a JSON object
  49093. * @param serializationObject defines the JSON object
  49094. */
  49095. parse(serializationObject: any): void;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /** @hidden */
  49100. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49101. private _useDeltaForWorldStep;
  49102. world: any;
  49103. name: string;
  49104. private _physicsMaterials;
  49105. private _fixedTimeStep;
  49106. BJSCANNON: any;
  49107. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49108. setGravity(gravity: Vector3): void;
  49109. setTimeStep(timeStep: number): void;
  49110. getTimeStep(): number;
  49111. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49112. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49113. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49114. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49115. private _processChildMeshes;
  49116. removePhysicsBody(impostor: PhysicsImpostor): void;
  49117. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49118. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49119. private _addMaterial;
  49120. private _checkWithEpsilon;
  49121. private _createShape;
  49122. private _createHeightmap;
  49123. private _minus90X;
  49124. private _plus90X;
  49125. private _tmpPosition;
  49126. private _tmpDeltaPosition;
  49127. private _tmpUnityRotation;
  49128. private _updatePhysicsBodyTransformation;
  49129. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49130. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49131. isSupported(): boolean;
  49132. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49133. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49134. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49135. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49136. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49137. getBodyMass(impostor: PhysicsImpostor): number;
  49138. getBodyFriction(impostor: PhysicsImpostor): number;
  49139. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49140. getBodyRestitution(impostor: PhysicsImpostor): number;
  49141. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49142. sleepBody(impostor: PhysicsImpostor): void;
  49143. wakeUpBody(impostor: PhysicsImpostor): void;
  49144. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49145. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49146. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49147. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49148. getRadius(impostor: PhysicsImpostor): number;
  49149. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49150. dispose(): void;
  49151. private _extendNamespace;
  49152. }
  49153. }
  49154. declare module BABYLON {
  49155. /** @hidden */
  49156. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49157. world: any;
  49158. name: string;
  49159. BJSOIMO: any;
  49160. constructor(iterations?: number);
  49161. setGravity(gravity: Vector3): void;
  49162. setTimeStep(timeStep: number): void;
  49163. getTimeStep(): number;
  49164. private _tmpImpostorsArray;
  49165. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49166. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49167. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49168. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49169. private _tmpPositionVector;
  49170. removePhysicsBody(impostor: PhysicsImpostor): void;
  49171. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49172. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49173. isSupported(): boolean;
  49174. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49175. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49177. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49179. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49180. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49181. getBodyMass(impostor: PhysicsImpostor): number;
  49182. getBodyFriction(impostor: PhysicsImpostor): number;
  49183. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49184. getBodyRestitution(impostor: PhysicsImpostor): number;
  49185. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49186. sleepBody(impostor: PhysicsImpostor): void;
  49187. wakeUpBody(impostor: PhysicsImpostor): void;
  49188. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49189. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49190. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49191. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49192. getRadius(impostor: PhysicsImpostor): number;
  49193. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49194. dispose(): void;
  49195. }
  49196. }
  49197. declare module BABYLON {
  49198. /**
  49199. * This represents a set of one or more post processes in Babylon.
  49200. * A post process can be used to apply a shader to a texture after it is rendered.
  49201. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49202. */
  49203. class PostProcessRenderEffect {
  49204. private _postProcesses;
  49205. private _getPostProcesses;
  49206. private _singleInstance;
  49207. private _cameras;
  49208. private _indicesForCamera;
  49209. /**
  49210. * Name of the effect
  49211. * @hidden
  49212. */
  49213. _name: string;
  49214. /**
  49215. * Instantiates a post process render effect.
  49216. * A post process can be used to apply a shader to a texture after it is rendered.
  49217. * @param engine The engine the effect is tied to
  49218. * @param name The name of the effect
  49219. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49220. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49221. */
  49222. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49223. /**
  49224. * Checks if all the post processes in the effect are supported.
  49225. */
  49226. readonly isSupported: boolean;
  49227. /**
  49228. * Updates the current state of the effect
  49229. * @hidden
  49230. */
  49231. _update(): void;
  49232. /**
  49233. * Attaches the effect on cameras
  49234. * @param cameras The camera to attach to.
  49235. * @hidden
  49236. */
  49237. _attachCameras(cameras: Camera): void;
  49238. /**
  49239. * Attaches the effect on cameras
  49240. * @param cameras The camera to attach to.
  49241. * @hidden
  49242. */
  49243. _attachCameras(cameras: Camera[]): void;
  49244. /**
  49245. * Detatches the effect on cameras
  49246. * @param cameras The camera to detatch from.
  49247. * @hidden
  49248. */
  49249. _detachCameras(cameras: Camera): void;
  49250. /**
  49251. * Detatches the effect on cameras
  49252. * @param cameras The camera to detatch from.
  49253. * @hidden
  49254. */
  49255. _detachCameras(cameras: Camera[]): void;
  49256. /**
  49257. * Enables the effect on given cameras
  49258. * @param cameras The camera to enable.
  49259. * @hidden
  49260. */
  49261. _enable(cameras: Camera): void;
  49262. /**
  49263. * Enables the effect on given cameras
  49264. * @param cameras The camera to enable.
  49265. * @hidden
  49266. */
  49267. _enable(cameras: Nullable<Camera[]>): void;
  49268. /**
  49269. * Disables the effect on the given cameras
  49270. * @param cameras The camera to disable.
  49271. * @hidden
  49272. */
  49273. _disable(cameras: Camera): void;
  49274. /**
  49275. * Disables the effect on the given cameras
  49276. * @param cameras The camera to disable.
  49277. * @hidden
  49278. */
  49279. _disable(cameras: Nullable<Camera[]>): void;
  49280. /**
  49281. * Gets a list of the post processes contained in the effect.
  49282. * @param camera The camera to get the post processes on.
  49283. * @returns The list of the post processes in the effect.
  49284. */
  49285. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49286. }
  49287. }
  49288. declare module BABYLON {
  49289. /**
  49290. * PostProcessRenderPipeline
  49291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49292. */
  49293. class PostProcessRenderPipeline {
  49294. private engine;
  49295. private _renderEffects;
  49296. private _renderEffectsForIsolatedPass;
  49297. /**
  49298. * @hidden
  49299. */
  49300. protected _cameras: Camera[];
  49301. /** @hidden */
  49302. _name: string;
  49303. /**
  49304. * Initializes a PostProcessRenderPipeline
  49305. * @param engine engine to add the pipeline to
  49306. * @param name name of the pipeline
  49307. */
  49308. constructor(engine: Engine, name: string);
  49309. /**
  49310. * "PostProcessRenderPipeline"
  49311. * @returns "PostProcessRenderPipeline"
  49312. */
  49313. getClassName(): string;
  49314. /**
  49315. * If all the render effects in the pipeline are support
  49316. */
  49317. readonly isSupported: boolean;
  49318. /**
  49319. * Adds an effect to the pipeline
  49320. * @param renderEffect the effect to add
  49321. */
  49322. addEffect(renderEffect: PostProcessRenderEffect): void;
  49323. /** @hidden */
  49324. _rebuild(): void;
  49325. /** @hidden */
  49326. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49327. /** @hidden */
  49328. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49329. /** @hidden */
  49330. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49331. /** @hidden */
  49332. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49333. /** @hidden */
  49334. _attachCameras(cameras: Camera, unique: boolean): void;
  49335. /** @hidden */
  49336. _attachCameras(cameras: Camera[], unique: boolean): void;
  49337. /** @hidden */
  49338. _detachCameras(cameras: Camera): void;
  49339. /** @hidden */
  49340. _detachCameras(cameras: Nullable<Camera[]>): void;
  49341. /** @hidden */
  49342. _update(): void;
  49343. /** @hidden */
  49344. _reset(): void;
  49345. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49346. /**
  49347. * Disposes of the pipeline
  49348. */
  49349. dispose(): void;
  49350. }
  49351. }
  49352. declare module BABYLON {
  49353. /**
  49354. * PostProcessRenderPipelineManager class
  49355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49356. */
  49357. class PostProcessRenderPipelineManager {
  49358. private _renderPipelines;
  49359. /**
  49360. * Initializes a PostProcessRenderPipelineManager
  49361. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49362. */
  49363. constructor();
  49364. /**
  49365. * Adds a pipeline to the manager
  49366. * @param renderPipeline The pipeline to add
  49367. */
  49368. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49369. /**
  49370. * Attaches a camera to the pipeline
  49371. * @param renderPipelineName The name of the pipeline to attach to
  49372. * @param cameras the camera to attach
  49373. * @param unique if the camera can be attached multiple times to the pipeline
  49374. */
  49375. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49376. /**
  49377. * Detaches a camera from the pipeline
  49378. * @param renderPipelineName The name of the pipeline to detach from
  49379. * @param cameras the camera to detach
  49380. */
  49381. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49382. /**
  49383. * Enables an effect by name on a pipeline
  49384. * @param renderPipelineName the name of the pipeline to enable the effect in
  49385. * @param renderEffectName the name of the effect to enable
  49386. * @param cameras the cameras that the effect should be enabled on
  49387. */
  49388. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49389. /**
  49390. * Disables an effect by name on a pipeline
  49391. * @param renderPipelineName the name of the pipeline to disable the effect in
  49392. * @param renderEffectName the name of the effect to disable
  49393. * @param cameras the cameras that the effect should be disabled on
  49394. */
  49395. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49396. /**
  49397. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49398. */
  49399. update(): void;
  49400. /** @hidden */
  49401. _rebuild(): void;
  49402. /**
  49403. * Disposes of the manager and pipelines
  49404. */
  49405. dispose(): void;
  49406. }
  49407. }
  49408. declare module BABYLON {
  49409. interface Scene {
  49410. /** @hidden (Backing field) */
  49411. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49412. /**
  49413. * Gets the postprocess render pipeline manager
  49414. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49415. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49416. */
  49417. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49418. }
  49419. /**
  49420. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49421. */
  49422. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49423. /**
  49424. * The component name helpfull to identify the component in the list of scene components.
  49425. */
  49426. readonly name: string;
  49427. /**
  49428. * The scene the component belongs to.
  49429. */
  49430. scene: Scene;
  49431. /**
  49432. * Creates a new instance of the component for the given scene
  49433. * @param scene Defines the scene to register the component in
  49434. */
  49435. constructor(scene: Scene);
  49436. /**
  49437. * Registers the component in a given scene
  49438. */
  49439. register(): void;
  49440. /**
  49441. * Rebuilds the elements related to this component in case of
  49442. * context lost for instance.
  49443. */
  49444. rebuild(): void;
  49445. /**
  49446. * Disposes the component and the associated ressources
  49447. */
  49448. dispose(): void;
  49449. private _gatherRenderTargets;
  49450. }
  49451. }
  49452. declare module BABYLON {
  49453. /**
  49454. * Helper class dealing with the extraction of spherical polynomial dataArray
  49455. * from a cube map.
  49456. */
  49457. class CubeMapToSphericalPolynomialTools {
  49458. private static FileFaces;
  49459. /**
  49460. * Converts a texture to the according Spherical Polynomial data.
  49461. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49462. *
  49463. * @param texture The texture to extract the information from.
  49464. * @return The Spherical Polynomial data.
  49465. */
  49466. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49467. /**
  49468. * Converts a cubemap to the according Spherical Polynomial data.
  49469. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49470. *
  49471. * @param cubeInfo The Cube map to extract the information from.
  49472. * @return The Spherical Polynomial data.
  49473. */
  49474. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49475. }
  49476. }
  49477. declare module BABYLON {
  49478. /**
  49479. * Header information of HDR texture files.
  49480. */
  49481. interface HDRInfo {
  49482. /**
  49483. * The height of the texture in pixels.
  49484. */
  49485. height: number;
  49486. /**
  49487. * The width of the texture in pixels.
  49488. */
  49489. width: number;
  49490. /**
  49491. * The index of the beginning of the data in the binary file.
  49492. */
  49493. dataPosition: number;
  49494. }
  49495. /**
  49496. * This groups tools to convert HDR texture to native colors array.
  49497. */
  49498. class HDRTools {
  49499. private static Ldexp;
  49500. private static Rgbe2float;
  49501. private static readStringLine;
  49502. /**
  49503. * Reads header information from an RGBE texture stored in a native array.
  49504. * More information on this format are available here:
  49505. * https://en.wikipedia.org/wiki/RGBE_image_format
  49506. *
  49507. * @param uint8array The binary file stored in native array.
  49508. * @return The header information.
  49509. */
  49510. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49511. /**
  49512. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49513. * This RGBE texture needs to store the information as a panorama.
  49514. *
  49515. * More information on this format are available here:
  49516. * https://en.wikipedia.org/wiki/RGBE_image_format
  49517. *
  49518. * @param buffer The binary file stored in an array buffer.
  49519. * @param size The expected size of the extracted cubemap.
  49520. * @return The Cube Map information.
  49521. */
  49522. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49523. /**
  49524. * Returns the pixels data extracted from an RGBE texture.
  49525. * This pixels will be stored left to right up to down in the R G B order in one array.
  49526. *
  49527. * More information on this format are available here:
  49528. * https://en.wikipedia.org/wiki/RGBE_image_format
  49529. *
  49530. * @param uint8array The binary file stored in an array buffer.
  49531. * @param hdrInfo The header information of the file.
  49532. * @return The pixels data in RGB right to left up to down order.
  49533. */
  49534. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49535. private static RGBE_ReadPixels_RLE;
  49536. }
  49537. }
  49538. declare module BABYLON {
  49539. /**
  49540. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49541. */
  49542. interface CubeMapInfo {
  49543. /**
  49544. * The pixel array for the front face.
  49545. * This is stored in format, left to right, up to down format.
  49546. */
  49547. front: Nullable<ArrayBufferView>;
  49548. /**
  49549. * The pixel array for the back face.
  49550. * This is stored in format, left to right, up to down format.
  49551. */
  49552. back: Nullable<ArrayBufferView>;
  49553. /**
  49554. * The pixel array for the left face.
  49555. * This is stored in format, left to right, up to down format.
  49556. */
  49557. left: Nullable<ArrayBufferView>;
  49558. /**
  49559. * The pixel array for the right face.
  49560. * This is stored in format, left to right, up to down format.
  49561. */
  49562. right: Nullable<ArrayBufferView>;
  49563. /**
  49564. * The pixel array for the up face.
  49565. * This is stored in format, left to right, up to down format.
  49566. */
  49567. up: Nullable<ArrayBufferView>;
  49568. /**
  49569. * The pixel array for the down face.
  49570. * This is stored in format, left to right, up to down format.
  49571. */
  49572. down: Nullable<ArrayBufferView>;
  49573. /**
  49574. * The size of the cubemap stored.
  49575. *
  49576. * Each faces will be size * size pixels.
  49577. */
  49578. size: number;
  49579. /**
  49580. * The format of the texture.
  49581. *
  49582. * RGBA, RGB.
  49583. */
  49584. format: number;
  49585. /**
  49586. * The type of the texture data.
  49587. *
  49588. * UNSIGNED_INT, FLOAT.
  49589. */
  49590. type: number;
  49591. /**
  49592. * Specifies whether the texture is in gamma space.
  49593. */
  49594. gammaSpace: boolean;
  49595. }
  49596. /**
  49597. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49598. */
  49599. class PanoramaToCubeMapTools {
  49600. private static FACE_FRONT;
  49601. private static FACE_BACK;
  49602. private static FACE_RIGHT;
  49603. private static FACE_LEFT;
  49604. private static FACE_DOWN;
  49605. private static FACE_UP;
  49606. /**
  49607. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49608. *
  49609. * @param float32Array The source data.
  49610. * @param inputWidth The width of the input panorama.
  49611. * @param inputHeight The height of the input panorama.
  49612. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49613. * @return The cubemap data
  49614. */
  49615. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49616. private static CreateCubemapTexture;
  49617. private static CalcProjectionSpherical;
  49618. }
  49619. }
  49620. declare module BABYLON {
  49621. }
  49622. declare module BABYLON {
  49623. }
  49624. declare module BABYLON {
  49625. }
  49626. declare module BABYLON {
  49627. }
  49628. declare module BABYLON {
  49629. /**
  49630. * 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.
  49631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49633. */
  49634. class CustomProceduralTexture extends ProceduralTexture {
  49635. private _animate;
  49636. private _time;
  49637. private _config;
  49638. private _texturePath;
  49639. /**
  49640. * Instantiates a new Custom Procedural Texture.
  49641. * 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.
  49642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49643. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49644. * @param name Define the name of the texture
  49645. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49646. * @param size Define the size of the texture to create
  49647. * @param scene Define the scene the texture belongs to
  49648. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49649. * @param generateMipMaps Define if the texture should creates mip maps or not
  49650. */
  49651. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49652. private _loadJson;
  49653. /**
  49654. * Is the texture ready to be used ? (rendered at least once)
  49655. * @returns true if ready, otherwise, false.
  49656. */
  49657. isReady(): boolean;
  49658. /**
  49659. * Render the texture to its associated render target.
  49660. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49661. */
  49662. render(useCameraPostProcess?: boolean): void;
  49663. /**
  49664. * Update the list of dependant textures samplers in the shader.
  49665. */
  49666. updateTextures(): void;
  49667. /**
  49668. * Update the uniform values of the procedural texture in the shader.
  49669. */
  49670. updateShaderUniforms(): void;
  49671. /**
  49672. * Define if the texture animates or not.
  49673. */
  49674. animate: boolean;
  49675. }
  49676. }
  49677. declare module BABYLON {
  49678. /**
  49679. * Class used to generate noise procedural textures
  49680. */
  49681. class NoiseProceduralTexture extends ProceduralTexture {
  49682. private _time;
  49683. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49684. brightness: number;
  49685. /** Defines the number of octaves to process */
  49686. octaves: number;
  49687. /** Defines the level of persistence (0.8 by default) */
  49688. persistence: number;
  49689. /** Gets or sets animation speed factor (default is 1) */
  49690. animationSpeedFactor: number;
  49691. /**
  49692. * Creates a new NoiseProceduralTexture
  49693. * @param name defines the name fo the texture
  49694. * @param size defines the size of the texture (default is 256)
  49695. * @param scene defines the hosting scene
  49696. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49697. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49698. */
  49699. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49700. private _updateShaderUniforms;
  49701. protected _getDefines(): string;
  49702. /** Generate the current state of the procedural texture */
  49703. render(useCameraPostProcess?: boolean): void;
  49704. /**
  49705. * Serializes this noise procedural texture
  49706. * @returns a serialized noise procedural texture object
  49707. */
  49708. serialize(): any;
  49709. /**
  49710. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49711. * @param parsedTexture defines parsed texture data
  49712. * @param scene defines the current scene
  49713. * @param rootUrl defines the root URL containing noise procedural texture information
  49714. * @returns a parsed NoiseProceduralTexture
  49715. */
  49716. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * 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.
  49722. * This is the base class of any Procedural texture and contains most of the shareable code.
  49723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49724. */
  49725. class ProceduralTexture extends Texture {
  49726. isCube: boolean;
  49727. /**
  49728. * Define if the texture is enabled or not (disabled texture will not render)
  49729. */
  49730. isEnabled: boolean;
  49731. /**
  49732. * Define if the texture must be cleared before rendering (default is true)
  49733. */
  49734. autoClear: boolean;
  49735. /**
  49736. * Callback called when the texture is generated
  49737. */
  49738. onGenerated: () => void;
  49739. /**
  49740. * Event raised when the texture is generated
  49741. */
  49742. onGeneratedObservable: Observable<ProceduralTexture>;
  49743. /** @hidden */
  49744. _generateMipMaps: boolean;
  49745. /** @hidden **/
  49746. _effect: Effect;
  49747. /** @hidden */
  49748. _textures: {
  49749. [key: string]: Texture;
  49750. };
  49751. private _size;
  49752. private _currentRefreshId;
  49753. private _refreshRate;
  49754. private _vertexBuffers;
  49755. private _indexBuffer;
  49756. private _uniforms;
  49757. private _samplers;
  49758. private _fragment;
  49759. private _floats;
  49760. private _ints;
  49761. private _floatsArrays;
  49762. private _colors3;
  49763. private _colors4;
  49764. private _vectors2;
  49765. private _vectors3;
  49766. private _matrices;
  49767. private _fallbackTexture;
  49768. private _fallbackTextureUsed;
  49769. private _engine;
  49770. private _cachedDefines;
  49771. private _contentUpdateId;
  49772. private _contentData;
  49773. /**
  49774. * Instantiates a new procedural texture.
  49775. * 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.
  49776. * This is the base class of any Procedural texture and contains most of the shareable code.
  49777. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49778. * @param name Define the name of the texture
  49779. * @param size Define the size of the texture to create
  49780. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49781. * @param scene Define the scene the texture belongs to
  49782. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49783. * @param generateMipMaps Define if the texture should creates mip maps or not
  49784. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49785. */
  49786. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49787. /**
  49788. * The effect that is created when initializing the post process.
  49789. * @returns The created effect corrisponding the the postprocess.
  49790. */
  49791. getEffect(): Effect;
  49792. /**
  49793. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49794. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49795. */
  49796. getContent(): Nullable<ArrayBufferView>;
  49797. private _createIndexBuffer;
  49798. /** @hidden */
  49799. _rebuild(): void;
  49800. /**
  49801. * Resets the texture in order to recreate its associated resources.
  49802. * This can be called in case of context loss
  49803. */
  49804. reset(): void;
  49805. protected _getDefines(): string;
  49806. /**
  49807. * Is the texture ready to be used ? (rendered at least once)
  49808. * @returns true if ready, otherwise, false.
  49809. */
  49810. isReady(): boolean;
  49811. /**
  49812. * Resets the refresh counter of the texture and start bak from scratch.
  49813. * Could be useful to regenerate the texture if it is setup to render only once.
  49814. */
  49815. resetRefreshCounter(): void;
  49816. /**
  49817. * Set the fragment shader to use in order to render the texture.
  49818. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49819. */
  49820. setFragment(fragment: any): void;
  49821. /**
  49822. * Define the refresh rate of the texture or the rendering frequency.
  49823. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49824. */
  49825. refreshRate: number;
  49826. /** @hidden */
  49827. _shouldRender(): boolean;
  49828. /**
  49829. * Get the size the texture is rendering at.
  49830. * @returns the size (texture is always squared)
  49831. */
  49832. getRenderSize(): number;
  49833. /**
  49834. * Resize the texture to new value.
  49835. * @param size Define the new size the texture should have
  49836. * @param generateMipMaps Define whether the new texture should create mip maps
  49837. */
  49838. resize(size: number, generateMipMaps: boolean): void;
  49839. private _checkUniform;
  49840. /**
  49841. * Set a texture in the shader program used to render.
  49842. * @param name Define the name of the uniform samplers as defined in the shader
  49843. * @param texture Define the texture to bind to this sampler
  49844. * @return the texture itself allowing "fluent" like uniform updates
  49845. */
  49846. setTexture(name: string, texture: Texture): ProceduralTexture;
  49847. /**
  49848. * Set a float in the shader.
  49849. * @param name Define the name of the uniform as defined in the shader
  49850. * @param value Define the value to give to the uniform
  49851. * @return the texture itself allowing "fluent" like uniform updates
  49852. */
  49853. setFloat(name: string, value: number): ProceduralTexture;
  49854. /**
  49855. * Set a int in the shader.
  49856. * @param name Define the name of the uniform as defined in the shader
  49857. * @param value Define the value to give to the uniform
  49858. * @return the texture itself allowing "fluent" like uniform updates
  49859. */
  49860. setInt(name: string, value: number): ProceduralTexture;
  49861. /**
  49862. * Set an array of floats in the shader.
  49863. * @param name Define the name of the uniform as defined in the shader
  49864. * @param value Define the value to give to the uniform
  49865. * @return the texture itself allowing "fluent" like uniform updates
  49866. */
  49867. setFloats(name: string, value: number[]): ProceduralTexture;
  49868. /**
  49869. * Set a vec3 in the shader from a Color3.
  49870. * @param name Define the name of the uniform as defined in the shader
  49871. * @param value Define the value to give to the uniform
  49872. * @return the texture itself allowing "fluent" like uniform updates
  49873. */
  49874. setColor3(name: string, value: Color3): ProceduralTexture;
  49875. /**
  49876. * Set a vec4 in the shader from a Color4.
  49877. * @param name Define the name of the uniform as defined in the shader
  49878. * @param value Define the value to give to the uniform
  49879. * @return the texture itself allowing "fluent" like uniform updates
  49880. */
  49881. setColor4(name: string, value: Color4): ProceduralTexture;
  49882. /**
  49883. * Set a vec2 in the shader from a Vector2.
  49884. * @param name Define the name of the uniform as defined in the shader
  49885. * @param value Define the value to give to the uniform
  49886. * @return the texture itself allowing "fluent" like uniform updates
  49887. */
  49888. setVector2(name: string, value: Vector2): ProceduralTexture;
  49889. /**
  49890. * Set a vec3 in the shader from a Vector3.
  49891. * @param name Define the name of the uniform as defined in the shader
  49892. * @param value Define the value to give to the uniform
  49893. * @return the texture itself allowing "fluent" like uniform updates
  49894. */
  49895. setVector3(name: string, value: Vector3): ProceduralTexture;
  49896. /**
  49897. * Set a mat4 in the shader from a MAtrix.
  49898. * @param name Define the name of the uniform as defined in the shader
  49899. * @param value Define the value to give to the uniform
  49900. * @return the texture itself allowing "fluent" like uniform updates
  49901. */
  49902. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49903. /**
  49904. * Render the texture to its associated render target.
  49905. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49906. */
  49907. render(useCameraPostProcess?: boolean): void;
  49908. /**
  49909. * Clone the texture.
  49910. * @returns the cloned texture
  49911. */
  49912. clone(): ProceduralTexture;
  49913. /**
  49914. * Dispose the texture and release its asoociated resources.
  49915. */
  49916. dispose(): void;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. interface AbstractScene {
  49921. /**
  49922. * The list of procedural textures added to the scene
  49923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49924. */
  49925. proceduralTextures: Array<ProceduralTexture>;
  49926. }
  49927. /**
  49928. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49929. * in a given scene.
  49930. */
  49931. class ProceduralTextureSceneComponent implements ISceneComponent {
  49932. /**
  49933. * The component name helpfull to identify the component in the list of scene components.
  49934. */
  49935. readonly name: string;
  49936. /**
  49937. * The scene the component belongs to.
  49938. */
  49939. scene: Scene;
  49940. /**
  49941. * Creates a new instance of the component for the given scene
  49942. * @param scene Defines the scene to register the component in
  49943. */
  49944. constructor(scene: Scene);
  49945. /**
  49946. * Registers the component in a given scene
  49947. */
  49948. register(): void;
  49949. /**
  49950. * Rebuilds the elements related to this component in case of
  49951. * context lost for instance.
  49952. */
  49953. rebuild(): void;
  49954. /**
  49955. * Disposes the component and the associated ressources.
  49956. */
  49957. dispose(): void;
  49958. private _beforeClear;
  49959. }
  49960. }
  49961. declare module BABYLON {
  49962. /**
  49963. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49964. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49965. */
  49966. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49967. private _scene;
  49968. private _camerasToBeAttached;
  49969. /**
  49970. * ID of the sharpen post process,
  49971. */
  49972. private readonly SharpenPostProcessId;
  49973. /**
  49974. * @ignore
  49975. * ID of the image processing post process;
  49976. */
  49977. readonly ImageProcessingPostProcessId: string;
  49978. /**
  49979. * @ignore
  49980. * ID of the Fast Approximate Anti-Aliasing post process;
  49981. */
  49982. readonly FxaaPostProcessId: string;
  49983. /**
  49984. * ID of the chromatic aberration post process,
  49985. */
  49986. private readonly ChromaticAberrationPostProcessId;
  49987. /**
  49988. * ID of the grain post process
  49989. */
  49990. private readonly GrainPostProcessId;
  49991. /**
  49992. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49993. */
  49994. sharpen: SharpenPostProcess;
  49995. private _sharpenEffect;
  49996. private bloom;
  49997. /**
  49998. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49999. */
  50000. depthOfField: DepthOfFieldEffect;
  50001. /**
  50002. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50003. */
  50004. fxaa: FxaaPostProcess;
  50005. /**
  50006. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50007. */
  50008. imageProcessing: ImageProcessingPostProcess;
  50009. /**
  50010. * Chromatic aberration post process which will shift rgb colors in the image
  50011. */
  50012. chromaticAberration: ChromaticAberrationPostProcess;
  50013. private _chromaticAberrationEffect;
  50014. /**
  50015. * Grain post process which add noise to the image
  50016. */
  50017. grain: GrainPostProcess;
  50018. private _grainEffect;
  50019. /**
  50020. * Glow post process which adds a glow to emmisive areas of the image
  50021. */
  50022. private _glowLayer;
  50023. /**
  50024. * Animations which can be used to tweak settings over a period of time
  50025. */
  50026. animations: Animation[];
  50027. private _imageProcessingConfigurationObserver;
  50028. private _sharpenEnabled;
  50029. private _bloomEnabled;
  50030. private _depthOfFieldEnabled;
  50031. private _depthOfFieldBlurLevel;
  50032. private _fxaaEnabled;
  50033. private _imageProcessingEnabled;
  50034. private _defaultPipelineTextureType;
  50035. private _bloomScale;
  50036. private _chromaticAberrationEnabled;
  50037. private _grainEnabled;
  50038. private _buildAllowed;
  50039. /**
  50040. * Enable or disable the sharpen process from the pipeline
  50041. */
  50042. sharpenEnabled: boolean;
  50043. private _resizeObserver;
  50044. private _hardwareScaleLevel;
  50045. private _bloomKernel;
  50046. /**
  50047. * Specifies the size of the bloom blur kernel, relative to the final output size
  50048. */
  50049. bloomKernel: number;
  50050. /**
  50051. * Specifies the weight of the bloom in the final rendering
  50052. */
  50053. private _bloomWeight;
  50054. /**
  50055. * Specifies the luma threshold for the area that will be blurred by the bloom
  50056. */
  50057. private _bloomThreshold;
  50058. private _hdr;
  50059. /**
  50060. * The strength of the bloom.
  50061. */
  50062. bloomWeight: number;
  50063. /**
  50064. * The strength of the bloom.
  50065. */
  50066. bloomThreshold: number;
  50067. /**
  50068. * The scale of the bloom, lower value will provide better performance.
  50069. */
  50070. bloomScale: number;
  50071. /**
  50072. * Enable or disable the bloom from the pipeline
  50073. */
  50074. bloomEnabled: boolean;
  50075. private _rebuildBloom;
  50076. /**
  50077. * If the depth of field is enabled.
  50078. */
  50079. depthOfFieldEnabled: boolean;
  50080. /**
  50081. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50082. */
  50083. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50084. /**
  50085. * If the anti aliasing is enabled.
  50086. */
  50087. fxaaEnabled: boolean;
  50088. private _samples;
  50089. /**
  50090. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50091. */
  50092. samples: number;
  50093. /**
  50094. * If image processing is enabled.
  50095. */
  50096. imageProcessingEnabled: boolean;
  50097. /**
  50098. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50099. */
  50100. glowLayerEnabled: boolean;
  50101. /**
  50102. * Enable or disable the chromaticAberration process from the pipeline
  50103. */
  50104. chromaticAberrationEnabled: boolean;
  50105. /**
  50106. * Enable or disable the grain process from the pipeline
  50107. */
  50108. grainEnabled: boolean;
  50109. /**
  50110. * @constructor
  50111. * @param name - The rendering pipeline name (default: "")
  50112. * @param hdr - If high dynamic range textures should be used (default: true)
  50113. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50114. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50115. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50116. */
  50117. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50118. /**
  50119. * Force the compilation of the entire pipeline.
  50120. */
  50121. prepare(): void;
  50122. private _hasCleared;
  50123. private _prevPostProcess;
  50124. private _prevPrevPostProcess;
  50125. private _setAutoClearAndTextureSharing;
  50126. private _depthOfFieldSceneObserver;
  50127. private _buildPipeline;
  50128. private _disposePostProcesses;
  50129. /**
  50130. * Adds a camera to the pipeline
  50131. * @param camera the camera to be added
  50132. */
  50133. addCamera(camera: Camera): void;
  50134. /**
  50135. * Removes a camera from the pipeline
  50136. * @param camera the camera to remove
  50137. */
  50138. removeCamera(camera: Camera): void;
  50139. /**
  50140. * Dispose of the pipeline and stop all post processes
  50141. */
  50142. dispose(): void;
  50143. /**
  50144. * Serialize the rendering pipeline (Used when exporting)
  50145. * @returns the serialized object
  50146. */
  50147. serialize(): any;
  50148. /**
  50149. * Parse the serialized pipeline
  50150. * @param source Source pipeline.
  50151. * @param scene The scene to load the pipeline to.
  50152. * @param rootUrl The URL of the serialized pipeline.
  50153. * @returns An instantiated pipeline from the serialized object.
  50154. */
  50155. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50156. }
  50157. }
  50158. declare module BABYLON {
  50159. /**
  50160. * BABYLON.JS Chromatic Aberration GLSL Shader
  50161. * Author: Olivier Guyot
  50162. * Separates very slightly R, G and B colors on the edges of the screen
  50163. * Inspired by Francois Tarlier & Martins Upitis
  50164. */
  50165. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50166. /**
  50167. * @ignore
  50168. * The chromatic aberration PostProcess id in the pipeline
  50169. */
  50170. LensChromaticAberrationEffect: string;
  50171. /**
  50172. * @ignore
  50173. * The highlights enhancing PostProcess id in the pipeline
  50174. */
  50175. HighlightsEnhancingEffect: string;
  50176. /**
  50177. * @ignore
  50178. * The depth-of-field PostProcess id in the pipeline
  50179. */
  50180. LensDepthOfFieldEffect: string;
  50181. private _scene;
  50182. private _depthTexture;
  50183. private _grainTexture;
  50184. private _chromaticAberrationPostProcess;
  50185. private _highlightsPostProcess;
  50186. private _depthOfFieldPostProcess;
  50187. private _edgeBlur;
  50188. private _grainAmount;
  50189. private _chromaticAberration;
  50190. private _distortion;
  50191. private _highlightsGain;
  50192. private _highlightsThreshold;
  50193. private _dofDistance;
  50194. private _dofAperture;
  50195. private _dofDarken;
  50196. private _dofPentagon;
  50197. private _blurNoise;
  50198. /**
  50199. * @constructor
  50200. *
  50201. * Effect parameters are as follow:
  50202. * {
  50203. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50204. * edge_blur: number; // from 0 to x (1 for realism)
  50205. * distortion: number; // from 0 to x (1 for realism)
  50206. * grain_amount: number; // from 0 to 1
  50207. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50208. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50209. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50210. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50211. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50212. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50213. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50214. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50215. * }
  50216. * Note: if an effect parameter is unset, effect is disabled
  50217. *
  50218. * @param name The rendering pipeline name
  50219. * @param parameters - An object containing all parameters (see above)
  50220. * @param scene The scene linked to this pipeline
  50221. * @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)
  50222. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50223. */
  50224. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50225. /**
  50226. * Sets the amount of blur at the edges
  50227. * @param amount blur amount
  50228. */
  50229. setEdgeBlur(amount: number): void;
  50230. /**
  50231. * Sets edge blur to 0
  50232. */
  50233. disableEdgeBlur(): void;
  50234. /**
  50235. * Sets the amout of grain
  50236. * @param amount Amount of grain
  50237. */
  50238. setGrainAmount(amount: number): void;
  50239. /**
  50240. * Set grain amount to 0
  50241. */
  50242. disableGrain(): void;
  50243. /**
  50244. * Sets the chromatic aberration amount
  50245. * @param amount amount of chromatic aberration
  50246. */
  50247. setChromaticAberration(amount: number): void;
  50248. /**
  50249. * Sets chromatic aberration amount to 0
  50250. */
  50251. disableChromaticAberration(): void;
  50252. /**
  50253. * Sets the EdgeDistortion amount
  50254. * @param amount amount of EdgeDistortion
  50255. */
  50256. setEdgeDistortion(amount: number): void;
  50257. /**
  50258. * Sets edge distortion to 0
  50259. */
  50260. disableEdgeDistortion(): void;
  50261. /**
  50262. * Sets the FocusDistance amount
  50263. * @param amount amount of FocusDistance
  50264. */
  50265. setFocusDistance(amount: number): void;
  50266. /**
  50267. * Disables depth of field
  50268. */
  50269. disableDepthOfField(): void;
  50270. /**
  50271. * Sets the Aperture amount
  50272. * @param amount amount of Aperture
  50273. */
  50274. setAperture(amount: number): void;
  50275. /**
  50276. * Sets the DarkenOutOfFocus amount
  50277. * @param amount amount of DarkenOutOfFocus
  50278. */
  50279. setDarkenOutOfFocus(amount: number): void;
  50280. /**
  50281. * Creates a pentagon bokeh effect
  50282. */
  50283. enablePentagonBokeh(): void;
  50284. /**
  50285. * Disables the pentagon bokeh effect
  50286. */
  50287. disablePentagonBokeh(): void;
  50288. /**
  50289. * Enables noise blur
  50290. */
  50291. enableNoiseBlur(): void;
  50292. /**
  50293. * Disables noise blur
  50294. */
  50295. disableNoiseBlur(): void;
  50296. /**
  50297. * Sets the HighlightsGain amount
  50298. * @param amount amount of HighlightsGain
  50299. */
  50300. setHighlightsGain(amount: number): void;
  50301. /**
  50302. * Sets the HighlightsThreshold amount
  50303. * @param amount amount of HighlightsThreshold
  50304. */
  50305. setHighlightsThreshold(amount: number): void;
  50306. /**
  50307. * Disables highlights
  50308. */
  50309. disableHighlights(): void;
  50310. /**
  50311. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50312. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50313. */
  50314. dispose(disableDepthRender?: boolean): void;
  50315. private _createChromaticAberrationPostProcess;
  50316. private _createHighlightsPostProcess;
  50317. private _createDepthOfFieldPostProcess;
  50318. private _createGrainTexture;
  50319. }
  50320. }
  50321. declare module BABYLON {
  50322. /**
  50323. * Render pipeline to produce ssao effect
  50324. */
  50325. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50326. /**
  50327. * @ignore
  50328. * The PassPostProcess id in the pipeline that contains the original scene color
  50329. */
  50330. SSAOOriginalSceneColorEffect: string;
  50331. /**
  50332. * @ignore
  50333. * The SSAO PostProcess id in the pipeline
  50334. */
  50335. SSAORenderEffect: string;
  50336. /**
  50337. * @ignore
  50338. * The horizontal blur PostProcess id in the pipeline
  50339. */
  50340. SSAOBlurHRenderEffect: string;
  50341. /**
  50342. * @ignore
  50343. * The vertical blur PostProcess id in the pipeline
  50344. */
  50345. SSAOBlurVRenderEffect: string;
  50346. /**
  50347. * @ignore
  50348. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50349. */
  50350. SSAOCombineRenderEffect: string;
  50351. /**
  50352. * The output strength of the SSAO post-process. Default value is 1.0.
  50353. */
  50354. totalStrength: number;
  50355. /**
  50356. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50357. */
  50358. maxZ: number;
  50359. /**
  50360. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50361. */
  50362. minZAspect: number;
  50363. private _samples;
  50364. /**
  50365. * Number of samples used for the SSAO calculations. Default value is 8
  50366. */
  50367. samples: number;
  50368. private _textureSamples;
  50369. /**
  50370. * Number of samples to use for antialiasing
  50371. */
  50372. textureSamples: number;
  50373. /**
  50374. * Ratio object used for SSAO ratio and blur ratio
  50375. */
  50376. private _ratio;
  50377. /**
  50378. * Dynamically generated sphere sampler.
  50379. */
  50380. private _sampleSphere;
  50381. /**
  50382. * Blur filter offsets
  50383. */
  50384. private _samplerOffsets;
  50385. private _expensiveBlur;
  50386. /**
  50387. * If bilateral blur should be used
  50388. */
  50389. expensiveBlur: boolean;
  50390. /**
  50391. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50392. */
  50393. radius: number;
  50394. /**
  50395. * The base color of the SSAO post-process
  50396. * The final result is "base + ssao" between [0, 1]
  50397. */
  50398. base: number;
  50399. /**
  50400. * Support test.
  50401. */
  50402. static readonly IsSupported: boolean;
  50403. private _scene;
  50404. private _depthTexture;
  50405. private _normalTexture;
  50406. private _randomTexture;
  50407. private _originalColorPostProcess;
  50408. private _ssaoPostProcess;
  50409. private _blurHPostProcess;
  50410. private _blurVPostProcess;
  50411. private _ssaoCombinePostProcess;
  50412. private _firstUpdate;
  50413. /**
  50414. * @constructor
  50415. * @param name The rendering pipeline name
  50416. * @param scene The scene linked to this pipeline
  50417. * @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 }
  50418. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50419. */
  50420. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50421. /**
  50422. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50423. */
  50424. dispose(disableGeometryBufferRenderer?: boolean): void;
  50425. private _createBlurPostProcess;
  50426. /** @hidden */
  50427. _rebuild(): void;
  50428. private _bits;
  50429. private _radicalInverse_VdC;
  50430. private _hammersley;
  50431. private _hemisphereSample_uniform;
  50432. private _generateHemisphere;
  50433. private _createSSAOPostProcess;
  50434. private _createSSAOCombinePostProcess;
  50435. private _createRandomTexture;
  50436. /**
  50437. * Serialize the rendering pipeline (Used when exporting)
  50438. * @returns the serialized object
  50439. */
  50440. serialize(): any;
  50441. /**
  50442. * Parse the serialized pipeline
  50443. * @param source Source pipeline.
  50444. * @param scene The scene to load the pipeline to.
  50445. * @param rootUrl The URL of the serialized pipeline.
  50446. * @returns An instantiated pipeline from the serialized object.
  50447. */
  50448. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50449. }
  50450. }
  50451. declare module BABYLON {
  50452. /**
  50453. * Render pipeline to produce ssao effect
  50454. */
  50455. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50456. /**
  50457. * @ignore
  50458. * The PassPostProcess id in the pipeline that contains the original scene color
  50459. */
  50460. SSAOOriginalSceneColorEffect: string;
  50461. /**
  50462. * @ignore
  50463. * The SSAO PostProcess id in the pipeline
  50464. */
  50465. SSAORenderEffect: string;
  50466. /**
  50467. * @ignore
  50468. * The horizontal blur PostProcess id in the pipeline
  50469. */
  50470. SSAOBlurHRenderEffect: string;
  50471. /**
  50472. * @ignore
  50473. * The vertical blur PostProcess id in the pipeline
  50474. */
  50475. SSAOBlurVRenderEffect: string;
  50476. /**
  50477. * @ignore
  50478. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50479. */
  50480. SSAOCombineRenderEffect: string;
  50481. /**
  50482. * The output strength of the SSAO post-process. Default value is 1.0.
  50483. */
  50484. totalStrength: number;
  50485. /**
  50486. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50487. */
  50488. radius: number;
  50489. /**
  50490. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50491. * Must not be equal to fallOff and superior to fallOff.
  50492. * Default value is 0.975
  50493. */
  50494. area: number;
  50495. /**
  50496. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50497. * Must not be equal to area and inferior to area.
  50498. * Default value is 0.0
  50499. */
  50500. fallOff: number;
  50501. /**
  50502. * The base color of the SSAO post-process
  50503. * The final result is "base + ssao" between [0, 1]
  50504. */
  50505. base: number;
  50506. private _scene;
  50507. private _depthTexture;
  50508. private _randomTexture;
  50509. private _originalColorPostProcess;
  50510. private _ssaoPostProcess;
  50511. private _blurHPostProcess;
  50512. private _blurVPostProcess;
  50513. private _ssaoCombinePostProcess;
  50514. private _firstUpdate;
  50515. /**
  50516. * @constructor
  50517. * @param name - The rendering pipeline name
  50518. * @param scene - The scene linked to this pipeline
  50519. * @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 }
  50520. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50521. */
  50522. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50523. /**
  50524. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50525. */
  50526. dispose(disableDepthRender?: boolean): void;
  50527. private _createBlurPostProcess;
  50528. /** @hidden */
  50529. _rebuild(): void;
  50530. private _createSSAOPostProcess;
  50531. private _createSSAOCombinePostProcess;
  50532. private _createRandomTexture;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * Standard rendering pipeline
  50538. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50539. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50540. */
  50541. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50542. /**
  50543. * Public members
  50544. */
  50545. /**
  50546. * Post-process which contains the original scene color before the pipeline applies all the effects
  50547. */
  50548. originalPostProcess: Nullable<PostProcess>;
  50549. /**
  50550. * Post-process used to down scale an image x4
  50551. */
  50552. downSampleX4PostProcess: Nullable<PostProcess>;
  50553. /**
  50554. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50555. */
  50556. brightPassPostProcess: Nullable<PostProcess>;
  50557. /**
  50558. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50559. */
  50560. blurHPostProcesses: PostProcess[];
  50561. /**
  50562. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50563. */
  50564. blurVPostProcesses: PostProcess[];
  50565. /**
  50566. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50567. */
  50568. textureAdderPostProcess: Nullable<PostProcess>;
  50569. /**
  50570. * Post-process used to create volumetric lighting effect
  50571. */
  50572. volumetricLightPostProcess: Nullable<PostProcess>;
  50573. /**
  50574. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50575. */
  50576. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50577. /**
  50578. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50579. */
  50580. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50581. /**
  50582. * Post-process used to merge the volumetric light effect and the real scene color
  50583. */
  50584. volumetricLightMergePostProces: Nullable<PostProcess>;
  50585. /**
  50586. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50587. */
  50588. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50589. /**
  50590. * Base post-process used to calculate the average luminance of the final image for HDR
  50591. */
  50592. luminancePostProcess: Nullable<PostProcess>;
  50593. /**
  50594. * Post-processes used to create down sample post-processes in order to get
  50595. * the average luminance of the final image for HDR
  50596. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50597. */
  50598. luminanceDownSamplePostProcesses: PostProcess[];
  50599. /**
  50600. * Post-process used to create a HDR effect (light adaptation)
  50601. */
  50602. hdrPostProcess: Nullable<PostProcess>;
  50603. /**
  50604. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50605. */
  50606. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50607. /**
  50608. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50609. */
  50610. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50611. /**
  50612. * Post-process used to merge the final HDR post-process and the real scene color
  50613. */
  50614. hdrFinalPostProcess: Nullable<PostProcess>;
  50615. /**
  50616. * Post-process used to create a lens flare effect
  50617. */
  50618. lensFlarePostProcess: Nullable<PostProcess>;
  50619. /**
  50620. * Post-process that merges the result of the lens flare post-process and the real scene color
  50621. */
  50622. lensFlareComposePostProcess: Nullable<PostProcess>;
  50623. /**
  50624. * Post-process used to create a motion blur effect
  50625. */
  50626. motionBlurPostProcess: Nullable<PostProcess>;
  50627. /**
  50628. * Post-process used to create a depth of field effect
  50629. */
  50630. depthOfFieldPostProcess: Nullable<PostProcess>;
  50631. /**
  50632. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50633. */
  50634. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50635. /**
  50636. * Represents the brightness threshold in order to configure the illuminated surfaces
  50637. */
  50638. brightThreshold: number;
  50639. /**
  50640. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50641. */
  50642. blurWidth: number;
  50643. /**
  50644. * Sets if the blur for highlighted surfaces must be only horizontal
  50645. */
  50646. horizontalBlur: boolean;
  50647. /**
  50648. * Sets the overall exposure used by the pipeline
  50649. */
  50650. exposure: number;
  50651. /**
  50652. * Texture used typically to simulate "dirty" on camera lens
  50653. */
  50654. lensTexture: Nullable<Texture>;
  50655. /**
  50656. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50657. */
  50658. volumetricLightCoefficient: number;
  50659. /**
  50660. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50661. */
  50662. volumetricLightPower: number;
  50663. /**
  50664. * Used the set the blur intensity to smooth the volumetric lights
  50665. */
  50666. volumetricLightBlurScale: number;
  50667. /**
  50668. * Light (spot or directional) used to generate the volumetric lights rays
  50669. * The source light must have a shadow generate so the pipeline can get its
  50670. * depth map
  50671. */
  50672. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50673. /**
  50674. * For eye adaptation, represents the minimum luminance the eye can see
  50675. */
  50676. hdrMinimumLuminance: number;
  50677. /**
  50678. * For eye adaptation, represents the decrease luminance speed
  50679. */
  50680. hdrDecreaseRate: number;
  50681. /**
  50682. * For eye adaptation, represents the increase luminance speed
  50683. */
  50684. hdrIncreaseRate: number;
  50685. /**
  50686. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50687. */
  50688. lensColorTexture: Nullable<Texture>;
  50689. /**
  50690. * The overall strengh for the lens flare effect
  50691. */
  50692. lensFlareStrength: number;
  50693. /**
  50694. * Dispersion coefficient for lens flare ghosts
  50695. */
  50696. lensFlareGhostDispersal: number;
  50697. /**
  50698. * Main lens flare halo width
  50699. */
  50700. lensFlareHaloWidth: number;
  50701. /**
  50702. * Based on the lens distortion effect, defines how much the lens flare result
  50703. * is distorted
  50704. */
  50705. lensFlareDistortionStrength: number;
  50706. /**
  50707. * Lens star texture must be used to simulate rays on the flares and is available
  50708. * in the documentation
  50709. */
  50710. lensStarTexture: Nullable<Texture>;
  50711. /**
  50712. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50713. * flare effect by taking account of the dirt texture
  50714. */
  50715. lensFlareDirtTexture: Nullable<Texture>;
  50716. /**
  50717. * Represents the focal length for the depth of field effect
  50718. */
  50719. depthOfFieldDistance: number;
  50720. /**
  50721. * Represents the blur intensity for the blurred part of the depth of field effect
  50722. */
  50723. depthOfFieldBlurWidth: number;
  50724. /**
  50725. * For motion blur, defines how much the image is blurred by the movement
  50726. */
  50727. motionStrength: number;
  50728. /**
  50729. * List of animations for the pipeline (IAnimatable implementation)
  50730. */
  50731. animations: Animation[];
  50732. /**
  50733. * Private members
  50734. */
  50735. private _scene;
  50736. private _currentDepthOfFieldSource;
  50737. private _basePostProcess;
  50738. private _hdrCurrentLuminance;
  50739. private _floatTextureType;
  50740. private _ratio;
  50741. private _bloomEnabled;
  50742. private _depthOfFieldEnabled;
  50743. private _vlsEnabled;
  50744. private _lensFlareEnabled;
  50745. private _hdrEnabled;
  50746. private _motionBlurEnabled;
  50747. private _fxaaEnabled;
  50748. private _motionBlurSamples;
  50749. private _volumetricLightStepsCount;
  50750. private _samples;
  50751. /**
  50752. * @ignore
  50753. * Specifies if the bloom pipeline is enabled
  50754. */
  50755. BloomEnabled: boolean;
  50756. /**
  50757. * @ignore
  50758. * Specifies if the depth of field pipeline is enabed
  50759. */
  50760. DepthOfFieldEnabled: boolean;
  50761. /**
  50762. * @ignore
  50763. * Specifies if the lens flare pipeline is enabed
  50764. */
  50765. LensFlareEnabled: boolean;
  50766. /**
  50767. * @ignore
  50768. * Specifies if the HDR pipeline is enabled
  50769. */
  50770. HDREnabled: boolean;
  50771. /**
  50772. * @ignore
  50773. * Specifies if the volumetric lights scattering effect is enabled
  50774. */
  50775. VLSEnabled: boolean;
  50776. /**
  50777. * @ignore
  50778. * Specifies if the motion blur effect is enabled
  50779. */
  50780. MotionBlurEnabled: boolean;
  50781. /**
  50782. * Specifies if anti-aliasing is enabled
  50783. */
  50784. fxaaEnabled: boolean;
  50785. /**
  50786. * Specifies the number of steps used to calculate the volumetric lights
  50787. * Typically in interval [50, 200]
  50788. */
  50789. volumetricLightStepsCount: number;
  50790. /**
  50791. * Specifies the number of samples used for the motion blur effect
  50792. * Typically in interval [16, 64]
  50793. */
  50794. motionBlurSamples: number;
  50795. /**
  50796. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50797. */
  50798. samples: number;
  50799. /**
  50800. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50801. * @constructor
  50802. * @param name The rendering pipeline name
  50803. * @param scene The scene linked to this pipeline
  50804. * @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)
  50805. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50806. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50807. */
  50808. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50809. private _buildPipeline;
  50810. private _createDownSampleX4PostProcess;
  50811. private _createBrightPassPostProcess;
  50812. private _createBlurPostProcesses;
  50813. private _createTextureAdderPostProcess;
  50814. private _createVolumetricLightPostProcess;
  50815. private _createLuminancePostProcesses;
  50816. private _createHdrPostProcess;
  50817. private _createLensFlarePostProcess;
  50818. private _createDepthOfFieldPostProcess;
  50819. private _createMotionBlurPostProcess;
  50820. private _getDepthTexture;
  50821. private _disposePostProcesses;
  50822. /**
  50823. * Dispose of the pipeline and stop all post processes
  50824. */
  50825. dispose(): void;
  50826. /**
  50827. * Serialize the rendering pipeline (Used when exporting)
  50828. * @returns the serialized object
  50829. */
  50830. serialize(): any;
  50831. /**
  50832. * Parse the serialized pipeline
  50833. * @param source Source pipeline.
  50834. * @param scene The scene to load the pipeline to.
  50835. * @param rootUrl The URL of the serialized pipeline.
  50836. * @returns An instantiated pipeline from the serialized object.
  50837. */
  50838. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50839. /**
  50840. * Luminance steps
  50841. */
  50842. static LuminanceSteps: number;
  50843. }
  50844. }