babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279
  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. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * 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
  570. * @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
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @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
  593. * @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
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @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
  600. * @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
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @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
  607. * @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
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @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
  614. * @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)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * 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)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * 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)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * 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).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @returns the animatable object created for this animation
  1778. */
  1779. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1780. /**
  1781. * Will start the animation sequence of a given target
  1782. * @param target defines the target
  1783. * @param from defines from which frame should animation start
  1784. * @param to defines until which frame should animation run.
  1785. * @param loop defines if the animation loops
  1786. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1787. * @param onAnimationEnd defines the function to be executed when the animation ends
  1788. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1789. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1790. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1791. * @returns the animatable object created for this animation
  1792. */
  1793. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1794. /**
  1795. * Will start the animation sequence of a given target and its hierarchy
  1796. * @param target defines the target
  1797. * @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.
  1798. * @param from defines from which frame should animation start
  1799. * @param to defines until which frame should animation run.
  1800. * @param loop defines if the animation loops
  1801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1802. * @param onAnimationEnd defines the function to be executed when the animation ends
  1803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1804. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1805. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1806. * @returns the list of created animatables
  1807. */
  1808. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1809. /**
  1810. * Begin a new animation on a given node
  1811. * @param target defines the target where the animation will take place
  1812. * @param animations defines the list of animations to start
  1813. * @param from defines the initial value
  1814. * @param to defines the final value
  1815. * @param loop defines if you want animation to loop (off by default)
  1816. * @param speedRatio defines the speed ratio to apply to all animations
  1817. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1818. * @returns the list of created animatables
  1819. */
  1820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1821. /**
  1822. * Begin a new animation on a given node and its hierarchy
  1823. * @param target defines the root node where the animation will take place
  1824. * @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.
  1825. * @param animations defines the list of animations to start
  1826. * @param from defines the initial value
  1827. * @param to defines the final value
  1828. * @param loop defines if you want animation to loop (off by default)
  1829. * @param speedRatio defines the speed ratio to apply to all animations
  1830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1831. * @returns the list of animatables created for all nodes
  1832. */
  1833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1834. /**
  1835. * Gets the animatable associated with a specific target
  1836. * @param target defines the target of the animatable
  1837. * @returns the required animatable if found
  1838. */
  1839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1840. /**
  1841. * Gets all animatables associated with a given target
  1842. * @param target defines the target to look animatables for
  1843. * @returns an array of Animatables
  1844. */
  1845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1846. /**
  1847. * Gets all animatable attached to the scene
  1848. */
  1849. readonly animatables: Animatable[];
  1850. /**
  1851. * Will stop the animation of the given target
  1852. * @param target - the target
  1853. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1854. * @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)
  1855. */
  1856. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1857. /**
  1858. * Stops and removes all animations that have been applied to the scene
  1859. */
  1860. stopAllAnimations(): void;
  1861. private _animate;
  1862. /** @hidden */
  1863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1864. private _processLateAnimationBindingsForMatrices;
  1865. private _processLateAnimationBindingsForQuaternions;
  1866. private _processLateAnimationBindings;
  1867. /** @hidden */
  1868. _switchToAlternateCameraConfiguration(active: boolean): void;
  1869. /**
  1870. * Gets the current view matrix
  1871. * @returns a Matrix
  1872. */
  1873. getViewMatrix(): Matrix;
  1874. /**
  1875. * Gets the current projection matrix
  1876. * @returns a Matrix
  1877. */
  1878. getProjectionMatrix(): Matrix;
  1879. /**
  1880. * Gets the current transform matrix
  1881. * @returns a Matrix made of View * Projection
  1882. */
  1883. getTransformMatrix(): Matrix;
  1884. /**
  1885. * Sets the current transform matrix
  1886. * @param view defines the View matrix to use
  1887. * @param projection defines the Projection matrix to use
  1888. */
  1889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1890. /** @hidden */
  1891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1892. /**
  1893. * Gets the uniform buffer used to store scene data
  1894. * @returns a UniformBuffer
  1895. */
  1896. getSceneUniformBuffer(): UniformBuffer;
  1897. /**
  1898. * Gets an unique (relatively to the current scene) Id
  1899. * @returns an unique number for the scene
  1900. */
  1901. getUniqueId(): number;
  1902. /**
  1903. * Add a mesh to the list of scene's meshes
  1904. * @param newMesh defines the mesh to add
  1905. * @param recursive if all child meshes should also be added to the scene
  1906. */
  1907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1908. /**
  1909. * Remove a mesh for the list of scene's meshes
  1910. * @param toRemove defines the mesh to remove
  1911. * @param recursive if all child meshes should also be removed from the scene
  1912. * @returns the index where the mesh was in the mesh list
  1913. */
  1914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1915. /**
  1916. * Add a transform node to the list of scene's transform nodes
  1917. * @param newTransformNode defines the transform node to add
  1918. */
  1919. addTransformNode(newTransformNode: TransformNode): void;
  1920. /**
  1921. * Remove a transform node for the list of scene's transform nodes
  1922. * @param toRemove defines the transform node to remove
  1923. * @returns the index where the transform node was in the transform node list
  1924. */
  1925. removeTransformNode(toRemove: TransformNode): number;
  1926. /**
  1927. * Remove a skeleton for the list of scene's skeletons
  1928. * @param toRemove defines the skeleton to remove
  1929. * @returns the index where the skeleton was in the skeleton list
  1930. */
  1931. removeSkeleton(toRemove: Skeleton): number;
  1932. /**
  1933. * Remove a morph target for the list of scene's morph targets
  1934. * @param toRemove defines the morph target to remove
  1935. * @returns the index where the morph target was in the morph target list
  1936. */
  1937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1938. /**
  1939. * Remove a light for the list of scene's lights
  1940. * @param toRemove defines the light to remove
  1941. * @returns the index where the light was in the light list
  1942. */
  1943. removeLight(toRemove: Light): number;
  1944. /**
  1945. * Remove a camera for the list of scene's cameras
  1946. * @param toRemove defines the camera to remove
  1947. * @returns the index where the camera was in the camera list
  1948. */
  1949. removeCamera(toRemove: Camera): number;
  1950. /**
  1951. * Remove a particle system for the list of scene's particle systems
  1952. * @param toRemove defines the particle system to remove
  1953. * @returns the index where the particle system was in the particle system list
  1954. */
  1955. removeParticleSystem(toRemove: IParticleSystem): number;
  1956. /**
  1957. * Remove a animation for the list of scene's animations
  1958. * @param toRemove defines the animation to remove
  1959. * @returns the index where the animation was in the animation list
  1960. */
  1961. removeAnimation(toRemove: Animation): number;
  1962. /**
  1963. * Removes the given animation group from this scene.
  1964. * @param toRemove The animation group to remove
  1965. * @returns The index of the removed animation group
  1966. */
  1967. removeAnimationGroup(toRemove: AnimationGroup): number;
  1968. /**
  1969. * Removes the given multi-material from this scene.
  1970. * @param toRemove The multi-material to remove
  1971. * @returns The index of the removed multi-material
  1972. */
  1973. removeMultiMaterial(toRemove: MultiMaterial): number;
  1974. /**
  1975. * Removes the given material from this scene.
  1976. * @param toRemove The material to remove
  1977. * @returns The index of the removed material
  1978. */
  1979. removeMaterial(toRemove: Material): number;
  1980. /**
  1981. * Removes the given action manager from this scene.
  1982. * @param toRemove The action manager to remove
  1983. * @returns The index of the removed action manager
  1984. */
  1985. removeActionManager(toRemove: ActionManager): number;
  1986. /**
  1987. * Removes the given texture from this scene.
  1988. * @param toRemove The texture to remove
  1989. * @returns The index of the removed texture
  1990. */
  1991. removeTexture(toRemove: BaseTexture): number;
  1992. /**
  1993. * Adds the given light to this scene
  1994. * @param newLight The light to add
  1995. */
  1996. addLight(newLight: Light): void;
  1997. /**
  1998. * Sorts the list list based on light priorities
  1999. */
  2000. sortLightsByPriority(): void;
  2001. /**
  2002. * Adds the given camera to this scene
  2003. * @param newCamera The camera to add
  2004. */
  2005. addCamera(newCamera: Camera): void;
  2006. /**
  2007. * Adds the given skeleton to this scene
  2008. * @param newSkeleton The skeleton to add
  2009. */
  2010. addSkeleton(newSkeleton: Skeleton): void;
  2011. /**
  2012. * Adds the given particle system to this scene
  2013. * @param newParticleSystem The particle system to add
  2014. */
  2015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2016. /**
  2017. * Adds the given animation to this scene
  2018. * @param newAnimation The animation to add
  2019. */
  2020. addAnimation(newAnimation: Animation): void;
  2021. /**
  2022. * Adds the given animation group to this scene.
  2023. * @param newAnimationGroup The animation group to add
  2024. */
  2025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2026. /**
  2027. * Adds the given multi-material to this scene
  2028. * @param newMultiMaterial The multi-material to add
  2029. */
  2030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2031. /**
  2032. * Adds the given material to this scene
  2033. * @param newMaterial The material to add
  2034. */
  2035. addMaterial(newMaterial: Material): void;
  2036. /**
  2037. * Adds the given morph target to this scene
  2038. * @param newMorphTargetManager The morph target to add
  2039. */
  2040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2041. /**
  2042. * Adds the given geometry to this scene
  2043. * @param newGeometry The geometry to add
  2044. */
  2045. addGeometry(newGeometry: Geometry): void;
  2046. /**
  2047. * Adds the given action manager to this scene
  2048. * @param newActionManager The action manager to add
  2049. */
  2050. addActionManager(newActionManager: ActionManager): void;
  2051. /**
  2052. * Adds the given texture to this scene.
  2053. * @param newTexture The texture to add
  2054. */
  2055. addTexture(newTexture: BaseTexture): void;
  2056. /**
  2057. * Switch active camera
  2058. * @param newCamera defines the new active camera
  2059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2060. */
  2061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2062. /**
  2063. * sets the active camera of the scene using its ID
  2064. * @param id defines the camera's ID
  2065. * @return the new active camera or null if none found.
  2066. */
  2067. setActiveCameraByID(id: string): Nullable<Camera>;
  2068. /**
  2069. * sets the active camera of the scene using its name
  2070. * @param name defines the camera's name
  2071. * @returns the new active camera or null if none found.
  2072. */
  2073. setActiveCameraByName(name: string): Nullable<Camera>;
  2074. /**
  2075. * get an animation group using its name
  2076. * @param name defines the material's name
  2077. * @return the animation group or null if none found.
  2078. */
  2079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2080. /**
  2081. * get a material using its id
  2082. * @param id defines the material's ID
  2083. * @return the material or null if none found.
  2084. */
  2085. getMaterialByID(id: string): Nullable<Material>;
  2086. /**
  2087. * Gets a material using its name
  2088. * @param name defines the material's name
  2089. * @return the material or null if none found.
  2090. */
  2091. getMaterialByName(name: string): Nullable<Material>;
  2092. /**
  2093. * Gets a camera using its id
  2094. * @param id defines the id to look for
  2095. * @returns the camera or null if not found
  2096. */
  2097. getCameraByID(id: string): Nullable<Camera>;
  2098. /**
  2099. * Gets a camera using its unique id
  2100. * @param uniqueId defines the unique id to look for
  2101. * @returns the camera or null if not found
  2102. */
  2103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2104. /**
  2105. * Gets a camera using its name
  2106. * @param name defines the camera's name
  2107. * @return the camera or null if none found.
  2108. */
  2109. getCameraByName(name: string): Nullable<Camera>;
  2110. /**
  2111. * Gets a bone using its id
  2112. * @param id defines the bone's id
  2113. * @return the bone or null if not found
  2114. */
  2115. getBoneByID(id: string): Nullable<Bone>;
  2116. /**
  2117. * Gets a bone using its id
  2118. * @param name defines the bone's name
  2119. * @return the bone or null if not found
  2120. */
  2121. getBoneByName(name: string): Nullable<Bone>;
  2122. /**
  2123. * Gets a light node using its name
  2124. * @param name defines the the light's name
  2125. * @return the light or null if none found.
  2126. */
  2127. getLightByName(name: string): Nullable<Light>;
  2128. /**
  2129. * Gets a light node using its id
  2130. * @param id defines the light's id
  2131. * @return the light or null if none found.
  2132. */
  2133. getLightByID(id: string): Nullable<Light>;
  2134. /**
  2135. * Gets a light node using its scene-generated unique ID
  2136. * @param uniqueId defines the light's unique id
  2137. * @return the light or null if none found.
  2138. */
  2139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2140. /**
  2141. * Gets a particle system by id
  2142. * @param id defines the particle system id
  2143. * @return the corresponding system or null if none found
  2144. */
  2145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2146. /**
  2147. * Gets a geometry using its ID
  2148. * @param id defines the geometry's id
  2149. * @return the geometry or null if none found.
  2150. */
  2151. getGeometryByID(id: string): Nullable<Geometry>;
  2152. private _getGeometryByUniqueID;
  2153. /**
  2154. * Add a new geometry to this scene
  2155. * @param geometry defines the geometry to be added to the scene.
  2156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2157. * @return a boolean defining if the geometry was added or not
  2158. */
  2159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2160. /**
  2161. * Removes an existing geometry
  2162. * @param geometry defines the geometry to be removed from the scene
  2163. * @return a boolean defining if the geometry was removed or not
  2164. */
  2165. removeGeometry(geometry: Geometry): boolean;
  2166. /**
  2167. * Gets the list of geometries attached to the scene
  2168. * @returns an array of Geometry
  2169. */
  2170. getGeometries(): Geometry[];
  2171. /**
  2172. * Gets the first added mesh found of a given ID
  2173. * @param id defines the id to search for
  2174. * @return the mesh found or null if not found at all
  2175. */
  2176. getMeshByID(id: string): Nullable<AbstractMesh>;
  2177. /**
  2178. * Gets a list of meshes using their id
  2179. * @param id defines the id to search for
  2180. * @returns a list of meshes
  2181. */
  2182. getMeshesByID(id: string): Array<AbstractMesh>;
  2183. /**
  2184. * Gets the first added transform node found of a given ID
  2185. * @param id defines the id to search for
  2186. * @return the found transform node or null if not found at all.
  2187. */
  2188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2189. /**
  2190. * Gets a list of transform nodes using their id
  2191. * @param id defines the id to search for
  2192. * @returns a list of transform nodes
  2193. */
  2194. getTransformNodesByID(id: string): Array<TransformNode>;
  2195. /**
  2196. * Gets a mesh with its auto-generated unique id
  2197. * @param uniqueId defines the unique id to search for
  2198. * @return the found mesh or null if not found at all.
  2199. */
  2200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2201. /**
  2202. * Gets a the last added mesh using a given id
  2203. * @param id defines the id to search for
  2204. * @return the found mesh or null if not found at all.
  2205. */
  2206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2207. /**
  2208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2209. * @param id defines the id to search for
  2210. * @return the found node or null if not found at all
  2211. */
  2212. getLastEntryByID(id: string): Nullable<Node>;
  2213. /**
  2214. * Gets a node (Mesh, Camera, Light) using a given id
  2215. * @param id defines the id to search for
  2216. * @return the found node or null if not found at all
  2217. */
  2218. getNodeByID(id: string): Nullable<Node>;
  2219. /**
  2220. * Gets a node (Mesh, Camera, Light) using a given name
  2221. * @param name defines the name to search for
  2222. * @return the found node or null if not found at all.
  2223. */
  2224. getNodeByName(name: string): Nullable<Node>;
  2225. /**
  2226. * Gets a mesh using a given name
  2227. * @param name defines the name to search for
  2228. * @return the found mesh or null if not found at all.
  2229. */
  2230. getMeshByName(name: string): Nullable<AbstractMesh>;
  2231. /**
  2232. * Gets a transform node using a given name
  2233. * @param name defines the name to search for
  2234. * @return the found transform node or null if not found at all.
  2235. */
  2236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2237. /**
  2238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2239. * @param id defines the id to search for
  2240. * @return the found skeleton or null if not found at all.
  2241. */
  2242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2243. /**
  2244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2245. * @param id defines the id to search for
  2246. * @return the found skeleton or null if not found at all.
  2247. */
  2248. getSkeletonById(id: string): Nullable<Skeleton>;
  2249. /**
  2250. * Gets a skeleton using a given name
  2251. * @param name defines the name to search for
  2252. * @return the found skeleton or null if not found at all.
  2253. */
  2254. getSkeletonByName(name: string): Nullable<Skeleton>;
  2255. /**
  2256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2257. * @param id defines the id to search for
  2258. * @return the found morph target manager or null if not found at all.
  2259. */
  2260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2261. /**
  2262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2263. * @param id defines the id to search for
  2264. * @return the found morph target or null if not found at all.
  2265. */
  2266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2267. /**
  2268. * Gets a boolean indicating if the given mesh is active
  2269. * @param mesh defines the mesh to look for
  2270. * @returns true if the mesh is in the active list
  2271. */
  2272. isActiveMesh(mesh: AbstractMesh): boolean;
  2273. /**
  2274. * Return a unique id as a string which can serve as an identifier for the scene
  2275. */
  2276. readonly uid: string;
  2277. /**
  2278. * Add an externaly attached data from its key.
  2279. * This method call will fail and return false, if such key already exists.
  2280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2281. * @param key the unique key that identifies the data
  2282. * @param data the data object to associate to the key for this Engine instance
  2283. * @return true if no such key were already present and the data was added successfully, false otherwise
  2284. */
  2285. addExternalData<T>(key: string, data: T): boolean;
  2286. /**
  2287. * Get an externaly attached data from its key
  2288. * @param key the unique key that identifies the data
  2289. * @return the associated data, if present (can be null), or undefined if not present
  2290. */
  2291. getExternalData<T>(key: string): Nullable<T>;
  2292. /**
  2293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2294. * @param key the unique key that identifies the data
  2295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2296. * @return the associated data, can be null if the factory returned null.
  2297. */
  2298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2299. /**
  2300. * Remove an externaly attached data from the Engine instance
  2301. * @param key the unique key that identifies the data
  2302. * @return true if the data was successfully removed, false if it doesn't exist
  2303. */
  2304. removeExternalData(key: string): boolean;
  2305. private _evaluateSubMesh;
  2306. /**
  2307. * Clear the processed materials smart array preventing retention point in material dispose.
  2308. */
  2309. freeProcessedMaterials(): void;
  2310. private _preventFreeActiveMeshesAndRenderingGroups;
  2311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2313. * when disposing several meshes in a row or a hierarchy of meshes.
  2314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2315. */
  2316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2317. /**
  2318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2319. */
  2320. freeActiveMeshes(): void;
  2321. /**
  2322. * Clear the info related to rendering groups preventing retention points during dispose.
  2323. */
  2324. freeRenderingGroups(): void;
  2325. /** @hidden */
  2326. _isInIntermediateRendering(): boolean;
  2327. /**
  2328. * Lambda returning the list of potentially active meshes.
  2329. */
  2330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2331. /**
  2332. * Lambda returning the list of potentially active sub meshes.
  2333. */
  2334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2335. /**
  2336. * Lambda returning the list of potentially intersecting sub meshes.
  2337. */
  2338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2339. /**
  2340. * Lambda returning the list of potentially colliding sub meshes.
  2341. */
  2342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2343. private _activeMeshesFrozen;
  2344. /**
  2345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2346. * @returns the current scene
  2347. */
  2348. freezeActiveMeshes(): Scene;
  2349. /**
  2350. * Use this function to restart evaluating active meshes on every frame
  2351. * @returns the current scene
  2352. */
  2353. unfreezeActiveMeshes(): Scene;
  2354. private _evaluateActiveMeshes;
  2355. private _activeMesh;
  2356. /**
  2357. * Update the transform matrix to update from the current active camera
  2358. * @param force defines a boolean used to force the update even if cache is up to date
  2359. */
  2360. updateTransformMatrix(force?: boolean): void;
  2361. /**
  2362. * 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)
  2363. * @param alternateCamera defines the camera to use
  2364. */
  2365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2366. /** @hidden */
  2367. _allowPostProcessClearColor: boolean;
  2368. private _renderForCamera;
  2369. private _processSubCameras;
  2370. private _checkIntersections;
  2371. /** @hidden */
  2372. _advancePhysicsEngineStep(step: number): void;
  2373. /**
  2374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2375. */
  2376. getDeterministicFrameTime: () => number;
  2377. /**
  2378. * Render the scene
  2379. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2380. */
  2381. render(updateCameras?: boolean): void;
  2382. /**
  2383. * Freeze all materials
  2384. * A frozen material will not be updatable but should be faster to render
  2385. */
  2386. freezeMaterials(): void;
  2387. /**
  2388. * Unfreeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. unfreezeMaterials(): void;
  2392. /**
  2393. * Releases all held ressources
  2394. */
  2395. dispose(): void;
  2396. /**
  2397. * Gets if the scene is already disposed
  2398. */
  2399. readonly isDisposed: boolean;
  2400. /**
  2401. * Call this function to reduce memory footprint of the scene.
  2402. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2403. */
  2404. clearCachedVertexData(): void;
  2405. /**
  2406. * This function will remove the local cached buffer data from texture.
  2407. * It will save memory but will prevent the texture from being rebuilt
  2408. */
  2409. cleanCachedTextureBuffer(): void;
  2410. /**
  2411. * Get the world extend vectors with an optional filter
  2412. *
  2413. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2414. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2415. */
  2416. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2417. min: Vector3;
  2418. max: Vector3;
  2419. };
  2420. /**
  2421. * Creates a ray that can be used to pick in the scene
  2422. * @param x defines the x coordinate of the origin (on-screen)
  2423. * @param y defines the y coordinate of the origin (on-screen)
  2424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2425. * @param camera defines the camera to use for the picking
  2426. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2427. * @returns a Ray
  2428. */
  2429. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2430. /**
  2431. * Creates a ray that can be used to pick in the scene
  2432. * @param x defines the x coordinate of the origin (on-screen)
  2433. * @param y defines the y coordinate of the origin (on-screen)
  2434. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2435. * @param result defines the ray where to store the picking ray
  2436. * @param camera defines the camera to use for the picking
  2437. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2438. * @returns the current scene
  2439. */
  2440. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  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 camera defines the camera to use for the picking
  2446. * @returns a Ray
  2447. */
  2448. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2449. /**
  2450. * Creates a ray that can be used to pick in the scene
  2451. * @param x defines the x coordinate of the origin (on-screen)
  2452. * @param y defines the y coordinate of the origin (on-screen)
  2453. * @param result defines the ray where to store the picking ray
  2454. * @param camera defines the camera to use for the picking
  2455. * @returns the current scene
  2456. */
  2457. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2458. private _internalPick;
  2459. private _internalMultiPick;
  2460. private _tempPickingRay;
  2461. /** Launch a ray to try to pick a mesh in the scene
  2462. * @param x position on screen
  2463. * @param y position on screen
  2464. * @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
  2465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2466. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2467. * @returns a PickingInfo
  2468. */
  2469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2470. private _cachedRayForTransform;
  2471. /** Use the given ray to pick a mesh in the scene
  2472. * @param ray The ray to use to pick meshes
  2473. * @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
  2474. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2475. * @returns a PickingInfo
  2476. */
  2477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2478. /**
  2479. * Launch a ray to try to pick a mesh in the scene
  2480. * @param x X position on screen
  2481. * @param y Y position on screen
  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. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2484. * @returns an array of PickingInfo
  2485. */
  2486. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2487. /**
  2488. * Launch a ray to try to pick a mesh in the scene
  2489. * @param ray Ray to use
  2490. * @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
  2491. * @returns an array of PickingInfo
  2492. */
  2493. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2494. /**
  2495. * Force the value of meshUnderPointer
  2496. * @param mesh defines the mesh to use
  2497. */
  2498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2499. /**
  2500. * Gets the mesh under the pointer
  2501. * @returns a Mesh or null if no mesh is under the pointer
  2502. */
  2503. getPointerOverMesh(): Nullable<AbstractMesh>;
  2504. /** @hidden */
  2505. _rebuildGeometries(): void;
  2506. /** @hidden */
  2507. _rebuildTextures(): void;
  2508. private _getByTags;
  2509. /**
  2510. * Get a list of meshes by tags
  2511. * @param tagsQuery defines the tags query to use
  2512. * @param forEach defines a predicate used to filter results
  2513. * @returns an array of Mesh
  2514. */
  2515. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2516. /**
  2517. * Get a list of cameras by tags
  2518. * @param tagsQuery defines the tags query to use
  2519. * @param forEach defines a predicate used to filter results
  2520. * @returns an array of Camera
  2521. */
  2522. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2523. /**
  2524. * Get a list of lights by tags
  2525. * @param tagsQuery defines the tags query to use
  2526. * @param forEach defines a predicate used to filter results
  2527. * @returns an array of Light
  2528. */
  2529. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2530. /**
  2531. * Get a list of materials by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Material
  2535. */
  2536. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2537. /**
  2538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2539. * This allowed control for front to back rendering or reversly depending of the special needs.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2545. */
  2546. 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;
  2547. /**
  2548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2549. *
  2550. * @param renderingGroupId The rendering group id corresponding to its index
  2551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2554. */
  2555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2556. /**
  2557. * Gets the current auto clear configuration for one rendering group of the rendering
  2558. * manager.
  2559. * @param index the rendering group index to get the information for
  2560. * @returns The auto clear setup for the requested rendering group
  2561. */
  2562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2563. private _blockMaterialDirtyMechanism;
  2564. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2565. blockMaterialDirtyMechanism: boolean;
  2566. /**
  2567. * Will flag all materials as dirty to trigger new shader compilation
  2568. * @param flag defines the flag used to specify which material part must be marked as dirty
  2569. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2570. */
  2571. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2572. /** @hidden */
  2573. _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;
  2574. /** @hidden */
  2575. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Groups all the scene component constants in one place to ease maintenance.
  2581. * @hidden
  2582. */
  2583. class SceneComponentConstants {
  2584. static readonly NAME_EFFECTLAYER: string;
  2585. static readonly NAME_LAYER: string;
  2586. static readonly NAME_LENSFLARESYSTEM: string;
  2587. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2588. static readonly NAME_PARTICLESYSTEM: string;
  2589. static readonly NAME_GAMEPAD: string;
  2590. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2591. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2592. static readonly NAME_DEPTHRENDERER: string;
  2593. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2594. static readonly NAME_SPRITE: string;
  2595. static readonly NAME_OUTLINERENDERER: string;
  2596. static readonly NAME_PROCEDURALTEXTURE: string;
  2597. static readonly NAME_SHADOWGENERATOR: string;
  2598. static readonly NAME_OCTREE: string;
  2599. static readonly NAME_PHYSICSENGINE: string;
  2600. static readonly NAME_AUDIO: string;
  2601. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2602. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2603. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2604. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2605. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2606. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2607. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2608. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2609. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2610. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2611. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2612. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2613. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2614. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2615. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2616. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2617. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2618. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2620. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2621. static readonly STEP_AFTERRENDER_AUDIO: number;
  2622. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2623. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2624. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2625. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2626. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2627. static readonly STEP_POINTERMOVE_SPRITE: number;
  2628. static readonly STEP_POINTERDOWN_SPRITE: number;
  2629. static readonly STEP_POINTERUP_SPRITE: number;
  2630. }
  2631. /**
  2632. * This represents a scene component.
  2633. *
  2634. * This is used to decouple the dependency the scene is having on the different workloads like
  2635. * layers, post processes...
  2636. */
  2637. interface ISceneComponent {
  2638. /**
  2639. * The name of the component. Each component must have a unique name.
  2640. */
  2641. name: string;
  2642. /**
  2643. * The scene the component belongs to.
  2644. */
  2645. scene: Scene;
  2646. /**
  2647. * Register the component to one instance of a scene.
  2648. */
  2649. register(): void;
  2650. /**
  2651. * Rebuilds the elements related to this component in case of
  2652. * context lost for instance.
  2653. */
  2654. rebuild(): void;
  2655. /**
  2656. * Disposes the component and the associated ressources.
  2657. */
  2658. dispose(): void;
  2659. }
  2660. /**
  2661. * This represents a SERIALIZABLE scene component.
  2662. *
  2663. * This extends Scene Component to add Serialization methods on top.
  2664. */
  2665. interface ISceneSerializableComponent extends ISceneComponent {
  2666. /**
  2667. * Adds all the element from the container to the scene
  2668. * @param container the container holding the elements
  2669. */
  2670. addFromContainer(container: AbstractScene): void;
  2671. /**
  2672. * Removes all the elements in the container from the scene
  2673. * @param container contains the elements to remove
  2674. */
  2675. removeFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Serializes the component data to the specified json object
  2678. * @param serializationObject The object to serialize to
  2679. */
  2680. serialize(serializationObject: any): void;
  2681. }
  2682. /**
  2683. * Strong typing of a Mesh related stage step action
  2684. */
  2685. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2686. /**
  2687. * Strong typing of a Evaluate Sub Mesh related stage step action
  2688. */
  2689. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2690. /**
  2691. * Strong typing of a Active Mesh related stage step action
  2692. */
  2693. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2694. /**
  2695. * Strong typing of a Camera related stage step action
  2696. */
  2697. type CameraStageAction = (camera: Camera) => void;
  2698. /**
  2699. * Strong typing of a Render Target related stage step action
  2700. */
  2701. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2702. /**
  2703. * Strong typing of a RenderingGroup related stage step action
  2704. */
  2705. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2706. /**
  2707. * Strong typing of a Mesh Render related stage step action
  2708. */
  2709. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2710. /**
  2711. * Strong typing of a simple stage step action
  2712. */
  2713. type SimpleStageAction = () => void;
  2714. /**
  2715. * Strong typing of a render target action.
  2716. */
  2717. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2718. /**
  2719. * Strong typing of a pointer move action.
  2720. */
  2721. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2722. /**
  2723. * Strong typing of a pointer up/down action.
  2724. */
  2725. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2726. /**
  2727. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2728. * @hidden
  2729. */
  2730. class Stage<T extends Function> extends Array<{
  2731. index: number;
  2732. component: ISceneComponent;
  2733. action: T;
  2734. }> {
  2735. /**
  2736. * Hide ctor from the rest of the world.
  2737. * @param items The items to add.
  2738. */
  2739. private constructor();
  2740. /**
  2741. * Creates a new Stage.
  2742. * @returns A new instance of a Stage
  2743. */
  2744. static Create<T extends Function>(): Stage<T>;
  2745. /**
  2746. * Registers a step in an ordered way in the targeted stage.
  2747. * @param index Defines the position to register the step in
  2748. * @param component Defines the component attached to the step
  2749. * @param action Defines the action to launch during the step
  2750. */
  2751. registerStep(index: number, component: ISceneComponent, action: T): void;
  2752. /**
  2753. * Clears all the steps from the stage.
  2754. */
  2755. clear(): void;
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /** Alias type for value that can be null */
  2760. type Nullable<T> = T | null;
  2761. /**
  2762. * Alias type for number that are floats
  2763. * @ignorenaming
  2764. */
  2765. type float = number;
  2766. /**
  2767. * Alias type for number that are doubles.
  2768. * @ignorenaming
  2769. */
  2770. type double = number;
  2771. /**
  2772. * Alias type for number that are integer
  2773. * @ignorenaming
  2774. */
  2775. type int = number;
  2776. /** Alias type for number array or Float32Array */
  2777. type FloatArray = number[] | Float32Array;
  2778. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2779. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2780. /**
  2781. * Alias for types that can be used by a Buffer or VertexBuffer.
  2782. */
  2783. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2784. /**
  2785. * Alias type for primitive types
  2786. * @ignorenaming
  2787. */
  2788. type Primitive = undefined | null | boolean | string | number | Function;
  2789. /**
  2790. * Type modifier to make all the properties of an object Readonly
  2791. */
  2792. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2793. /**
  2794. * Type modifier to make all the properties of an object Readonly recursively
  2795. */
  2796. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2797. /** @hidden */
  2798. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2799. }
  2800. /** @hidden */
  2801. /** @hidden */
  2802. type DeepImmutableObject<T> = {
  2803. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2804. };
  2805. }
  2806. declare module BABYLON {
  2807. /**
  2808. * The action to be carried out following a trigger
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2810. */
  2811. class Action {
  2812. /** the trigger, with or without parameters, for the action */
  2813. triggerOptions: any;
  2814. /**
  2815. * Trigger for the action
  2816. */
  2817. trigger: number;
  2818. /**
  2819. * Internal only - manager for action
  2820. * @hidden
  2821. */
  2822. _actionManager: ActionManager;
  2823. private _nextActiveAction;
  2824. private _child;
  2825. private _condition?;
  2826. private _triggerParameter;
  2827. /**
  2828. * An event triggered prior to action being executed.
  2829. */
  2830. onBeforeExecuteObservable: Observable<Action>;
  2831. /**
  2832. * Creates a new Action
  2833. * @param triggerOptions the trigger, with or without parameters, for the action
  2834. * @param condition an optional determinant of action
  2835. */
  2836. constructor(
  2837. /** the trigger, with or without parameters, for the action */
  2838. triggerOptions: any, condition?: Condition);
  2839. /**
  2840. * Internal only
  2841. * @hidden
  2842. */
  2843. _prepare(): void;
  2844. /**
  2845. * Gets the trigger parameters
  2846. * @returns the trigger parameters
  2847. */
  2848. getTriggerParameter(): any;
  2849. /**
  2850. * Internal only - executes current action event
  2851. * @hidden
  2852. */
  2853. _executeCurrent(evt?: ActionEvent): void;
  2854. /**
  2855. * Execute placeholder for child classes
  2856. * @param evt optional action event
  2857. */
  2858. execute(evt?: ActionEvent): void;
  2859. /**
  2860. * Skips to next active action
  2861. */
  2862. skipToNextActiveAction(): void;
  2863. /**
  2864. * Adds action to chain of actions, may be a DoNothingAction
  2865. * @param action defines the next action to execute
  2866. * @returns The action passed in
  2867. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2868. */
  2869. then(action: Action): Action;
  2870. /**
  2871. * Internal only
  2872. * @hidden
  2873. */
  2874. _getProperty(propertyPath: string): string;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getEffectiveTarget(target: any, propertyPath: string): any;
  2880. /**
  2881. * Serialize placeholder for child classes
  2882. * @param parent of child
  2883. * @returns the serialized object
  2884. */
  2885. serialize(parent: any): any;
  2886. /**
  2887. * Internal only called by serialize
  2888. * @hidden
  2889. */
  2890. protected _serialize(serializedAction: any, parent?: any): any;
  2891. /**
  2892. * Internal only
  2893. * @hidden
  2894. */
  2895. static _SerializeValueAsString: (value: any) => string;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _GetTargetProperty: (target: Scene | Node) => {
  2901. name: string;
  2902. targetType: string;
  2903. value: string;
  2904. };
  2905. }
  2906. }
  2907. declare module BABYLON {
  2908. /**
  2909. * ActionEvent is the event being sent when an action is triggered.
  2910. */
  2911. class ActionEvent {
  2912. /** The mesh or sprite that triggered the action */
  2913. source: any;
  2914. /** The X mouse cursor position at the time of the event */
  2915. pointerX: number;
  2916. /** The Y mouse cursor position at the time of the event */
  2917. pointerY: number;
  2918. /** The mesh that is currently pointed at (can be null) */
  2919. meshUnderPointer: Nullable<AbstractMesh>;
  2920. /** the original (browser) event that triggered the ActionEvent */
  2921. sourceEvent?: any;
  2922. /** additional data for the event */
  2923. additionalData?: any;
  2924. /**
  2925. * Creates a new ActionEvent
  2926. * @param source The mesh or sprite that triggered the action
  2927. * @param pointerX The X mouse cursor position at the time of the event
  2928. * @param pointerY The Y mouse cursor position at the time of the event
  2929. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2930. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2931. * @param additionalData additional data for the event
  2932. */
  2933. constructor(
  2934. /** The mesh or sprite that triggered the action */
  2935. source: any,
  2936. /** The X mouse cursor position at the time of the event */
  2937. pointerX: number,
  2938. /** The Y mouse cursor position at the time of the event */
  2939. pointerY: number,
  2940. /** The mesh that is currently pointed at (can be null) */
  2941. meshUnderPointer: Nullable<AbstractMesh>,
  2942. /** the original (browser) event that triggered the ActionEvent */
  2943. sourceEvent?: any,
  2944. /** additional data for the event */
  2945. additionalData?: any);
  2946. /**
  2947. * Helper function to auto-create an ActionEvent from a source mesh.
  2948. * @param source The source mesh that triggered the event
  2949. * @param evt The original (browser) event
  2950. * @param additionalData additional data for the event
  2951. * @returns the new ActionEvent
  2952. */
  2953. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2954. /**
  2955. * Helper function to auto-create an ActionEvent from a source sprite
  2956. * @param source The source sprite that triggered the event
  2957. * @param scene Scene associated with the sprite
  2958. * @param evt The original (browser) event
  2959. * @param additionalData additional data for the event
  2960. * @returns the new ActionEvent
  2961. */
  2962. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2963. /**
  2964. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2965. * @param scene the scene where the event occurred
  2966. * @param evt The original (browser) event
  2967. * @returns the new ActionEvent
  2968. */
  2969. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2970. /**
  2971. * Helper function to auto-create an ActionEvent from a primitive
  2972. * @param prim defines the target primitive
  2973. * @param pointerPos defines the pointer position
  2974. * @param evt The original (browser) event
  2975. * @param additionalData additional data for the event
  2976. * @returns the new ActionEvent
  2977. */
  2978. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2979. }
  2980. /**
  2981. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2982. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2984. */
  2985. class ActionManager {
  2986. /**
  2987. * Nothing
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2989. */
  2990. static readonly NothingTrigger: number;
  2991. /**
  2992. * On pick
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly OnPickTrigger: number;
  2996. /**
  2997. * On left pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnLeftPickTrigger: number;
  3001. /**
  3002. * On right pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnRightPickTrigger: number;
  3006. /**
  3007. * On center pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnCenterPickTrigger: number;
  3011. /**
  3012. * On pick down
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnPickDownTrigger: number;
  3016. /**
  3017. * On double pick
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnDoublePickTrigger: number;
  3021. /**
  3022. * On pick up
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnPickUpTrigger: number;
  3026. /**
  3027. * On pick out.
  3028. * This trigger will only be raised if you also declared a OnPickDown
  3029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3030. */
  3031. static readonly OnPickOutTrigger: number;
  3032. /**
  3033. * On long press
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnLongPressTrigger: number;
  3037. /**
  3038. * On pointer over
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnPointerOverTrigger: number;
  3042. /**
  3043. * On pointer out
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOutTrigger: number;
  3047. /**
  3048. * On every frame
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnEveryFrameTrigger: number;
  3052. /**
  3053. * On intersection enter
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnIntersectionEnterTrigger: number;
  3057. /**
  3058. * On intersection exit
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionExitTrigger: number;
  3062. /**
  3063. * On key down
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnKeyDownTrigger: number;
  3067. /**
  3068. * On key up
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyUpTrigger: number;
  3072. /** Gets the list of active triggers */
  3073. static Triggers: {
  3074. [key: string]: number;
  3075. };
  3076. /** Gets the list of actions */
  3077. actions: Action[];
  3078. /** Gets the cursor to use when hovering items */
  3079. hoverCursor: string;
  3080. private _scene;
  3081. /**
  3082. * Creates a new action manager
  3083. * @param scene defines the hosting scene
  3084. */
  3085. constructor(scene: Scene);
  3086. /**
  3087. * Releases all associated resources
  3088. */
  3089. dispose(): void;
  3090. /**
  3091. * Gets hosting scene
  3092. * @returns the hosting scene
  3093. */
  3094. getScene(): Scene;
  3095. /**
  3096. * Does this action manager handles actions of any of the given triggers
  3097. * @param triggers defines the triggers to be tested
  3098. * @return a boolean indicating whether one (or more) of the triggers is handled
  3099. */
  3100. hasSpecificTriggers(triggers: number[]): boolean;
  3101. /**
  3102. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3103. * speed.
  3104. * @param triggerA defines the trigger to be tested
  3105. * @param triggerB defines the trigger to be tested
  3106. * @return a boolean indicating whether one (or more) of the triggers is handled
  3107. */
  3108. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3109. /**
  3110. * Does this action manager handles actions of a given trigger
  3111. * @param trigger defines the trigger to be tested
  3112. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3113. * @return whether the trigger is handled
  3114. */
  3115. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3116. /**
  3117. * Does this action manager has pointer triggers
  3118. */
  3119. readonly hasPointerTriggers: boolean;
  3120. /**
  3121. * Does this action manager has pick triggers
  3122. */
  3123. readonly hasPickTriggers: boolean;
  3124. /**
  3125. * Does exist one action manager with at least one trigger
  3126. **/
  3127. static readonly HasTriggers: boolean;
  3128. /**
  3129. * Does exist one action manager with at least one pick trigger
  3130. **/
  3131. static readonly HasPickTriggers: boolean;
  3132. /**
  3133. * Does exist one action manager that handles actions of a given trigger
  3134. * @param trigger defines the trigger to be tested
  3135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3136. **/
  3137. static HasSpecificTrigger(trigger: number): boolean;
  3138. /**
  3139. * Registers an action to this action manager
  3140. * @param action defines the action to be registered
  3141. * @return the action amended (prepared) after registration
  3142. */
  3143. registerAction(action: Action): Nullable<Action>;
  3144. /**
  3145. * Unregisters an action to this action manager
  3146. * @param action defines the action to be unregistered
  3147. * @return a boolean indicating whether the action has been unregistered
  3148. */
  3149. unregisterAction(action: Action): Boolean;
  3150. /**
  3151. * Process a specific trigger
  3152. * @param trigger defines the trigger to process
  3153. * @param evt defines the event details to be processed
  3154. */
  3155. processTrigger(trigger: number, evt?: ActionEvent): void;
  3156. /** @hidden */
  3157. _getEffectiveTarget(target: any, propertyPath: string): any;
  3158. /** @hidden */
  3159. _getProperty(propertyPath: string): string;
  3160. /**
  3161. * Serialize this manager to a JSON object
  3162. * @param name defines the property name to store this manager
  3163. * @returns a JSON representation of this manager
  3164. */
  3165. serialize(name: string): any;
  3166. /**
  3167. * Creates a new ActionManager from a JSON data
  3168. * @param parsedActions defines the JSON data to read from
  3169. * @param object defines the hosting mesh
  3170. * @param scene defines the hosting scene
  3171. */
  3172. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3173. /**
  3174. * Get a trigger name by index
  3175. * @param trigger defines the trigger index
  3176. * @returns a trigger name
  3177. */
  3178. static GetTriggerName(trigger: number): string;
  3179. }
  3180. }
  3181. declare module BABYLON {
  3182. /**
  3183. * A Condition applied to an Action
  3184. */
  3185. class Condition {
  3186. /**
  3187. * Internal only - manager for action
  3188. * @hidden
  3189. */
  3190. _actionManager: ActionManager;
  3191. /**
  3192. * Internal only
  3193. * @hidden
  3194. */
  3195. _evaluationId: number;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _currentResult: boolean;
  3201. /**
  3202. * Creates a new Condition
  3203. * @param actionManager the manager of the action the condition is applied to
  3204. */
  3205. constructor(actionManager: ActionManager);
  3206. /**
  3207. * Check if the current condition is valid
  3208. * @returns a boolean
  3209. */
  3210. isValid(): boolean;
  3211. /**
  3212. * Internal only
  3213. * @hidden
  3214. */
  3215. _getProperty(propertyPath: string): string;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getEffectiveTarget(target: any, propertyPath: string): any;
  3221. /**
  3222. * Serialize placeholder for child classes
  3223. * @returns the serialized object
  3224. */
  3225. serialize(): any;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. protected _serialize(serializedCondition: any): any;
  3231. }
  3232. /**
  3233. * Defines specific conditional operators as extensions of Condition
  3234. */
  3235. class ValueCondition extends Condition {
  3236. /** path to specify the property of the target the conditional operator uses */
  3237. propertyPath: string;
  3238. /** the value compared by the conditional operator against the current value of the property */
  3239. value: any;
  3240. /** the conditional operator, default ValueCondition.IsEqual */
  3241. operator: number;
  3242. /**
  3243. * Internal only
  3244. * @hidden
  3245. */
  3246. private static _IsEqual;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsDifferent;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsGreater;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsLesser;
  3262. /**
  3263. * returns the number for IsEqual
  3264. */
  3265. static readonly IsEqual: number;
  3266. /**
  3267. * Returns the number for IsDifferent
  3268. */
  3269. static readonly IsDifferent: number;
  3270. /**
  3271. * Returns the number for IsGreater
  3272. */
  3273. static readonly IsGreater: number;
  3274. /**
  3275. * Returns the number for IsLesser
  3276. */
  3277. static readonly IsLesser: number;
  3278. /**
  3279. * Internal only The action manager for the condition
  3280. * @hidden
  3281. */
  3282. _actionManager: ActionManager;
  3283. /**
  3284. * Internal only
  3285. * @hidden
  3286. */
  3287. private _target;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _effectiveTarget;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _property;
  3298. /**
  3299. * Creates a new ValueCondition
  3300. * @param actionManager manager for the action the condition applies to
  3301. * @param target for the action
  3302. * @param propertyPath path to specify the property of the target the conditional operator uses
  3303. * @param value the value compared by the conditional operator against the current value of the property
  3304. * @param operator the conditional operator, default ValueCondition.IsEqual
  3305. */
  3306. constructor(actionManager: ActionManager, target: any,
  3307. /** path to specify the property of the target the conditional operator uses */
  3308. propertyPath: string,
  3309. /** the value compared by the conditional operator against the current value of the property */
  3310. value: any,
  3311. /** the conditional operator, default ValueCondition.IsEqual */
  3312. operator?: number);
  3313. /**
  3314. * Compares the given value with the property value for the specified conditional operator
  3315. * @returns the result of the comparison
  3316. */
  3317. isValid(): boolean;
  3318. /**
  3319. * Serialize the ValueCondition into a JSON compatible object
  3320. * @returns serialization object
  3321. */
  3322. serialize(): any;
  3323. /**
  3324. * Gets the name of the conditional operator for the ValueCondition
  3325. * @param operator the conditional operator
  3326. * @returns the name
  3327. */
  3328. static GetOperatorName(operator: number): string;
  3329. }
  3330. /**
  3331. * Defines a predicate condition as an extension of Condition
  3332. */
  3333. class PredicateCondition extends Condition {
  3334. /** defines the predicate function used to validate the condition */
  3335. predicate: () => boolean;
  3336. /**
  3337. * Internal only - manager for action
  3338. * @hidden
  3339. */
  3340. _actionManager: ActionManager;
  3341. /**
  3342. * Creates a new PredicateCondition
  3343. * @param actionManager manager for the action the condition applies to
  3344. * @param predicate defines the predicate function used to validate the condition
  3345. */
  3346. constructor(actionManager: ActionManager,
  3347. /** defines the predicate function used to validate the condition */
  3348. predicate: () => boolean);
  3349. /**
  3350. * @returns the validity of the predicate condition
  3351. */
  3352. isValid(): boolean;
  3353. }
  3354. /**
  3355. * Defines a state condition as an extension of Condition
  3356. */
  3357. class StateCondition extends Condition {
  3358. /** Value to compare with target state */
  3359. value: string;
  3360. /**
  3361. * Internal only - manager for action
  3362. * @hidden
  3363. */
  3364. _actionManager: ActionManager;
  3365. /**
  3366. * Internal only
  3367. * @hidden
  3368. */
  3369. private _target;
  3370. /**
  3371. * Creates a new StateCondition
  3372. * @param actionManager manager for the action the condition applies to
  3373. * @param target of the condition
  3374. * @param value to compare with target state
  3375. */
  3376. constructor(actionManager: ActionManager, target: any,
  3377. /** Value to compare with target state */
  3378. value: string);
  3379. /**
  3380. * Gets a boolean indicating if the current condition is met
  3381. * @returns the validity of the state
  3382. */
  3383. isValid(): boolean;
  3384. /**
  3385. * Serialize the StateCondition into a JSON compatible object
  3386. * @returns serialization object
  3387. */
  3388. serialize(): any;
  3389. }
  3390. }
  3391. declare module BABYLON {
  3392. /**
  3393. * This defines an action responsible to toggle a boolean once triggered.
  3394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3395. */
  3396. class SwitchBooleanAction extends Action {
  3397. /**
  3398. * The path to the boolean property in the target object
  3399. */
  3400. propertyPath: string;
  3401. private _target;
  3402. private _effectiveTarget;
  3403. private _property;
  3404. /**
  3405. * Instantiate the action
  3406. * @param triggerOptions defines the trigger options
  3407. * @param target defines the object containing the boolean
  3408. * @param propertyPath defines the path to the boolean property in the target object
  3409. * @param condition defines the trigger related conditions
  3410. */
  3411. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3412. /** @hidden */
  3413. _prepare(): void;
  3414. /**
  3415. * Execute the action toggle the boolean value.
  3416. */
  3417. execute(): void;
  3418. /**
  3419. * Serializes the actions and its related information.
  3420. * @param parent defines the object to serialize in
  3421. * @returns the serialized object
  3422. */
  3423. serialize(parent: any): any;
  3424. }
  3425. /**
  3426. * This defines an action responsible to set a the state field of the target
  3427. * to a desired value once triggered.
  3428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3429. */
  3430. class SetStateAction extends Action {
  3431. /**
  3432. * The value to store in the state field.
  3433. */
  3434. value: string;
  3435. private _target;
  3436. /**
  3437. * Instantiate the action
  3438. * @param triggerOptions defines the trigger options
  3439. * @param target defines the object containing the state property
  3440. * @param value defines the value to store in the state field
  3441. * @param condition defines the trigger related conditions
  3442. */
  3443. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3444. /**
  3445. * Execute the action and store the value on the target state property.
  3446. */
  3447. execute(): void;
  3448. /**
  3449. * Serializes the actions and its related information.
  3450. * @param parent defines the object to serialize in
  3451. * @returns the serialized object
  3452. */
  3453. serialize(parent: any): any;
  3454. }
  3455. /**
  3456. * This defines an action responsible to set a property of the target
  3457. * to a desired value once triggered.
  3458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3459. */
  3460. class SetValueAction extends Action {
  3461. /**
  3462. * The path of the property to set in the target.
  3463. */
  3464. propertyPath: string;
  3465. /**
  3466. * The value to set in the property
  3467. */
  3468. value: any;
  3469. private _target;
  3470. private _effectiveTarget;
  3471. private _property;
  3472. /**
  3473. * Instantiate the action
  3474. * @param triggerOptions defines the trigger options
  3475. * @param target defines the object containing the property
  3476. * @param propertyPath defines the path of the property to set in the target
  3477. * @param value defines the value to set in the property
  3478. * @param condition defines the trigger related conditions
  3479. */
  3480. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3481. /** @hidden */
  3482. _prepare(): void;
  3483. /**
  3484. * Execute the action and set the targetted property to the desired value.
  3485. */
  3486. execute(): void;
  3487. /**
  3488. * Serializes the actions and its related information.
  3489. * @param parent defines the object to serialize in
  3490. * @returns the serialized object
  3491. */
  3492. serialize(parent: any): any;
  3493. }
  3494. /**
  3495. * This defines an action responsible to increment the target value
  3496. * to a desired value once triggered.
  3497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3498. */
  3499. class IncrementValueAction extends Action {
  3500. /**
  3501. * The path of the property to increment in the target.
  3502. */
  3503. propertyPath: string;
  3504. /**
  3505. * The value we should increment the property by.
  3506. */
  3507. value: any;
  3508. private _target;
  3509. private _effectiveTarget;
  3510. private _property;
  3511. /**
  3512. * Instantiate the action
  3513. * @param triggerOptions defines the trigger options
  3514. * @param target defines the object containing the property
  3515. * @param propertyPath defines the path of the property to increment in the target
  3516. * @param value defines the value value we should increment the property by
  3517. * @param condition defines the trigger related conditions
  3518. */
  3519. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3520. /** @hidden */
  3521. _prepare(): void;
  3522. /**
  3523. * Execute the action and increment the target of the value amount.
  3524. */
  3525. execute(): void;
  3526. /**
  3527. * Serializes the actions and its related information.
  3528. * @param parent defines the object to serialize in
  3529. * @returns the serialized object
  3530. */
  3531. serialize(parent: any): any;
  3532. }
  3533. /**
  3534. * This defines an action responsible to start an animation once triggered.
  3535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3536. */
  3537. class PlayAnimationAction extends Action {
  3538. /**
  3539. * Where the animation should start (animation frame)
  3540. */
  3541. from: number;
  3542. /**
  3543. * Where the animation should stop (animation frame)
  3544. */
  3545. to: number;
  3546. /**
  3547. * Define if the animation should loop or stop after the first play.
  3548. */
  3549. loop?: boolean;
  3550. private _target;
  3551. /**
  3552. * Instantiate the action
  3553. * @param triggerOptions defines the trigger options
  3554. * @param target defines the target animation or animation name
  3555. * @param from defines from where the animation should start (animation frame)
  3556. * @param end defines where the animation should stop (animation frame)
  3557. * @param loop defines if the animation should loop or stop after the first play
  3558. * @param condition defines the trigger related conditions
  3559. */
  3560. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3561. /** @hidden */
  3562. _prepare(): void;
  3563. /**
  3564. * Execute the action and play the animation.
  3565. */
  3566. execute(): void;
  3567. /**
  3568. * Serializes the actions and its related information.
  3569. * @param parent defines the object to serialize in
  3570. * @returns the serialized object
  3571. */
  3572. serialize(parent: any): any;
  3573. }
  3574. /**
  3575. * This defines an action responsible to stop an animation once triggered.
  3576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3577. */
  3578. class StopAnimationAction extends Action {
  3579. private _target;
  3580. /**
  3581. * Instantiate the action
  3582. * @param triggerOptions defines the trigger options
  3583. * @param target defines the target animation or animation name
  3584. * @param condition defines the trigger related conditions
  3585. */
  3586. constructor(triggerOptions: any, target: any, condition?: Condition);
  3587. /** @hidden */
  3588. _prepare(): void;
  3589. /**
  3590. * Execute the action and stop the animation.
  3591. */
  3592. execute(): void;
  3593. /**
  3594. * Serializes the actions and its related information.
  3595. * @param parent defines the object to serialize in
  3596. * @returns the serialized object
  3597. */
  3598. serialize(parent: any): any;
  3599. }
  3600. /**
  3601. * This defines an action responsible that does nothing once triggered.
  3602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3603. */
  3604. class DoNothingAction extends Action {
  3605. /**
  3606. * Instantiate the action
  3607. * @param triggerOptions defines the trigger options
  3608. * @param condition defines the trigger related conditions
  3609. */
  3610. constructor(triggerOptions?: any, condition?: Condition);
  3611. /**
  3612. * Execute the action and do nothing.
  3613. */
  3614. execute(): void;
  3615. /**
  3616. * Serializes the actions and its related information.
  3617. * @param parent defines the object to serialize in
  3618. * @returns the serialized object
  3619. */
  3620. serialize(parent: any): any;
  3621. }
  3622. /**
  3623. * This defines an action responsible to trigger several actions once triggered.
  3624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3625. */
  3626. class CombineAction extends Action {
  3627. /**
  3628. * The list of aggregated animations to run.
  3629. */
  3630. children: Action[];
  3631. /**
  3632. * Instantiate the action
  3633. * @param triggerOptions defines the trigger options
  3634. * @param children defines the list of aggregated animations to run
  3635. * @param condition defines the trigger related conditions
  3636. */
  3637. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3638. /** @hidden */
  3639. _prepare(): void;
  3640. /**
  3641. * Execute the action and executes all the aggregated actions.
  3642. */
  3643. execute(evt: ActionEvent): void;
  3644. /**
  3645. * Serializes the actions and its related information.
  3646. * @param parent defines the object to serialize in
  3647. * @returns the serialized object
  3648. */
  3649. serialize(parent: any): any;
  3650. }
  3651. /**
  3652. * This defines an action responsible to run code (external event) once triggered.
  3653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3654. */
  3655. class ExecuteCodeAction extends Action {
  3656. /**
  3657. * The callback function to run.
  3658. */
  3659. func: (evt: ActionEvent) => void;
  3660. /**
  3661. * Instantiate the action
  3662. * @param triggerOptions defines the trigger options
  3663. * @param func defines the callback function to run
  3664. * @param condition defines the trigger related conditions
  3665. */
  3666. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3667. /**
  3668. * Execute the action and run the attached code.
  3669. */
  3670. execute(evt: ActionEvent): void;
  3671. }
  3672. /**
  3673. * This defines an action responsible to set the parent property of the target once triggered.
  3674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3675. */
  3676. class SetParentAction extends Action {
  3677. private _parent;
  3678. private _target;
  3679. /**
  3680. * Instantiate the action
  3681. * @param triggerOptions defines the trigger options
  3682. * @param target defines the target containing the parent property
  3683. * @param parent defines from where the animation should start (animation frame)
  3684. * @param condition defines the trigger related conditions
  3685. */
  3686. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3687. /** @hidden */
  3688. _prepare(): void;
  3689. /**
  3690. * Execute the action and set the parent property.
  3691. */
  3692. execute(): void;
  3693. /**
  3694. * Serializes the actions and its related information.
  3695. * @param parent defines the object to serialize in
  3696. * @returns the serialized object
  3697. */
  3698. serialize(parent: any): any;
  3699. }
  3700. }
  3701. declare module BABYLON {
  3702. /**
  3703. * This defines an action helpful to play a defined sound on a triggered action.
  3704. */
  3705. class PlaySoundAction extends Action {
  3706. private _sound;
  3707. /**
  3708. * Instantiate the action
  3709. * @param triggerOptions defines the trigger options
  3710. * @param sound defines the sound to play
  3711. * @param condition defines the trigger related conditions
  3712. */
  3713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3714. /** @hidden */
  3715. _prepare(): void;
  3716. /**
  3717. * Execute the action and play the sound.
  3718. */
  3719. execute(): void;
  3720. /**
  3721. * Serializes the actions and its related information.
  3722. * @param parent defines the object to serialize in
  3723. * @returns the serialized object
  3724. */
  3725. serialize(parent: any): any;
  3726. }
  3727. /**
  3728. * This defines an action helpful to stop a defined sound on a triggered action.
  3729. */
  3730. class StopSoundAction extends Action {
  3731. private _sound;
  3732. /**
  3733. * Instantiate the action
  3734. * @param triggerOptions defines the trigger options
  3735. * @param sound defines the sound to stop
  3736. * @param condition defines the trigger related conditions
  3737. */
  3738. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3739. /** @hidden */
  3740. _prepare(): void;
  3741. /**
  3742. * Execute the action and stop the sound.
  3743. */
  3744. execute(): void;
  3745. /**
  3746. * Serializes the actions and its related information.
  3747. * @param parent defines the object to serialize in
  3748. * @returns the serialized object
  3749. */
  3750. serialize(parent: any): any;
  3751. }
  3752. }
  3753. declare module BABYLON {
  3754. /**
  3755. * This defines an action responsible to change the value of a property
  3756. * by interpolating between its current value and the newly set one once triggered.
  3757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3758. */
  3759. class InterpolateValueAction extends Action {
  3760. /**
  3761. * Defines the path of the property where the value should be interpolated
  3762. */
  3763. propertyPath: string;
  3764. /**
  3765. * Defines the target value at the end of the interpolation.
  3766. */
  3767. value: any;
  3768. /**
  3769. * Defines the time it will take for the property to interpolate to the value.
  3770. */
  3771. duration: number;
  3772. /**
  3773. * Defines if the other scene animations should be stopped when the action has been triggered
  3774. */
  3775. stopOtherAnimations?: boolean;
  3776. /**
  3777. * Defines a callback raised once the interpolation animation has been done.
  3778. */
  3779. onInterpolationDone?: () => void;
  3780. /**
  3781. * Observable triggered once the interpolation animation has been done.
  3782. */
  3783. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3784. private _target;
  3785. private _effectiveTarget;
  3786. private _property;
  3787. /**
  3788. * Instantiate the action
  3789. * @param triggerOptions defines the trigger options
  3790. * @param target defines the object containing the value to interpolate
  3791. * @param propertyPath defines the path to the property in the target object
  3792. * @param value defines the target value at the end of the interpolation
  3793. * @param duration deines the time it will take for the property to interpolate to the value.
  3794. * @param condition defines the trigger related conditions
  3795. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3796. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3797. */
  3798. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3799. /** @hidden */
  3800. _prepare(): void;
  3801. /**
  3802. * Execute the action starts the value interpolation.
  3803. */
  3804. execute(): void;
  3805. /**
  3806. * Serializes the actions and its related information.
  3807. * @param parent defines the object to serialize in
  3808. * @returns the serialized object
  3809. */
  3810. serialize(parent: any): any;
  3811. }
  3812. }
  3813. declare module BABYLON {
  3814. /**
  3815. * Class used to store an actual running animation
  3816. */
  3817. class Animatable {
  3818. /** defines the target object */
  3819. target: any;
  3820. /** defines the starting frame number (default is 0) */
  3821. fromFrame: number;
  3822. /** defines the ending frame number (default is 100) */
  3823. toFrame: number;
  3824. /** defines if the animation must loop (default is false) */
  3825. loopAnimation: boolean;
  3826. /** defines a callback to call when animation ends if it is not looping */
  3827. onAnimationEnd?: (() => void) | null | undefined;
  3828. private _localDelayOffset;
  3829. private _pausedDelay;
  3830. private _runtimeAnimations;
  3831. private _paused;
  3832. private _scene;
  3833. private _speedRatio;
  3834. private _weight;
  3835. private _syncRoot;
  3836. /**
  3837. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3838. * This will only apply for non looping animation (default is true)
  3839. */
  3840. disposeOnEnd: boolean;
  3841. /**
  3842. * Gets a boolean indicating if the animation has started
  3843. */
  3844. animationStarted: boolean;
  3845. /**
  3846. * Observer raised when the animation ends
  3847. */
  3848. onAnimationEndObservable: Observable<Animatable>;
  3849. /**
  3850. * Gets the root Animatable used to synchronize and normalize animations
  3851. */
  3852. readonly syncRoot: Animatable;
  3853. /**
  3854. * Gets the current frame of the first RuntimeAnimation
  3855. * Used to synchronize Animatables
  3856. */
  3857. readonly masterFrame: number;
  3858. /**
  3859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3860. */
  3861. weight: number;
  3862. /**
  3863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3864. */
  3865. speedRatio: number;
  3866. /**
  3867. * Creates a new Animatable
  3868. * @param scene defines the hosting scene
  3869. * @param target defines the target object
  3870. * @param fromFrame defines the starting frame number (default is 0)
  3871. * @param toFrame defines the ending frame number (default is 100)
  3872. * @param loopAnimation defines if the animation must loop (default is false)
  3873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3875. * @param animations defines a group of animation to add to the new Animatable
  3876. */
  3877. constructor(scene: Scene,
  3878. /** defines the target object */
  3879. target: any,
  3880. /** defines the starting frame number (default is 0) */
  3881. fromFrame?: number,
  3882. /** defines the ending frame number (default is 100) */
  3883. toFrame?: number,
  3884. /** defines if the animation must loop (default is false) */
  3885. loopAnimation?: boolean, speedRatio?: number,
  3886. /** defines a callback to call when animation ends if it is not looping */
  3887. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3888. /**
  3889. * Synchronize and normalize current Animatable with a source Animatable
  3890. * This is useful when using animation weights and when animations are not of the same length
  3891. * @param root defines the root Animatable to synchronize with
  3892. * @returns the current Animatable
  3893. */
  3894. syncWith(root: Animatable): Animatable;
  3895. /**
  3896. * Gets the list of runtime animations
  3897. * @returns an array of RuntimeAnimation
  3898. */
  3899. getAnimations(): RuntimeAnimation[];
  3900. /**
  3901. * Adds more animations to the current animatable
  3902. * @param target defines the target of the animations
  3903. * @param animations defines the new animations to add
  3904. */
  3905. appendAnimations(target: any, animations: Animation[]): void;
  3906. /**
  3907. * Gets the source animation for a specific property
  3908. * @param property defines the propertyu to look for
  3909. * @returns null or the source animation for the given property
  3910. */
  3911. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3912. /**
  3913. * Gets the runtime animation for a specific property
  3914. * @param property defines the propertyu to look for
  3915. * @returns null or the runtime animation for the given property
  3916. */
  3917. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3918. /**
  3919. * Resets the animatable to its original state
  3920. */
  3921. reset(): void;
  3922. /**
  3923. * Allows the animatable to blend with current running animations
  3924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3925. * @param blendingSpeed defines the blending speed to use
  3926. */
  3927. enableBlending(blendingSpeed: number): void;
  3928. /**
  3929. * Disable animation blending
  3930. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3931. */
  3932. disableBlending(): void;
  3933. /**
  3934. * Jump directly to a given frame
  3935. * @param frame defines the frame to jump to
  3936. */
  3937. goToFrame(frame: number): void;
  3938. /**
  3939. * Pause the animation
  3940. */
  3941. pause(): void;
  3942. /**
  3943. * Restart the animation
  3944. */
  3945. restart(): void;
  3946. private _raiseOnAnimationEnd;
  3947. /**
  3948. * Stop and delete the current animation
  3949. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3950. * @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)
  3951. */
  3952. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3953. /**
  3954. * Wait asynchronously for the animation to end
  3955. * @returns a promise which will be fullfilled when the animation ends
  3956. */
  3957. waitAsync(): Promise<Animatable>;
  3958. /** @hidden */
  3959. _animate(delay: number): boolean;
  3960. }
  3961. }
  3962. declare module BABYLON {
  3963. /**
  3964. * Represents the range of an animation
  3965. */
  3966. class AnimationRange {
  3967. /**The name of the animation range**/
  3968. name: string;
  3969. /**The starting frame of the animation */
  3970. from: number;
  3971. /**The ending frame of the animation*/
  3972. to: number;
  3973. /**
  3974. * Initializes the range of an animation
  3975. * @param name The name of the animation range
  3976. * @param from The starting frame of the animation
  3977. * @param to The ending frame of the animation
  3978. */
  3979. constructor(
  3980. /**The name of the animation range**/
  3981. name: string,
  3982. /**The starting frame of the animation */
  3983. from: number,
  3984. /**The ending frame of the animation*/
  3985. to: number);
  3986. /**
  3987. * Makes a copy of the animation range
  3988. * @returns A copy of the animation range
  3989. */
  3990. clone(): AnimationRange;
  3991. }
  3992. /**
  3993. * Composed of a frame, and an action function
  3994. */
  3995. class AnimationEvent {
  3996. /** The frame for which the event is triggered **/
  3997. frame: number;
  3998. /** The event to perform when triggered **/
  3999. action: (currentFrame: number) => void;
  4000. /** Specifies if the event should be triggered only once**/
  4001. onlyOnce?: boolean | undefined;
  4002. /**
  4003. * Specifies if the animation event is done
  4004. */
  4005. isDone: boolean;
  4006. /**
  4007. * Initializes the animation event
  4008. * @param frame The frame for which the event is triggered
  4009. * @param action The event to perform when triggered
  4010. * @param onlyOnce Specifies if the event should be triggered only once
  4011. */
  4012. constructor(
  4013. /** The frame for which the event is triggered **/
  4014. frame: number,
  4015. /** The event to perform when triggered **/
  4016. action: (currentFrame: number) => void,
  4017. /** Specifies if the event should be triggered only once**/
  4018. onlyOnce?: boolean | undefined);
  4019. /** @hidden */
  4020. _clone(): AnimationEvent;
  4021. }
  4022. /**
  4023. * A cursor which tracks a point on a path
  4024. */
  4025. class PathCursor {
  4026. private path;
  4027. /**
  4028. * Stores path cursor callbacks for when an onchange event is triggered
  4029. */
  4030. private _onchange;
  4031. /**
  4032. * The value of the path cursor
  4033. */
  4034. value: number;
  4035. /**
  4036. * The animation array of the path cursor
  4037. */
  4038. animations: Animation[];
  4039. /**
  4040. * Initializes the path cursor
  4041. * @param path The path to track
  4042. */
  4043. constructor(path: Path2);
  4044. /**
  4045. * Gets the cursor point on the path
  4046. * @returns A point on the path cursor at the cursor location
  4047. */
  4048. getPoint(): Vector3;
  4049. /**
  4050. * Moves the cursor ahead by the step amount
  4051. * @param step The amount to move the cursor forward
  4052. * @returns This path cursor
  4053. */
  4054. moveAhead(step?: number): PathCursor;
  4055. /**
  4056. * Moves the cursor behind by the step amount
  4057. * @param step The amount to move the cursor back
  4058. * @returns This path cursor
  4059. */
  4060. moveBack(step?: number): PathCursor;
  4061. /**
  4062. * Moves the cursor by the step amount
  4063. * If the step amount is greater than one, an exception is thrown
  4064. * @param step The amount to move the cursor
  4065. * @returns This path cursor
  4066. */
  4067. move(step: number): PathCursor;
  4068. /**
  4069. * Ensures that the value is limited between zero and one
  4070. * @returns This path cursor
  4071. */
  4072. private ensureLimits;
  4073. /**
  4074. * Runs onchange callbacks on change (used by the animation engine)
  4075. * @returns This path cursor
  4076. */
  4077. private raiseOnChange;
  4078. /**
  4079. * Executes a function on change
  4080. * @param f A path cursor onchange callback
  4081. * @returns This path cursor
  4082. */
  4083. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4084. }
  4085. /**
  4086. * Defines an interface which represents an animation key frame
  4087. */
  4088. interface IAnimationKey {
  4089. /**
  4090. * Frame of the key frame
  4091. */
  4092. frame: number;
  4093. /**
  4094. * Value at the specifies key frame
  4095. */
  4096. value: any;
  4097. /**
  4098. * The input tangent for the cubic hermite spline
  4099. */
  4100. inTangent?: any;
  4101. /**
  4102. * The output tangent for the cubic hermite spline
  4103. */
  4104. outTangent?: any;
  4105. /**
  4106. * The animation interpolation type
  4107. */
  4108. interpolation?: AnimationKeyInterpolation;
  4109. }
  4110. /**
  4111. * Enum for the animation key frame interpolation type
  4112. */
  4113. enum AnimationKeyInterpolation {
  4114. /**
  4115. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4116. */
  4117. STEP = 1
  4118. }
  4119. /**
  4120. * Class used to store any kind of animation
  4121. */
  4122. class Animation {
  4123. /**Name of the animation */
  4124. name: string;
  4125. /**Property to animate */
  4126. targetProperty: string;
  4127. /**The frames per second of the animation */
  4128. framePerSecond: number;
  4129. /**The data type of the animation */
  4130. dataType: number;
  4131. /**The loop mode of the animation */
  4132. loopMode?: number | undefined;
  4133. /**Specifies if blending should be enabled */
  4134. enableBlending?: boolean | undefined;
  4135. /**
  4136. * Use matrix interpolation instead of using direct key value when animating matrices
  4137. */
  4138. static AllowMatricesInterpolation: boolean;
  4139. /**
  4140. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4141. */
  4142. static AllowMatrixDecomposeForInterpolation: boolean;
  4143. /**
  4144. * Stores the key frames of the animation
  4145. */
  4146. private _keys;
  4147. /**
  4148. * Stores the easing function of the animation
  4149. */
  4150. private _easingFunction;
  4151. /**
  4152. * @hidden Internal use only
  4153. */
  4154. _runtimeAnimations: RuntimeAnimation[];
  4155. /**
  4156. * The set of event that will be linked to this animation
  4157. */
  4158. private _events;
  4159. /**
  4160. * Stores an array of target property paths
  4161. */
  4162. targetPropertyPath: string[];
  4163. /**
  4164. * Stores the blending speed of the animation
  4165. */
  4166. blendingSpeed: number;
  4167. /**
  4168. * Stores the animation ranges for the animation
  4169. */
  4170. private _ranges;
  4171. /**
  4172. * @hidden Internal use
  4173. */
  4174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4175. /**
  4176. * Sets up an animation
  4177. * @param property The property to animate
  4178. * @param animationType The animation type to apply
  4179. * @param framePerSecond The frames per second of the animation
  4180. * @param easingFunction The easing function used in the animation
  4181. * @returns The created animation
  4182. */
  4183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4184. /**
  4185. * Create and start an animation on a node
  4186. * @param name defines the name of the global animation that will be run on all nodes
  4187. * @param node defines the root node where the animation will take place
  4188. * @param targetProperty defines property to animate
  4189. * @param framePerSecond defines the number of frame per second yo use
  4190. * @param totalFrame defines the number of frames in total
  4191. * @param from defines the initial value
  4192. * @param to defines the final value
  4193. * @param loopMode defines which loop mode you want to use (off by default)
  4194. * @param easingFunction defines the easing function to use (linear by default)
  4195. * @param onAnimationEnd defines the callback to call when animation end
  4196. * @returns the animatable created for this animation
  4197. */
  4198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4199. /**
  4200. * Create and start an animation on a node and its descendants
  4201. * @param name defines the name of the global animation that will be run on all nodes
  4202. * @param node defines the root node where the animation will take place
  4203. * @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
  4204. * @param targetProperty defines property to animate
  4205. * @param framePerSecond defines the number of frame per second to use
  4206. * @param totalFrame defines the number of frames in total
  4207. * @param from defines the initial value
  4208. * @param to defines the final value
  4209. * @param loopMode defines which loop mode you want to use (off by default)
  4210. * @param easingFunction defines the easing function to use (linear by default)
  4211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4212. * @returns the list of animatables created for all nodes
  4213. * @example https://www.babylonjs-playground.com/#MH0VLI
  4214. */
  4215. 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[]>;
  4216. /**
  4217. * Creates a new animation, merges it with the existing animations and starts it
  4218. * @param name Name of the animation
  4219. * @param node Node which contains the scene that begins the animations
  4220. * @param targetProperty Specifies which property to animate
  4221. * @param framePerSecond The frames per second of the animation
  4222. * @param totalFrame The total number of frames
  4223. * @param from The frame at the beginning of the animation
  4224. * @param to The frame at the end of the animation
  4225. * @param loopMode Specifies the loop mode of the animation
  4226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4227. * @param onAnimationEnd Callback to run once the animation is complete
  4228. * @returns Nullable animation
  4229. */
  4230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4231. /**
  4232. * Transition property of an host to the target Value
  4233. * @param property The property to transition
  4234. * @param targetValue The target Value of the property
  4235. * @param host The object where the property to animate belongs
  4236. * @param scene Scene used to run the animation
  4237. * @param frameRate Framerate (in frame/s) to use
  4238. * @param transition The transition type we want to use
  4239. * @param duration The duration of the animation, in milliseconds
  4240. * @param onAnimationEnd Callback trigger at the end of the animation
  4241. * @returns Nullable animation
  4242. */
  4243. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4244. /**
  4245. * Return the array of runtime animations currently using this animation
  4246. */
  4247. readonly runtimeAnimations: RuntimeAnimation[];
  4248. /**
  4249. * Specifies if any of the runtime animations are currently running
  4250. */
  4251. readonly hasRunningRuntimeAnimations: boolean;
  4252. /**
  4253. * Initializes the animation
  4254. * @param name Name of the animation
  4255. * @param targetProperty Property to animate
  4256. * @param framePerSecond The frames per second of the animation
  4257. * @param dataType The data type of the animation
  4258. * @param loopMode The loop mode of the animation
  4259. * @param enableBlendings Specifies if blending should be enabled
  4260. */
  4261. constructor(
  4262. /**Name of the animation */
  4263. name: string,
  4264. /**Property to animate */
  4265. targetProperty: string,
  4266. /**The frames per second of the animation */
  4267. framePerSecond: number,
  4268. /**The data type of the animation */
  4269. dataType: number,
  4270. /**The loop mode of the animation */
  4271. loopMode?: number | undefined,
  4272. /**Specifies if blending should be enabled */
  4273. enableBlending?: boolean | undefined);
  4274. /**
  4275. * Converts the animation to a string
  4276. * @param fullDetails support for multiple levels of logging within scene loading
  4277. * @returns String form of the animation
  4278. */
  4279. toString(fullDetails?: boolean): string;
  4280. /**
  4281. * Add an event to this animation
  4282. * @param event Event to add
  4283. */
  4284. addEvent(event: AnimationEvent): void;
  4285. /**
  4286. * Remove all events found at the given frame
  4287. * @param frame The frame to remove events from
  4288. */
  4289. removeEvents(frame: number): void;
  4290. /**
  4291. * Retrieves all the events from the animation
  4292. * @returns Events from the animation
  4293. */
  4294. getEvents(): AnimationEvent[];
  4295. /**
  4296. * Creates an animation range
  4297. * @param name Name of the animation range
  4298. * @param from Starting frame of the animation range
  4299. * @param to Ending frame of the animation
  4300. */
  4301. createRange(name: string, from: number, to: number): void;
  4302. /**
  4303. * Deletes an animation range by name
  4304. * @param name Name of the animation range to delete
  4305. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4306. */
  4307. deleteRange(name: string, deleteFrames?: boolean): void;
  4308. /**
  4309. * Gets the animation range by name, or null if not defined
  4310. * @param name Name of the animation range
  4311. * @returns Nullable animation range
  4312. */
  4313. getRange(name: string): Nullable<AnimationRange>;
  4314. /**
  4315. * Gets the key frames from the animation
  4316. * @returns The key frames of the animation
  4317. */
  4318. getKeys(): Array<IAnimationKey>;
  4319. /**
  4320. * Gets the highest frame rate of the animation
  4321. * @returns Highest frame rate of the animation
  4322. */
  4323. getHighestFrame(): number;
  4324. /**
  4325. * Gets the easing function of the animation
  4326. * @returns Easing function of the animation
  4327. */
  4328. getEasingFunction(): IEasingFunction;
  4329. /**
  4330. * Sets the easing function of the animation
  4331. * @param easingFunction A custom mathematical formula for animation
  4332. */
  4333. setEasingFunction(easingFunction: EasingFunction): void;
  4334. /**
  4335. * Interpolates a scalar linearly
  4336. * @param startValue Start value of the animation curve
  4337. * @param endValue End value of the animation curve
  4338. * @param gradient Scalar amount to interpolate
  4339. * @returns Interpolated scalar value
  4340. */
  4341. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4342. /**
  4343. * Interpolates a scalar cubically
  4344. * @param startValue Start value of the animation curve
  4345. * @param outTangent End tangent of the animation
  4346. * @param endValue End value of the animation curve
  4347. * @param inTangent Start tangent of the animation curve
  4348. * @param gradient Scalar amount to interpolate
  4349. * @returns Interpolated scalar value
  4350. */
  4351. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4352. /**
  4353. * Interpolates a quaternion using a spherical linear interpolation
  4354. * @param startValue Start value of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param gradient Scalar amount to interpolate
  4357. * @returns Interpolated quaternion value
  4358. */
  4359. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4360. /**
  4361. * Interpolates a quaternion cubically
  4362. * @param startValue Start value of the animation curve
  4363. * @param outTangent End tangent of the animation curve
  4364. * @param endValue End value of the animation curve
  4365. * @param inTangent Start tangent of the animation curve
  4366. * @param gradient Scalar amount to interpolate
  4367. * @returns Interpolated quaternion value
  4368. */
  4369. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4370. /**
  4371. * Interpolates a Vector3 linearl
  4372. * @param startValue Start value of the animation curve
  4373. * @param endValue End value of the animation curve
  4374. * @param gradient Scalar amount to interpolate
  4375. * @returns Interpolated scalar value
  4376. */
  4377. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4378. /**
  4379. * Interpolates a Vector3 cubically
  4380. * @param startValue Start value of the animation curve
  4381. * @param outTangent End tangent of the animation
  4382. * @param endValue End value of the animation curve
  4383. * @param inTangent Start tangent of the animation curve
  4384. * @param gradient Scalar amount to interpolate
  4385. * @returns InterpolatedVector3 value
  4386. */
  4387. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4388. /**
  4389. * Interpolates a Vector2 linearly
  4390. * @param startValue Start value of the animation curve
  4391. * @param endValue End value of the animation curve
  4392. * @param gradient Scalar amount to interpolate
  4393. * @returns Interpolated Vector2 value
  4394. */
  4395. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4396. /**
  4397. * Interpolates a Vector2 cubically
  4398. * @param startValue Start value of the animation curve
  4399. * @param outTangent End tangent of the animation
  4400. * @param endValue End value of the animation curve
  4401. * @param inTangent Start tangent of the animation curve
  4402. * @param gradient Scalar amount to interpolate
  4403. * @returns Interpolated Vector2 value
  4404. */
  4405. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4406. /**
  4407. * Interpolates a size 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 Size value
  4412. */
  4413. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4414. /**
  4415. * Interpolates a Color3 linearly
  4416. * @param startValue Start value of the animation curve
  4417. * @param endValue End value of the animation curve
  4418. * @param gradient Scalar amount to interpolate
  4419. * @returns Interpolated Color3 value
  4420. */
  4421. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4422. /**
  4423. * @hidden Internal use only
  4424. */
  4425. _getKeyValue(value: any): any;
  4426. /**
  4427. * @hidden Internal use only
  4428. */
  4429. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4430. /**
  4431. * Defines the function to use to interpolate matrices
  4432. * @param startValue defines the start matrix
  4433. * @param endValue defines the end matrix
  4434. * @param gradient defines the gradient between both matrices
  4435. * @param result defines an optional target matrix where to store the interpolation
  4436. * @returns the interpolated matrix
  4437. */
  4438. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4439. /**
  4440. * Makes a copy of the animation
  4441. * @returns Cloned animation
  4442. */
  4443. clone(): Animation;
  4444. /**
  4445. * Sets the key frames of the animation
  4446. * @param values The animation key frames to set
  4447. */
  4448. setKeys(values: Array<IAnimationKey>): void;
  4449. /**
  4450. * Serializes the animation to an object
  4451. * @returns Serialized object
  4452. */
  4453. serialize(): any;
  4454. /**
  4455. * Float animation type
  4456. */
  4457. private static _ANIMATIONTYPE_FLOAT;
  4458. /**
  4459. * Vector3 animation type
  4460. */
  4461. private static _ANIMATIONTYPE_VECTOR3;
  4462. /**
  4463. * Quaternion animation type
  4464. */
  4465. private static _ANIMATIONTYPE_QUATERNION;
  4466. /**
  4467. * Matrix animation type
  4468. */
  4469. private static _ANIMATIONTYPE_MATRIX;
  4470. /**
  4471. * Color3 animation type
  4472. */
  4473. private static _ANIMATIONTYPE_COLOR3;
  4474. /**
  4475. * Vector2 animation type
  4476. */
  4477. private static _ANIMATIONTYPE_VECTOR2;
  4478. /**
  4479. * Size animation type
  4480. */
  4481. private static _ANIMATIONTYPE_SIZE;
  4482. /**
  4483. * Relative Loop Mode
  4484. */
  4485. private static _ANIMATIONLOOPMODE_RELATIVE;
  4486. /**
  4487. * Cycle Loop Mode
  4488. */
  4489. private static _ANIMATIONLOOPMODE_CYCLE;
  4490. /**
  4491. * Constant Loop Mode
  4492. */
  4493. private static _ANIMATIONLOOPMODE_CONSTANT;
  4494. /**
  4495. * Get the float animation type
  4496. */
  4497. static readonly ANIMATIONTYPE_FLOAT: number;
  4498. /**
  4499. * Get the Vector3 animation type
  4500. */
  4501. static readonly ANIMATIONTYPE_VECTOR3: number;
  4502. /**
  4503. * Get the Vector2 animation type
  4504. */
  4505. static readonly ANIMATIONTYPE_VECTOR2: number;
  4506. /**
  4507. * Get the Size animation type
  4508. */
  4509. static readonly ANIMATIONTYPE_SIZE: number;
  4510. /**
  4511. * Get the Quaternion animation type
  4512. */
  4513. static readonly ANIMATIONTYPE_QUATERNION: number;
  4514. /**
  4515. * Get the Matrix animation type
  4516. */
  4517. static readonly ANIMATIONTYPE_MATRIX: number;
  4518. /**
  4519. * Get the Color3 animation type
  4520. */
  4521. static readonly ANIMATIONTYPE_COLOR3: number;
  4522. /**
  4523. * Get the Relative Loop Mode
  4524. */
  4525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4526. /**
  4527. * Get the Cycle Loop Mode
  4528. */
  4529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4530. /**
  4531. * Get the Constant Loop Mode
  4532. */
  4533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4534. /** @hidden */
  4535. static _UniversalLerp(left: any, right: any, amount: number): any;
  4536. /**
  4537. * Parses an animation object and creates an animation
  4538. * @param parsedAnimation Parsed animation object
  4539. * @returns Animation object
  4540. */
  4541. static Parse(parsedAnimation: any): Animation;
  4542. /**
  4543. * Appends the serialized animations from the source animations
  4544. * @param source Source containing the animations
  4545. * @param destination Target to store the animations
  4546. */
  4547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * This class defines the direct association between an animation and a target
  4553. */
  4554. class TargetedAnimation {
  4555. /**
  4556. * Animation to perform
  4557. */
  4558. animation: Animation;
  4559. /**
  4560. * Target to animate
  4561. */
  4562. target: any;
  4563. }
  4564. /**
  4565. * Use this class to create coordinated animations on multiple targets
  4566. */
  4567. class AnimationGroup implements IDisposable {
  4568. /** The name of the animation group */
  4569. name: string;
  4570. private _scene;
  4571. private _targetedAnimations;
  4572. private _animatables;
  4573. private _from;
  4574. private _to;
  4575. private _isStarted;
  4576. private _isPaused;
  4577. private _speedRatio;
  4578. /**
  4579. * Gets or sets the unique id of the node
  4580. */
  4581. uniqueId: number;
  4582. /**
  4583. * This observable will notify when one animation have ended.
  4584. */
  4585. onAnimationEndObservable: Observable<TargetedAnimation>;
  4586. /**
  4587. * This observable will notify when all animations have ended.
  4588. */
  4589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4590. /**
  4591. * This observable will notify when all animations have paused.
  4592. */
  4593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4594. /**
  4595. * This observable will notify when all animations are playing.
  4596. */
  4597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4598. /**
  4599. * Gets the first frame
  4600. */
  4601. readonly from: number;
  4602. /**
  4603. * Gets the last frame
  4604. */
  4605. readonly to: number;
  4606. /**
  4607. * Define if the animations are started
  4608. */
  4609. readonly isStarted: boolean;
  4610. /**
  4611. * Gets a value indicating that the current group is playing
  4612. */
  4613. readonly isPlaying: boolean;
  4614. /**
  4615. * Gets or sets the speed ratio to use for all animations
  4616. */
  4617. /**
  4618. * Gets or sets the speed ratio to use for all animations
  4619. */
  4620. speedRatio: number;
  4621. /**
  4622. * Gets the targeted animations for this animation group
  4623. */
  4624. readonly targetedAnimations: Array<TargetedAnimation>;
  4625. /**
  4626. * returning the list of animatables controlled by this animation group.
  4627. */
  4628. readonly animatables: Array<Animatable>;
  4629. /**
  4630. * Instantiates a new Animation Group.
  4631. * This helps managing several animations at once.
  4632. * @see http://doc.babylonjs.com/how_to/group
  4633. * @param name Defines the name of the group
  4634. * @param scene Defines the scene the group belongs to
  4635. */
  4636. constructor(
  4637. /** The name of the animation group */
  4638. name: string, scene?: Nullable<Scene>);
  4639. /**
  4640. * Add an animation (with its target) in the group
  4641. * @param animation defines the animation we want to add
  4642. * @param target defines the target of the animation
  4643. * @returns the TargetedAnimation object
  4644. */
  4645. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4646. /**
  4647. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4648. * It can add constant keys at begin or end
  4649. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4650. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4651. * @returns the animation group
  4652. */
  4653. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4654. /**
  4655. * Start all animations on given targets
  4656. * @param loop defines if animations must loop
  4657. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4658. * @param from defines the from key (optional)
  4659. * @param to defines the to key (optional)
  4660. * @returns the current animation group
  4661. */
  4662. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4663. /**
  4664. * Pause all animations
  4665. * @returns the animation group
  4666. */
  4667. pause(): AnimationGroup;
  4668. /**
  4669. * Play all animations to initial state
  4670. * This function will start() the animations if they were not started or will restart() them if they were paused
  4671. * @param loop defines if animations must loop
  4672. * @returns the animation group
  4673. */
  4674. play(loop?: boolean): AnimationGroup;
  4675. /**
  4676. * Reset all animations to initial state
  4677. * @returns the animation group
  4678. */
  4679. reset(): AnimationGroup;
  4680. /**
  4681. * Restart animations from key 0
  4682. * @returns the animation group
  4683. */
  4684. restart(): AnimationGroup;
  4685. /**
  4686. * Stop all animations
  4687. * @returns the animation group
  4688. */
  4689. stop(): AnimationGroup;
  4690. /**
  4691. * Set animation weight for all animatables
  4692. * @param weight defines the weight to use
  4693. * @return the animationGroup
  4694. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4695. */
  4696. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4697. /**
  4698. * Synchronize and normalize all animatables with a source animatable
  4699. * @param root defines the root animatable to synchronize with
  4700. * @return the animationGroup
  4701. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4702. */
  4703. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4704. /**
  4705. * Goes to a specific frame in this animation group
  4706. * @param frame the frame number to go to
  4707. * @return the animationGroup
  4708. */
  4709. goToFrame(frame: number): AnimationGroup;
  4710. /**
  4711. * Dispose all associated resources
  4712. */
  4713. dispose(): void;
  4714. private _checkAnimationGroupEnded;
  4715. /**
  4716. * Returns a new AnimationGroup object parsed from the source provided.
  4717. * @param parsedAnimationGroup defines the source
  4718. * @param scene defines the scene that will receive the animationGroup
  4719. * @returns a new AnimationGroup
  4720. */
  4721. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4722. /**
  4723. * Returns the string "AnimationGroup"
  4724. * @returns "AnimationGroup"
  4725. */
  4726. getClassName(): string;
  4727. /**
  4728. * Creates a detailled string about the object
  4729. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4730. * @returns a string representing the object
  4731. */
  4732. toString(fullDetails?: boolean): string;
  4733. }
  4734. }
  4735. declare module BABYLON {
  4736. /**
  4737. * Class used to override all child animations of a given target
  4738. */
  4739. class AnimationPropertiesOverride {
  4740. /**
  4741. * Gets or sets a value indicating if animation blending must be used
  4742. */
  4743. enableBlending: boolean;
  4744. /**
  4745. * Gets or sets the blending speed to use when enableBlending is true
  4746. */
  4747. blendingSpeed: number;
  4748. /**
  4749. * Gets or sets the default loop mode to use
  4750. */
  4751. loopMode: number;
  4752. }
  4753. }
  4754. declare module BABYLON {
  4755. /**
  4756. * This represents the main contract an easing function should follow.
  4757. * Easing functions are used throughout the animation system.
  4758. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4759. */
  4760. interface IEasingFunction {
  4761. /**
  4762. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4763. * of the easing function.
  4764. * The link below provides some of the most common examples of easing functions.
  4765. * @see https://easings.net/
  4766. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4767. * @returns the corresponding value on the curve defined by the easing function
  4768. */
  4769. ease(gradient: number): number;
  4770. }
  4771. /**
  4772. * Base class used for every default easing function.
  4773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4774. */
  4775. class EasingFunction implements IEasingFunction {
  4776. /**
  4777. * Interpolation follows the mathematical formula associated with the easing function.
  4778. */
  4779. static readonly EASINGMODE_EASEIN: number;
  4780. /**
  4781. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4782. */
  4783. static readonly EASINGMODE_EASEOUT: number;
  4784. /**
  4785. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4786. */
  4787. static readonly EASINGMODE_EASEINOUT: number;
  4788. private _easingMode;
  4789. /**
  4790. * Sets the easing mode of the current function.
  4791. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4792. */
  4793. setEasingMode(easingMode: number): void;
  4794. /**
  4795. * Gets the current easing mode.
  4796. * @returns the easing mode
  4797. */
  4798. getEasingMode(): number;
  4799. /**
  4800. * @hidden
  4801. */
  4802. easeInCore(gradient: number): number;
  4803. /**
  4804. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4805. * of the easing function.
  4806. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4807. * @returns the corresponding value on the curve defined by the easing function
  4808. */
  4809. ease(gradient: number): number;
  4810. }
  4811. /**
  4812. * Easing function with a circle shape (see link below).
  4813. * @see https://easings.net/#easeInCirc
  4814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4815. */
  4816. class CircleEase extends EasingFunction implements IEasingFunction {
  4817. /** @hidden */
  4818. easeInCore(gradient: number): number;
  4819. }
  4820. /**
  4821. * Easing function with a ease back shape (see link below).
  4822. * @see https://easings.net/#easeInBack
  4823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4824. */
  4825. class BackEase extends EasingFunction implements IEasingFunction {
  4826. /** Defines the amplitude of the function */
  4827. amplitude: number;
  4828. /**
  4829. * Instantiates a back ease easing
  4830. * @see https://easings.net/#easeInBack
  4831. * @param amplitude Defines the amplitude of the function
  4832. */
  4833. constructor(
  4834. /** Defines the amplitude of the function */
  4835. amplitude?: number);
  4836. /** @hidden */
  4837. easeInCore(gradient: number): number;
  4838. }
  4839. /**
  4840. * Easing function with a bouncing shape (see link below).
  4841. * @see https://easings.net/#easeInBounce
  4842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4843. */
  4844. class BounceEase extends EasingFunction implements IEasingFunction {
  4845. /** Defines the number of bounces */
  4846. bounces: number;
  4847. /** Defines the amplitude of the bounce */
  4848. bounciness: number;
  4849. /**
  4850. * Instantiates a bounce easing
  4851. * @see https://easings.net/#easeInBounce
  4852. * @param bounces Defines the number of bounces
  4853. * @param bounciness Defines the amplitude of the bounce
  4854. */
  4855. constructor(
  4856. /** Defines the number of bounces */
  4857. bounces?: number,
  4858. /** Defines the amplitude of the bounce */
  4859. bounciness?: number);
  4860. /** @hidden */
  4861. easeInCore(gradient: number): number;
  4862. }
  4863. /**
  4864. * Easing function with a power of 3 shape (see link below).
  4865. * @see https://easings.net/#easeInCubic
  4866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4867. */
  4868. class CubicEase extends EasingFunction implements IEasingFunction {
  4869. /** @hidden */
  4870. easeInCore(gradient: number): number;
  4871. }
  4872. /**
  4873. * Easing function with an elastic shape (see link below).
  4874. * @see https://easings.net/#easeInElastic
  4875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4876. */
  4877. class ElasticEase extends EasingFunction implements IEasingFunction {
  4878. /** Defines the number of oscillations*/
  4879. oscillations: number;
  4880. /** Defines the amplitude of the oscillations*/
  4881. springiness: number;
  4882. /**
  4883. * Instantiates an elastic easing function
  4884. * @see https://easings.net/#easeInElastic
  4885. * @param oscillations Defines the number of oscillations
  4886. * @param springiness Defines the amplitude of the oscillations
  4887. */
  4888. constructor(
  4889. /** Defines the number of oscillations*/
  4890. oscillations?: number,
  4891. /** Defines the amplitude of the oscillations*/
  4892. springiness?: number);
  4893. /** @hidden */
  4894. easeInCore(gradient: number): number;
  4895. }
  4896. /**
  4897. * Easing function with an exponential shape (see link below).
  4898. * @see https://easings.net/#easeInExpo
  4899. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4900. */
  4901. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4902. /** Defines the exponent of the function */
  4903. exponent: number;
  4904. /**
  4905. * Instantiates an exponential easing function
  4906. * @see https://easings.net/#easeInExpo
  4907. * @param exponent Defines the exponent of the function
  4908. */
  4909. constructor(
  4910. /** Defines the exponent of the function */
  4911. exponent?: number);
  4912. /** @hidden */
  4913. easeInCore(gradient: number): number;
  4914. }
  4915. /**
  4916. * Easing function with a power shape (see link below).
  4917. * @see https://easings.net/#easeInQuad
  4918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4919. */
  4920. class PowerEase extends EasingFunction implements IEasingFunction {
  4921. /** Defines the power of the function */
  4922. power: number;
  4923. /**
  4924. * Instantiates an power base easing function
  4925. * @see https://easings.net/#easeInQuad
  4926. * @param power Defines the power of the function
  4927. */
  4928. constructor(
  4929. /** Defines the power of the function */
  4930. power?: number);
  4931. /** @hidden */
  4932. easeInCore(gradient: number): number;
  4933. }
  4934. /**
  4935. * Easing function with a power of 2 shape (see link below).
  4936. * @see https://easings.net/#easeInQuad
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4940. /** @hidden */
  4941. easeInCore(gradient: number): number;
  4942. }
  4943. /**
  4944. * Easing function with a power of 4 shape (see link below).
  4945. * @see https://easings.net/#easeInQuart
  4946. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4947. */
  4948. class QuarticEase extends EasingFunction implements IEasingFunction {
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 5 shape (see link below).
  4954. * @see https://easings.net/#easeInQuint
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuinticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a sin shape (see link below).
  4963. * @see https://easings.net/#easeInSine
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class SineEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a bezier shape (see link below).
  4972. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the x component of the start tangent in the bezier curve */
  4977. x1: number;
  4978. /** Defines the y component of the start tangent in the bezier curve */
  4979. y1: number;
  4980. /** Defines the x component of the end tangent in the bezier curve */
  4981. x2: number;
  4982. /** Defines the y component of the end tangent in the bezier curve */
  4983. y2: number;
  4984. /**
  4985. * Instantiates a bezier function
  4986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4987. * @param x1 Defines the x component of the start tangent in the bezier curve
  4988. * @param y1 Defines the y component of the start tangent in the bezier curve
  4989. * @param x2 Defines the x component of the end tangent in the bezier curve
  4990. * @param y2 Defines the y component of the end tangent in the bezier curve
  4991. */
  4992. constructor(
  4993. /** Defines the x component of the start tangent in the bezier curve */
  4994. x1?: number,
  4995. /** Defines the y component of the start tangent in the bezier curve */
  4996. y1?: number,
  4997. /** Defines the x component of the end tangent in the bezier curve */
  4998. x2?: number,
  4999. /** Defines the y component of the end tangent in the bezier curve */
  5000. y2?: number);
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. }
  5005. declare module BABYLON {
  5006. /**
  5007. * Defines a runtime animation
  5008. */
  5009. class RuntimeAnimation {
  5010. private _events;
  5011. /**
  5012. * The current frame of the runtime animation
  5013. */
  5014. private _currentFrame;
  5015. /**
  5016. * The animation used by the runtime animation
  5017. */
  5018. private _animation;
  5019. /**
  5020. * The target of the runtime animation
  5021. */
  5022. private _target;
  5023. /**
  5024. * The initiating animatable
  5025. */
  5026. private _host;
  5027. /**
  5028. * The original value of the runtime animation
  5029. */
  5030. private _originalValue;
  5031. /**
  5032. * The original blend value of the runtime animation
  5033. */
  5034. private _originalBlendValue;
  5035. /**
  5036. * The offsets cache of the runtime animation
  5037. */
  5038. private _offsetsCache;
  5039. /**
  5040. * The high limits cache of the runtime animation
  5041. */
  5042. private _highLimitsCache;
  5043. /**
  5044. * Specifies if the runtime animation has been stopped
  5045. */
  5046. private _stopped;
  5047. /**
  5048. * The blending factor of the runtime animation
  5049. */
  5050. private _blendingFactor;
  5051. /**
  5052. * The BabylonJS scene
  5053. */
  5054. private _scene;
  5055. /**
  5056. * The current value of the runtime animation
  5057. */
  5058. private _currentValue;
  5059. /** @hidden */
  5060. _workValue: any;
  5061. /**
  5062. * The active target of the runtime animation
  5063. */
  5064. private _activeTarget;
  5065. /**
  5066. * The target path of the runtime animation
  5067. */
  5068. private _targetPath;
  5069. /**
  5070. * The weight of the runtime animation
  5071. */
  5072. private _weight;
  5073. /**
  5074. * The ratio offset of the runtime animation
  5075. */
  5076. private _ratioOffset;
  5077. /**
  5078. * The previous delay of the runtime animation
  5079. */
  5080. private _previousDelay;
  5081. /**
  5082. * The previous ratio of the runtime animation
  5083. */
  5084. private _previousRatio;
  5085. /**
  5086. * Gets the current frame of the runtime animation
  5087. */
  5088. readonly currentFrame: number;
  5089. /**
  5090. * Gets the weight of the runtime animation
  5091. */
  5092. readonly weight: number;
  5093. /**
  5094. * Gets the current value of the runtime animation
  5095. */
  5096. readonly currentValue: any;
  5097. /**
  5098. * Gets the target path of the runtime animation
  5099. */
  5100. readonly targetPath: string;
  5101. /**
  5102. * Gets the actual target of the runtime animation
  5103. */
  5104. readonly target: any;
  5105. /**
  5106. * Create a new RuntimeAnimation object
  5107. * @param target defines the target of the animation
  5108. * @param animation defines the source animation object
  5109. * @param scene defines the hosting scene
  5110. * @param host defines the initiating Animatable
  5111. */
  5112. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5113. /**
  5114. * Gets the animation from the runtime animation
  5115. */
  5116. readonly animation: Animation;
  5117. /**
  5118. * Resets the runtime animation to the beginning
  5119. * @param restoreOriginal defines whether to restore the target property to the original value
  5120. */
  5121. reset(restoreOriginal?: boolean): void;
  5122. /**
  5123. * Specifies if the runtime animation is stopped
  5124. * @returns Boolean specifying if the runtime animation is stopped
  5125. */
  5126. isStopped(): boolean;
  5127. /**
  5128. * Disposes of the runtime animation
  5129. */
  5130. dispose(): void;
  5131. /**
  5132. * Interpolates the animation from the current frame
  5133. * @param currentFrame The frame to interpolate the animation to
  5134. * @param repeatCount The number of times that the animation should loop
  5135. * @param loopMode The type of looping mode to use
  5136. * @param offsetValue Animation offset value
  5137. * @param highLimitValue The high limit value
  5138. * @returns The interpolated value
  5139. */
  5140. private _interpolate;
  5141. /**
  5142. * Apply the interpolated value to the target
  5143. * @param currentValue defines the value computed by the animation
  5144. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5145. */
  5146. setValue(currentValue: any, weight?: number): void;
  5147. private _setValue;
  5148. /**
  5149. * Gets the loop pmode of the runtime animation
  5150. * @returns Loop Mode
  5151. */
  5152. private _getCorrectLoopMode;
  5153. /**
  5154. * Move the current animation to a given frame
  5155. * @param frame defines the frame to move to
  5156. */
  5157. goToFrame(frame: number): void;
  5158. /**
  5159. * @hidden Internal use only
  5160. */
  5161. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5162. /**
  5163. * Execute the current animation
  5164. * @param delay defines the delay to add to the current frame
  5165. * @param from defines the lower bound of the animation range
  5166. * @param to defines the upper bound of the animation range
  5167. * @param loop defines if the current animation must loop
  5168. * @param speedRatio defines the current speed ratio
  5169. * @param weight defines the weight of the animation (default is -1 so no weight)
  5170. * @returns a boolean indicating if the animation is running
  5171. */
  5172. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5173. }
  5174. }
  5175. declare module BABYLON {
  5176. /**
  5177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5179. */
  5180. class Analyser {
  5181. /**
  5182. * Gets or sets the smoothing
  5183. * @ignorenaming
  5184. */
  5185. SMOOTHING: number;
  5186. /**
  5187. * Gets or sets the FFT table size
  5188. * @ignorenaming
  5189. */
  5190. FFT_SIZE: number;
  5191. /**
  5192. * Gets or sets the bar graph amplitude
  5193. * @ignorenaming
  5194. */
  5195. BARGRAPHAMPLITUDE: number;
  5196. /**
  5197. * Gets or sets the position of the debug canvas
  5198. * @ignorenaming
  5199. */
  5200. DEBUGCANVASPOS: {
  5201. x: number;
  5202. y: number;
  5203. };
  5204. /**
  5205. * Gets or sets the debug canvas size
  5206. * @ignorenaming
  5207. */
  5208. DEBUGCANVASSIZE: {
  5209. width: number;
  5210. height: number;
  5211. };
  5212. private _byteFreqs;
  5213. private _byteTime;
  5214. private _floatFreqs;
  5215. private _webAudioAnalyser;
  5216. private _debugCanvas;
  5217. private _debugCanvasContext;
  5218. private _scene;
  5219. private _registerFunc;
  5220. private _audioEngine;
  5221. /**
  5222. * Creates a new analyser
  5223. * @param scene defines hosting scene
  5224. */
  5225. constructor(scene: Scene);
  5226. /**
  5227. * Get the number of data values you will have to play with for the visualization
  5228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5229. * @returns a number
  5230. */
  5231. getFrequencyBinCount(): number;
  5232. /**
  5233. * Gets the current frequency data as a byte array
  5234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5235. * @returns a Uint8Array
  5236. */
  5237. getByteFrequencyData(): Uint8Array;
  5238. /**
  5239. * Gets the current waveform as a byte array
  5240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5241. * @returns a Uint8Array
  5242. */
  5243. getByteTimeDomainData(): Uint8Array;
  5244. /**
  5245. * Gets the current frequency data as a float array
  5246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5247. * @returns a Float32Array
  5248. */
  5249. getFloatFrequencyData(): Float32Array;
  5250. /**
  5251. * Renders the debug canvas
  5252. */
  5253. drawDebugCanvas(): void;
  5254. /**
  5255. * Stops rendering the debug canvas and removes it
  5256. */
  5257. stopDebugCanvas(): void;
  5258. /**
  5259. * Connects two audio nodes
  5260. * @param inputAudioNode defines first node to connect
  5261. * @param outputAudioNode defines second node to connect
  5262. */
  5263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5264. /**
  5265. * Releases all associated resources
  5266. */
  5267. dispose(): void;
  5268. }
  5269. }
  5270. declare module BABYLON {
  5271. /**
  5272. * This represents an audio engine and it is responsible
  5273. * to play, synchronize and analyse sounds throughout the application.
  5274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5275. */
  5276. interface IAudioEngine extends IDisposable {
  5277. /**
  5278. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5279. */
  5280. readonly canUseWebAudio: boolean;
  5281. /**
  5282. * Gets the current AudioContext if available.
  5283. */
  5284. readonly audioContext: Nullable<AudioContext>;
  5285. /**
  5286. * The master gain node defines the global audio volume of your audio engine.
  5287. */
  5288. readonly masterGain: GainNode;
  5289. /**
  5290. * Gets whether or not mp3 are supported by your browser.
  5291. */
  5292. readonly isMP3supported: boolean;
  5293. /**
  5294. * Gets whether or not ogg are supported by your browser.
  5295. */
  5296. readonly isOGGsupported: boolean;
  5297. /**
  5298. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5299. * @ignoreNaming
  5300. */
  5301. WarnedWebAudioUnsupported: boolean;
  5302. /**
  5303. * Defines if the audio engine relies on a custom unlocked button.
  5304. * In this case, the embedded button will not be displayed.
  5305. */
  5306. useCustomUnlockedButton: boolean;
  5307. /**
  5308. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5309. */
  5310. readonly unlocked: boolean;
  5311. /**
  5312. * Event raised when audio has been unlocked on the browser.
  5313. */
  5314. onAudioUnlockedObservable: Observable<AudioEngine>;
  5315. /**
  5316. * Event raised when audio has been locked on the browser.
  5317. */
  5318. onAudioLockedObservable: Observable<AudioEngine>;
  5319. /**
  5320. * Flags the audio engine in Locked state.
  5321. * This happens due to new browser policies preventing audio to autoplay.
  5322. */
  5323. lock(): void;
  5324. /**
  5325. * Unlocks the audio engine once a user action has been done on the dom.
  5326. * This is helpful to resume play once browser policies have been satisfied.
  5327. */
  5328. unlock(): void;
  5329. }
  5330. /**
  5331. * This represents the default audio engine used in babylon.
  5332. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5334. */
  5335. class AudioEngine implements IAudioEngine {
  5336. private _audioContext;
  5337. private _audioContextInitialized;
  5338. private _muteButton;
  5339. private _hostElement;
  5340. /**
  5341. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5342. */
  5343. canUseWebAudio: boolean;
  5344. /**
  5345. * The master gain node defines the global audio volume of your audio engine.
  5346. */
  5347. masterGain: GainNode;
  5348. /**
  5349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5350. * @ignoreNaming
  5351. */
  5352. WarnedWebAudioUnsupported: boolean;
  5353. /**
  5354. * Gets whether or not mp3 are supported by your browser.
  5355. */
  5356. isMP3supported: boolean;
  5357. /**
  5358. * Gets whether or not ogg are supported by your browser.
  5359. */
  5360. isOGGsupported: boolean;
  5361. /**
  5362. * Gets whether audio has been unlocked on the device.
  5363. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5364. * a user interaction has happened.
  5365. */
  5366. unlocked: boolean;
  5367. /**
  5368. * Defines if the audio engine relies on a custom unlocked button.
  5369. * In this case, the embedded button will not be displayed.
  5370. */
  5371. useCustomUnlockedButton: boolean;
  5372. /**
  5373. * Event raised when audio has been unlocked on the browser.
  5374. */
  5375. onAudioUnlockedObservable: Observable<AudioEngine>;
  5376. /**
  5377. * Event raised when audio has been locked on the browser.
  5378. */
  5379. onAudioLockedObservable: Observable<AudioEngine>;
  5380. /**
  5381. * Gets the current AudioContext if available.
  5382. */
  5383. readonly audioContext: Nullable<AudioContext>;
  5384. private _connectedAnalyser;
  5385. /**
  5386. * Instantiates a new audio engine.
  5387. *
  5388. * There should be only one per page as some browsers restrict the number
  5389. * of audio contexts you can create.
  5390. * @param hostElement defines the host element where to display the mute icon if necessary
  5391. */
  5392. constructor(hostElement?: Nullable<HTMLElement>);
  5393. /**
  5394. * Flags the audio engine in Locked state.
  5395. * This happens due to new browser policies preventing audio to autoplay.
  5396. */
  5397. lock(): void;
  5398. /**
  5399. * Unlocks the audio engine once a user action has been done on the dom.
  5400. * This is helpful to resume play once browser policies have been satisfied.
  5401. */
  5402. unlock(): void;
  5403. private _resumeAudioContext;
  5404. private _initializeAudioContext;
  5405. private _tryToRun;
  5406. private _triggerRunningState;
  5407. private _triggerSuspendedState;
  5408. private _displayMuteButton;
  5409. private _moveButtonToTopLeft;
  5410. private _onResize;
  5411. private _hideMuteButton;
  5412. /**
  5413. * Destroy and release the resources associated with the audio ccontext.
  5414. */
  5415. dispose(): void;
  5416. /**
  5417. * Gets the global volume sets on the master gain.
  5418. * @returns the global volume if set or -1 otherwise
  5419. */
  5420. getGlobalVolume(): number;
  5421. /**
  5422. * Sets the global volume of your experience (sets on the master gain).
  5423. * @param newVolume Defines the new global volume of the application
  5424. */
  5425. setGlobalVolume(newVolume: number): void;
  5426. /**
  5427. * Connect the audio engine to an audio analyser allowing some amazing
  5428. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5430. * @param analyser The analyser to connect to the engine
  5431. */
  5432. connectToAnalyser(analyser: Analyser): void;
  5433. }
  5434. }
  5435. declare module BABYLON {
  5436. interface AbstractScene {
  5437. /**
  5438. * The list of sounds used in the scene.
  5439. */
  5440. sounds: Nullable<Array<Sound>>;
  5441. }
  5442. interface Scene {
  5443. /**
  5444. * @hidden
  5445. * Backing field
  5446. */
  5447. _mainSoundTrack: SoundTrack;
  5448. /**
  5449. * The main sound track played by the scene.
  5450. * It cotains your primary collection of sounds.
  5451. */
  5452. mainSoundTrack: SoundTrack;
  5453. /**
  5454. * The list of sound tracks added to the scene
  5455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5456. */
  5457. soundTracks: Nullable<Array<SoundTrack>>;
  5458. /**
  5459. * Gets a sound using a given name
  5460. * @param name defines the name to search for
  5461. * @return the found sound or null if not found at all.
  5462. */
  5463. getSoundByName(name: string): Nullable<Sound>;
  5464. /**
  5465. * Gets or sets if audio support is enabled
  5466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5467. */
  5468. audioEnabled: boolean;
  5469. /**
  5470. * Gets or sets if audio will be output to headphones
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5472. */
  5473. headphone: boolean;
  5474. }
  5475. /**
  5476. * Defines the sound scene component responsible to manage any sounds
  5477. * in a given scene.
  5478. */
  5479. class AudioSceneComponent implements ISceneSerializableComponent {
  5480. /**
  5481. * The component name helpfull to identify the component in the list of scene components.
  5482. */
  5483. readonly name: string;
  5484. /**
  5485. * The scene the component belongs to.
  5486. */
  5487. scene: Scene;
  5488. private _audioEnabled;
  5489. /**
  5490. * Gets whether audio is enabled or not.
  5491. * Please use related enable/disable method to switch state.
  5492. */
  5493. readonly audioEnabled: boolean;
  5494. private _headphone;
  5495. /**
  5496. * Gets whether audio is outputing to headphone or not.
  5497. * Please use the according Switch methods to change output.
  5498. */
  5499. readonly headphone: boolean;
  5500. /**
  5501. * Creates a new instance of the component for the given scene
  5502. * @param scene Defines the scene to register the component in
  5503. */
  5504. constructor(scene: Scene);
  5505. /**
  5506. * Registers the component in a given scene
  5507. */
  5508. register(): void;
  5509. /**
  5510. * Rebuilds the elements related to this component in case of
  5511. * context lost for instance.
  5512. */
  5513. rebuild(): void;
  5514. /**
  5515. * Serializes the component data to the specified json object
  5516. * @param serializationObject The object to serialize to
  5517. */
  5518. serialize(serializationObject: any): void;
  5519. /**
  5520. * Adds all the element from the container to the scene
  5521. * @param container the container holding the elements
  5522. */
  5523. addFromContainer(container: AbstractScene): void;
  5524. /**
  5525. * Removes all the elements in the container from the scene
  5526. * @param container contains the elements to remove
  5527. */
  5528. removeFromContainer(container: AbstractScene): void;
  5529. /**
  5530. * Disposes the component and the associated ressources.
  5531. */
  5532. dispose(): void;
  5533. /**
  5534. * Disables audio in the associated scene.
  5535. */
  5536. disableAudio(): void;
  5537. /**
  5538. * Enables audio in the associated scene.
  5539. */
  5540. enableAudio(): void;
  5541. /**
  5542. * Switch audio to headphone output.
  5543. */
  5544. switchAudioModeForHeadphones(): void;
  5545. /**
  5546. * Switch audio to normal speakers.
  5547. */
  5548. switchAudioModeForNormalSpeakers(): void;
  5549. private _afterRender;
  5550. }
  5551. }
  5552. declare module BABYLON {
  5553. /**
  5554. * Defines a sound that can be played in the application.
  5555. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5557. */
  5558. class Sound {
  5559. /**
  5560. * The name of the sound in the scene.
  5561. */
  5562. name: string;
  5563. /**
  5564. * Does the sound autoplay once loaded.
  5565. */
  5566. autoplay: boolean;
  5567. /**
  5568. * Does the sound loop after it finishes playing once.
  5569. */
  5570. loop: boolean;
  5571. /**
  5572. * Does the sound use a custom attenuation curve to simulate the falloff
  5573. * happening when the source gets further away from the camera.
  5574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5575. */
  5576. useCustomAttenuation: boolean;
  5577. /**
  5578. * The sound track id this sound belongs to.
  5579. */
  5580. soundTrackId: number;
  5581. /**
  5582. * Is this sound currently played.
  5583. */
  5584. isPlaying: boolean;
  5585. /**
  5586. * Is this sound currently paused.
  5587. */
  5588. isPaused: boolean;
  5589. /**
  5590. * Does this sound enables spatial sound.
  5591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5592. */
  5593. spatialSound: boolean;
  5594. /**
  5595. * Define the reference distance the sound should be heard perfectly.
  5596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5597. */
  5598. refDistance: number;
  5599. /**
  5600. * Define the roll off factor of spatial sounds.
  5601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5602. */
  5603. rolloffFactor: number;
  5604. /**
  5605. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5607. */
  5608. maxDistance: number;
  5609. /**
  5610. * Define the distance attenuation model the sound will follow.
  5611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5612. */
  5613. distanceModel: string;
  5614. /**
  5615. * @hidden
  5616. * Back Compat
  5617. **/
  5618. onended: () => any;
  5619. /**
  5620. * Observable event when the current playing sound finishes.
  5621. */
  5622. onEndedObservable: Observable<Sound>;
  5623. private _panningModel;
  5624. private _playbackRate;
  5625. private _streaming;
  5626. private _startTime;
  5627. private _startOffset;
  5628. private _position;
  5629. /** @hidden */
  5630. _positionInEmitterSpace: boolean;
  5631. private _localDirection;
  5632. private _volume;
  5633. private _isReadyToPlay;
  5634. private _isDirectional;
  5635. private _readyToPlayCallback;
  5636. private _audioBuffer;
  5637. private _soundSource;
  5638. private _streamingSource;
  5639. private _soundPanner;
  5640. private _soundGain;
  5641. private _inputAudioNode;
  5642. private _outputAudioNode;
  5643. private _coneInnerAngle;
  5644. private _coneOuterAngle;
  5645. private _coneOuterGain;
  5646. private _scene;
  5647. private _connectedTransformNode;
  5648. private _customAttenuationFunction;
  5649. private _registerFunc;
  5650. private _isOutputConnected;
  5651. private _htmlAudioElement;
  5652. private _urlType;
  5653. /**
  5654. * Create a sound and attach it to a scene
  5655. * @param name Name of your sound
  5656. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5657. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5658. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5659. */
  5660. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5661. /**
  5662. * Release the sound and its associated resources
  5663. */
  5664. dispose(): void;
  5665. /**
  5666. * Gets if the sounds is ready to be played or not.
  5667. * @returns true if ready, otherwise false
  5668. */
  5669. isReady(): boolean;
  5670. private _soundLoaded;
  5671. /**
  5672. * Sets the data of the sound from an audiobuffer
  5673. * @param audioBuffer The audioBuffer containing the data
  5674. */
  5675. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5676. /**
  5677. * Updates the current sounds options such as maxdistance, loop...
  5678. * @param options A JSON object containing values named as the object properties
  5679. */
  5680. updateOptions(options: any): void;
  5681. private _createSpatialParameters;
  5682. private _updateSpatialParameters;
  5683. /**
  5684. * Switch the panning model to HRTF:
  5685. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5687. */
  5688. switchPanningModelToHRTF(): void;
  5689. /**
  5690. * Switch the panning model to Equal Power:
  5691. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5693. */
  5694. switchPanningModelToEqualPower(): void;
  5695. private _switchPanningModel;
  5696. /**
  5697. * Connect this sound to a sound track audio node like gain...
  5698. * @param soundTrackAudioNode the sound track audio node to connect to
  5699. */
  5700. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5701. /**
  5702. * Transform this sound into a directional source
  5703. * @param coneInnerAngle Size of the inner cone in degree
  5704. * @param coneOuterAngle Size of the outer cone in degree
  5705. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5706. */
  5707. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5708. /**
  5709. * Gets or sets the inner angle for the directional cone.
  5710. */
  5711. /**
  5712. * Gets or sets the inner angle for the directional cone.
  5713. */
  5714. directionalConeInnerAngle: number;
  5715. /**
  5716. * Gets or sets the outer angle for the directional cone.
  5717. */
  5718. /**
  5719. * Gets or sets the outer angle for the directional cone.
  5720. */
  5721. directionalConeOuterAngle: number;
  5722. /**
  5723. * Sets the position of the emitter if spatial sound is enabled
  5724. * @param newPosition Defines the new posisiton
  5725. */
  5726. setPosition(newPosition: Vector3): void;
  5727. /**
  5728. * Sets the local direction of the emitter if spatial sound is enabled
  5729. * @param newLocalDirection Defines the new local direction
  5730. */
  5731. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5732. private _updateDirection;
  5733. /** @hidden */
  5734. updateDistanceFromListener(): void;
  5735. /**
  5736. * Sets a new custom attenuation function for the sound.
  5737. * @param callback Defines the function used for the attenuation
  5738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5739. */
  5740. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5741. /**
  5742. * Play the sound
  5743. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5744. * @param offset (optional) Start the sound setting it at a specific time
  5745. */
  5746. play(time?: number, offset?: number): void;
  5747. private _onended;
  5748. /**
  5749. * Stop the sound
  5750. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5751. */
  5752. stop(time?: number): void;
  5753. /**
  5754. * Put the sound in pause
  5755. */
  5756. pause(): void;
  5757. /**
  5758. * Sets a dedicated volume for this sounds
  5759. * @param newVolume Define the new volume of the sound
  5760. * @param time Define in how long the sound should be at this value
  5761. */
  5762. setVolume(newVolume: number, time?: number): void;
  5763. /**
  5764. * Set the sound play back rate
  5765. * @param newPlaybackRate Define the playback rate the sound should be played at
  5766. */
  5767. setPlaybackRate(newPlaybackRate: number): void;
  5768. /**
  5769. * Gets the volume of the sound.
  5770. * @returns the volume of the sound
  5771. */
  5772. getVolume(): number;
  5773. /**
  5774. * Attach the sound to a dedicated mesh
  5775. * @param transformNode The transform node to connect the sound with
  5776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5777. */
  5778. attachToMesh(transformNode: TransformNode): void;
  5779. /**
  5780. * Detach the sound from the previously attached mesh
  5781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5782. */
  5783. detachFromMesh(): void;
  5784. private _onRegisterAfterWorldMatrixUpdate;
  5785. /**
  5786. * Clone the current sound in the scene.
  5787. * @returns the new sound clone
  5788. */
  5789. clone(): Nullable<Sound>;
  5790. /**
  5791. * Gets the current underlying audio buffer containing the data
  5792. * @returns the audio buffer
  5793. */
  5794. getAudioBuffer(): Nullable<AudioBuffer>;
  5795. /**
  5796. * Serializes the Sound in a JSON representation
  5797. * @returns the JSON representation of the sound
  5798. */
  5799. serialize(): any;
  5800. /**
  5801. * Parse a JSON representation of a sound to innstantiate in a given scene
  5802. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5803. * @param scene Define the scene the new parsed sound should be created in
  5804. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5805. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5806. * @returns the newly parsed sound
  5807. */
  5808. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. /**
  5813. * Options allowed during the creation of a sound track.
  5814. */
  5815. interface ISoundTrackOptions {
  5816. /**
  5817. * The volume the sound track should take during creation
  5818. */
  5819. volume?: number;
  5820. /**
  5821. * Define if the sound track is the main sound track of the scene
  5822. */
  5823. mainTrack?: boolean;
  5824. }
  5825. /**
  5826. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5827. * It will be also used in a future release to apply effects on a specific track.
  5828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5829. */
  5830. class SoundTrack {
  5831. /**
  5832. * The unique identifier of the sound track in the scene.
  5833. */
  5834. id: number;
  5835. /**
  5836. * The list of sounds included in the sound track.
  5837. */
  5838. soundCollection: Array<Sound>;
  5839. private _outputAudioNode;
  5840. private _scene;
  5841. private _isMainTrack;
  5842. private _connectedAnalyser;
  5843. private _options;
  5844. private _isInitialized;
  5845. /**
  5846. * Creates a new sound track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. * @param scene Define the scene the sound track belongs to
  5849. * @param options
  5850. */
  5851. constructor(scene: Scene, options?: ISoundTrackOptions);
  5852. private _initializeSoundTrackAudioGraph;
  5853. /**
  5854. * Release the sound track and its associated resources
  5855. */
  5856. dispose(): void;
  5857. /**
  5858. * Adds a sound to this sound track
  5859. * @param sound define the cound to add
  5860. * @ignoreNaming
  5861. */
  5862. AddSound(sound: Sound): void;
  5863. /**
  5864. * Removes a sound to this sound track
  5865. * @param sound define the cound to remove
  5866. * @ignoreNaming
  5867. */
  5868. RemoveSound(sound: Sound): void;
  5869. /**
  5870. * Set a global volume for the full sound track.
  5871. * @param newVolume Define the new volume of the sound track
  5872. */
  5873. setVolume(newVolume: number): void;
  5874. /**
  5875. * Switch the panning model to HRTF:
  5876. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5878. */
  5879. switchPanningModelToHRTF(): void;
  5880. /**
  5881. * Switch the panning model to Equal Power:
  5882. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5884. */
  5885. switchPanningModelToEqualPower(): void;
  5886. /**
  5887. * Connect the sound track to an audio analyser allowing some amazing
  5888. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5890. * @param analyser The analyser to connect to the engine
  5891. */
  5892. connectToAnalyser(analyser: Analyser): void;
  5893. }
  5894. }
  5895. declare module BABYLON {
  5896. /**
  5897. * Wraps one or more Sound objects and selects one with random weight for playback.
  5898. */
  5899. class WeightedSound {
  5900. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5901. loop: boolean;
  5902. private _coneInnerAngle;
  5903. private _coneOuterAngle;
  5904. private _volume;
  5905. /** A Sound is currently playing. */
  5906. isPlaying: boolean;
  5907. /** A Sound is currently paused. */
  5908. isPaused: boolean;
  5909. private _sounds;
  5910. private _weights;
  5911. private _currentIndex?;
  5912. /**
  5913. * Creates a new WeightedSound from the list of sounds given.
  5914. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5915. * @param sounds Array of Sounds that will be selected from.
  5916. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5917. */
  5918. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5919. /**
  5920. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5921. */
  5922. /**
  5923. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5924. */
  5925. directionalConeInnerAngle: number;
  5926. /**
  5927. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5928. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5929. */
  5930. /**
  5931. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5932. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5933. */
  5934. directionalConeOuterAngle: number;
  5935. /**
  5936. * Playback volume.
  5937. */
  5938. /**
  5939. * Playback volume.
  5940. */
  5941. volume: number;
  5942. private _onended;
  5943. /**
  5944. * Suspend playback
  5945. */
  5946. pause(): void;
  5947. /**
  5948. * Stop playback
  5949. */
  5950. stop(): void;
  5951. /**
  5952. * Start playback.
  5953. * @param startOffset Position the clip head at a specific time in seconds.
  5954. */
  5955. play(startOffset?: number): void;
  5956. }
  5957. }
  5958. declare module BABYLON {
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module BABYLON {
  6004. /**
  6005. * Class used to store bone information
  6006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6007. */
  6008. class Bone extends Node {
  6009. /**
  6010. * defines the bone name
  6011. */
  6012. name: string;
  6013. private static _tmpVecs;
  6014. private static _tmpQuat;
  6015. private static _tmpMats;
  6016. /**
  6017. * Gets the list of child bones
  6018. */
  6019. children: Bone[];
  6020. /** Gets the animations associated with this bone */
  6021. animations: Animation[];
  6022. /**
  6023. * Gets or sets bone length
  6024. */
  6025. length: number;
  6026. /**
  6027. * @hidden Internal only
  6028. * Set this value to map this bone to a different index in the transform matrices
  6029. * Set this value to -1 to exclude the bone from the transform matrices
  6030. */
  6031. _index: Nullable<number>;
  6032. private _skeleton;
  6033. private _localMatrix;
  6034. private _restPose;
  6035. private _baseMatrix;
  6036. private _absoluteTransform;
  6037. private _invertedAbsoluteTransform;
  6038. private _parent;
  6039. private _scalingDeterminant;
  6040. private _worldTransform;
  6041. private _localScaling;
  6042. private _localRotation;
  6043. private _localPosition;
  6044. private _needToDecompose;
  6045. private _needToCompose;
  6046. /** @hidden */
  6047. _linkedTransformNode: Nullable<TransformNode>;
  6048. /** @hidden */
  6049. /** @hidden */
  6050. _matrix: Matrix;
  6051. /**
  6052. * Create a new bone
  6053. * @param name defines the bone name
  6054. * @param skeleton defines the parent skeleton
  6055. * @param parentBone defines the parent (can be null if the bone is the root)
  6056. * @param localMatrix defines the local matrix
  6057. * @param restPose defines the rest pose matrix
  6058. * @param baseMatrix defines the base matrix
  6059. * @param index defines index of the bone in the hiearchy
  6060. */
  6061. constructor(
  6062. /**
  6063. * defines the bone name
  6064. */
  6065. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6066. /**
  6067. * Gets the parent skeleton
  6068. * @returns a skeleton
  6069. */
  6070. getSkeleton(): Skeleton;
  6071. /**
  6072. * Gets parent bone
  6073. * @returns a bone or null if the bone is the root of the bone hierarchy
  6074. */
  6075. getParent(): Nullable<Bone>;
  6076. /**
  6077. * Sets the parent bone
  6078. * @param parent defines the parent (can be null if the bone is the root)
  6079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6080. */
  6081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6082. /**
  6083. * Gets the local matrix
  6084. * @returns a matrix
  6085. */
  6086. getLocalMatrix(): Matrix;
  6087. /**
  6088. * Gets the base matrix (initial matrix which remains unchanged)
  6089. * @returns a matrix
  6090. */
  6091. getBaseMatrix(): Matrix;
  6092. /**
  6093. * Gets the rest pose matrix
  6094. * @returns a matrix
  6095. */
  6096. getRestPose(): Matrix;
  6097. /**
  6098. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6099. */
  6100. getWorldMatrix(): Matrix;
  6101. /**
  6102. * Sets the local matrix to rest pose matrix
  6103. */
  6104. returnToRest(): void;
  6105. /**
  6106. * Gets the inverse of the absolute transform matrix.
  6107. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6108. * @returns a matrix
  6109. */
  6110. getInvertedAbsoluteTransform(): Matrix;
  6111. /**
  6112. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6113. * @returns a matrix
  6114. */
  6115. getAbsoluteTransform(): Matrix;
  6116. /**
  6117. * Links with the given transform node.
  6118. * The local matrix of this bone is copied from the transform node every frame.
  6119. * @param transformNode defines the transform node to link to
  6120. */
  6121. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6122. /** Gets or sets current position (in local space) */
  6123. position: Vector3;
  6124. /** Gets or sets current rotation (in local space) */
  6125. rotation: Vector3;
  6126. /** Gets or sets current rotation quaternion (in local space) */
  6127. rotationQuaternion: Quaternion;
  6128. /** Gets or sets current scaling (in local space) */
  6129. scaling: Vector3;
  6130. /**
  6131. * Gets the animation properties override
  6132. */
  6133. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6134. private _decompose;
  6135. private _compose;
  6136. /**
  6137. * Update the base and local matrices
  6138. * @param matrix defines the new base or local matrix
  6139. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6140. * @param updateLocalMatrix defines if the local matrix should be updated
  6141. */
  6142. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6143. /** @hidden */
  6144. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6145. /**
  6146. * Flag the bone as dirty (Forcing it to update everything)
  6147. */
  6148. markAsDirty(): void;
  6149. private _markAsDirtyAndCompose;
  6150. private _markAsDirtyAndDecompose;
  6151. /**
  6152. * Copy an animation range from another bone
  6153. * @param source defines the source bone
  6154. * @param rangeName defines the range name to copy
  6155. * @param frameOffset defines the frame offset
  6156. * @param rescaleAsRequired defines if rescaling must be applied if required
  6157. * @param skelDimensionsRatio defines the scaling ratio
  6158. * @returns true if operation was successful
  6159. */
  6160. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6161. /**
  6162. * Translate the bone in local or world space
  6163. * @param vec The amount to translate the bone
  6164. * @param space The space that the translation is in
  6165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6166. */
  6167. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6168. /**
  6169. * Set the postion of the bone in local or world space
  6170. * @param position The position to set the bone
  6171. * @param space The space that the position is in
  6172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6173. */
  6174. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6175. /**
  6176. * Set the absolute position of the bone (world space)
  6177. * @param position The position to set the bone
  6178. * @param mesh The mesh that this bone is attached to
  6179. */
  6180. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6181. /**
  6182. * Scale the bone on the x, y and z axes (in local space)
  6183. * @param x The amount to scale the bone on the x axis
  6184. * @param y The amount to scale the bone on the y axis
  6185. * @param z The amount to scale the bone on the z axis
  6186. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6187. */
  6188. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6189. /**
  6190. * Set the bone scaling in local space
  6191. * @param scale defines the scaling vector
  6192. */
  6193. setScale(scale: Vector3): void;
  6194. /**
  6195. * Gets the current scaling in local space
  6196. * @returns the current scaling vector
  6197. */
  6198. getScale(): Vector3;
  6199. /**
  6200. * Gets the current scaling in local space and stores it in a target vector
  6201. * @param result defines the target vector
  6202. */
  6203. getScaleToRef(result: Vector3): void;
  6204. /**
  6205. * Set the yaw, pitch, and roll of the bone in local or world space
  6206. * @param yaw The rotation of the bone on the y axis
  6207. * @param pitch The rotation of the bone on the x axis
  6208. * @param roll The rotation of the bone on the z axis
  6209. * @param space The space that the axes of rotation are in
  6210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6211. */
  6212. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6213. /**
  6214. * Add a rotation to the bone on an axis in local or world space
  6215. * @param axis The axis to rotate the bone on
  6216. * @param amount The amount to rotate the bone
  6217. * @param space The space that the axis is in
  6218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6219. */
  6220. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6221. /**
  6222. * Set the rotation of the bone to a particular axis angle in local or world space
  6223. * @param axis The axis to rotate the bone on
  6224. * @param angle The angle that the bone should be rotated to
  6225. * @param space The space that the axis is in
  6226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6227. */
  6228. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6229. /**
  6230. * Set the euler rotation of the bone in local of world space
  6231. * @param rotation The euler rotation that the bone should be set to
  6232. * @param space The space that the rotation is in
  6233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6234. */
  6235. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6236. /**
  6237. * Set the quaternion rotation of the bone in local of world space
  6238. * @param quat The quaternion rotation that the bone should be set to
  6239. * @param space The space that the rotation is in
  6240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6241. */
  6242. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6243. /**
  6244. * Set the rotation matrix of the bone in local of world space
  6245. * @param rotMat The rotation matrix that the bone should be set to
  6246. * @param space The space that the rotation is in
  6247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6248. */
  6249. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6250. private _rotateWithMatrix;
  6251. private _getNegativeRotationToRef;
  6252. /**
  6253. * Get the position of the bone in local or world space
  6254. * @param space The space that the returned position is in
  6255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6256. * @returns The position of the bone
  6257. */
  6258. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6259. /**
  6260. * Copy the position of the bone to a vector3 in local or world space
  6261. * @param space The space that the returned position is in
  6262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6263. * @param result The vector3 to copy the position to
  6264. */
  6265. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6266. /**
  6267. * Get the absolute position of the bone (world space)
  6268. * @param mesh The mesh that this bone is attached to
  6269. * @returns The absolute position of the bone
  6270. */
  6271. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6272. /**
  6273. * Copy the absolute position of the bone (world space) to the result param
  6274. * @param mesh The mesh that this bone is attached to
  6275. * @param result The vector3 to copy the absolute position to
  6276. */
  6277. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6278. /**
  6279. * Compute the absolute transforms of this bone and its children
  6280. */
  6281. computeAbsoluteTransforms(): void;
  6282. /**
  6283. * Get the world direction from an axis that is in the local space of the bone
  6284. * @param localAxis The local direction that is used to compute the world direction
  6285. * @param mesh The mesh that this bone is attached to
  6286. * @returns The world direction
  6287. */
  6288. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6289. /**
  6290. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6291. * @param localAxis The local direction that is used to compute the world direction
  6292. * @param mesh The mesh that this bone is attached to
  6293. * @param result The vector3 that the world direction will be copied to
  6294. */
  6295. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6296. /**
  6297. * Get the euler rotation of the bone in local or world space
  6298. * @param space The space that the rotation should be in
  6299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6300. * @returns The euler rotation
  6301. */
  6302. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6303. /**
  6304. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6305. * @param space The space that the rotation should be in
  6306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6307. * @param result The vector3 that the rotation should be copied to
  6308. */
  6309. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6310. /**
  6311. * Get the quaternion rotation of the bone in either local or world space
  6312. * @param space The space that the rotation should be in
  6313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6314. * @returns The quaternion rotation
  6315. */
  6316. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6317. /**
  6318. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6319. * @param space The space that the rotation should be in
  6320. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6321. * @param result The quaternion that the rotation should be copied to
  6322. */
  6323. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6324. /**
  6325. * Get the rotation matrix of the bone in local or world space
  6326. * @param space The space that the rotation should be in
  6327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6328. * @returns The rotation matrix
  6329. */
  6330. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6331. /**
  6332. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6333. * @param space The space that the rotation should be in
  6334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6335. * @param result The quaternion that the rotation should be copied to
  6336. */
  6337. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6338. /**
  6339. * Get the world position of a point that is in the local space of the bone
  6340. * @param position The local position
  6341. * @param mesh The mesh that this bone is attached to
  6342. * @returns The world position
  6343. */
  6344. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6345. /**
  6346. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6347. * @param position The local position
  6348. * @param mesh The mesh that this bone is attached to
  6349. * @param result The vector3 that the world position should be copied to
  6350. */
  6351. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6352. /**
  6353. * Get the local position of a point that is in world space
  6354. * @param position The world position
  6355. * @param mesh The mesh that this bone is attached to
  6356. * @returns The local position
  6357. */
  6358. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6359. /**
  6360. * Get the local position of a point that is in world space and copy it to the result param
  6361. * @param position The world position
  6362. * @param mesh The mesh that this bone is attached to
  6363. * @param result The vector3 that the local position should be copied to
  6364. */
  6365. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6366. }
  6367. }
  6368. declare module BABYLON {
  6369. /**
  6370. * Class used to apply inverse kinematics to bones
  6371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6372. */
  6373. class BoneIKController {
  6374. private static _tmpVecs;
  6375. private static _tmpQuat;
  6376. private static _tmpMats;
  6377. /**
  6378. * Gets or sets the target mesh
  6379. */
  6380. targetMesh: AbstractMesh;
  6381. /** Gets or sets the mesh used as pole */
  6382. poleTargetMesh: AbstractMesh;
  6383. /**
  6384. * Gets or sets the bone used as pole
  6385. */
  6386. poleTargetBone: Nullable<Bone>;
  6387. /**
  6388. * Gets or sets the target position
  6389. */
  6390. targetPosition: Vector3;
  6391. /**
  6392. * Gets or sets the pole target position
  6393. */
  6394. poleTargetPosition: Vector3;
  6395. /**
  6396. * Gets or sets the pole target local offset
  6397. */
  6398. poleTargetLocalOffset: Vector3;
  6399. /**
  6400. * Gets or sets the pole angle
  6401. */
  6402. poleAngle: number;
  6403. /**
  6404. * Gets or sets the mesh associated with the controller
  6405. */
  6406. mesh: AbstractMesh;
  6407. /**
  6408. * 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)
  6409. */
  6410. slerpAmount: number;
  6411. private _bone1Quat;
  6412. private _bone1Mat;
  6413. private _bone2Ang;
  6414. private _bone1;
  6415. private _bone2;
  6416. private _bone1Length;
  6417. private _bone2Length;
  6418. private _maxAngle;
  6419. private _maxReach;
  6420. private _rightHandedSystem;
  6421. private _bendAxis;
  6422. private _slerping;
  6423. private _adjustRoll;
  6424. /**
  6425. * Gets or sets maximum allowed angle
  6426. */
  6427. maxAngle: number;
  6428. /**
  6429. * Creates a new BoneIKController
  6430. * @param mesh defines the mesh to control
  6431. * @param bone defines the bone to control
  6432. * @param options defines options to set up the controller
  6433. */
  6434. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6435. targetMesh?: AbstractMesh;
  6436. poleTargetMesh?: AbstractMesh;
  6437. poleTargetBone?: Bone;
  6438. poleTargetLocalOffset?: Vector3;
  6439. poleAngle?: number;
  6440. bendAxis?: Vector3;
  6441. maxAngle?: number;
  6442. slerpAmount?: number;
  6443. });
  6444. private _setMaxAngle;
  6445. /**
  6446. * Force the controller to update the bones
  6447. */
  6448. update(): void;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Class used to make a bone look toward a point in space
  6454. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6455. */
  6456. class BoneLookController {
  6457. private static _tmpVecs;
  6458. private static _tmpQuat;
  6459. private static _tmpMats;
  6460. /**
  6461. * The target Vector3 that the bone will look at
  6462. */
  6463. target: Vector3;
  6464. /**
  6465. * The mesh that the bone is attached to
  6466. */
  6467. mesh: AbstractMesh;
  6468. /**
  6469. * The bone that will be looking to the target
  6470. */
  6471. bone: Bone;
  6472. /**
  6473. * The up axis of the coordinate system that is used when the bone is rotated
  6474. */
  6475. upAxis: Vector3;
  6476. /**
  6477. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6478. */
  6479. upAxisSpace: Space;
  6480. /**
  6481. * Used to make an adjustment to the yaw of the bone
  6482. */
  6483. adjustYaw: number;
  6484. /**
  6485. * Used to make an adjustment to the pitch of the bone
  6486. */
  6487. adjustPitch: number;
  6488. /**
  6489. * Used to make an adjustment to the roll of the bone
  6490. */
  6491. adjustRoll: number;
  6492. /**
  6493. * 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)
  6494. */
  6495. slerpAmount: number;
  6496. private _minYaw;
  6497. private _maxYaw;
  6498. private _minPitch;
  6499. private _maxPitch;
  6500. private _minYawSin;
  6501. private _minYawCos;
  6502. private _maxYawSin;
  6503. private _maxYawCos;
  6504. private _midYawConstraint;
  6505. private _minPitchTan;
  6506. private _maxPitchTan;
  6507. private _boneQuat;
  6508. private _slerping;
  6509. private _transformYawPitch;
  6510. private _transformYawPitchInv;
  6511. private _firstFrameSkipped;
  6512. private _yawRange;
  6513. private _fowardAxis;
  6514. /**
  6515. * Gets or sets the minimum yaw angle that the bone can look to
  6516. */
  6517. minYaw: number;
  6518. /**
  6519. * Gets or sets the maximum yaw angle that the bone can look to
  6520. */
  6521. maxYaw: number;
  6522. /**
  6523. * Gets or sets the minimum pitch angle that the bone can look to
  6524. */
  6525. minPitch: number;
  6526. /**
  6527. * Gets or sets the maximum pitch angle that the bone can look to
  6528. */
  6529. maxPitch: number;
  6530. /**
  6531. * Create a BoneLookController
  6532. * @param mesh the mesh that the bone belongs to
  6533. * @param bone the bone that will be looking to the target
  6534. * @param target the target Vector3 to look at
  6535. * @param settings optional settings:
  6536. * * maxYaw: the maximum angle the bone will yaw to
  6537. * * minYaw: the minimum angle the bone will yaw to
  6538. * * maxPitch: the maximum angle the bone will pitch to
  6539. * * minPitch: the minimum angle the bone will yaw to
  6540. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6541. * * upAxis: the up axis of the coordinate system
  6542. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6543. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6544. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6545. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6546. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6547. * * adjustRoll: used to make an adjustment to the roll of the bone
  6548. **/
  6549. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6550. maxYaw?: number;
  6551. minYaw?: number;
  6552. maxPitch?: number;
  6553. minPitch?: number;
  6554. slerpAmount?: number;
  6555. upAxis?: Vector3;
  6556. upAxisSpace?: Space;
  6557. yawAxis?: Vector3;
  6558. pitchAxis?: Vector3;
  6559. adjustYaw?: number;
  6560. adjustPitch?: number;
  6561. adjustRoll?: number;
  6562. });
  6563. /**
  6564. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6565. */
  6566. update(): void;
  6567. private _getAngleDiff;
  6568. private _getAngleBetween;
  6569. private _isAngleBetween;
  6570. }
  6571. }
  6572. declare module BABYLON {
  6573. /**
  6574. * Class used to handle skinning animations
  6575. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6576. */
  6577. class Skeleton implements IAnimatable {
  6578. /** defines the skeleton name */
  6579. name: string;
  6580. /** defines the skeleton Id */
  6581. id: string;
  6582. /**
  6583. * Defines the list of child bones
  6584. */
  6585. bones: Bone[];
  6586. /**
  6587. * Defines an estimate of the dimension of the skeleton at rest
  6588. */
  6589. dimensionsAtRest: Vector3;
  6590. /**
  6591. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6592. */
  6593. needInitialSkinMatrix: boolean;
  6594. /**
  6595. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6596. */
  6597. overrideMesh: Nullable<AbstractMesh>;
  6598. /**
  6599. * Gets the list of animations attached to this skeleton
  6600. */
  6601. animations: Array<Animation>;
  6602. private _scene;
  6603. private _isDirty;
  6604. private _transformMatrices;
  6605. private _transformMatrixTexture;
  6606. private _meshesWithPoseMatrix;
  6607. private _animatables;
  6608. private _identity;
  6609. private _synchronizedWithMesh;
  6610. private _ranges;
  6611. private _lastAbsoluteTransformsUpdateId;
  6612. private _canUseTextureForBones;
  6613. /** @hidden */
  6614. _numBonesWithLinkedTransformNode: number;
  6615. /**
  6616. * Specifies if the skeleton should be serialized
  6617. */
  6618. doNotSerialize: boolean;
  6619. /**
  6620. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6621. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6622. */
  6623. useTextureToStoreBoneMatrices: boolean;
  6624. private _animationPropertiesOverride;
  6625. /**
  6626. * Gets or sets the animation properties override
  6627. */
  6628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6629. /**
  6630. * An observable triggered before computing the skeleton's matrices
  6631. */
  6632. onBeforeComputeObservable: Observable<Skeleton>;
  6633. /**
  6634. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6635. */
  6636. readonly isUsingTextureForMatrices: boolean;
  6637. /**
  6638. * Creates a new skeleton
  6639. * @param name defines the skeleton name
  6640. * @param id defines the skeleton Id
  6641. * @param scene defines the hosting scene
  6642. */
  6643. constructor(
  6644. /** defines the skeleton name */
  6645. name: string,
  6646. /** defines the skeleton Id */
  6647. id: string, scene: Scene);
  6648. /**
  6649. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6650. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6651. * @returns a Float32Array containing matrices data
  6652. */
  6653. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6654. /**
  6655. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6656. * @returns a raw texture containing the data
  6657. */
  6658. getTransformMatrixTexture(): Nullable<RawTexture>;
  6659. /**
  6660. * Gets the current hosting scene
  6661. * @returns a scene object
  6662. */
  6663. getScene(): Scene;
  6664. /**
  6665. * Gets a string representing the current skeleton data
  6666. * @param fullDetails defines a boolean indicating if we want a verbose version
  6667. * @returns a string representing the current skeleton data
  6668. */
  6669. toString(fullDetails?: boolean): string;
  6670. /**
  6671. * Get bone's index searching by name
  6672. * @param name defines bone's name to search for
  6673. * @return the indice of the bone. Returns -1 if not found
  6674. */
  6675. getBoneIndexByName(name: string): number;
  6676. /**
  6677. * Creater a new animation range
  6678. * @param name defines the name of the range
  6679. * @param from defines the start key
  6680. * @param to defines the end key
  6681. */
  6682. createAnimationRange(name: string, from: number, to: number): void;
  6683. /**
  6684. * Delete a specific animation range
  6685. * @param name defines the name of the range
  6686. * @param deleteFrames defines if frames must be removed as well
  6687. */
  6688. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6689. /**
  6690. * Gets a specific animation range
  6691. * @param name defines the name of the range to look for
  6692. * @returns the requested animation range or null if not found
  6693. */
  6694. getAnimationRange(name: string): Nullable<AnimationRange>;
  6695. /**
  6696. * Gets the list of all animation ranges defined on this skeleton
  6697. * @returns an array
  6698. */
  6699. getAnimationRanges(): Nullable<AnimationRange>[];
  6700. /**
  6701. * Copy animation range from a source skeleton.
  6702. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6703. * @param source defines the source skeleton
  6704. * @param name defines the name of the range to copy
  6705. * @param rescaleAsRequired defines if rescaling must be applied if required
  6706. * @returns true if operation was successful
  6707. */
  6708. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6709. /**
  6710. * Forces the skeleton to go to rest pose
  6711. */
  6712. returnToRest(): void;
  6713. private _getHighestAnimationFrame;
  6714. /**
  6715. * Begin a specific animation range
  6716. * @param name defines the name of the range to start
  6717. * @param loop defines if looping must be turned on (false by default)
  6718. * @param speedRatio defines the speed ratio to apply (1 by default)
  6719. * @param onAnimationEnd defines a callback which will be called when animation will end
  6720. * @returns a new animatable
  6721. */
  6722. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6723. /** @hidden */
  6724. _markAsDirty(): void;
  6725. /** @hidden */
  6726. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6727. /** @hidden */
  6728. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6729. private _computeTransformMatrices;
  6730. /**
  6731. * Build all resources required to render a skeleton
  6732. */
  6733. prepare(): void;
  6734. /**
  6735. * Gets the list of animatables currently running for this skeleton
  6736. * @returns an array of animatables
  6737. */
  6738. getAnimatables(): IAnimatable[];
  6739. /**
  6740. * Clone the current skeleton
  6741. * @param name defines the name of the new skeleton
  6742. * @param id defines the id of the enw skeleton
  6743. * @returns the new skeleton
  6744. */
  6745. clone(name: string, id: string): Skeleton;
  6746. /**
  6747. * Enable animation blending for this skeleton
  6748. * @param blendingSpeed defines the blending speed to apply
  6749. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6750. */
  6751. enableBlending(blendingSpeed?: number): void;
  6752. /**
  6753. * Releases all resources associated with the current skeleton
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Serialize the skeleton in a JSON object
  6758. * @returns a JSON object
  6759. */
  6760. serialize(): any;
  6761. /**
  6762. * Creates a new skeleton from serialized data
  6763. * @param parsedSkeleton defines the serialized data
  6764. * @param scene defines the hosting scene
  6765. * @returns a new skeleton
  6766. */
  6767. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6768. /**
  6769. * Compute all node absolute transforms
  6770. * @param forceUpdate defines if computation must be done even if cache is up to date
  6771. */
  6772. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6773. /**
  6774. * Gets the root pose matrix
  6775. * @returns a matrix
  6776. */
  6777. getPoseMatrix(): Nullable<Matrix>;
  6778. /**
  6779. * Sorts bones per internal index
  6780. */
  6781. sortBones(): void;
  6782. private _sortBones;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /** @hidden */
  6849. var CollisionWorker: string;
  6850. /** @hidden */
  6851. interface ICollisionCoordinator {
  6852. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6853. init(scene: Scene): void;
  6854. destroy(): void;
  6855. onMeshAdded(mesh: AbstractMesh): void;
  6856. onMeshUpdated(mesh: AbstractMesh): void;
  6857. onMeshRemoved(mesh: AbstractMesh): void;
  6858. onGeometryAdded(geometry: Geometry): void;
  6859. onGeometryUpdated(geometry: Geometry): void;
  6860. onGeometryDeleted(geometry: Geometry): void;
  6861. }
  6862. /** @hidden */
  6863. interface SerializedMesh {
  6864. id: string;
  6865. name: string;
  6866. uniqueId: number;
  6867. geometryId: Nullable<string>;
  6868. sphereCenter: Array<number>;
  6869. sphereRadius: number;
  6870. boxMinimum: Array<number>;
  6871. boxMaximum: Array<number>;
  6872. worldMatrixFromCache: any;
  6873. subMeshes: Array<SerializedSubMesh>;
  6874. checkCollisions: boolean;
  6875. }
  6876. /** @hidden */
  6877. interface SerializedSubMesh {
  6878. position: number;
  6879. verticesStart: number;
  6880. verticesCount: number;
  6881. indexStart: number;
  6882. indexCount: number;
  6883. hasMaterial: boolean;
  6884. sphereCenter: Array<number>;
  6885. sphereRadius: number;
  6886. boxMinimum: Array<number>;
  6887. boxMaximum: Array<number>;
  6888. }
  6889. /**
  6890. * Interface describing the value associated with a geometry.
  6891. * @hidden
  6892. */
  6893. interface SerializedGeometry {
  6894. /**
  6895. * Defines the unique ID of the geometry
  6896. */
  6897. id: string;
  6898. /**
  6899. * Defines the array containing the positions
  6900. */
  6901. positions: Float32Array;
  6902. /**
  6903. * Defines the array containing the indices
  6904. */
  6905. indices: Uint32Array;
  6906. /**
  6907. * Defines the array containing the normals
  6908. */
  6909. normals: Float32Array;
  6910. }
  6911. /** @hidden */
  6912. interface BabylonMessage {
  6913. taskType: WorkerTaskType;
  6914. payload: InitPayload | CollidePayload | UpdatePayload;
  6915. }
  6916. /** @hidden */
  6917. interface SerializedColliderToWorker {
  6918. position: Array<number>;
  6919. velocity: Array<number>;
  6920. radius: Array<number>;
  6921. }
  6922. /** Defines supported task for worker process */
  6923. enum WorkerTaskType {
  6924. /** Initialization */
  6925. INIT = 0,
  6926. /** Update of geometry */
  6927. UPDATE = 1,
  6928. /** Evaluate collision */
  6929. COLLIDE = 2
  6930. }
  6931. /** @hidden */
  6932. interface WorkerReply {
  6933. error: WorkerReplyType;
  6934. taskType: WorkerTaskType;
  6935. payload?: any;
  6936. }
  6937. /** @hidden */
  6938. interface CollisionReplyPayload {
  6939. newPosition: Array<number>;
  6940. collisionId: number;
  6941. collidedMeshUniqueId: number;
  6942. }
  6943. /** @hidden */
  6944. interface InitPayload {
  6945. }
  6946. /** @hidden */
  6947. interface CollidePayload {
  6948. collisionId: number;
  6949. collider: SerializedColliderToWorker;
  6950. maximumRetry: number;
  6951. excludedMeshUniqueId: Nullable<number>;
  6952. }
  6953. /** @hidden */
  6954. interface UpdatePayload {
  6955. updatedMeshes: {
  6956. [n: number]: SerializedMesh;
  6957. };
  6958. updatedGeometries: {
  6959. [s: string]: SerializedGeometry;
  6960. };
  6961. removedMeshes: Array<number>;
  6962. removedGeometries: Array<string>;
  6963. }
  6964. /** Defines kind of replies returned by worker */
  6965. enum WorkerReplyType {
  6966. /** Success */
  6967. SUCCESS = 0,
  6968. /** Unkown error */
  6969. UNKNOWN_ERROR = 1
  6970. }
  6971. /** @hidden */
  6972. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6973. private _scene;
  6974. private _scaledPosition;
  6975. private _scaledVelocity;
  6976. private _collisionsCallbackArray;
  6977. private _init;
  6978. private _runningUpdated;
  6979. private _worker;
  6980. private _addUpdateMeshesList;
  6981. private _addUpdateGeometriesList;
  6982. private _toRemoveMeshesArray;
  6983. private _toRemoveGeometryArray;
  6984. constructor();
  6985. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6986. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6987. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6988. init(scene: Scene): void;
  6989. destroy(): void;
  6990. onMeshAdded(mesh: AbstractMesh): void;
  6991. onMeshUpdated: (transformNode: TransformNode) => void;
  6992. onMeshRemoved(mesh: AbstractMesh): void;
  6993. onGeometryAdded(geometry: Geometry): void;
  6994. onGeometryUpdated: (geometry: Geometry) => void;
  6995. onGeometryDeleted(geometry: Geometry): void;
  6996. private _afterRender;
  6997. private _onMessageFromWorker;
  6998. }
  6999. /** @hidden */
  7000. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7001. private _scene;
  7002. private _scaledPosition;
  7003. private _scaledVelocity;
  7004. private _finalPosition;
  7005. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7006. init(scene: Scene): void;
  7007. destroy(): void;
  7008. onMeshAdded(mesh: AbstractMesh): void;
  7009. onMeshUpdated(mesh: AbstractMesh): void;
  7010. onMeshRemoved(mesh: AbstractMesh): void;
  7011. onGeometryAdded(geometry: Geometry): void;
  7012. onGeometryUpdated(geometry: Geometry): void;
  7013. onGeometryDeleted(geometry: Geometry): void;
  7014. private _collideWithWorld;
  7015. }
  7016. }
  7017. declare function importScripts(...urls: string[]): void;
  7018. declare const safePostMessage: any;
  7019. declare module BABYLON {
  7020. /** @hidden */
  7021. var WorkerIncluded: boolean;
  7022. /** @hidden */
  7023. class CollisionCache {
  7024. private _meshes;
  7025. private _geometries;
  7026. getMeshes(): {
  7027. [n: number]: SerializedMesh;
  7028. };
  7029. getGeometries(): {
  7030. [s: number]: SerializedGeometry;
  7031. };
  7032. getMesh(id: any): SerializedMesh;
  7033. addMesh(mesh: SerializedMesh): void;
  7034. removeMesh(uniqueId: number): void;
  7035. getGeometry(id: string): SerializedGeometry;
  7036. addGeometry(geometry: SerializedGeometry): void;
  7037. removeGeometry(id: string): void;
  7038. }
  7039. /** @hidden */
  7040. class CollideWorker {
  7041. collider: Collider;
  7042. private _collisionCache;
  7043. private finalPosition;
  7044. private collisionsScalingMatrix;
  7045. private collisionTranformationMatrix;
  7046. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7047. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7048. private checkCollision;
  7049. private processCollisionsForSubMeshes;
  7050. private collideForSubMesh;
  7051. private checkSubmeshCollision;
  7052. }
  7053. /** @hidden */
  7054. interface ICollisionDetector {
  7055. onInit(payload: InitPayload): void;
  7056. onUpdate(payload: UpdatePayload): void;
  7057. onCollision(payload: CollidePayload): void;
  7058. }
  7059. /** @hidden */
  7060. class CollisionDetectorTransferable implements ICollisionDetector {
  7061. private _collisionCache;
  7062. onInit(payload: InitPayload): void;
  7063. onUpdate(payload: UpdatePayload): void;
  7064. onCollision(payload: CollidePayload): void;
  7065. }
  7066. }
  7067. declare module BABYLON {
  7068. /**
  7069. * @hidden
  7070. */
  7071. class IntersectionInfo {
  7072. bu: Nullable<number>;
  7073. bv: Nullable<number>;
  7074. distance: number;
  7075. faceId: number;
  7076. subMeshId: number;
  7077. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7078. }
  7079. /**
  7080. * Information about the result of picking within a scene
  7081. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7082. */
  7083. class PickingInfo {
  7084. /**
  7085. * If the pick collided with an object
  7086. */
  7087. hit: boolean;
  7088. /**
  7089. * Distance away where the pick collided
  7090. */
  7091. distance: number;
  7092. /**
  7093. * The location of pick collision
  7094. */
  7095. pickedPoint: Nullable<Vector3>;
  7096. /**
  7097. * The mesh corresponding the the pick collision
  7098. */
  7099. pickedMesh: Nullable<AbstractMesh>;
  7100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7101. bu: number;
  7102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7103. bv: number;
  7104. /** The id of the face on the mesh that was picked */
  7105. faceId: number;
  7106. /** Id of the the submesh that was picked */
  7107. subMeshId: number;
  7108. /** If a sprite was picked, this will be the sprite the pick collided with */
  7109. pickedSprite: Nullable<Sprite>;
  7110. /**
  7111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7112. */
  7113. originMesh: Nullable<AbstractMesh>;
  7114. /**
  7115. * The ray that was used to perform the picking.
  7116. */
  7117. ray: Nullable<Ray>;
  7118. /**
  7119. * Gets the normal correspodning to the face the pick collided with
  7120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7122. * @returns The normal correspodning to the face the pick collided with
  7123. */
  7124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7125. /**
  7126. * Gets the texture coordinates of where the pick occured
  7127. * @returns the vector containing the coordnates of the texture
  7128. */
  7129. getTextureCoordinates(): Nullable<Vector2>;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * This represents an orbital type of camera.
  7135. *
  7136. * 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.
  7137. * 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.
  7138. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7139. */
  7140. class ArcRotateCamera extends TargetCamera {
  7141. /**
  7142. * Defines the rotation angle of the camera along the longitudinal axis.
  7143. */
  7144. alpha: number;
  7145. /**
  7146. * Defines the rotation angle of the camera along the latitudinal axis.
  7147. */
  7148. beta: number;
  7149. /**
  7150. * Defines the radius of the camera from it s target point.
  7151. */
  7152. radius: number;
  7153. protected _target: Vector3;
  7154. protected _targetHost: Nullable<AbstractMesh>;
  7155. /**
  7156. * Defines the target point of the camera.
  7157. * The camera looks towards it form the radius distance.
  7158. */
  7159. target: Vector3;
  7160. /**
  7161. * Current inertia value on the longitudinal axis.
  7162. * The bigger this number the longer it will take for the camera to stop.
  7163. */
  7164. inertialAlphaOffset: number;
  7165. /**
  7166. * Current inertia value on the latitudinal axis.
  7167. * The bigger this number the longer it will take for the camera to stop.
  7168. */
  7169. inertialBetaOffset: number;
  7170. /**
  7171. * Current inertia value on the radius axis.
  7172. * The bigger this number the longer it will take for the camera to stop.
  7173. */
  7174. inertialRadiusOffset: number;
  7175. /**
  7176. * Minimum allowed angle on the longitudinal axis.
  7177. * This can help limiting how the Camera is able to move in the scene.
  7178. */
  7179. lowerAlphaLimit: Nullable<number>;
  7180. /**
  7181. * Maximum allowed angle on the longitudinal axis.
  7182. * This can help limiting how the Camera is able to move in the scene.
  7183. */
  7184. upperAlphaLimit: Nullable<number>;
  7185. /**
  7186. * Minimum allowed angle on the latitudinal axis.
  7187. * This can help limiting how the Camera is able to move in the scene.
  7188. */
  7189. lowerBetaLimit: number;
  7190. /**
  7191. * Maximum allowed angle on the latitudinal axis.
  7192. * This can help limiting how the Camera is able to move in the scene.
  7193. */
  7194. upperBetaLimit: number;
  7195. /**
  7196. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7197. * This can help limiting how the Camera is able to move in the scene.
  7198. */
  7199. lowerRadiusLimit: Nullable<number>;
  7200. /**
  7201. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7202. * This can help limiting how the Camera is able to move in the scene.
  7203. */
  7204. upperRadiusLimit: Nullable<number>;
  7205. /**
  7206. * Defines the current inertia value used during panning of the camera along the X axis.
  7207. */
  7208. inertialPanningX: number;
  7209. /**
  7210. * Defines the current inertia value used during panning of the camera along the Y axis.
  7211. */
  7212. inertialPanningY: number;
  7213. /**
  7214. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7215. * Basically if your fingers moves away from more than this distance you will be considered
  7216. * in pinch mode.
  7217. */
  7218. pinchToPanMaxDistance: number;
  7219. /**
  7220. * Defines the maximum distance the camera can pan.
  7221. * This could help keeping the cammera always in your scene.
  7222. */
  7223. panningDistanceLimit: Nullable<number>;
  7224. /**
  7225. * Defines the target of the camera before paning.
  7226. */
  7227. panningOriginTarget: Vector3;
  7228. /**
  7229. * Defines the value of the inertia used during panning.
  7230. * 0 would mean stop inertia and one would mean no decelleration at all.
  7231. */
  7232. panningInertia: number;
  7233. /**
  7234. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7235. */
  7236. angularSensibilityX: number;
  7237. /**
  7238. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7239. */
  7240. angularSensibilityY: number;
  7241. /**
  7242. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7243. */
  7244. pinchPrecision: number;
  7245. /**
  7246. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7247. * It will be used instead of pinchDeltaPrecision if different from 0.
  7248. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7249. */
  7250. pinchDeltaPercentage: number;
  7251. /**
  7252. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7253. */
  7254. panningSensibility: number;
  7255. /**
  7256. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7257. */
  7258. keysUp: number[];
  7259. /**
  7260. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7261. */
  7262. keysDown: number[];
  7263. /**
  7264. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7265. */
  7266. keysLeft: number[];
  7267. /**
  7268. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7269. */
  7270. keysRight: number[];
  7271. /**
  7272. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7273. */
  7274. wheelPrecision: number;
  7275. /**
  7276. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7277. * It will be used instead of pinchDeltaPrecision if different from 0.
  7278. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7279. */
  7280. wheelDeltaPercentage: number;
  7281. /**
  7282. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7283. */
  7284. zoomOnFactor: number;
  7285. /**
  7286. * Defines a screen offset for the camera position.
  7287. */
  7288. targetScreenOffset: Vector2;
  7289. /**
  7290. * Allows the camera to be completely reversed.
  7291. * If false the camera can not arrive upside down.
  7292. */
  7293. allowUpsideDown: boolean;
  7294. /**
  7295. * Define if double tap/click is used to restore the previously saved state of the camera.
  7296. */
  7297. useInputToRestoreState: boolean;
  7298. /** @hidden */
  7299. _viewMatrix: Matrix;
  7300. /** @hidden */
  7301. _useCtrlForPanning: boolean;
  7302. /** @hidden */
  7303. _panningMouseButton: number;
  7304. /**
  7305. * Defines the inpute associated to the camera.
  7306. */
  7307. inputs: ArcRotateCameraInputsManager;
  7308. /** @hidden */
  7309. _reset: () => void;
  7310. /**
  7311. * Defines the allowed panning axis.
  7312. */
  7313. panningAxis: Vector3;
  7314. protected _localDirection: Vector3;
  7315. protected _transformedDirection: Vector3;
  7316. private _bouncingBehavior;
  7317. /**
  7318. * Gets the bouncing behavior of the camera if it has been enabled.
  7319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7320. */
  7321. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7322. /**
  7323. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7325. */
  7326. useBouncingBehavior: boolean;
  7327. private _framingBehavior;
  7328. /**
  7329. * Gets the framing behavior of the camera if it has been enabled.
  7330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7331. */
  7332. readonly framingBehavior: Nullable<FramingBehavior>;
  7333. /**
  7334. * Defines if the framing behavior of the camera is enabled on the camera.
  7335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7336. */
  7337. useFramingBehavior: boolean;
  7338. private _autoRotationBehavior;
  7339. /**
  7340. * Gets the auto rotation behavior of the camera if it has been enabled.
  7341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7342. */
  7343. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7344. /**
  7345. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7346. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7347. */
  7348. useAutoRotationBehavior: boolean;
  7349. /**
  7350. * Observable triggered when the mesh target has been changed on the camera.
  7351. */
  7352. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7353. /**
  7354. * Event raised when the camera is colliding with a mesh.
  7355. */
  7356. onCollide: (collidedMesh: AbstractMesh) => void;
  7357. /**
  7358. * Defines whether the camera should check collision with the objects oh the scene.
  7359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7360. */
  7361. checkCollisions: boolean;
  7362. /**
  7363. * Defines the collision radius of the camera.
  7364. * This simulates a sphere around the camera.
  7365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7366. */
  7367. collisionRadius: Vector3;
  7368. protected _collider: Collider;
  7369. protected _previousPosition: Vector3;
  7370. protected _collisionVelocity: Vector3;
  7371. protected _newPosition: Vector3;
  7372. protected _previousAlpha: number;
  7373. protected _previousBeta: number;
  7374. protected _previousRadius: number;
  7375. protected _collisionTriggered: boolean;
  7376. protected _targetBoundingCenter: Nullable<Vector3>;
  7377. private _computationVector;
  7378. /**
  7379. * Instantiates a new ArcRotateCamera in a given scene
  7380. * @param name Defines the name of the camera
  7381. * @param alpha Defines the camera rotation along the logitudinal axis
  7382. * @param beta Defines the camera rotation along the latitudinal axis
  7383. * @param radius Defines the camera distance from its target
  7384. * @param target Defines the camera target
  7385. * @param scene Defines the scene the camera belongs to
  7386. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7387. */
  7388. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7389. /** @hidden */
  7390. _initCache(): void;
  7391. /** @hidden */
  7392. _updateCache(ignoreParentClass?: boolean): void;
  7393. protected _getTargetPosition(): Vector3;
  7394. private _storedAlpha;
  7395. private _storedBeta;
  7396. private _storedRadius;
  7397. private _storedTarget;
  7398. /**
  7399. * Stores the current state of the camera (alpha, beta, radius and target)
  7400. * @returns the camera itself
  7401. */
  7402. storeState(): Camera;
  7403. /**
  7404. * @hidden
  7405. * Restored camera state. You must call storeState() first
  7406. */
  7407. _restoreStateValues(): boolean;
  7408. /** @hidden */
  7409. _isSynchronizedViewMatrix(): boolean;
  7410. /**
  7411. * Attached controls to the current camera.
  7412. * @param element Defines the element the controls should be listened from
  7413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7414. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7415. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7416. */
  7417. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7418. /**
  7419. * Detach the current controls from the camera.
  7420. * The camera will stop reacting to inputs.
  7421. * @param element Defines the element to stop listening the inputs from
  7422. */
  7423. detachControl(element: HTMLElement): void;
  7424. /** @hidden */
  7425. _checkInputs(): void;
  7426. protected _checkLimits(): void;
  7427. /**
  7428. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7429. */
  7430. rebuildAnglesAndRadius(): void;
  7431. /**
  7432. * Use a position to define the current camera related information like aplha, beta and radius
  7433. * @param position Defines the position to set the camera at
  7434. */
  7435. setPosition(position: Vector3): void;
  7436. /**
  7437. * Defines the target the camera should look at.
  7438. * This will automatically adapt alpha beta and radius to fit within the new target.
  7439. * @param target Defines the new target as a Vector or a mesh
  7440. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7441. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7442. */
  7443. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7444. /** @hidden */
  7445. _getViewMatrix(): Matrix;
  7446. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7447. /**
  7448. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7449. * @param meshes Defines the mesh to zoom on
  7450. * @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)
  7451. */
  7452. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7453. /**
  7454. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7455. * The target will be changed but the radius
  7456. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7457. * @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)
  7458. */
  7459. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7460. min: Vector3;
  7461. max: Vector3;
  7462. distance: number;
  7463. }, doNotUpdateMaxZ?: boolean): void;
  7464. /**
  7465. * @override
  7466. * Override Camera.createRigCamera
  7467. */
  7468. createRigCamera(name: string, cameraIndex: number): Camera;
  7469. /**
  7470. * @hidden
  7471. * @override
  7472. * Override Camera._updateRigCameras
  7473. */
  7474. _updateRigCameras(): void;
  7475. /**
  7476. * Destroy the camera and release the current resources hold by it.
  7477. */
  7478. dispose(): void;
  7479. /**
  7480. * Gets the current object class name.
  7481. * @return the class name
  7482. */
  7483. getClassName(): string;
  7484. }
  7485. }
  7486. declare module BABYLON {
  7487. /**
  7488. * Default Inputs manager for the ArcRotateCamera.
  7489. * It groups all the default supported inputs for ease of use.
  7490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7491. */
  7492. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7493. /**
  7494. * Instantiates a new ArcRotateCameraInputsManager.
  7495. * @param camera Defines the camera the inputs belong to
  7496. */
  7497. constructor(camera: ArcRotateCamera);
  7498. /**
  7499. * Add mouse wheel input support to the input manager.
  7500. * @returns the current input manager
  7501. */
  7502. addMouseWheel(): ArcRotateCameraInputsManager;
  7503. /**
  7504. * Add pointers input support to the input manager.
  7505. * @returns the current input manager
  7506. */
  7507. addPointers(): ArcRotateCameraInputsManager;
  7508. /**
  7509. * Add keyboard input support to the input manager.
  7510. * @returns the current input manager
  7511. */
  7512. addKeyboard(): ArcRotateCameraInputsManager;
  7513. /**
  7514. * Add orientation input support to the input manager.
  7515. * @returns the current input manager
  7516. */
  7517. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7518. }
  7519. }
  7520. declare module BABYLON {
  7521. /**
  7522. * This is the base class of all the camera used in the application.
  7523. * @see http://doc.babylonjs.com/features/cameras
  7524. */
  7525. class Camera extends Node {
  7526. /**
  7527. * This is the default projection mode used by the cameras.
  7528. * It helps recreating a feeling of perspective and better appreciate depth.
  7529. * This is the best way to simulate real life cameras.
  7530. */
  7531. static readonly PERSPECTIVE_CAMERA: number;
  7532. /**
  7533. * This helps creating camera with an orthographic mode.
  7534. * 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.
  7535. */
  7536. static readonly ORTHOGRAPHIC_CAMERA: number;
  7537. /**
  7538. * This is the default FOV mode for perspective cameras.
  7539. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7540. */
  7541. static readonly FOVMODE_VERTICAL_FIXED: number;
  7542. /**
  7543. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7544. */
  7545. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7546. /**
  7547. * This specifies ther is no need for a camera rig.
  7548. * Basically only one eye is rendered corresponding to the camera.
  7549. */
  7550. static readonly RIG_MODE_NONE: number;
  7551. /**
  7552. * Simulates a camera Rig with one blue eye and one red eye.
  7553. * This can be use with 3d blue and red glasses.
  7554. */
  7555. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7556. /**
  7557. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7558. */
  7559. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7560. /**
  7561. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7562. */
  7563. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7564. /**
  7565. * Defines that both eyes of the camera will be rendered over under each other.
  7566. */
  7567. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7568. /**
  7569. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7570. */
  7571. static readonly RIG_MODE_VR: number;
  7572. /**
  7573. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7574. */
  7575. static readonly RIG_MODE_WEBVR: number;
  7576. /**
  7577. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7578. */
  7579. static readonly RIG_MODE_CUSTOM: number;
  7580. /**
  7581. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7582. */
  7583. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7584. /**
  7585. * @hidden
  7586. * Might be removed once multiview will be a thing
  7587. */
  7588. static UseAlternateWebVRRendering: boolean;
  7589. /**
  7590. * Define the input manager associated with the camera.
  7591. */
  7592. inputs: CameraInputsManager<Camera>;
  7593. /**
  7594. * Define the current local position of the camera in the scene
  7595. */
  7596. position: Vector3;
  7597. /**
  7598. * The vector the camera should consider as up.
  7599. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7600. */
  7601. upVector: Vector3;
  7602. /**
  7603. * Define the current limit on the left side for an orthographic camera
  7604. * In scene unit
  7605. */
  7606. orthoLeft: Nullable<number>;
  7607. /**
  7608. * Define the current limit on the right side for an orthographic camera
  7609. * In scene unit
  7610. */
  7611. orthoRight: Nullable<number>;
  7612. /**
  7613. * Define the current limit on the bottom side for an orthographic camera
  7614. * In scene unit
  7615. */
  7616. orthoBottom: Nullable<number>;
  7617. /**
  7618. * Define the current limit on the top side for an orthographic camera
  7619. * In scene unit
  7620. */
  7621. orthoTop: Nullable<number>;
  7622. /**
  7623. * Field Of View is set in Radians. (default is 0.8)
  7624. */
  7625. fov: number;
  7626. /**
  7627. * Define the minimum distance the camera can see from.
  7628. * This is important to note that the depth buffer are not infinite and the closer it starts
  7629. * the more your scene might encounter depth fighting issue.
  7630. */
  7631. minZ: number;
  7632. /**
  7633. * Define the maximum distance the camera can see to.
  7634. * This is important to note that the depth buffer are not infinite and the further it end
  7635. * the more your scene might encounter depth fighting issue.
  7636. */
  7637. maxZ: number;
  7638. /**
  7639. * Define the default inertia of the camera.
  7640. * This helps giving a smooth feeling to the camera movement.
  7641. */
  7642. inertia: number;
  7643. /**
  7644. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7645. */
  7646. mode: number;
  7647. /**
  7648. * Define wether the camera is intermediate.
  7649. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7650. */
  7651. isIntermediate: boolean;
  7652. /**
  7653. * Define the viewport of the camera.
  7654. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7655. */
  7656. viewport: Viewport;
  7657. /**
  7658. * Restricts the camera to viewing objects with the same layerMask.
  7659. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7660. */
  7661. layerMask: number;
  7662. /**
  7663. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7664. */
  7665. fovMode: number;
  7666. /**
  7667. * Rig mode of the camera.
  7668. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7669. * This is normally controlled byt the camera themselves as internal use.
  7670. */
  7671. cameraRigMode: number;
  7672. /**
  7673. * Defines the distance between both "eyes" in case of a RIG
  7674. */
  7675. interaxialDistance: number;
  7676. /**
  7677. * Defines if stereoscopic rendering is done side by side or over under.
  7678. */
  7679. isStereoscopicSideBySide: boolean;
  7680. /**
  7681. * 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
  7682. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7683. * else in the scene.
  7684. */
  7685. customRenderTargets: RenderTargetTexture[];
  7686. /**
  7687. * When set, the camera will render to this render target instead of the default canvas
  7688. */
  7689. outputRenderTarget: Nullable<RenderTargetTexture>;
  7690. /**
  7691. * Observable triggered when the camera view matrix has changed.
  7692. */
  7693. onViewMatrixChangedObservable: Observable<Camera>;
  7694. /**
  7695. * Observable triggered when the camera Projection matrix has changed.
  7696. */
  7697. onProjectionMatrixChangedObservable: Observable<Camera>;
  7698. /**
  7699. * Observable triggered when the inputs have been processed.
  7700. */
  7701. onAfterCheckInputsObservable: Observable<Camera>;
  7702. /**
  7703. * Observable triggered when reset has been called and applied to the camera.
  7704. */
  7705. onRestoreStateObservable: Observable<Camera>;
  7706. /** @hidden */
  7707. _cameraRigParams: any;
  7708. /** @hidden */
  7709. _rigCameras: Camera[];
  7710. /** @hidden */
  7711. _rigPostProcess: Nullable<PostProcess>;
  7712. protected _webvrViewMatrix: Matrix;
  7713. /** @hidden */
  7714. _skipRendering: boolean;
  7715. /** @hidden */
  7716. _alternateCamera: Camera;
  7717. /** @hidden */
  7718. _projectionMatrix: Matrix;
  7719. /** @hidden */
  7720. _postProcesses: Nullable<PostProcess>[];
  7721. /** @hidden */
  7722. _activeMeshes: SmartArray<AbstractMesh>;
  7723. protected _globalPosition: Vector3;
  7724. /** hidden */
  7725. _computedViewMatrix: Matrix;
  7726. private _doNotComputeProjectionMatrix;
  7727. private _transformMatrix;
  7728. private _frustumPlanes;
  7729. private _refreshFrustumPlanes;
  7730. private _storedFov;
  7731. private _stateStored;
  7732. /**
  7733. * Instantiates a new camera object.
  7734. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7735. * @see http://doc.babylonjs.com/features/cameras
  7736. * @param name Defines the name of the camera in the scene
  7737. * @param position Defines the position of the camera
  7738. * @param scene Defines the scene the camera belongs too
  7739. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7740. */
  7741. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7742. /**
  7743. * Store current camera state (fov, position, etc..)
  7744. * @returns the camera
  7745. */
  7746. storeState(): Camera;
  7747. /**
  7748. * Restores the camera state values if it has been stored. You must call storeState() first
  7749. */
  7750. protected _restoreStateValues(): boolean;
  7751. /**
  7752. * Restored camera state. You must call storeState() first.
  7753. * @returns true if restored and false otherwise
  7754. */
  7755. restoreState(): boolean;
  7756. /**
  7757. * Gets the class name of the camera.
  7758. * @returns the class name
  7759. */
  7760. getClassName(): string;
  7761. /**
  7762. * Gets a string representation of the camera useful for debug purpose.
  7763. * @param fullDetails Defines that a more verboe level of logging is required
  7764. * @returns the string representation
  7765. */
  7766. toString(fullDetails?: boolean): string;
  7767. /**
  7768. * Gets the current world space position of the camera.
  7769. */
  7770. readonly globalPosition: Vector3;
  7771. /**
  7772. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7773. * @returns the active meshe list
  7774. */
  7775. getActiveMeshes(): SmartArray<AbstractMesh>;
  7776. /**
  7777. * Check wether a mesh is part of the current active mesh list of the camera
  7778. * @param mesh Defines the mesh to check
  7779. * @returns true if active, false otherwise
  7780. */
  7781. isActiveMesh(mesh: Mesh): boolean;
  7782. /**
  7783. * Is this camera ready to be used/rendered
  7784. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7785. * @return true if the camera is ready
  7786. */
  7787. isReady(completeCheck?: boolean): boolean;
  7788. /** @hidden */
  7789. _initCache(): void;
  7790. /** @hidden */
  7791. _updateCache(ignoreParentClass?: boolean): void;
  7792. /** @hidden */
  7793. _isSynchronized(): boolean;
  7794. /** @hidden */
  7795. _isSynchronizedViewMatrix(): boolean;
  7796. /** @hidden */
  7797. _isSynchronizedProjectionMatrix(): boolean;
  7798. /**
  7799. * Attach the input controls to a specific dom element to get the input from.
  7800. * @param element Defines the element the controls should be listened from
  7801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7802. */
  7803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7804. /**
  7805. * Detach the current controls from the specified dom element.
  7806. * @param element Defines the element to stop listening the inputs from
  7807. */
  7808. detachControl(element: HTMLElement): void;
  7809. /**
  7810. * Update the camera state according to the different inputs gathered during the frame.
  7811. */
  7812. update(): void;
  7813. /** @hidden */
  7814. _checkInputs(): void;
  7815. /** @hidden */
  7816. readonly rigCameras: Camera[];
  7817. /**
  7818. * Gets the post process used by the rig cameras
  7819. */
  7820. readonly rigPostProcess: Nullable<PostProcess>;
  7821. /**
  7822. * Internal, gets the first post proces.
  7823. * @returns the first post process to be run on this camera.
  7824. */
  7825. _getFirstPostProcess(): Nullable<PostProcess>;
  7826. private _cascadePostProcessesToRigCams;
  7827. /**
  7828. * Attach a post process to the camera.
  7829. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7830. * @param postProcess The post process to attach to the camera
  7831. * @param insertAt The position of the post process in case several of them are in use in the scene
  7832. * @returns the position the post process has been inserted at
  7833. */
  7834. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7835. /**
  7836. * Detach a post process to the camera.
  7837. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7838. * @param postProcess The post process to detach from the camera
  7839. */
  7840. detachPostProcess(postProcess: PostProcess): void;
  7841. /**
  7842. * Gets the current world matrix of the camera
  7843. */
  7844. getWorldMatrix(): Matrix;
  7845. /** @hidden */
  7846. protected _getViewMatrix(): Matrix;
  7847. /**
  7848. * Gets the current view matrix of the camera.
  7849. * @param force forces the camera to recompute the matrix without looking at the cached state
  7850. * @returns the view matrix
  7851. */
  7852. getViewMatrix(force?: boolean): Matrix;
  7853. /**
  7854. * Freeze the projection matrix.
  7855. * It will prevent the cache check of the camera projection compute and can speed up perf
  7856. * if no parameter of the camera are meant to change
  7857. * @param projection Defines manually a projection if necessary
  7858. */
  7859. freezeProjectionMatrix(projection?: Matrix): void;
  7860. /**
  7861. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7862. */
  7863. unfreezeProjectionMatrix(): void;
  7864. /**
  7865. * Gets the current projection matrix of the camera.
  7866. * @param force forces the camera to recompute the matrix without looking at the cached state
  7867. * @returns the projection matrix
  7868. */
  7869. getProjectionMatrix(force?: boolean): Matrix;
  7870. /**
  7871. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7872. * @returns a Matrix
  7873. */
  7874. getTransformationMatrix(): Matrix;
  7875. private _updateFrustumPlanes;
  7876. /**
  7877. * Checks if a cullable object (mesh...) is in the camera frustum
  7878. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7879. * @param target The object to check
  7880. * @returns true if the object is in frustum otherwise false
  7881. */
  7882. isInFrustum(target: ICullable): boolean;
  7883. /**
  7884. * Checks if a cullable object (mesh...) is in the camera frustum
  7885. * Unlike isInFrustum this cheks the full bounding box
  7886. * @param target The object to check
  7887. * @returns true if the object is in frustum otherwise false
  7888. */
  7889. isCompletelyInFrustum(target: ICullable): boolean;
  7890. /**
  7891. * Gets a ray in the forward direction from the camera.
  7892. * @param length Defines the length of the ray to create
  7893. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7894. * @param origin Defines the start point of the ray which defaults to the camera position
  7895. * @returns the forward ray
  7896. */
  7897. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7898. /**
  7899. * Releases resources associated with this node.
  7900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7902. */
  7903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7904. /**
  7905. * Gets the left camera of a rig setup in case of Rigged Camera
  7906. */
  7907. readonly leftCamera: Nullable<FreeCamera>;
  7908. /**
  7909. * Gets the right camera of a rig setup in case of Rigged Camera
  7910. */
  7911. readonly rightCamera: Nullable<FreeCamera>;
  7912. /**
  7913. * Gets the left camera target of a rig setup in case of Rigged Camera
  7914. * @returns the target position
  7915. */
  7916. getLeftTarget(): Nullable<Vector3>;
  7917. /**
  7918. * Gets the right camera target of a rig setup in case of Rigged Camera
  7919. * @returns the target position
  7920. */
  7921. getRightTarget(): Nullable<Vector3>;
  7922. /**
  7923. * @hidden
  7924. */
  7925. setCameraRigMode(mode: number, rigParams: any): void;
  7926. private _getVRProjectionMatrix;
  7927. protected _updateCameraRotationMatrix(): void;
  7928. protected _updateWebVRCameraRotationMatrix(): void;
  7929. /**
  7930. * This function MUST be overwritten by the different WebVR cameras available.
  7931. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7932. */
  7933. protected _getWebVRProjectionMatrix(): Matrix;
  7934. /**
  7935. * This function MUST be overwritten by the different WebVR cameras available.
  7936. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7937. */
  7938. protected _getWebVRViewMatrix(): Matrix;
  7939. /** @hidden */
  7940. setCameraRigParameter(name: string, value: any): void;
  7941. /**
  7942. * needs to be overridden by children so sub has required properties to be copied
  7943. * @hidden
  7944. */
  7945. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7946. /**
  7947. * May need to be overridden by children
  7948. * @hidden
  7949. */
  7950. _updateRigCameras(): void;
  7951. /** @hidden */
  7952. _setupInputs(): void;
  7953. /**
  7954. * Serialiaze the camera setup to a json represention
  7955. * @returns the JSON representation
  7956. */
  7957. serialize(): any;
  7958. /**
  7959. * Clones the current camera.
  7960. * @param name The cloned camera name
  7961. * @returns the cloned camera
  7962. */
  7963. clone(name: string): Camera;
  7964. /**
  7965. * Gets the direction of the camera relative to a given local axis.
  7966. * @param localAxis Defines the reference axis to provide a relative direction.
  7967. * @return the direction
  7968. */
  7969. getDirection(localAxis: Vector3): Vector3;
  7970. /**
  7971. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7972. * @param localAxis Defines the reference axis to provide a relative direction.
  7973. * @param result Defines the vector to store the result in
  7974. */
  7975. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7976. /**
  7977. * Gets a camera constructor for a given camera type
  7978. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7979. * @param name The name of the camera the result will be able to instantiate
  7980. * @param scene The scene the result will construct the camera in
  7981. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7982. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7983. * @returns a factory method to construc the camera
  7984. */
  7985. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7986. /**
  7987. * Compute the world matrix of the camera.
  7988. * @returns the camera workd matrix
  7989. */
  7990. computeWorldMatrix(): Matrix;
  7991. /**
  7992. * Parse a JSON and creates the camera from the parsed information
  7993. * @param parsedCamera The JSON to parse
  7994. * @param scene The scene to instantiate the camera in
  7995. * @returns the newly constructed camera
  7996. */
  7997. static Parse(parsedCamera: any, scene: Scene): Camera;
  7998. }
  7999. }
  8000. declare module BABYLON {
  8001. /**
  8002. * @ignore
  8003. * This is a list of all the different input types that are available in the application.
  8004. * Fo instance: ArcRotateCameraGamepadInput...
  8005. */
  8006. var CameraInputTypes: {};
  8007. /**
  8008. * This is the contract to implement in order to create a new input class.
  8009. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8010. */
  8011. interface ICameraInput<TCamera extends Camera> {
  8012. /**
  8013. * Defines the camera the input is attached to.
  8014. */
  8015. camera: Nullable<TCamera>;
  8016. /**
  8017. * Gets the class name of the current intput.
  8018. * @returns the class name
  8019. */
  8020. getClassName(): string;
  8021. /**
  8022. * Get the friendly name associated with the input class.
  8023. * @returns the input friendly name
  8024. */
  8025. getSimpleName(): string;
  8026. /**
  8027. * Attach the input controls to a specific dom element to get the input from.
  8028. * @param element Defines the element the controls should be listened from
  8029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8030. */
  8031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8032. /**
  8033. * Detach the current controls from the specified dom element.
  8034. * @param element Defines the element to stop listening the inputs from
  8035. */
  8036. detachControl(element: Nullable<HTMLElement>): void;
  8037. /**
  8038. * Update the current camera state depending on the inputs that have been used this frame.
  8039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8040. */
  8041. checkInputs?: () => void;
  8042. }
  8043. /**
  8044. * Represents a map of input types to input instance or input index to input instance.
  8045. */
  8046. interface CameraInputsMap<TCamera extends Camera> {
  8047. /**
  8048. * Accessor to the input by input type.
  8049. */
  8050. [name: string]: ICameraInput<TCamera>;
  8051. /**
  8052. * Accessor to the input by input index.
  8053. */
  8054. [idx: number]: ICameraInput<TCamera>;
  8055. }
  8056. /**
  8057. * This represents the input manager used within a camera.
  8058. * It helps dealing with all the different kind of input attached to a camera.
  8059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8060. */
  8061. class CameraInputsManager<TCamera extends Camera> {
  8062. /**
  8063. * Defines the list of inputs attahed to the camera.
  8064. */
  8065. attached: CameraInputsMap<TCamera>;
  8066. /**
  8067. * Defines the dom element the camera is collecting inputs from.
  8068. * This is null if the controls have not been attached.
  8069. */
  8070. attachedElement: Nullable<HTMLElement>;
  8071. /**
  8072. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8073. */
  8074. noPreventDefault: boolean;
  8075. /**
  8076. * Defined the camera the input manager belongs to.
  8077. */
  8078. camera: TCamera;
  8079. /**
  8080. * Update the current camera state depending on the inputs that have been used this frame.
  8081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8082. */
  8083. checkInputs: () => void;
  8084. /**
  8085. * Instantiate a new Camera Input Manager.
  8086. * @param camera Defines the camera the input manager blongs to
  8087. */
  8088. constructor(camera: TCamera);
  8089. /**
  8090. * Add an input method to a camera
  8091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8092. * @param input camera input method
  8093. */
  8094. add(input: ICameraInput<TCamera>): void;
  8095. /**
  8096. * Remove a specific input method from a camera
  8097. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8098. * @param inputToRemove camera input method
  8099. */
  8100. remove(inputToRemove: ICameraInput<TCamera>): void;
  8101. /**
  8102. * Remove a specific input type from a camera
  8103. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8104. * @param inputType the type of the input to remove
  8105. */
  8106. removeByType(inputType: string): void;
  8107. private _addCheckInputs;
  8108. /**
  8109. * Attach the input controls to the currently attached dom element to listen the events from.
  8110. * @param input Defines the input to attach
  8111. */
  8112. attachInput(input: ICameraInput<TCamera>): void;
  8113. /**
  8114. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8115. * @param element Defines the dom element to collect the events from
  8116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8117. */
  8118. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8119. /**
  8120. * Detach the current manager inputs controls from a specific dom element.
  8121. * @param element Defines the dom element to collect the events from
  8122. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8123. */
  8124. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8125. /**
  8126. * Rebuild the dynamic inputCheck function from the current list of
  8127. * defined inputs in the manager.
  8128. */
  8129. rebuildInputCheck(): void;
  8130. /**
  8131. * Remove all attached input methods from a camera
  8132. */
  8133. clear(): void;
  8134. /**
  8135. * Serialize the current input manager attached to a camera.
  8136. * This ensures than once parsed,
  8137. * the input associated to the camera will be identical to the current ones
  8138. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8139. */
  8140. serialize(serializedCamera: any): void;
  8141. /**
  8142. * Parses an input manager serialized JSON to restore the previous list of inputs
  8143. * and states associated to a camera.
  8144. * @param parsedCamera Defines the JSON to parse
  8145. */
  8146. parse(parsedCamera: any): void;
  8147. }
  8148. }
  8149. declare module BABYLON {
  8150. /**
  8151. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8152. * being tilted forward or back and left or right.
  8153. */
  8154. class DeviceOrientationCamera extends FreeCamera {
  8155. private _initialQuaternion;
  8156. private _quaternionCache;
  8157. /**
  8158. * Creates a new device orientation camera
  8159. * @param name The name of the camera
  8160. * @param position The start position camera
  8161. * @param scene The scene the camera belongs to
  8162. */
  8163. constructor(name: string, position: Vector3, scene: Scene);
  8164. /**
  8165. * Gets the current instance class name ("DeviceOrientationCamera").
  8166. * This helps avoiding instanceof at run time.
  8167. * @returns the class name
  8168. */
  8169. getClassName(): string;
  8170. /**
  8171. * @hidden
  8172. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8173. */
  8174. _checkInputs(): void;
  8175. /**
  8176. * Reset the camera to its default orientation on the specified axis only.
  8177. * @param axis The axis to reset
  8178. */
  8179. resetToCurrentRotation(axis?: Axis): void;
  8180. }
  8181. }
  8182. declare module BABYLON {
  8183. /**
  8184. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8185. * such as in a 3D Space Shooter or a Flight Simulator.
  8186. */
  8187. class FlyCamera extends TargetCamera {
  8188. /**
  8189. * Define the collision ellipsoid of the camera.
  8190. * This is helpful for simulating a camera body, like a player's body.
  8191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8192. */
  8193. ellipsoid: Vector3;
  8194. /**
  8195. * Define an offset for the position of the ellipsoid around the camera.
  8196. * This can be helpful if the camera is attached away from the player's body center,
  8197. * such as at its head.
  8198. */
  8199. ellipsoidOffset: Vector3;
  8200. /**
  8201. * Enable or disable collisions of the camera with the rest of the scene objects.
  8202. */
  8203. checkCollisions: boolean;
  8204. /**
  8205. * Enable or disable gravity on the camera.
  8206. */
  8207. applyGravity: boolean;
  8208. /**
  8209. * Define the current direction the camera is moving to.
  8210. */
  8211. cameraDirection: Vector3;
  8212. /**
  8213. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8214. * This overrides and empties cameraRotation.
  8215. */
  8216. rotationQuaternion: BABYLON.Quaternion;
  8217. /**
  8218. * Track Roll to maintain the wanted Rolling when looking around.
  8219. */
  8220. _trackRoll: number;
  8221. /**
  8222. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8223. */
  8224. rollCorrect: number;
  8225. /**
  8226. * Mimic a banked turn, Rolling the camera when Yawing.
  8227. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8228. */
  8229. bankedTurn: boolean;
  8230. /**
  8231. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8232. */
  8233. bankedTurnLimit: number;
  8234. /**
  8235. * Value of 0 disables the banked Roll.
  8236. * Value of 1 is equal to the Yaw angle in radians.
  8237. */
  8238. bankedTurnMultiplier: number;
  8239. /**
  8240. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8241. */
  8242. inputs: FlyCameraInputsManager;
  8243. /**
  8244. * Gets the input sensibility for mouse input.
  8245. * Higher values reduce sensitivity.
  8246. */
  8247. /**
  8248. * Sets the input sensibility for a mouse input.
  8249. * Higher values reduce sensitivity.
  8250. */
  8251. angularSensibility: number;
  8252. /**
  8253. * Get the keys for camera movement forward.
  8254. */
  8255. /**
  8256. * Set the keys for camera movement forward.
  8257. */
  8258. keysForward: number[];
  8259. /**
  8260. * Get the keys for camera movement backward.
  8261. */
  8262. keysBackward: number[];
  8263. /**
  8264. * Get the keys for camera movement up.
  8265. */
  8266. /**
  8267. * Set the keys for camera movement up.
  8268. */
  8269. keysUp: number[];
  8270. /**
  8271. * Get the keys for camera movement down.
  8272. */
  8273. /**
  8274. * Set the keys for camera movement down.
  8275. */
  8276. keysDown: number[];
  8277. /**
  8278. * Get the keys for camera movement left.
  8279. */
  8280. /**
  8281. * Set the keys for camera movement left.
  8282. */
  8283. keysLeft: number[];
  8284. /**
  8285. * Set the keys for camera movement right.
  8286. */
  8287. /**
  8288. * Set the keys for camera movement right.
  8289. */
  8290. keysRight: number[];
  8291. /**
  8292. * Event raised when the camera collides with a mesh in the scene.
  8293. */
  8294. onCollide: (collidedMesh: AbstractMesh) => void;
  8295. private _collider;
  8296. private _needMoveForGravity;
  8297. private _oldPosition;
  8298. private _diffPosition;
  8299. private _newPosition;
  8300. /** @hidden */
  8301. _localDirection: Vector3;
  8302. /** @hidden */
  8303. _transformedDirection: Vector3;
  8304. /**
  8305. * Instantiates a FlyCamera.
  8306. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8307. * such as in a 3D Space Shooter or a Flight Simulator.
  8308. * @param name Define the name of the camera in the scene.
  8309. * @param position Define the starting position of the camera in the scene.
  8310. * @param scene Define the scene the camera belongs to.
  8311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8312. */
  8313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8314. /**
  8315. * Attach a control to the HTML DOM element.
  8316. * @param element Defines the element that listens to the input events.
  8317. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8318. */
  8319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8320. /**
  8321. * Detach a control from the HTML DOM element.
  8322. * The camera will stop reacting to that input.
  8323. * @param element Defines the element that listens to the input events.
  8324. */
  8325. detachControl(element: HTMLElement): void;
  8326. private _collisionMask;
  8327. /**
  8328. * Get the mask that the camera ignores in collision events.
  8329. */
  8330. /**
  8331. * Set the mask that the camera ignores in collision events.
  8332. */
  8333. collisionMask: number;
  8334. /** @hidden */
  8335. _collideWithWorld(displacement: Vector3): void;
  8336. /** @hidden */
  8337. private _onCollisionPositionChange;
  8338. /** @hidden */
  8339. _checkInputs(): void;
  8340. /** @hidden */
  8341. _decideIfNeedsToMove(): boolean;
  8342. /** @hidden */
  8343. _updatePosition(): void;
  8344. /**
  8345. * Restore the Roll to its target value at the rate specified.
  8346. * @param rate - Higher means slower restoring.
  8347. * @hidden
  8348. */
  8349. restoreRoll(rate: number): void;
  8350. /**
  8351. * Destroy the camera and release the current resources held by it.
  8352. */
  8353. dispose(): void;
  8354. /**
  8355. * Get the current object class name.
  8356. * @returns the class name.
  8357. */
  8358. getClassName(): string;
  8359. }
  8360. }
  8361. declare module BABYLON {
  8362. /**
  8363. * Default Inputs manager for the FlyCamera.
  8364. * It groups all the default supported inputs for ease of use.
  8365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8366. */
  8367. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8368. /**
  8369. * Instantiates a new FlyCameraInputsManager.
  8370. * @param camera Defines the camera the inputs belong to.
  8371. */
  8372. constructor(camera: FlyCamera);
  8373. /**
  8374. * Add keyboard input support to the input manager.
  8375. * @returns the new FlyCameraKeyboardMoveInput().
  8376. */
  8377. addKeyboard(): FlyCameraInputsManager;
  8378. /**
  8379. * Add mouse input support to the input manager.
  8380. * @param touchEnabled Enable touch screen support.
  8381. * @returns the new FlyCameraMouseInput().
  8382. */
  8383. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8384. }
  8385. }
  8386. declare module BABYLON {
  8387. /**
  8388. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8389. * an arc rotate version arcFollowCamera are available.
  8390. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8391. */
  8392. class FollowCamera extends TargetCamera {
  8393. /**
  8394. * Distance the follow camera should follow an object at
  8395. */
  8396. radius: number;
  8397. /**
  8398. * Define a rotation offset between the camera and the object it follows
  8399. */
  8400. rotationOffset: number;
  8401. /**
  8402. * Define a height offset between the camera and the object it follows.
  8403. * It can help following an object from the top (like a car chaing a plane)
  8404. */
  8405. heightOffset: number;
  8406. /**
  8407. * Define how fast the camera can accelerate to follow it s target.
  8408. */
  8409. cameraAcceleration: number;
  8410. /**
  8411. * Define the speed limit of the camera following an object.
  8412. */
  8413. maxCameraSpeed: number;
  8414. /**
  8415. * Define the target of the camera.
  8416. */
  8417. lockedTarget: Nullable<AbstractMesh>;
  8418. /**
  8419. * Instantiates the follow camera.
  8420. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8421. * @param name Define the name of the camera in the scene
  8422. * @param position Define the position of the camera
  8423. * @param scene Define the scene the camera belong to
  8424. * @param lockedTarget Define the target of the camera
  8425. */
  8426. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8427. private _follow;
  8428. /** @hidden */
  8429. _checkInputs(): void;
  8430. /**
  8431. * Gets the camera class name.
  8432. * @returns the class name
  8433. */
  8434. getClassName(): string;
  8435. }
  8436. /**
  8437. * Arc Rotate version of the follow camera.
  8438. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8439. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8440. */
  8441. class ArcFollowCamera extends TargetCamera {
  8442. /** The longitudinal angle of the camera */
  8443. alpha: number;
  8444. /** The latitudinal angle of the camera */
  8445. beta: number;
  8446. /** The radius of the camera from its target */
  8447. radius: number;
  8448. /** Define the camera target (the messh it should follow) */
  8449. target: Nullable<AbstractMesh>;
  8450. private _cartesianCoordinates;
  8451. /**
  8452. * Instantiates a new ArcFollowCamera
  8453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8454. * @param name Define the name of the camera
  8455. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8456. * @param beta Define the rotation angle of the camera around the elevation axis
  8457. * @param radius Define the radius of the camera from its target point
  8458. * @param target Define the target of the camera
  8459. * @param scene Define the scene the camera belongs to
  8460. */
  8461. constructor(name: string,
  8462. /** The longitudinal angle of the camera */
  8463. alpha: number,
  8464. /** The latitudinal angle of the camera */
  8465. beta: number,
  8466. /** The radius of the camera from its target */
  8467. radius: number,
  8468. /** Define the camera target (the messh it should follow) */
  8469. target: Nullable<AbstractMesh>, scene: Scene);
  8470. private _follow;
  8471. /** @hidden */
  8472. _checkInputs(): void;
  8473. /**
  8474. * Returns the class name of the object.
  8475. * It is mostly used internally for serialization purposes.
  8476. */
  8477. getClassName(): string;
  8478. }
  8479. }
  8480. declare module BABYLON {
  8481. /**
  8482. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8483. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8485. */
  8486. class FreeCamera extends TargetCamera {
  8487. /**
  8488. * Define the collision ellipsoid of the camera.
  8489. * This is helpful to simulate a camera body like the player body around the camera
  8490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8491. */
  8492. ellipsoid: Vector3;
  8493. /**
  8494. * Define an offset for the position of the ellipsoid around the camera.
  8495. * This can be helpful to determine the center of the body near the gravity center of the body
  8496. * instead of its head.
  8497. */
  8498. ellipsoidOffset: Vector3;
  8499. /**
  8500. * Enable or disable collisions of the camera with the rest of the scene objects.
  8501. */
  8502. checkCollisions: boolean;
  8503. /**
  8504. * Enable or disable gravity on the camera.
  8505. */
  8506. applyGravity: boolean;
  8507. /**
  8508. * Define the input manager associated to the camera.
  8509. */
  8510. inputs: FreeCameraInputsManager;
  8511. /**
  8512. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8513. * Higher values reduce sensitivity.
  8514. */
  8515. /**
  8516. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8517. * Higher values reduce sensitivity.
  8518. */
  8519. angularSensibility: number;
  8520. /**
  8521. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8522. */
  8523. keysUp: number[];
  8524. /**
  8525. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8526. */
  8527. keysDown: number[];
  8528. /**
  8529. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8530. */
  8531. keysLeft: number[];
  8532. /**
  8533. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8534. */
  8535. keysRight: number[];
  8536. /**
  8537. * Event raised when the camera collide with a mesh in the scene.
  8538. */
  8539. onCollide: (collidedMesh: AbstractMesh) => void;
  8540. private _collider;
  8541. private _needMoveForGravity;
  8542. private _oldPosition;
  8543. private _diffPosition;
  8544. private _newPosition;
  8545. /** @hidden */
  8546. _localDirection: Vector3;
  8547. /** @hidden */
  8548. _transformedDirection: Vector3;
  8549. /**
  8550. * Instantiates a Free Camera.
  8551. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8552. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8553. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8554. * @param name Define the name of the camera in the scene
  8555. * @param position Define the start position of the camera in the scene
  8556. * @param scene Define the scene the camera belongs to
  8557. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8558. */
  8559. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8560. /**
  8561. * Attached controls to the current camera.
  8562. * @param element Defines the element the controls should be listened from
  8563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8564. */
  8565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8566. /**
  8567. * Detach the current controls from the camera.
  8568. * The camera will stop reacting to inputs.
  8569. * @param element Defines the element to stop listening the inputs from
  8570. */
  8571. detachControl(element: HTMLElement): void;
  8572. private _collisionMask;
  8573. /**
  8574. * Define a collision mask to limit the list of object the camera can collide with
  8575. */
  8576. collisionMask: number;
  8577. /** @hidden */
  8578. _collideWithWorld(displacement: Vector3): void;
  8579. private _onCollisionPositionChange;
  8580. /** @hidden */
  8581. _checkInputs(): void;
  8582. /** @hidden */
  8583. _decideIfNeedsToMove(): boolean;
  8584. /** @hidden */
  8585. _updatePosition(): void;
  8586. /**
  8587. * Destroy the camera and release the current resources hold by it.
  8588. */
  8589. dispose(): void;
  8590. /**
  8591. * Gets the current object class name.
  8592. * @return the class name
  8593. */
  8594. getClassName(): string;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. /**
  8599. * Default Inputs manager for the FreeCamera.
  8600. * It groups all the default supported inputs for ease of use.
  8601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8602. */
  8603. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8604. /**
  8605. * Instantiates a new FreeCameraInputsManager.
  8606. * @param camera Defines the camera the inputs belong to
  8607. */
  8608. constructor(camera: FreeCamera);
  8609. /**
  8610. * Add keyboard input support to the input manager.
  8611. * @returns the current input manager
  8612. */
  8613. addKeyboard(): FreeCameraInputsManager;
  8614. /**
  8615. * Add mouse input support to the input manager.
  8616. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8617. * @returns the current input manager
  8618. */
  8619. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8620. /**
  8621. * Add orientation input support to the input manager.
  8622. * @returns the current input manager
  8623. */
  8624. addDeviceOrientation(): FreeCameraInputsManager;
  8625. /**
  8626. * Add touch input support to the input manager.
  8627. * @returns the current input manager
  8628. */
  8629. addTouch(): FreeCameraInputsManager;
  8630. /**
  8631. * Add virtual joystick input support to the input manager.
  8632. * @returns the current input manager
  8633. */
  8634. addVirtualJoystick(): FreeCameraInputsManager;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * This represents a FPS type of camera. This is only here for back compat purpose.
  8640. * Please use the UniversalCamera instead as both are identical.
  8641. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8642. */
  8643. class GamepadCamera extends UniversalCamera {
  8644. /**
  8645. * Instantiates a new Gamepad Camera
  8646. * This represents a FPS type of camera. This is only here for back compat purpose.
  8647. * Please use the UniversalCamera instead as both are identical.
  8648. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8649. * @param name Define the name of the camera in the scene
  8650. * @param position Define the start position of the camera in the scene
  8651. * @param scene Define the scene the camera belongs to
  8652. */
  8653. constructor(name: string, position: Vector3, scene: Scene);
  8654. /**
  8655. * Gets the current object class name.
  8656. * @return the class name
  8657. */
  8658. getClassName(): string;
  8659. }
  8660. }
  8661. declare module BABYLON {
  8662. /**
  8663. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8664. * This is the base of the follow, arc rotate cameras and Free camera
  8665. * @see http://doc.babylonjs.com/features/cameras
  8666. */
  8667. class TargetCamera extends Camera {
  8668. private static _RigCamTransformMatrix;
  8669. private static _TargetTransformMatrix;
  8670. private static _TargetFocalPoint;
  8671. /**
  8672. * Define the current direction the camera is moving to
  8673. */
  8674. cameraDirection: Vector3;
  8675. /**
  8676. * Define the current rotation the camera is rotating to
  8677. */
  8678. cameraRotation: Vector2;
  8679. /**
  8680. * When set, the up vector of the camera will be updated by the rotation of the camera
  8681. */
  8682. updateUpVectorFromRotation: boolean;
  8683. private _tmpQuaternion;
  8684. /**
  8685. * Define the current rotation of the camera
  8686. */
  8687. rotation: Vector3;
  8688. /**
  8689. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8690. */
  8691. rotationQuaternion: Quaternion;
  8692. /**
  8693. * Define the current speed of the camera
  8694. */
  8695. speed: number;
  8696. /**
  8697. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8698. * around all axis.
  8699. */
  8700. noRotationConstraint: boolean;
  8701. /**
  8702. * Define the current target of the camera as an object or a position.
  8703. */
  8704. lockedTarget: any;
  8705. /** @hidden */
  8706. _currentTarget: Vector3;
  8707. /** @hidden */
  8708. _initialFocalDistance: number;
  8709. /** @hidden */
  8710. _viewMatrix: Matrix;
  8711. /** @hidden */
  8712. _camMatrix: Matrix;
  8713. /** @hidden */
  8714. _cameraTransformMatrix: Matrix;
  8715. /** @hidden */
  8716. _cameraRotationMatrix: Matrix;
  8717. /** @hidden */
  8718. _referencePoint: Vector3;
  8719. /** @hidden */
  8720. _transformedReferencePoint: Vector3;
  8721. protected _globalCurrentTarget: Vector3;
  8722. protected _globalCurrentUpVector: Vector3;
  8723. /** @hidden */
  8724. _reset: () => void;
  8725. private _defaultUp;
  8726. /**
  8727. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8728. * This is the base of the follow, arc rotate cameras and Free camera
  8729. * @see http://doc.babylonjs.com/features/cameras
  8730. * @param name Defines the name of the camera in the scene
  8731. * @param position Defines the start position of the camera in the scene
  8732. * @param scene Defines the scene the camera belongs to
  8733. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8734. */
  8735. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8736. /**
  8737. * Gets the position in front of the camera at a given distance.
  8738. * @param distance The distance from the camera we want the position to be
  8739. * @returns the position
  8740. */
  8741. getFrontPosition(distance: number): Vector3;
  8742. /** @hidden */
  8743. _getLockedTargetPosition(): Nullable<Vector3>;
  8744. private _storedPosition;
  8745. private _storedRotation;
  8746. private _storedRotationQuaternion;
  8747. /**
  8748. * Store current camera state of the camera (fov, position, rotation, etc..)
  8749. * @returns the camera
  8750. */
  8751. storeState(): Camera;
  8752. /**
  8753. * Restored camera state. You must call storeState() first
  8754. * @returns whether it was successful or not
  8755. * @hidden
  8756. */
  8757. _restoreStateValues(): boolean;
  8758. /** @hidden */
  8759. _initCache(): void;
  8760. /** @hidden */
  8761. _updateCache(ignoreParentClass?: boolean): void;
  8762. /** @hidden */
  8763. _isSynchronizedViewMatrix(): boolean;
  8764. /** @hidden */
  8765. _computeLocalCameraSpeed(): number;
  8766. /** @hidden */
  8767. setTarget(target: Vector3): void;
  8768. /**
  8769. * Return the current target position of the camera. This value is expressed in local space.
  8770. * @returns the target position
  8771. */
  8772. getTarget(): Vector3;
  8773. /** @hidden */
  8774. _decideIfNeedsToMove(): boolean;
  8775. /** @hidden */
  8776. _updatePosition(): void;
  8777. /** @hidden */
  8778. _checkInputs(): void;
  8779. protected _updateCameraRotationMatrix(): void;
  8780. /**
  8781. * 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)
  8782. * @returns the current camera
  8783. */
  8784. private _rotateUpVectorWithCameraRotationMatrix;
  8785. private _cachedRotationZ;
  8786. private _cachedQuaternionRotationZ;
  8787. /** @hidden */
  8788. _getViewMatrix(): Matrix;
  8789. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8790. /**
  8791. * @hidden
  8792. */
  8793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8794. /**
  8795. * @hidden
  8796. */
  8797. _updateRigCameras(): void;
  8798. private _getRigCamPositionAndTarget;
  8799. /**
  8800. * Gets the current object class name.
  8801. * @return the class name
  8802. */
  8803. getClassName(): string;
  8804. }
  8805. }
  8806. declare module BABYLON {
  8807. /**
  8808. * This represents a FPS type of camera controlled by touch.
  8809. * This is like a universal camera minus the Gamepad controls.
  8810. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8811. */
  8812. class TouchCamera extends FreeCamera {
  8813. /**
  8814. * Defines the touch sensibility for rotation.
  8815. * The higher the faster.
  8816. */
  8817. touchAngularSensibility: number;
  8818. /**
  8819. * Defines the touch sensibility for move.
  8820. * The higher the faster.
  8821. */
  8822. touchMoveSensibility: number;
  8823. /**
  8824. * Instantiates a new touch camera.
  8825. * This represents a FPS type of camera controlled by touch.
  8826. * This is like a universal camera minus the Gamepad controls.
  8827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8828. * @param name Define the name of the camera in the scene
  8829. * @param position Define the start position of the camera in the scene
  8830. * @param scene Define the scene the camera belongs to
  8831. */
  8832. constructor(name: string, position: Vector3, scene: Scene);
  8833. /**
  8834. * Gets the current object class name.
  8835. * @return the class name
  8836. */
  8837. getClassName(): string;
  8838. /** @hidden */
  8839. _setupInputs(): void;
  8840. }
  8841. }
  8842. declare module BABYLON {
  8843. /**
  8844. * 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,
  8845. * which still works and will still be found in many Playgrounds.
  8846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8847. */
  8848. class UniversalCamera extends TouchCamera {
  8849. /**
  8850. * Defines the gamepad rotation sensiblity.
  8851. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8852. */
  8853. gamepadAngularSensibility: number;
  8854. /**
  8855. * Defines the gamepad move sensiblity.
  8856. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8857. */
  8858. gamepadMoveSensibility: number;
  8859. /**
  8860. * 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,
  8861. * which still works and will still be found in many Playgrounds.
  8862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8863. * @param name Define the name of the camera in the scene
  8864. * @param position Define the start position of the camera in the scene
  8865. * @param scene Define the scene the camera belongs to
  8866. */
  8867. constructor(name: string, position: Vector3, scene: Scene);
  8868. /**
  8869. * Gets the current object class name.
  8870. * @return the class name
  8871. */
  8872. getClassName(): string;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8878. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8879. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8880. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8881. */
  8882. class VirtualJoysticksCamera extends FreeCamera {
  8883. /**
  8884. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8885. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8886. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8887. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8888. * @param name Define the name of the camera in the scene
  8889. * @param position Define the start position of the camera in the scene
  8890. * @param scene Define the scene the camera belongs to
  8891. */
  8892. constructor(name: string, position: Vector3, scene: Scene);
  8893. /**
  8894. * Gets the current object class name.
  8895. * @return the class name
  8896. */
  8897. getClassName(): string;
  8898. }
  8899. }
  8900. interface VRDisplay extends EventTarget {
  8901. /**
  8902. * Dictionary of capabilities describing the VRDisplay.
  8903. */
  8904. readonly capabilities: VRDisplayCapabilities;
  8905. /**
  8906. * z-depth defining the far plane of the eye view frustum
  8907. * enables mapping of values in the render target depth
  8908. * attachment to scene coordinates. Initially set to 10000.0.
  8909. */
  8910. depthFar: number;
  8911. /**
  8912. * z-depth defining the near plane of the eye view frustum
  8913. * enables mapping of values in the render target depth
  8914. * attachment to scene coordinates. Initially set to 0.01.
  8915. */
  8916. depthNear: number;
  8917. /**
  8918. * An identifier for this distinct VRDisplay. Used as an
  8919. * association point in the Gamepad API.
  8920. */
  8921. readonly displayId: number;
  8922. /**
  8923. * A display name, a user-readable name identifying it.
  8924. */
  8925. readonly displayName: string;
  8926. readonly isConnected: boolean;
  8927. readonly isPresenting: boolean;
  8928. /**
  8929. * If this VRDisplay supports room-scale experiences, the optional
  8930. * stage attribute contains details on the room-scale parameters.
  8931. */
  8932. readonly stageParameters: VRStageParameters | null;
  8933. /**
  8934. * Passing the value returned by `requestAnimationFrame` to
  8935. * `cancelAnimationFrame` will unregister the callback.
  8936. * @param handle Define the hanle of the request to cancel
  8937. */
  8938. cancelAnimationFrame(handle: number): void;
  8939. /**
  8940. * Stops presenting to the VRDisplay.
  8941. * @returns a promise to know when it stopped
  8942. */
  8943. exitPresent(): Promise<void>;
  8944. /**
  8945. * Return the current VREyeParameters for the given eye.
  8946. * @param whichEye Define the eye we want the parameter for
  8947. * @returns the eye parameters
  8948. */
  8949. getEyeParameters(whichEye: string): VREyeParameters;
  8950. /**
  8951. * Populates the passed VRFrameData with the information required to render
  8952. * the current frame.
  8953. * @param frameData Define the data structure to populate
  8954. * @returns true if ok otherwise false
  8955. */
  8956. getFrameData(frameData: VRFrameData): boolean;
  8957. /**
  8958. * Get the layers currently being presented.
  8959. * @returns the list of VR layers
  8960. */
  8961. getLayers(): VRLayer[];
  8962. /**
  8963. * Return a VRPose containing the future predicted pose of the VRDisplay
  8964. * when the current frame will be presented. The value returned will not
  8965. * change until JavaScript has returned control to the browser.
  8966. *
  8967. * The VRPose will contain the position, orientation, velocity,
  8968. * and acceleration of each of these properties.
  8969. * @returns the pose object
  8970. */
  8971. getPose(): VRPose;
  8972. /**
  8973. * Return the current instantaneous pose of the VRDisplay, with no
  8974. * prediction applied.
  8975. * @returns the current instantaneous pose
  8976. */
  8977. getImmediatePose(): VRPose;
  8978. /**
  8979. * The callback passed to `requestAnimationFrame` will be called
  8980. * any time a new frame should be rendered. When the VRDisplay is
  8981. * presenting the callback will be called at the native refresh
  8982. * rate of the HMD. When not presenting this function acts
  8983. * identically to how window.requestAnimationFrame acts. Content should
  8984. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8985. * asynchronously from other displays and at differing refresh rates.
  8986. * @param callback Define the eaction to run next frame
  8987. * @returns the request handle it
  8988. */
  8989. requestAnimationFrame(callback: FrameRequestCallback): number;
  8990. /**
  8991. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8992. * Repeat calls while already presenting will update the VRLayers being displayed.
  8993. * @param layers Define the list of layer to present
  8994. * @returns a promise to know when the request has been fulfilled
  8995. */
  8996. requestPresent(layers: VRLayer[]): Promise<void>;
  8997. /**
  8998. * Reset the pose for this display, treating its current position and
  8999. * orientation as the "origin/zero" values. VRPose.position,
  9000. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9001. * updated when calling resetPose(). This should be called in only
  9002. * sitting-space experiences.
  9003. */
  9004. resetPose(): void;
  9005. /**
  9006. * The VRLayer provided to the VRDisplay will be captured and presented
  9007. * in the HMD. Calling this function has the same effect on the source
  9008. * canvas as any other operation that uses its source image, and canvases
  9009. * created without preserveDrawingBuffer set to true will be cleared.
  9010. * @param pose Define the pose to submit
  9011. */
  9012. submitFrame(pose?: VRPose): void;
  9013. }
  9014. declare var VRDisplay: {
  9015. prototype: VRDisplay;
  9016. new (): VRDisplay;
  9017. };
  9018. interface VRLayer {
  9019. leftBounds?: number[] | Float32Array | null;
  9020. rightBounds?: number[] | Float32Array | null;
  9021. source?: HTMLCanvasElement | null;
  9022. }
  9023. interface VRDisplayCapabilities {
  9024. readonly canPresent: boolean;
  9025. readonly hasExternalDisplay: boolean;
  9026. readonly hasOrientation: boolean;
  9027. readonly hasPosition: boolean;
  9028. readonly maxLayers: number;
  9029. }
  9030. interface VREyeParameters {
  9031. /** @deprecated */
  9032. readonly fieldOfView: VRFieldOfView;
  9033. readonly offset: Float32Array;
  9034. readonly renderHeight: number;
  9035. readonly renderWidth: number;
  9036. }
  9037. interface VRFieldOfView {
  9038. readonly downDegrees: number;
  9039. readonly leftDegrees: number;
  9040. readonly rightDegrees: number;
  9041. readonly upDegrees: number;
  9042. }
  9043. interface VRFrameData {
  9044. readonly leftProjectionMatrix: Float32Array;
  9045. readonly leftViewMatrix: Float32Array;
  9046. readonly pose: VRPose;
  9047. readonly rightProjectionMatrix: Float32Array;
  9048. readonly rightViewMatrix: Float32Array;
  9049. readonly timestamp: number;
  9050. }
  9051. interface VRPose {
  9052. readonly angularAcceleration: Float32Array | null;
  9053. readonly angularVelocity: Float32Array | null;
  9054. readonly linearAcceleration: Float32Array | null;
  9055. readonly linearVelocity: Float32Array | null;
  9056. readonly orientation: Float32Array | null;
  9057. readonly position: Float32Array | null;
  9058. readonly timestamp: number;
  9059. }
  9060. interface VRStageParameters {
  9061. sittingToStandingTransform?: Float32Array;
  9062. sizeX?: number;
  9063. sizeY?: number;
  9064. }
  9065. interface Navigator {
  9066. getVRDisplays(): Promise<VRDisplay[]>;
  9067. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9068. }
  9069. interface Window {
  9070. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9071. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9072. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9073. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9074. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9075. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9076. }
  9077. interface Gamepad {
  9078. readonly displayId: number;
  9079. }
  9080. declare module BABYLON {
  9081. /**
  9082. * Class used to store bounding box information
  9083. */
  9084. class BoundingBox implements ICullable {
  9085. /**
  9086. * Gets the 8 vectors representing the bounding box in local space
  9087. */
  9088. readonly vectors: Vector3[];
  9089. /**
  9090. * Gets the center of the bounding box in local space
  9091. */
  9092. readonly center: Vector3;
  9093. /**
  9094. * Gets the center of the bounding box in world space
  9095. */
  9096. readonly centerWorld: Vector3;
  9097. /**
  9098. * Gets the extend size in local space
  9099. */
  9100. readonly extendSize: Vector3;
  9101. /**
  9102. * Gets the extend size in world space
  9103. */
  9104. readonly extendSizeWorld: Vector3;
  9105. /**
  9106. * Gets the OBB (object bounding box) directions
  9107. */
  9108. readonly directions: Vector3[];
  9109. /**
  9110. * Gets the 8 vectors representing the bounding box in world space
  9111. */
  9112. readonly vectorsWorld: Vector3[];
  9113. /**
  9114. * Gets the minimum vector in world space
  9115. */
  9116. readonly minimumWorld: Vector3;
  9117. /**
  9118. * Gets the maximum vector in world space
  9119. */
  9120. readonly maximumWorld: Vector3;
  9121. /**
  9122. * Gets the minimum vector in local space
  9123. */
  9124. readonly minimum: Vector3;
  9125. /**
  9126. * Gets the maximum vector in local space
  9127. */
  9128. readonly maximum: Vector3;
  9129. private _worldMatrix;
  9130. private static readonly TmpVector3;
  9131. /**
  9132. * @hidden
  9133. */
  9134. _tag: number;
  9135. /**
  9136. * Creates a new bounding box
  9137. * @param min defines the minimum vector (in local space)
  9138. * @param max defines the maximum vector (in local space)
  9139. * @param worldMatrix defines the new world matrix
  9140. */
  9141. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9142. /**
  9143. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9144. * @param min defines the new minimum vector (in local space)
  9145. * @param max defines the new maximum vector (in local space)
  9146. * @param worldMatrix defines the new world matrix
  9147. */
  9148. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9149. /**
  9150. * Scale the current bounding box by applying a scale factor
  9151. * @param factor defines the scale factor to apply
  9152. * @returns the current bounding box
  9153. */
  9154. scale(factor: number): BoundingBox;
  9155. /**
  9156. * Gets the world matrix of the bounding box
  9157. * @returns a matrix
  9158. */
  9159. getWorldMatrix(): DeepImmutable<Matrix>;
  9160. /** @hidden */
  9161. _update(world: DeepImmutable<Matrix>): void;
  9162. /**
  9163. * Tests if the bounding box is intersecting the frustum planes
  9164. * @param frustumPlanes defines the frustum planes to test
  9165. * @returns true if there is an intersection
  9166. */
  9167. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9168. /**
  9169. * Tests if the bounding box is entirely inside the frustum planes
  9170. * @param frustumPlanes defines the frustum planes to test
  9171. * @returns true if there is an inclusion
  9172. */
  9173. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9174. /**
  9175. * Tests if a point is inside the bounding box
  9176. * @param point defines the point to test
  9177. * @returns true if the point is inside the bounding box
  9178. */
  9179. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9180. /**
  9181. * Tests if the bounding box intersects with a bounding sphere
  9182. * @param sphere defines the sphere to test
  9183. * @returns true if there is an intersection
  9184. */
  9185. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9186. /**
  9187. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9188. * @param min defines the min vector to use
  9189. * @param max defines the max vector to use
  9190. * @returns true if there is an intersection
  9191. */
  9192. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9193. /**
  9194. * Tests if two bounding boxes are intersections
  9195. * @param box0 defines the first box to test
  9196. * @param box1 defines the second box to test
  9197. * @returns true if there is an intersection
  9198. */
  9199. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9200. /**
  9201. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9202. * @param minPoint defines the minimum vector of the bounding box
  9203. * @param maxPoint defines the maximum vector of the bounding box
  9204. * @param sphereCenter defines the sphere center
  9205. * @param sphereRadius defines the sphere radius
  9206. * @returns true if there is an intersection
  9207. */
  9208. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9209. /**
  9210. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9211. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9212. * @param frustumPlanes defines the frustum planes to test
  9213. * @return true if there is an inclusion
  9214. */
  9215. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9216. /**
  9217. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9218. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9219. * @param frustumPlanes defines the frustum planes to test
  9220. * @return true if there is an intersection
  9221. */
  9222. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9223. }
  9224. }
  9225. declare module BABYLON {
  9226. /**
  9227. * Interface for cullable objects
  9228. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9229. */
  9230. interface ICullable {
  9231. /**
  9232. * Checks if the object or part of the object is in the frustum
  9233. * @param frustumPlanes Camera near/planes
  9234. * @returns true if the object is in frustum otherwise false
  9235. */
  9236. isInFrustum(frustumPlanes: Plane[]): boolean;
  9237. /**
  9238. * Checks if a cullable object (mesh...) is in the camera frustum
  9239. * Unlike isInFrustum this cheks the full bounding box
  9240. * @param frustumPlanes Camera near/planes
  9241. * @returns true if the object is in frustum otherwise false
  9242. */
  9243. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9244. }
  9245. /**
  9246. * Info for a bounding data of a mesh
  9247. */
  9248. class BoundingInfo implements ICullable {
  9249. /**
  9250. * Bounding box for the mesh
  9251. */
  9252. readonly boundingBox: BoundingBox;
  9253. /**
  9254. * Bounding sphere for the mesh
  9255. */
  9256. readonly boundingSphere: BoundingSphere;
  9257. private _isLocked;
  9258. private static readonly TmpVector3;
  9259. /**
  9260. * Constructs bounding info
  9261. * @param minimum min vector of the bounding box/sphere
  9262. * @param maximum max vector of the bounding box/sphere
  9263. * @param worldMatrix defines the new world matrix
  9264. */
  9265. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9266. /**
  9267. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9268. * @param min defines the new minimum vector (in local space)
  9269. * @param max defines the new maximum vector (in local space)
  9270. * @param worldMatrix defines the new world matrix
  9271. */
  9272. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9273. /**
  9274. * min vector of the bounding box/sphere
  9275. */
  9276. readonly minimum: Vector3;
  9277. /**
  9278. * max vector of the bounding box/sphere
  9279. */
  9280. readonly maximum: Vector3;
  9281. /**
  9282. * If the info is locked and won't be updated to avoid perf overhead
  9283. */
  9284. isLocked: boolean;
  9285. /**
  9286. * Updates the bounding sphere and box
  9287. * @param world world matrix to be used to update
  9288. */
  9289. update(world: DeepImmutable<Matrix>): void;
  9290. /**
  9291. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9292. * @param center New center of the bounding info
  9293. * @param extend New extend of the bounding info
  9294. * @returns the current bounding info
  9295. */
  9296. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9297. /**
  9298. * Scale the current bounding info by applying a scale factor
  9299. * @param factor defines the scale factor to apply
  9300. * @returns the current bounding info
  9301. */
  9302. scale(factor: number): BoundingInfo;
  9303. /**
  9304. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9305. * @param frustumPlanes defines the frustum to test
  9306. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9307. * @returns true if the bounding info is in the frustum planes
  9308. */
  9309. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9310. /**
  9311. * Gets the world distance between the min and max points of the bounding box
  9312. */
  9313. readonly diagonalLength: number;
  9314. /**
  9315. * Checks if a cullable object (mesh...) is in the camera frustum
  9316. * Unlike isInFrustum this cheks the full bounding box
  9317. * @param frustumPlanes Camera near/planes
  9318. * @returns true if the object is in frustum otherwise false
  9319. */
  9320. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9321. /** @hidden */
  9322. _checkCollision(collider: Collider): boolean;
  9323. /**
  9324. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9325. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9326. * @param point the point to check intersection with
  9327. * @returns if the point intersects
  9328. */
  9329. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9330. /**
  9331. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9332. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9333. * @param boundingInfo the bounding info to check intersection with
  9334. * @param precise if the intersection should be done using OBB
  9335. * @returns if the bounding info intersects
  9336. */
  9337. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /**
  9342. * Class used to store bounding sphere information
  9343. */
  9344. class BoundingSphere {
  9345. /**
  9346. * Gets the center of the bounding sphere in local space
  9347. */
  9348. readonly center: Vector3;
  9349. /**
  9350. * Radius of the bounding sphere in local space
  9351. */
  9352. radius: number;
  9353. /**
  9354. * Gets the center of the bounding sphere in world space
  9355. */
  9356. readonly centerWorld: Vector3;
  9357. /**
  9358. * Radius of the bounding sphere in world space
  9359. */
  9360. radiusWorld: number;
  9361. /**
  9362. * Gets the minimum vector in local space
  9363. */
  9364. readonly minimum: Vector3;
  9365. /**
  9366. * Gets the maximum vector in local space
  9367. */
  9368. readonly maximum: Vector3;
  9369. private _worldMatrix;
  9370. private static readonly TmpVector3;
  9371. /**
  9372. * Creates a new bounding sphere
  9373. * @param min defines the minimum vector (in local space)
  9374. * @param max defines the maximum vector (in local space)
  9375. * @param worldMatrix defines the new world matrix
  9376. */
  9377. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9378. /**
  9379. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9380. * @param min defines the new minimum vector (in local space)
  9381. * @param max defines the new maximum vector (in local space)
  9382. * @param worldMatrix defines the new world matrix
  9383. */
  9384. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9385. /**
  9386. * Scale the current bounding sphere by applying a scale factor
  9387. * @param factor defines the scale factor to apply
  9388. * @returns the current bounding box
  9389. */
  9390. scale(factor: number): BoundingSphere;
  9391. /**
  9392. * Gets the world matrix of the bounding box
  9393. * @returns a matrix
  9394. */
  9395. getWorldMatrix(): DeepImmutable<Matrix>;
  9396. /** @hidden */
  9397. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9398. /**
  9399. * Tests if the bounding sphere is intersecting the frustum planes
  9400. * @param frustumPlanes defines the frustum planes to test
  9401. * @returns true if there is an intersection
  9402. */
  9403. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9404. /**
  9405. * Tests if a point is inside the bounding sphere
  9406. * @param point defines the point to test
  9407. * @returns true if the point is inside the bounding sphere
  9408. */
  9409. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9410. /**
  9411. * Checks if two sphere intersct
  9412. * @param sphere0 sphere 0
  9413. * @param sphere1 sphere 1
  9414. * @returns true if the speres intersect
  9415. */
  9416. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9417. }
  9418. }
  9419. declare module BABYLON {
  9420. /**
  9421. * Class representing a ray with position and direction
  9422. */
  9423. class Ray {
  9424. /** origin point */
  9425. origin: Vector3;
  9426. /** direction */
  9427. direction: Vector3;
  9428. /** length of the ray */
  9429. length: number;
  9430. private static readonly TmpVector3;
  9431. private _tmpRay;
  9432. /**
  9433. * Creates a new ray
  9434. * @param origin origin point
  9435. * @param direction direction
  9436. * @param length length of the ray
  9437. */
  9438. constructor(
  9439. /** origin point */
  9440. origin: Vector3,
  9441. /** direction */
  9442. direction: Vector3,
  9443. /** length of the ray */
  9444. length?: number);
  9445. /**
  9446. * Checks if the ray intersects a box
  9447. * @param minimum bound of the box
  9448. * @param maximum bound of the box
  9449. * @param intersectionTreshold extra extend to be added to the box in all direction
  9450. * @returns if the box was hit
  9451. */
  9452. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9453. /**
  9454. * Checks if the ray intersects a box
  9455. * @param box the bounding box to check
  9456. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9457. * @returns if the box was hit
  9458. */
  9459. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9460. /**
  9461. * If the ray hits a sphere
  9462. * @param sphere the bounding sphere to check
  9463. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9464. * @returns true if it hits the sphere
  9465. */
  9466. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9467. /**
  9468. * If the ray hits a triange
  9469. * @param vertex0 triangle vertex
  9470. * @param vertex1 triangle vertex
  9471. * @param vertex2 triangle vertex
  9472. * @returns intersection information if hit
  9473. */
  9474. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9475. /**
  9476. * Checks if ray intersects a plane
  9477. * @param plane the plane to check
  9478. * @returns the distance away it was hit
  9479. */
  9480. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9481. /**
  9482. * Checks if ray intersects a mesh
  9483. * @param mesh the mesh to check
  9484. * @param fastCheck if only the bounding box should checked
  9485. * @returns picking info of the intersecton
  9486. */
  9487. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9488. /**
  9489. * Checks if ray intersects a mesh
  9490. * @param meshes the meshes to check
  9491. * @param fastCheck if only the bounding box should checked
  9492. * @param results array to store result in
  9493. * @returns Array of picking infos
  9494. */
  9495. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9496. private _comparePickingInfo;
  9497. private static smallnum;
  9498. private static rayl;
  9499. /**
  9500. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9501. * @param sega the first point of the segment to test the intersection against
  9502. * @param segb the second point of the segment to test the intersection against
  9503. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9504. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9505. */
  9506. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9507. /**
  9508. * Update the ray from viewport position
  9509. * @param x position
  9510. * @param y y position
  9511. * @param viewportWidth viewport width
  9512. * @param viewportHeight viewport height
  9513. * @param world world matrix
  9514. * @param view view matrix
  9515. * @param projection projection matrix
  9516. * @returns this ray updated
  9517. */
  9518. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9519. /**
  9520. * Creates a ray with origin and direction of 0,0,0
  9521. * @returns the new ray
  9522. */
  9523. static Zero(): Ray;
  9524. /**
  9525. * Creates a new ray from screen space and viewport
  9526. * @param x position
  9527. * @param y y position
  9528. * @param viewportWidth viewport width
  9529. * @param viewportHeight viewport height
  9530. * @param world world matrix
  9531. * @param view view matrix
  9532. * @param projection projection matrix
  9533. * @returns new ray
  9534. */
  9535. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9536. /**
  9537. * 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
  9538. * transformed to the given world matrix.
  9539. * @param origin The origin point
  9540. * @param end The end point
  9541. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9542. * @returns the new ray
  9543. */
  9544. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9545. /**
  9546. * Transforms a ray by a matrix
  9547. * @param ray ray to transform
  9548. * @param matrix matrix to apply
  9549. * @returns the resulting new ray
  9550. */
  9551. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9552. /**
  9553. * Transforms a ray by a matrix
  9554. * @param ray ray to transform
  9555. * @param matrix matrix to apply
  9556. * @param result ray to store result in
  9557. */
  9558. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9559. }
  9560. }
  9561. /**
  9562. * Module Debug contains the (visual) components to debug a scene correctly
  9563. */
  9564. declare module BABYLON.Debug {
  9565. /**
  9566. * The Axes viewer will show 3 axes in a specific point in space
  9567. */
  9568. class AxesViewer {
  9569. private _xmesh;
  9570. private _ymesh;
  9571. private _zmesh;
  9572. private _tmpVector;
  9573. private _scaleLinesFactor;
  9574. /**
  9575. * Gets the hosting scene
  9576. */
  9577. scene: Nullable<Scene>;
  9578. /**
  9579. * Gets or sets a number used to scale line length
  9580. */
  9581. scaleLines: number;
  9582. /** Gets the mesh used to render x-axis */
  9583. readonly xAxisMesh: Nullable<AbstractMesh>;
  9584. /** Gets the mesh used to render x-axis */
  9585. readonly yAxisMesh: Nullable<AbstractMesh>;
  9586. /** Gets the mesh used to render x-axis */
  9587. readonly zAxisMesh: Nullable<AbstractMesh>;
  9588. private static _recursiveChangeRenderingGroupId;
  9589. /**
  9590. * Creates a new AxesViewer
  9591. * @param scene defines the hosting scene
  9592. * @param scaleLines defines a number used to scale line length (1 by default)
  9593. */
  9594. constructor(scene: Scene, scaleLines?: number);
  9595. /**
  9596. * Force the viewer to update
  9597. * @param position defines the position of the viewer
  9598. * @param xaxis defines the x axis of the viewer
  9599. * @param yaxis defines the y axis of the viewer
  9600. * @param zaxis defines the z axis of the viewer
  9601. */
  9602. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9603. /** Releases resources */
  9604. dispose(): void;
  9605. }
  9606. }
  9607. declare module BABYLON.Debug {
  9608. /**
  9609. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9610. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9611. */
  9612. class BoneAxesViewer extends AxesViewer {
  9613. /**
  9614. * Gets or sets the target mesh where to display the axes viewer
  9615. */
  9616. mesh: Nullable<Mesh>;
  9617. /**
  9618. * Gets or sets the target bone where to display the axes viewer
  9619. */
  9620. bone: Nullable<Bone>;
  9621. /** Gets current position */
  9622. pos: Vector3;
  9623. /** Gets direction of X axis */
  9624. xaxis: Vector3;
  9625. /** Gets direction of Y axis */
  9626. yaxis: Vector3;
  9627. /** Gets direction of Z axis */
  9628. zaxis: Vector3;
  9629. /**
  9630. * Creates a new BoneAxesViewer
  9631. * @param scene defines the hosting scene
  9632. * @param bone defines the target bone
  9633. * @param mesh defines the target mesh
  9634. * @param scaleLines defines a scaling factor for line length (1 by default)
  9635. */
  9636. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9637. /**
  9638. * Force the viewer to update
  9639. */
  9640. update(): void;
  9641. /** Releases resources */
  9642. dispose(): void;
  9643. }
  9644. }
  9645. declare module BABYLON {
  9646. /**
  9647. * Interface used to define scene explorer extensibility option
  9648. */
  9649. interface IExplorerExtensibilityOption {
  9650. /**
  9651. * Define the option label
  9652. */
  9653. label: string;
  9654. /**
  9655. * Defines the action to execute on click
  9656. */
  9657. action: (entity: any) => void;
  9658. }
  9659. /**
  9660. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9661. */
  9662. interface IExplorerExtensibilityGroup {
  9663. /**
  9664. * Defines a predicate to test if a given type mut be extended
  9665. */
  9666. predicate: (entity: any) => boolean;
  9667. /**
  9668. * Gets the list of options added to a type
  9669. */
  9670. entries: IExplorerExtensibilityOption[];
  9671. }
  9672. /**
  9673. * Interface used to define the options to use to create the Inspector
  9674. */
  9675. interface IInspectorOptions {
  9676. /**
  9677. * Display in overlay mode (default: false)
  9678. */
  9679. overlay?: boolean;
  9680. /**
  9681. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9682. */
  9683. globalRoot?: HTMLElement;
  9684. /**
  9685. * Display the Scene explorer
  9686. */
  9687. showExplorer?: boolean;
  9688. /**
  9689. * Display the property inspector
  9690. */
  9691. showInspector?: boolean;
  9692. /**
  9693. * Display in embed mode (both panes on the right)
  9694. */
  9695. embedMode?: boolean;
  9696. /**
  9697. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9698. */
  9699. handleResize?: boolean;
  9700. /**
  9701. * Allow the panes to popup (default: true)
  9702. */
  9703. enablePopup?: boolean;
  9704. /**
  9705. * Allow the panes to be closed by users (default: true)
  9706. */
  9707. enableClose?: boolean;
  9708. /**
  9709. * Optional list of extensibility entries
  9710. */
  9711. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9712. }
  9713. interface Scene {
  9714. /**
  9715. * @hidden
  9716. * Backing field
  9717. */
  9718. _debugLayer: DebugLayer;
  9719. /**
  9720. * Gets the debug layer (aka Inspector) associated with the scene
  9721. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9722. */
  9723. debugLayer: DebugLayer;
  9724. }
  9725. /**
  9726. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9727. * what is happening in your scene
  9728. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9729. */
  9730. class DebugLayer {
  9731. /**
  9732. * Define the url to get the inspector script from.
  9733. * By default it uses the babylonjs CDN.
  9734. * @ignoreNaming
  9735. */
  9736. static InspectorURL: string;
  9737. private _scene;
  9738. private BJSINSPECTOR;
  9739. /**
  9740. * Observable triggered when a property is changed through the inspector.
  9741. */
  9742. onPropertyChangedObservable: Observable<{
  9743. object: any;
  9744. property: string;
  9745. value: any;
  9746. initialValue: any;
  9747. }>;
  9748. /**
  9749. * Instantiates a new debug layer.
  9750. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9751. * what is happening in your scene
  9752. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9753. * @param scene Defines the scene to inspect
  9754. */
  9755. constructor(scene: Scene);
  9756. /** Creates the inspector window. */
  9757. private _createInspector;
  9758. /**
  9759. * Get if the inspector is visible or not.
  9760. * @returns true if visible otherwise, false
  9761. */
  9762. isVisible(): boolean;
  9763. /**
  9764. * Hide the inspector and close its window.
  9765. */
  9766. hide(): void;
  9767. /**
  9768. * Launch the debugLayer.
  9769. * @param config Define the configuration of the inspector
  9770. */
  9771. show(config?: IInspectorOptions): void;
  9772. }
  9773. }
  9774. declare module BABYLON.Debug {
  9775. /**
  9776. * Used to show the physics impostor around the specific mesh
  9777. */
  9778. class PhysicsViewer {
  9779. /** @hidden */
  9780. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9781. /** @hidden */
  9782. protected _meshes: Array<Nullable<AbstractMesh>>;
  9783. /** @hidden */
  9784. protected _scene: Nullable<Scene>;
  9785. /** @hidden */
  9786. protected _numMeshes: number;
  9787. /** @hidden */
  9788. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9789. private _renderFunction;
  9790. private _utilityLayer;
  9791. private _debugBoxMesh;
  9792. private _debugSphereMesh;
  9793. private _debugMaterial;
  9794. /**
  9795. * Creates a new PhysicsViewer
  9796. * @param scene defines the hosting scene
  9797. */
  9798. constructor(scene: Scene);
  9799. /** @hidden */
  9800. protected _updateDebugMeshes(): void;
  9801. /**
  9802. * Renders a specified physic impostor
  9803. * @param impostor defines the impostor to render
  9804. * @returns the new debug mesh used to render the impostor
  9805. */
  9806. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9807. /**
  9808. * Hides a specified physic impostor
  9809. * @param impostor defines the impostor to hide
  9810. */
  9811. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9812. private _getDebugMaterial;
  9813. private _getDebugBoxMesh;
  9814. private _getDebugSphereMesh;
  9815. private _getDebugMesh;
  9816. /** Releases all resources */
  9817. dispose(): void;
  9818. }
  9819. }
  9820. declare module BABYLON {
  9821. /**
  9822. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9823. * in order to better appreciate the issue one might have.
  9824. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9825. */
  9826. class RayHelper {
  9827. /**
  9828. * Defines the ray we are currently tryin to visualize.
  9829. */
  9830. ray: Nullable<Ray>;
  9831. private _renderPoints;
  9832. private _renderLine;
  9833. private _renderFunction;
  9834. private _scene;
  9835. private _updateToMeshFunction;
  9836. private _attachedToMesh;
  9837. private _meshSpaceDirection;
  9838. private _meshSpaceOrigin;
  9839. /**
  9840. * Helper function to create a colored helper in a scene in one line.
  9841. * @param ray Defines the ray we are currently tryin to visualize
  9842. * @param scene Defines the scene the ray is used in
  9843. * @param color Defines the color we want to see the ray in
  9844. * @returns The newly created ray helper.
  9845. */
  9846. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9847. /**
  9848. * Instantiate a new ray helper.
  9849. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9850. * in order to better appreciate the issue one might have.
  9851. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9852. * @param ray Defines the ray we are currently tryin to visualize
  9853. */
  9854. constructor(ray: Ray);
  9855. /**
  9856. * Shows the ray we are willing to debug.
  9857. * @param scene Defines the scene the ray needs to be rendered in
  9858. * @param color Defines the color the ray needs to be rendered in
  9859. */
  9860. show(scene: Scene, color?: Color3): void;
  9861. /**
  9862. * Hides the ray we are debugging.
  9863. */
  9864. hide(): void;
  9865. private _render;
  9866. /**
  9867. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9868. * @param mesh Defines the mesh we want the helper attached to
  9869. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9870. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9871. * @param length Defines the length of the ray
  9872. */
  9873. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9874. /**
  9875. * Detach the ray helper from the mesh it has previously been attached to.
  9876. */
  9877. detachFromMesh(): void;
  9878. private _updateToMesh;
  9879. /**
  9880. * Dispose the helper and release its associated resources.
  9881. */
  9882. dispose(): void;
  9883. }
  9884. }
  9885. declare module BABYLON.Debug {
  9886. /**
  9887. * Class used to render a debug view of a given skeleton
  9888. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9889. */
  9890. class SkeletonViewer {
  9891. /** defines the skeleton to render */
  9892. skeleton: Skeleton;
  9893. /** defines the mesh attached to the skeleton */
  9894. mesh: AbstractMesh;
  9895. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9896. autoUpdateBonesMatrices: boolean;
  9897. /** defines the rendering group id to use with the viewer */
  9898. renderingGroupId: number;
  9899. /** Gets or sets the color used to render the skeleton */
  9900. color: Color3;
  9901. private _scene;
  9902. private _debugLines;
  9903. private _debugMesh;
  9904. private _isEnabled;
  9905. private _renderFunction;
  9906. private _utilityLayer;
  9907. /**
  9908. * Returns the mesh used to render the bones
  9909. */
  9910. readonly debugMesh: Nullable<LinesMesh>;
  9911. /**
  9912. * Creates a new SkeletonViewer
  9913. * @param skeleton defines the skeleton to render
  9914. * @param mesh defines the mesh attached to the skeleton
  9915. * @param scene defines the hosting scene
  9916. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9917. * @param renderingGroupId defines the rendering group id to use with the viewer
  9918. */
  9919. constructor(
  9920. /** defines the skeleton to render */
  9921. skeleton: Skeleton,
  9922. /** defines the mesh attached to the skeleton */
  9923. mesh: AbstractMesh, scene: Scene,
  9924. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9925. autoUpdateBonesMatrices?: boolean,
  9926. /** defines the rendering group id to use with the viewer */
  9927. renderingGroupId?: number);
  9928. /** Gets or sets a boolean indicating if the viewer is enabled */
  9929. isEnabled: boolean;
  9930. private _getBonePosition;
  9931. private _getLinesForBonesWithLength;
  9932. private _getLinesForBonesNoLength;
  9933. /** Update the viewer to sync with current skeleton state */
  9934. update(): void;
  9935. /** Release associated resources */
  9936. dispose(): void;
  9937. }
  9938. }
  9939. declare module BABYLON {
  9940. /**
  9941. * Interface for attribute information associated with buffer instanciation
  9942. */
  9943. class InstancingAttributeInfo {
  9944. /**
  9945. * Index/offset of the attribute in the vertex shader
  9946. */
  9947. index: number;
  9948. /**
  9949. * size of the attribute, 1, 2, 3 or 4
  9950. */
  9951. attributeSize: number;
  9952. /**
  9953. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9954. * default is FLOAT
  9955. */
  9956. attribyteType: number;
  9957. /**
  9958. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9959. */
  9960. normalized: boolean;
  9961. /**
  9962. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9963. */
  9964. offset: number;
  9965. /**
  9966. * Name of the GLSL attribute, for debugging purpose only
  9967. */
  9968. attributeName: string;
  9969. }
  9970. /**
  9971. * Define options used to create a render target texture
  9972. */
  9973. class RenderTargetCreationOptions {
  9974. /**
  9975. * Specifies is mipmaps must be generated
  9976. */
  9977. generateMipMaps?: boolean;
  9978. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9979. generateDepthBuffer?: boolean;
  9980. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9981. generateStencilBuffer?: boolean;
  9982. /** Defines texture type (int by default) */
  9983. type?: number;
  9984. /** Defines sampling mode (trilinear by default) */
  9985. samplingMode?: number;
  9986. /** Defines format (RGBA by default) */
  9987. format?: number;
  9988. }
  9989. /**
  9990. * Define options used to create a depth texture
  9991. */
  9992. class DepthTextureCreationOptions {
  9993. /** Specifies whether or not a stencil should be allocated in the texture */
  9994. generateStencil?: boolean;
  9995. /** Specifies whether or not bilinear filtering is enable on the texture */
  9996. bilinearFiltering?: boolean;
  9997. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9998. comparisonFunction?: number;
  9999. /** Specifies if the created texture is a cube texture */
  10000. isCube?: boolean;
  10001. }
  10002. /**
  10003. * Class used to describe the capabilities of the engine relatively to the current browser
  10004. */
  10005. class EngineCapabilities {
  10006. /** Maximum textures units per fragment shader */
  10007. maxTexturesImageUnits: number;
  10008. /** Maximum texture units per vertex shader */
  10009. maxVertexTextureImageUnits: number;
  10010. /** Maximum textures units in the entire pipeline */
  10011. maxCombinedTexturesImageUnits: number;
  10012. /** Maximum texture size */
  10013. maxTextureSize: number;
  10014. /** Maximum cube texture size */
  10015. maxCubemapTextureSize: number;
  10016. /** Maximum render texture size */
  10017. maxRenderTextureSize: number;
  10018. /** Maximum number of vertex attributes */
  10019. maxVertexAttribs: number;
  10020. /** Maximum number of varyings */
  10021. maxVaryingVectors: number;
  10022. /** Maximum number of uniforms per vertex shader */
  10023. maxVertexUniformVectors: number;
  10024. /** Maximum number of uniforms per fragment shader */
  10025. maxFragmentUniformVectors: number;
  10026. /** Defines if standard derivates (dx/dy) are supported */
  10027. standardDerivatives: boolean;
  10028. /** Defines if s3tc texture compression is supported */
  10029. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10030. /** Defines if pvrtc texture compression is supported */
  10031. pvrtc: any;
  10032. /** Defines if etc1 texture compression is supported */
  10033. etc1: any;
  10034. /** Defines if etc2 texture compression is supported */
  10035. etc2: any;
  10036. /** Defines if astc texture compression is supported */
  10037. astc: any;
  10038. /** Defines if float textures are supported */
  10039. textureFloat: boolean;
  10040. /** Defines if vertex array objects are supported */
  10041. vertexArrayObject: boolean;
  10042. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10043. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10044. /** Gets the maximum level of anisotropy supported */
  10045. maxAnisotropy: number;
  10046. /** Defines if instancing is supported */
  10047. instancedArrays: boolean;
  10048. /** Defines if 32 bits indices are supported */
  10049. uintIndices: boolean;
  10050. /** Defines if high precision shaders are supported */
  10051. highPrecisionShaderSupported: boolean;
  10052. /** Defines if depth reading in the fragment shader is supported */
  10053. fragmentDepthSupported: boolean;
  10054. /** Defines if float texture linear filtering is supported*/
  10055. textureFloatLinearFiltering: boolean;
  10056. /** Defines if rendering to float textures is supported */
  10057. textureFloatRender: boolean;
  10058. /** Defines if half float textures are supported*/
  10059. textureHalfFloat: boolean;
  10060. /** Defines if half float texture linear filtering is supported*/
  10061. textureHalfFloatLinearFiltering: boolean;
  10062. /** Defines if rendering to half float textures is supported */
  10063. textureHalfFloatRender: boolean;
  10064. /** Defines if textureLOD shader command is supported */
  10065. textureLOD: boolean;
  10066. /** Defines if draw buffers extension is supported */
  10067. drawBuffersExtension: boolean;
  10068. /** Defines if depth textures are supported */
  10069. depthTextureExtension: boolean;
  10070. /** Defines if float color buffer are supported */
  10071. colorBufferFloat: boolean;
  10072. /** Gets disjoint timer query extension (null if not supported) */
  10073. timerQuery: EXT_disjoint_timer_query;
  10074. /** Defines if timestamp can be used with timer query */
  10075. canUseTimestampForTimerQuery: boolean;
  10076. /** Function used to let the system compiles shaders in background */
  10077. parallelShaderCompile: {
  10078. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10079. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10080. COMPLETION_STATUS_KHR: number;
  10081. };
  10082. }
  10083. /** Interface defining initialization parameters for Engine class */
  10084. interface EngineOptions extends WebGLContextAttributes {
  10085. /**
  10086. * Defines if the engine should no exceed a specified device ratio
  10087. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10088. */
  10089. limitDeviceRatio?: number;
  10090. /**
  10091. * Defines if webvr should be enabled automatically
  10092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10093. */
  10094. autoEnableWebVR?: boolean;
  10095. /**
  10096. * Defines if webgl2 should be turned off even if supported
  10097. * @see http://doc.babylonjs.com/features/webgl2
  10098. */
  10099. disableWebGL2Support?: boolean;
  10100. /**
  10101. * Defines if webaudio should be initialized as well
  10102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10103. */
  10104. audioEngine?: boolean;
  10105. /**
  10106. * Defines if animations should run using a deterministic lock step
  10107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10108. */
  10109. deterministicLockstep?: boolean;
  10110. /** Defines the maximum steps to use with deterministic lock step mode */
  10111. lockstepMaxSteps?: number;
  10112. /**
  10113. * Defines that engine should ignore context lost events
  10114. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10115. */
  10116. doNotHandleContextLost?: boolean;
  10117. }
  10118. /**
  10119. * Defines the interface used by display changed events
  10120. */
  10121. interface IDisplayChangedEventArgs {
  10122. /** Gets the vrDisplay object (if any) */
  10123. vrDisplay: Nullable<any>;
  10124. /** Gets a boolean indicating if webVR is supported */
  10125. vrSupported: boolean;
  10126. }
  10127. /**
  10128. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10129. */
  10130. class Engine {
  10131. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10132. static ExceptionList: ({
  10133. key: string;
  10134. capture: string;
  10135. captureConstraint: number;
  10136. targets: string[];
  10137. } | {
  10138. key: string;
  10139. capture: null;
  10140. captureConstraint: null;
  10141. targets: string[];
  10142. })[];
  10143. /** Gets the list of created engines */
  10144. static Instances: Engine[];
  10145. /**
  10146. * Gets the latest created engine
  10147. */
  10148. static readonly LastCreatedEngine: Nullable<Engine>;
  10149. /**
  10150. * Gets the latest created scene
  10151. */
  10152. static readonly LastCreatedScene: Nullable<Scene>;
  10153. /**
  10154. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10155. * @param flag defines which part of the materials must be marked as dirty
  10156. * @param predicate defines a predicate used to filter which materials should be affected
  10157. */
  10158. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10159. /**
  10160. * Hidden
  10161. */
  10162. static _TextureLoaders: IInternalTextureLoader[];
  10163. /** Defines that alpha blending is disabled */
  10164. static readonly ALPHA_DISABLE: number;
  10165. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10166. static readonly ALPHA_ADD: number;
  10167. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10168. static readonly ALPHA_COMBINE: number;
  10169. /** Defines that alpha blending to DEST - SRC * DEST */
  10170. static readonly ALPHA_SUBTRACT: number;
  10171. /** Defines that alpha blending to SRC * DEST */
  10172. static readonly ALPHA_MULTIPLY: number;
  10173. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10174. static readonly ALPHA_MAXIMIZED: number;
  10175. /** Defines that alpha blending to SRC + DEST */
  10176. static readonly ALPHA_ONEONE: number;
  10177. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10178. static readonly ALPHA_PREMULTIPLIED: number;
  10179. /**
  10180. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10181. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10182. */
  10183. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10184. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10185. static readonly ALPHA_INTERPOLATE: number;
  10186. /**
  10187. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10188. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10189. */
  10190. static readonly ALPHA_SCREENMODE: number;
  10191. /** Defines that the ressource is not delayed*/
  10192. static readonly DELAYLOADSTATE_NONE: number;
  10193. /** Defines that the ressource was successfully delay loaded */
  10194. static readonly DELAYLOADSTATE_LOADED: number;
  10195. /** Defines that the ressource is currently delay loading */
  10196. static readonly DELAYLOADSTATE_LOADING: number;
  10197. /** Defines that the ressource is delayed and has not started loading */
  10198. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10199. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10200. static readonly NEVER: number;
  10201. /** 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 */
  10202. static readonly ALWAYS: number;
  10203. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10204. static readonly LESS: number;
  10205. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10206. static readonly EQUAL: number;
  10207. /** 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 */
  10208. static readonly LEQUAL: number;
  10209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10210. static readonly GREATER: number;
  10211. /** 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 */
  10212. static readonly GEQUAL: number;
  10213. /** 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 */
  10214. static readonly NOTEQUAL: number;
  10215. /** Passed to stencilOperation to specify that stencil value must be kept */
  10216. static readonly KEEP: number;
  10217. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10218. static readonly REPLACE: number;
  10219. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10220. static readonly INCR: number;
  10221. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10222. static readonly DECR: number;
  10223. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10224. static readonly INVERT: number;
  10225. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10226. static readonly INCR_WRAP: number;
  10227. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10228. static readonly DECR_WRAP: number;
  10229. /** Texture is not repeating outside of 0..1 UVs */
  10230. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10231. /** Texture is repeating outside of 0..1 UVs */
  10232. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10233. /** Texture is repeating and mirrored */
  10234. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10235. /** ALPHA */
  10236. static readonly TEXTUREFORMAT_ALPHA: number;
  10237. /** LUMINANCE */
  10238. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10239. /** LUMINANCE_ALPHA */
  10240. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10241. /** RGB */
  10242. static readonly TEXTUREFORMAT_RGB: number;
  10243. /** RGBA */
  10244. static readonly TEXTUREFORMAT_RGBA: number;
  10245. /** RED */
  10246. static readonly TEXTUREFORMAT_RED: number;
  10247. /** RED (2nd reference) */
  10248. static readonly TEXTUREFORMAT_R: number;
  10249. /** RG */
  10250. static readonly TEXTUREFORMAT_RG: number;
  10251. /** RED_INTEGER */
  10252. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10253. /** RED_INTEGER (2nd reference) */
  10254. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10255. /** RG_INTEGER */
  10256. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10257. /** RGB_INTEGER */
  10258. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10259. /** RGBA_INTEGER */
  10260. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10261. /** UNSIGNED_BYTE */
  10262. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10263. /** UNSIGNED_BYTE (2nd reference) */
  10264. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10265. /** FLOAT */
  10266. static readonly TEXTURETYPE_FLOAT: number;
  10267. /** HALF_FLOAT */
  10268. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10269. /** BYTE */
  10270. static readonly TEXTURETYPE_BYTE: number;
  10271. /** SHORT */
  10272. static readonly TEXTURETYPE_SHORT: number;
  10273. /** UNSIGNED_SHORT */
  10274. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10275. /** INT */
  10276. static readonly TEXTURETYPE_INT: number;
  10277. /** UNSIGNED_INT */
  10278. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10279. /** UNSIGNED_SHORT_4_4_4_4 */
  10280. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10281. /** UNSIGNED_SHORT_5_5_5_1 */
  10282. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10283. /** UNSIGNED_SHORT_5_6_5 */
  10284. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10285. /** UNSIGNED_INT_2_10_10_10_REV */
  10286. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10287. /** UNSIGNED_INT_24_8 */
  10288. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10289. /** UNSIGNED_INT_10F_11F_11F_REV */
  10290. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10291. /** UNSIGNED_INT_5_9_9_9_REV */
  10292. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10293. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10294. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10295. /** nearest is mag = nearest and min = nearest and mip = linear */
  10296. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10297. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10298. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10299. /** Trilinear is mag = linear and min = linear and mip = linear */
  10300. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10301. /** nearest is mag = nearest and min = nearest and mip = linear */
  10302. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10303. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10304. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10305. /** Trilinear is mag = linear and min = linear and mip = linear */
  10306. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10307. /** mag = nearest and min = nearest and mip = nearest */
  10308. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10309. /** mag = nearest and min = linear and mip = nearest */
  10310. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10311. /** mag = nearest and min = linear and mip = linear */
  10312. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10313. /** mag = nearest and min = linear and mip = none */
  10314. static readonly TEXTURE_NEAREST_LINEAR: number;
  10315. /** mag = nearest and min = nearest and mip = none */
  10316. static readonly TEXTURE_NEAREST_NEAREST: number;
  10317. /** mag = linear and min = nearest and mip = nearest */
  10318. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10319. /** mag = linear and min = nearest and mip = linear */
  10320. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10321. /** mag = linear and min = linear and mip = none */
  10322. static readonly TEXTURE_LINEAR_LINEAR: number;
  10323. /** mag = linear and min = nearest and mip = none */
  10324. static readonly TEXTURE_LINEAR_NEAREST: number;
  10325. /** Explicit coordinates mode */
  10326. static readonly TEXTURE_EXPLICIT_MODE: number;
  10327. /** Spherical coordinates mode */
  10328. static readonly TEXTURE_SPHERICAL_MODE: number;
  10329. /** Planar coordinates mode */
  10330. static readonly TEXTURE_PLANAR_MODE: number;
  10331. /** Cubic coordinates mode */
  10332. static readonly TEXTURE_CUBIC_MODE: number;
  10333. /** Projection coordinates mode */
  10334. static readonly TEXTURE_PROJECTION_MODE: number;
  10335. /** Skybox coordinates mode */
  10336. static readonly TEXTURE_SKYBOX_MODE: number;
  10337. /** Inverse Cubic coordinates mode */
  10338. static readonly TEXTURE_INVCUBIC_MODE: number;
  10339. /** Equirectangular coordinates mode */
  10340. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10341. /** Equirectangular Fixed coordinates mode */
  10342. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10343. /** Equirectangular Fixed Mirrored coordinates mode */
  10344. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10345. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10346. static readonly SCALEMODE_FLOOR: number;
  10347. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10348. static readonly SCALEMODE_NEAREST: number;
  10349. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10350. static readonly SCALEMODE_CEILING: number;
  10351. /**
  10352. * Returns the current version of the framework
  10353. */
  10354. static readonly Version: string;
  10355. /**
  10356. * Returns a string describing the current engine
  10357. */
  10358. readonly description: string;
  10359. /**
  10360. * Gets or sets the epsilon value used by collision engine
  10361. */
  10362. static CollisionsEpsilon: number;
  10363. /**
  10364. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10365. */
  10366. static CodeRepository: string;
  10367. /**
  10368. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10369. */
  10370. static ShadersRepository: string;
  10371. /**
  10372. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10373. */
  10374. forcePOTTextures: boolean;
  10375. /**
  10376. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10377. */
  10378. isFullscreen: boolean;
  10379. /**
  10380. * Gets a boolean indicating if the pointer is currently locked
  10381. */
  10382. isPointerLock: boolean;
  10383. /**
  10384. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10385. */
  10386. cullBackFaces: boolean;
  10387. /**
  10388. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10389. */
  10390. renderEvenInBackground: boolean;
  10391. /**
  10392. * Gets or sets a boolean indicating that cache can be kept between frames
  10393. */
  10394. preventCacheWipeBetweenFrames: boolean;
  10395. /**
  10396. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10397. **/
  10398. enableOfflineSupport: boolean;
  10399. /**
  10400. * 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)
  10401. **/
  10402. disableManifestCheck: boolean;
  10403. /**
  10404. * Gets the list of created scenes
  10405. */
  10406. scenes: Scene[];
  10407. /**
  10408. * Event raised when a new scene is created
  10409. */
  10410. onNewSceneAddedObservable: Observable<Scene>;
  10411. /**
  10412. * Gets the list of created postprocesses
  10413. */
  10414. postProcesses: PostProcess[];
  10415. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10416. validateShaderPrograms: boolean;
  10417. /**
  10418. * Observable event triggered each time the rendering canvas is resized
  10419. */
  10420. onResizeObservable: Observable<Engine>;
  10421. /**
  10422. * Observable event triggered each time the canvas loses focus
  10423. */
  10424. onCanvasBlurObservable: Observable<Engine>;
  10425. /**
  10426. * Observable event triggered each time the canvas gains focus
  10427. */
  10428. onCanvasFocusObservable: Observable<Engine>;
  10429. /**
  10430. * Observable event triggered each time the canvas receives pointerout event
  10431. */
  10432. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10433. /**
  10434. * Observable event triggered before each texture is initialized
  10435. */
  10436. onBeforeTextureInitObservable: Observable<Texture>;
  10437. private _vrDisplay;
  10438. private _vrSupported;
  10439. private _oldSize;
  10440. private _oldHardwareScaleFactor;
  10441. private _vrExclusivePointerMode;
  10442. private _webVRInitPromise;
  10443. /**
  10444. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10445. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10446. */
  10447. readonly isInVRExclusivePointerMode: boolean;
  10448. /**
  10449. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10450. */
  10451. disableUniformBuffers: boolean;
  10452. /** @hidden */
  10453. _uniformBuffers: UniformBuffer[];
  10454. /**
  10455. * Gets a boolean indicating that the engine supports uniform buffers
  10456. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10457. */
  10458. readonly supportsUniformBuffers: boolean;
  10459. /**
  10460. * Observable raised when the engine begins a new frame
  10461. */
  10462. onBeginFrameObservable: Observable<Engine>;
  10463. /**
  10464. * If set, will be used to request the next animation frame for the render loop
  10465. */
  10466. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10467. /**
  10468. * Observable raised when the engine ends the current frame
  10469. */
  10470. onEndFrameObservable: Observable<Engine>;
  10471. /**
  10472. * Observable raised when the engine is about to compile a shader
  10473. */
  10474. onBeforeShaderCompilationObservable: Observable<Engine>;
  10475. /**
  10476. * Observable raised when the engine has jsut compiled a shader
  10477. */
  10478. onAfterShaderCompilationObservable: Observable<Engine>;
  10479. /** @hidden */
  10480. _gl: WebGLRenderingContext;
  10481. private _renderingCanvas;
  10482. private _windowIsBackground;
  10483. private _webGLVersion;
  10484. /**
  10485. * Gets a boolean indicating that only power of 2 textures are supported
  10486. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10487. */
  10488. readonly needPOTTextures: boolean;
  10489. /** @hidden */
  10490. _badOS: boolean;
  10491. /** @hidden */
  10492. _badDesktopOS: boolean;
  10493. /**
  10494. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10495. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10496. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10497. */
  10498. disableTextureBindingOptimization: boolean;
  10499. /**
  10500. * Gets the audio engine
  10501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10502. * @ignorenaming
  10503. */
  10504. static audioEngine: IAudioEngine;
  10505. /**
  10506. * Default AudioEngine factory responsible of creating the Audio Engine.
  10507. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10508. */
  10509. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10510. /**
  10511. * Default offline support factory responsible of creating a tool used to store data locally.
  10512. * By default, this will create a Database object if the workload has been embedded.
  10513. */
  10514. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10515. private _onFocus;
  10516. private _onBlur;
  10517. private _onCanvasPointerOut;
  10518. private _onCanvasBlur;
  10519. private _onCanvasFocus;
  10520. private _onFullscreenChange;
  10521. private _onPointerLockChange;
  10522. private _onVRDisplayPointerRestricted;
  10523. private _onVRDisplayPointerUnrestricted;
  10524. private _onVrDisplayConnect;
  10525. private _onVrDisplayDisconnect;
  10526. private _onVrDisplayPresentChange;
  10527. /**
  10528. * Observable signaled when VR display mode changes
  10529. */
  10530. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10531. /**
  10532. * Observable signaled when VR request present is complete
  10533. */
  10534. onVRRequestPresentComplete: Observable<boolean>;
  10535. /**
  10536. * Observable signaled when VR request present starts
  10537. */
  10538. onVRRequestPresentStart: Observable<Engine>;
  10539. private _hardwareScalingLevel;
  10540. /** @hidden */
  10541. protected _caps: EngineCapabilities;
  10542. private _pointerLockRequested;
  10543. private _isStencilEnable;
  10544. private _colorWrite;
  10545. private _loadingScreen;
  10546. /** @hidden */
  10547. _drawCalls: PerfCounter;
  10548. /** @hidden */
  10549. _textureCollisions: PerfCounter;
  10550. private _glVersion;
  10551. private _glRenderer;
  10552. private _glVendor;
  10553. private _videoTextureSupported;
  10554. private _renderingQueueLaunched;
  10555. private _activeRenderLoops;
  10556. private _deterministicLockstep;
  10557. private _lockstepMaxSteps;
  10558. /**
  10559. * Observable signaled when a context lost event is raised
  10560. */
  10561. onContextLostObservable: Observable<Engine>;
  10562. /**
  10563. * Observable signaled when a context restored event is raised
  10564. */
  10565. onContextRestoredObservable: Observable<Engine>;
  10566. private _onContextLost;
  10567. private _onContextRestored;
  10568. private _contextWasLost;
  10569. private _doNotHandleContextLost;
  10570. /**
  10571. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10573. */
  10574. doNotHandleContextLost: boolean;
  10575. private _performanceMonitor;
  10576. private _fps;
  10577. private _deltaTime;
  10578. /**
  10579. * Turn this value on if you want to pause FPS computation when in background
  10580. */
  10581. disablePerformanceMonitorInBackground: boolean;
  10582. /**
  10583. * Gets the performance monitor attached to this engine
  10584. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10585. */
  10586. readonly performanceMonitor: PerformanceMonitor;
  10587. /** @hidden */
  10588. protected _depthCullingState: _DepthCullingState;
  10589. /** @hidden */
  10590. protected _stencilState: _StencilState;
  10591. /** @hidden */
  10592. protected _alphaState: _AlphaState;
  10593. /** @hidden */
  10594. protected _alphaMode: number;
  10595. protected _internalTexturesCache: InternalTexture[];
  10596. /** @hidden */
  10597. protected _activeChannel: number;
  10598. private _currentTextureChannel;
  10599. /** @hidden */
  10600. protected _boundTexturesCache: {
  10601. [key: string]: Nullable<InternalTexture>;
  10602. };
  10603. /** @hidden */
  10604. protected _currentEffect: Nullable<Effect>;
  10605. /** @hidden */
  10606. protected _currentProgram: Nullable<WebGLProgram>;
  10607. private _compiledEffects;
  10608. private _vertexAttribArraysEnabled;
  10609. /** @hidden */
  10610. protected _cachedViewport: Nullable<Viewport>;
  10611. private _cachedVertexArrayObject;
  10612. /** @hidden */
  10613. protected _cachedVertexBuffers: any;
  10614. /** @hidden */
  10615. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10616. /** @hidden */
  10617. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10618. /** @hidden */
  10619. protected _currentRenderTarget: Nullable<InternalTexture>;
  10620. private _uintIndicesCurrentlySet;
  10621. private _currentBoundBuffer;
  10622. /** @hidden */
  10623. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10624. private _currentBufferPointers;
  10625. private _currentInstanceLocations;
  10626. private _currentInstanceBuffers;
  10627. private _textureUnits;
  10628. private _firstBoundInternalTextureTracker;
  10629. private _lastBoundInternalTextureTracker;
  10630. private _workingCanvas;
  10631. private _workingContext;
  10632. private _rescalePostProcess;
  10633. private _dummyFramebuffer;
  10634. private _externalData;
  10635. private _bindedRenderFunction;
  10636. private _vaoRecordInProgress;
  10637. private _mustWipeVertexAttributes;
  10638. private _emptyTexture;
  10639. private _emptyCubeTexture;
  10640. private _emptyTexture3D;
  10641. /** @hidden */
  10642. _frameHandler: number;
  10643. private _nextFreeTextureSlots;
  10644. private _maxSimultaneousTextures;
  10645. private _activeRequests;
  10646. private _texturesSupported;
  10647. private _textureFormatInUse;
  10648. /**
  10649. * Gets the list of texture formats supported
  10650. */
  10651. readonly texturesSupported: Array<string>;
  10652. /**
  10653. * Gets the list of texture formats in use
  10654. */
  10655. readonly textureFormatInUse: Nullable<string>;
  10656. /**
  10657. * Gets the current viewport
  10658. */
  10659. readonly currentViewport: Nullable<Viewport>;
  10660. /**
  10661. * Gets the default empty texture
  10662. */
  10663. readonly emptyTexture: InternalTexture;
  10664. /**
  10665. * Gets the default empty 3D texture
  10666. */
  10667. readonly emptyTexture3D: InternalTexture;
  10668. /**
  10669. * Gets the default empty cube texture
  10670. */
  10671. readonly emptyCubeTexture: InternalTexture;
  10672. /**
  10673. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10674. */
  10675. readonly premultipliedAlpha: boolean;
  10676. /**
  10677. * Creates a new engine
  10678. * @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
  10679. * @param antialias defines enable antialiasing (default: false)
  10680. * @param options defines further options to be sent to the getContext() function
  10681. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10682. */
  10683. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10684. private _rebuildInternalTextures;
  10685. private _rebuildEffects;
  10686. /**
  10687. * Gets a boolean indicating if all created effects are ready
  10688. * @returns true if all effects are ready
  10689. */
  10690. areAllEffectsReady(): boolean;
  10691. private _rebuildBuffers;
  10692. private _initGLContext;
  10693. /**
  10694. * Gets version of the current webGL context
  10695. */
  10696. readonly webGLVersion: number;
  10697. /**
  10698. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10699. */
  10700. readonly isStencilEnable: boolean;
  10701. private _prepareWorkingCanvas;
  10702. /**
  10703. * Reset the texture cache to empty state
  10704. */
  10705. resetTextureCache(): void;
  10706. /**
  10707. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10709. * @returns true if engine is in deterministic lock step mode
  10710. */
  10711. isDeterministicLockStep(): boolean;
  10712. /**
  10713. * Gets the max steps when engine is running in deterministic lock step
  10714. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10715. * @returns the max steps
  10716. */
  10717. getLockstepMaxSteps(): number;
  10718. /**
  10719. * Gets an object containing information about the current webGL context
  10720. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10721. */
  10722. getGlInfo(): {
  10723. vendor: string;
  10724. renderer: string;
  10725. version: string;
  10726. };
  10727. /**
  10728. * Gets current aspect ratio
  10729. * @param camera defines the camera to use to get the aspect ratio
  10730. * @param useScreen defines if screen size must be used (or the current render target if any)
  10731. * @returns a number defining the aspect ratio
  10732. */
  10733. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10734. /**
  10735. * Gets current screen aspect ratio
  10736. * @returns a number defining the aspect ratio
  10737. */
  10738. getScreenAspectRatio(): number;
  10739. /**
  10740. * Gets the current render width
  10741. * @param useScreen defines if screen size must be used (or the current render target if any)
  10742. * @returns a number defining the current render width
  10743. */
  10744. getRenderWidth(useScreen?: boolean): number;
  10745. /**
  10746. * Gets the current render height
  10747. * @param useScreen defines if screen size must be used (or the current render target if any)
  10748. * @returns a number defining the current render height
  10749. */
  10750. getRenderHeight(useScreen?: boolean): number;
  10751. /**
  10752. * Gets the HTML canvas attached with the current webGL context
  10753. * @returns a HTML canvas
  10754. */
  10755. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10756. /**
  10757. * Gets the client rect of the HTML canvas attached with the current webGL context
  10758. * @returns a client rectanglee
  10759. */
  10760. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10761. /**
  10762. * Defines the hardware scaling level.
  10763. * By default the hardware scaling level is computed from the window device ratio.
  10764. * 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.
  10765. * @param level defines the level to use
  10766. */
  10767. setHardwareScalingLevel(level: number): void;
  10768. /**
  10769. * Gets the current hardware scaling level.
  10770. * By default the hardware scaling level is computed from the window device ratio.
  10771. * 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.
  10772. * @returns a number indicating the current hardware scaling level
  10773. */
  10774. getHardwareScalingLevel(): number;
  10775. /**
  10776. * Gets the list of loaded textures
  10777. * @returns an array containing all loaded textures
  10778. */
  10779. getLoadedTexturesCache(): InternalTexture[];
  10780. /**
  10781. * Gets the object containing all engine capabilities
  10782. * @returns the EngineCapabilities object
  10783. */
  10784. getCaps(): EngineCapabilities;
  10785. /**
  10786. * Gets the current depth function
  10787. * @returns a number defining the depth function
  10788. */
  10789. getDepthFunction(): Nullable<number>;
  10790. /**
  10791. * Sets the current depth function
  10792. * @param depthFunc defines the function to use
  10793. */
  10794. setDepthFunction(depthFunc: number): void;
  10795. /**
  10796. * Sets the current depth function to GREATER
  10797. */
  10798. setDepthFunctionToGreater(): void;
  10799. /**
  10800. * Sets the current depth function to GEQUAL
  10801. */
  10802. setDepthFunctionToGreaterOrEqual(): void;
  10803. /**
  10804. * Sets the current depth function to LESS
  10805. */
  10806. setDepthFunctionToLess(): void;
  10807. /**
  10808. * Sets the current depth function to LEQUAL
  10809. */
  10810. setDepthFunctionToLessOrEqual(): void;
  10811. /**
  10812. * Gets a boolean indicating if stencil buffer is enabled
  10813. * @returns the current stencil buffer state
  10814. */
  10815. getStencilBuffer(): boolean;
  10816. /**
  10817. * Enable or disable the stencil buffer
  10818. * @param enable defines if the stencil buffer must be enabled or disabled
  10819. */
  10820. setStencilBuffer(enable: boolean): void;
  10821. /**
  10822. * Gets the current stencil mask
  10823. * @returns a number defining the new stencil mask to use
  10824. */
  10825. getStencilMask(): number;
  10826. /**
  10827. * Sets the current stencil mask
  10828. * @param mask defines the new stencil mask to use
  10829. */
  10830. setStencilMask(mask: number): void;
  10831. /**
  10832. * Gets the current stencil function
  10833. * @returns a number defining the stencil function to use
  10834. */
  10835. getStencilFunction(): number;
  10836. /**
  10837. * Gets the current stencil reference value
  10838. * @returns a number defining the stencil reference value to use
  10839. */
  10840. getStencilFunctionReference(): number;
  10841. /**
  10842. * Gets the current stencil mask
  10843. * @returns a number defining the stencil mask to use
  10844. */
  10845. getStencilFunctionMask(): number;
  10846. /**
  10847. * Sets the current stencil function
  10848. * @param stencilFunc defines the new stencil function to use
  10849. */
  10850. setStencilFunction(stencilFunc: number): void;
  10851. /**
  10852. * Sets the current stencil reference
  10853. * @param reference defines the new stencil reference to use
  10854. */
  10855. setStencilFunctionReference(reference: number): void;
  10856. /**
  10857. * Sets the current stencil mask
  10858. * @param mask defines the new stencil mask to use
  10859. */
  10860. setStencilFunctionMask(mask: number): void;
  10861. /**
  10862. * Gets the current stencil operation when stencil fails
  10863. * @returns a number defining stencil operation to use when stencil fails
  10864. */
  10865. getStencilOperationFail(): number;
  10866. /**
  10867. * Gets the current stencil operation when depth fails
  10868. * @returns a number defining stencil operation to use when depth fails
  10869. */
  10870. getStencilOperationDepthFail(): number;
  10871. /**
  10872. * Gets the current stencil operation when stencil passes
  10873. * @returns a number defining stencil operation to use when stencil passes
  10874. */
  10875. getStencilOperationPass(): number;
  10876. /**
  10877. * Sets the stencil operation to use when stencil fails
  10878. * @param operation defines the stencil operation to use when stencil fails
  10879. */
  10880. setStencilOperationFail(operation: number): void;
  10881. /**
  10882. * Sets the stencil operation to use when depth fails
  10883. * @param operation defines the stencil operation to use when depth fails
  10884. */
  10885. setStencilOperationDepthFail(operation: number): void;
  10886. /**
  10887. * Sets the stencil operation to use when stencil passes
  10888. * @param operation defines the stencil operation to use when stencil passes
  10889. */
  10890. setStencilOperationPass(operation: number): void;
  10891. /**
  10892. * Sets a boolean indicating if the dithering state is enabled or disabled
  10893. * @param value defines the dithering state
  10894. */
  10895. setDitheringState(value: boolean): void;
  10896. /**
  10897. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10898. * @param value defines the rasterizer state
  10899. */
  10900. setRasterizerState(value: boolean): void;
  10901. /**
  10902. * stop executing a render loop function and remove it from the execution array
  10903. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10904. */
  10905. stopRenderLoop(renderFunction?: () => void): void;
  10906. /** @hidden */
  10907. _renderLoop(): void;
  10908. /**
  10909. * Register and execute a render loop. The engine can have more than one render function
  10910. * @param renderFunction defines the function to continuously execute
  10911. */
  10912. runRenderLoop(renderFunction: () => void): void;
  10913. /**
  10914. * Toggle full screen mode
  10915. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10916. */
  10917. switchFullscreen(requestPointerLock: boolean): void;
  10918. /**
  10919. * Clear the current render buffer or the current render target (if any is set up)
  10920. * @param color defines the color to use
  10921. * @param backBuffer defines if the back buffer must be cleared
  10922. * @param depth defines if the depth buffer must be cleared
  10923. * @param stencil defines if the stencil buffer must be cleared
  10924. */
  10925. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10926. /**
  10927. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10928. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10929. * @param y defines the y-coordinate of the corner of the clear rectangle
  10930. * @param width defines the width of the clear rectangle
  10931. * @param height defines the height of the clear rectangle
  10932. * @param clearColor defines the clear color
  10933. */
  10934. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10935. private _viewportCached;
  10936. /** @hidden */
  10937. _viewport(x: number, y: number, width: number, height: number): void;
  10938. /**
  10939. * Set the WebGL's viewport
  10940. * @param viewport defines the viewport element to be used
  10941. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10942. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10943. */
  10944. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10945. /**
  10946. * Directly set the WebGL Viewport
  10947. * @param x defines the x coordinate of the viewport (in screen space)
  10948. * @param y defines the y coordinate of the viewport (in screen space)
  10949. * @param width defines the width of the viewport (in screen space)
  10950. * @param height defines the height of the viewport (in screen space)
  10951. * @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
  10952. */
  10953. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10954. /**
  10955. * Begin a new frame
  10956. */
  10957. beginFrame(): void;
  10958. /**
  10959. * Enf the current frame
  10960. */
  10961. endFrame(): void;
  10962. /**
  10963. * Resize the view according to the canvas' size
  10964. */
  10965. resize(): void;
  10966. /**
  10967. * Force a specific size of the canvas
  10968. * @param width defines the new canvas' width
  10969. * @param height defines the new canvas' height
  10970. */
  10971. setSize(width: number, height: number): void;
  10972. /**
  10973. * Gets a boolean indicating if a webVR device was detected
  10974. * @returns true if a webVR device was detected
  10975. */
  10976. isVRDevicePresent(): boolean;
  10977. /**
  10978. * Gets the current webVR device
  10979. * @returns the current webVR device (or null)
  10980. */
  10981. getVRDevice(): any;
  10982. /**
  10983. * Initializes a webVR display and starts listening to display change events
  10984. * The onVRDisplayChangedObservable will be notified upon these changes
  10985. * @returns The onVRDisplayChangedObservable
  10986. */
  10987. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10988. /**
  10989. * Initializes a webVR display and starts listening to display change events
  10990. * The onVRDisplayChangedObservable will be notified upon these changes
  10991. * @returns A promise containing a VRDisplay and if vr is supported
  10992. */
  10993. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10994. /**
  10995. * Call this function to switch to webVR mode
  10996. * Will do nothing if webVR is not supported or if there is no webVR device
  10997. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10998. */
  10999. enableVR(): void;
  11000. /**
  11001. * Call this function to leave webVR mode
  11002. * Will do nothing if webVR is not supported or if there is no webVR device
  11003. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11004. */
  11005. disableVR(): void;
  11006. private _onVRFullScreenTriggered;
  11007. private _getVRDisplaysAsync;
  11008. /**
  11009. * Binds the frame buffer to the specified texture.
  11010. * @param texture The texture to render to or null for the default canvas
  11011. * @param faceIndex The face of the texture to render to in case of cube texture
  11012. * @param requiredWidth The width of the target to render to
  11013. * @param requiredHeight The height of the target to render to
  11014. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11015. * @param depthStencilTexture The depth stencil texture to use to render
  11016. * @param lodLevel defines le lod level to bind to the frame buffer
  11017. */
  11018. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11019. private bindUnboundFramebuffer;
  11020. /**
  11021. * Unbind the current render target texture from the webGL context
  11022. * @param texture defines the render target texture to unbind
  11023. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11024. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11025. */
  11026. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11027. /**
  11028. * Unbind a list of render target textures from the webGL context
  11029. * This is used only when drawBuffer extension or webGL2 are active
  11030. * @param textures defines the render target textures to unbind
  11031. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11032. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11033. */
  11034. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11035. /**
  11036. * Force the mipmap generation for the given render target texture
  11037. * @param texture defines the render target texture to use
  11038. */
  11039. generateMipMapsForCubemap(texture: InternalTexture): void;
  11040. /**
  11041. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11042. */
  11043. flushFramebuffer(): void;
  11044. /**
  11045. * Unbind the current render target and bind the default framebuffer
  11046. */
  11047. restoreDefaultFramebuffer(): void;
  11048. /**
  11049. * Create an uniform buffer
  11050. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11051. * @param elements defines the content of the uniform buffer
  11052. * @returns the webGL uniform buffer
  11053. */
  11054. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11055. /**
  11056. * Create a dynamic uniform buffer
  11057. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11058. * @param elements defines the content of the uniform buffer
  11059. * @returns the webGL uniform buffer
  11060. */
  11061. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11062. /**
  11063. * Update an existing uniform buffer
  11064. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11065. * @param uniformBuffer defines the target uniform buffer
  11066. * @param elements defines the content to update
  11067. * @param offset defines the offset in the uniform buffer where update should start
  11068. * @param count defines the size of the data to update
  11069. */
  11070. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11071. private _resetVertexBufferBinding;
  11072. /**
  11073. * Creates a vertex buffer
  11074. * @param data the data for the vertex buffer
  11075. * @returns the new WebGL static buffer
  11076. */
  11077. createVertexBuffer(data: DataArray): WebGLBuffer;
  11078. /**
  11079. * Creates a dynamic vertex buffer
  11080. * @param data the data for the dynamic vertex buffer
  11081. * @returns the new WebGL dynamic buffer
  11082. */
  11083. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11084. /**
  11085. * Update a dynamic index buffer
  11086. * @param indexBuffer defines the target index buffer
  11087. * @param indices defines the data to update
  11088. * @param offset defines the offset in the target index buffer where update should start
  11089. */
  11090. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11091. /**
  11092. * Updates a dynamic vertex buffer.
  11093. * @param vertexBuffer the vertex buffer to update
  11094. * @param data the data used to update the vertex buffer
  11095. * @param byteOffset the byte offset of the data
  11096. * @param byteLength the byte length of the data
  11097. */
  11098. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11099. private _resetIndexBufferBinding;
  11100. /**
  11101. * Creates a new index buffer
  11102. * @param indices defines the content of the index buffer
  11103. * @param updatable defines if the index buffer must be updatable
  11104. * @returns a new webGL buffer
  11105. */
  11106. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11107. /**
  11108. * Bind a webGL buffer to the webGL context
  11109. * @param buffer defines the buffer to bind
  11110. */
  11111. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11112. /**
  11113. * Bind an uniform buffer to the current webGL context
  11114. * @param buffer defines the buffer to bind
  11115. */
  11116. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11117. /**
  11118. * Bind a buffer to the current webGL context at a given location
  11119. * @param buffer defines the buffer to bind
  11120. * @param location defines the index where to bind the buffer
  11121. */
  11122. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11123. /**
  11124. * Bind a specific block at a given index in a specific shader program
  11125. * @param shaderProgram defines the shader program
  11126. * @param blockName defines the block name
  11127. * @param index defines the index where to bind the block
  11128. */
  11129. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11130. private bindIndexBuffer;
  11131. private bindBuffer;
  11132. /**
  11133. * update the bound buffer with the given data
  11134. * @param data defines the data to update
  11135. */
  11136. updateArrayBuffer(data: Float32Array): void;
  11137. private _vertexAttribPointer;
  11138. private _bindIndexBufferWithCache;
  11139. private _bindVertexBuffersAttributes;
  11140. /**
  11141. * Records a vertex array object
  11142. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11143. * @param vertexBuffers defines the list of vertex buffers to store
  11144. * @param indexBuffer defines the index buffer to store
  11145. * @param effect defines the effect to store
  11146. * @returns the new vertex array object
  11147. */
  11148. recordVertexArrayObject(vertexBuffers: {
  11149. [key: string]: VertexBuffer;
  11150. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11151. /**
  11152. * Bind a specific vertex array object
  11153. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11154. * @param vertexArrayObject defines the vertex array object to bind
  11155. * @param indexBuffer defines the index buffer to bind
  11156. */
  11157. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11158. /**
  11159. * Bind webGl buffers directly to the webGL context
  11160. * @param vertexBuffer defines the vertex buffer to bind
  11161. * @param indexBuffer defines the index buffer to bind
  11162. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11163. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11164. * @param effect defines the effect associated with the vertex buffer
  11165. */
  11166. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11167. private _unbindVertexArrayObject;
  11168. /**
  11169. * Bind a list of vertex buffers to the webGL context
  11170. * @param vertexBuffers defines the list of vertex buffers to bind
  11171. * @param indexBuffer defines the index buffer to bind
  11172. * @param effect defines the effect associated with the vertex buffers
  11173. */
  11174. bindBuffers(vertexBuffers: {
  11175. [key: string]: Nullable<VertexBuffer>;
  11176. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11177. /**
  11178. * Unbind all instance attributes
  11179. */
  11180. unbindInstanceAttributes(): void;
  11181. /**
  11182. * Release and free the memory of a vertex array object
  11183. * @param vao defines the vertex array object to delete
  11184. */
  11185. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11186. /** @hidden */
  11187. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11188. /**
  11189. * Creates a webGL buffer to use with instanciation
  11190. * @param capacity defines the size of the buffer
  11191. * @returns the webGL buffer
  11192. */
  11193. createInstancesBuffer(capacity: number): WebGLBuffer;
  11194. /**
  11195. * Delete a webGL buffer used with instanciation
  11196. * @param buffer defines the webGL buffer to delete
  11197. */
  11198. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11199. /**
  11200. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11201. * @param instancesBuffer defines the webGL buffer to update and bind
  11202. * @param data defines the data to store in the buffer
  11203. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11204. */
  11205. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11206. /**
  11207. * Apply all cached states (depth, culling, stencil and alpha)
  11208. */
  11209. applyStates(): void;
  11210. /**
  11211. * Send a draw order
  11212. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11213. * @param indexStart defines the starting index
  11214. * @param indexCount defines the number of index to draw
  11215. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11216. */
  11217. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11218. /**
  11219. * Draw a list of points
  11220. * @param verticesStart defines the index of first vertex to draw
  11221. * @param verticesCount defines the count of vertices to draw
  11222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11223. */
  11224. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11225. /**
  11226. * Draw a list of unindexed primitives
  11227. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11228. * @param verticesStart defines the index of first vertex to draw
  11229. * @param verticesCount defines the count of vertices to draw
  11230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11231. */
  11232. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11233. /**
  11234. * Draw a list of indexed primitives
  11235. * @param fillMode defines the primitive to use
  11236. * @param indexStart defines the starting index
  11237. * @param indexCount defines the number of index to draw
  11238. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11239. */
  11240. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11241. /**
  11242. * Draw a list of unindexed primitives
  11243. * @param fillMode defines the primitive to use
  11244. * @param verticesStart defines the index of first vertex to draw
  11245. * @param verticesCount defines the count of vertices to draw
  11246. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11247. */
  11248. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11249. private _drawMode;
  11250. /** @hidden */
  11251. _releaseEffect(effect: Effect): void;
  11252. /** @hidden */
  11253. _deleteProgram(program: WebGLProgram): void;
  11254. /**
  11255. * Create a new effect (used to store vertex/fragment shaders)
  11256. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11257. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11258. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11259. * @param samplers defines an array of string used to represent textures
  11260. * @param defines defines the string containing the defines to use to compile the shaders
  11261. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11262. * @param onCompiled defines a function to call when the effect creation is successful
  11263. * @param onError defines a function to call when the effect creation has failed
  11264. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11265. * @returns the new Effect
  11266. */
  11267. 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;
  11268. private _compileShader;
  11269. private _compileRawShader;
  11270. /**
  11271. * Directly creates a webGL program
  11272. * @param vertexCode defines the vertex shader code to use
  11273. * @param fragmentCode defines the fragment shader code to use
  11274. * @param context defines the webGL context to use (if not set, the current one will be used)
  11275. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11276. * @returns the new webGL program
  11277. */
  11278. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11279. /**
  11280. * Creates a webGL program
  11281. * @param vertexCode defines the vertex shader code to use
  11282. * @param fragmentCode defines the fragment shader code to use
  11283. * @param defines defines the string containing the defines to use to compile the shaders
  11284. * @param context defines the webGL context to use (if not set, the current one will be used)
  11285. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11286. * @returns the new webGL program
  11287. */
  11288. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11289. private _createShaderProgram;
  11290. private _finalizeProgram;
  11291. /** @hidden */
  11292. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11293. /** @hidden */
  11294. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11295. /**
  11296. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11297. * @param shaderProgram defines the webGL program to use
  11298. * @param uniformsNames defines the list of uniform names
  11299. * @returns an array of webGL uniform locations
  11300. */
  11301. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11302. /**
  11303. * Gets the lsit of active attributes for a given webGL program
  11304. * @param shaderProgram defines the webGL program to use
  11305. * @param attributesNames defines the list of attribute names to get
  11306. * @returns an array of indices indicating the offset of each attribute
  11307. */
  11308. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11309. /**
  11310. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11311. * @param effect defines the effect to activate
  11312. */
  11313. enableEffect(effect: Nullable<Effect>): void;
  11314. /**
  11315. * Set the value of an uniform to an array of int32
  11316. * @param uniform defines the webGL uniform location where to store the value
  11317. * @param array defines the array of int32 to store
  11318. */
  11319. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11320. /**
  11321. * Set the value of an uniform to an array of int32 (stored as vec2)
  11322. * @param uniform defines the webGL uniform location where to store the value
  11323. * @param array defines the array of int32 to store
  11324. */
  11325. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11326. /**
  11327. * Set the value of an uniform to an array of int32 (stored as vec3)
  11328. * @param uniform defines the webGL uniform location where to store the value
  11329. * @param array defines the array of int32 to store
  11330. */
  11331. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11332. /**
  11333. * Set the value of an uniform to an array of int32 (stored as vec4)
  11334. * @param uniform defines the webGL uniform location where to store the value
  11335. * @param array defines the array of int32 to store
  11336. */
  11337. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11338. /**
  11339. * Set the value of an uniform to an array of float32
  11340. * @param uniform defines the webGL uniform location where to store the value
  11341. * @param array defines the array of float32 to store
  11342. */
  11343. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11344. /**
  11345. * Set the value of an uniform to an array of float32 (stored as vec2)
  11346. * @param uniform defines the webGL uniform location where to store the value
  11347. * @param array defines the array of float32 to store
  11348. */
  11349. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11350. /**
  11351. * Set the value of an uniform to an array of float32 (stored as vec3)
  11352. * @param uniform defines the webGL uniform location where to store the value
  11353. * @param array defines the array of float32 to store
  11354. */
  11355. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11356. /**
  11357. * Set the value of an uniform to an array of float32 (stored as vec4)
  11358. * @param uniform defines the webGL uniform location where to store the value
  11359. * @param array defines the array of float32 to store
  11360. */
  11361. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11362. /**
  11363. * Set the value of an uniform to an array of number
  11364. * @param uniform defines the webGL uniform location where to store the value
  11365. * @param array defines the array of number to store
  11366. */
  11367. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11368. /**
  11369. * Set the value of an uniform to an array of number (stored as vec2)
  11370. * @param uniform defines the webGL uniform location where to store the value
  11371. * @param array defines the array of number to store
  11372. */
  11373. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11374. /**
  11375. * Set the value of an uniform to an array of number (stored as vec3)
  11376. * @param uniform defines the webGL uniform location where to store the value
  11377. * @param array defines the array of number to store
  11378. */
  11379. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11380. /**
  11381. * Set the value of an uniform to an array of number (stored as vec4)
  11382. * @param uniform defines the webGL uniform location where to store the value
  11383. * @param array defines the array of number to store
  11384. */
  11385. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11386. /**
  11387. * Set the value of an uniform to an array of float32 (stored as matrices)
  11388. * @param uniform defines the webGL uniform location where to store the value
  11389. * @param matrices defines the array of float32 to store
  11390. */
  11391. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11392. /**
  11393. * Set the value of an uniform to a matrix
  11394. * @param uniform defines the webGL uniform location where to store the value
  11395. * @param matrix defines the matrix to store
  11396. */
  11397. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11398. /**
  11399. * Set the value of an uniform to a matrix (3x3)
  11400. * @param uniform defines the webGL uniform location where to store the value
  11401. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11402. */
  11403. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11404. /**
  11405. * Set the value of an uniform to a matrix (2x2)
  11406. * @param uniform defines the webGL uniform location where to store the value
  11407. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11408. */
  11409. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11410. /**
  11411. * Set the value of an uniform to a number (int)
  11412. * @param uniform defines the webGL uniform location where to store the value
  11413. * @param value defines the int number to store
  11414. */
  11415. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11416. /**
  11417. * Set the value of an uniform to a number (float)
  11418. * @param uniform defines the webGL uniform location where to store the value
  11419. * @param value defines the float number to store
  11420. */
  11421. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11422. /**
  11423. * Set the value of an uniform to a vec2
  11424. * @param uniform defines the webGL uniform location where to store the value
  11425. * @param x defines the 1st component of the value
  11426. * @param y defines the 2nd component of the value
  11427. */
  11428. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11429. /**
  11430. * Set the value of an uniform to a vec3
  11431. * @param uniform defines the webGL uniform location where to store the value
  11432. * @param x defines the 1st component of the value
  11433. * @param y defines the 2nd component of the value
  11434. * @param z defines the 3rd component of the value
  11435. */
  11436. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11437. /**
  11438. * Set the value of an uniform to a boolean
  11439. * @param uniform defines the webGL uniform location where to store the value
  11440. * @param bool defines the boolean to store
  11441. */
  11442. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11443. /**
  11444. * Set the value of an uniform to a vec4
  11445. * @param uniform defines the webGL uniform location where to store the value
  11446. * @param x defines the 1st component of the value
  11447. * @param y defines the 2nd component of the value
  11448. * @param z defines the 3rd component of the value
  11449. * @param w defines the 4th component of the value
  11450. */
  11451. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11452. /**
  11453. * Set the value of an uniform to a Color3
  11454. * @param uniform defines the webGL uniform location where to store the value
  11455. * @param color3 defines the color to store
  11456. */
  11457. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11458. /**
  11459. * Set the value of an uniform to a Color3 and an alpha value
  11460. * @param uniform defines the webGL uniform location where to store the value
  11461. * @param color3 defines the color to store
  11462. * @param alpha defines the alpha component to store
  11463. */
  11464. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11465. /**
  11466. * Sets a Color4 on a uniform variable
  11467. * @param uniform defines the uniform location
  11468. * @param color4 defines the value to be set
  11469. */
  11470. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11471. /**
  11472. * Set various states to the webGL context
  11473. * @param culling defines backface culling state
  11474. * @param zOffset defines the value to apply to zOffset (0 by default)
  11475. * @param force defines if states must be applied even if cache is up to date
  11476. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11477. */
  11478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11479. /**
  11480. * Set the z offset to apply to current rendering
  11481. * @param value defines the offset to apply
  11482. */
  11483. setZOffset(value: number): void;
  11484. /**
  11485. * Gets the current value of the zOffset
  11486. * @returns the current zOffset state
  11487. */
  11488. getZOffset(): number;
  11489. /**
  11490. * Enable or disable depth buffering
  11491. * @param enable defines the state to set
  11492. */
  11493. setDepthBuffer(enable: boolean): void;
  11494. /**
  11495. * Gets a boolean indicating if depth writing is enabled
  11496. * @returns the current depth writing state
  11497. */
  11498. getDepthWrite(): boolean;
  11499. /**
  11500. * Enable or disable depth writing
  11501. * @param enable defines the state to set
  11502. */
  11503. setDepthWrite(enable: boolean): void;
  11504. /**
  11505. * Enable or disable color writing
  11506. * @param enable defines the state to set
  11507. */
  11508. setColorWrite(enable: boolean): void;
  11509. /**
  11510. * Gets a boolean indicating if color writing is enabled
  11511. * @returns the current color writing state
  11512. */
  11513. getColorWrite(): boolean;
  11514. /**
  11515. * Sets alpha constants used by some alpha blending modes
  11516. * @param r defines the red component
  11517. * @param g defines the green component
  11518. * @param b defines the blue component
  11519. * @param a defines the alpha component
  11520. */
  11521. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11522. /**
  11523. * Sets the current alpha mode
  11524. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11526. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11527. */
  11528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11529. /**
  11530. * Gets the current alpha mode
  11531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11532. * @returns the current alpha mode
  11533. */
  11534. getAlphaMode(): number;
  11535. /**
  11536. * Clears the list of texture accessible through engine.
  11537. * This can help preventing texture load conflict due to name collision.
  11538. */
  11539. clearInternalTexturesCache(): void;
  11540. /**
  11541. * Force the entire cache to be cleared
  11542. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11543. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11544. */
  11545. wipeCaches(bruteForce?: boolean): void;
  11546. /**
  11547. * Set the compressed texture format to use, based on the formats you have, and the formats
  11548. * supported by the hardware / browser.
  11549. *
  11550. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11551. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11552. * to API arguments needed to compressed textures. This puts the burden on the container
  11553. * generator to house the arcane code for determining these for current & future formats.
  11554. *
  11555. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11556. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11557. *
  11558. * Note: The result of this call is not taken into account when a texture is base64.
  11559. *
  11560. * @param formatsAvailable defines the list of those format families you have created
  11561. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11562. *
  11563. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11564. * @returns The extension selected.
  11565. */
  11566. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11567. private _getSamplingParameters;
  11568. private _partialLoadImg;
  11569. private _cascadeLoadImgs;
  11570. /** @hidden */
  11571. _createTexture(): WebGLTexture;
  11572. /**
  11573. * Usually called from BABYLON.Texture.ts.
  11574. * Passed information to create a WebGLTexture
  11575. * @param urlArg defines a value which contains one of the following:
  11576. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11577. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11578. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11579. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11580. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11581. * @param scene needed for loading to the correct scene
  11582. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11583. * @param onLoad optional callback to be called upon successful completion
  11584. * @param onError optional callback to be called upon failure
  11585. * @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
  11586. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11587. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11588. * @param forcedExtension defines the extension to use to pick the right loader
  11589. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11590. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11591. */
  11592. 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;
  11593. private _rescaleTexture;
  11594. /**
  11595. * Update a raw texture
  11596. * @param texture defines the texture to update
  11597. * @param data defines the data to store in the texture
  11598. * @param format defines the format of the data
  11599. * @param invertY defines if data must be stored with Y axis inverted
  11600. * @param compression defines the compression used (null by default)
  11601. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11602. */
  11603. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11604. /**
  11605. * Creates a raw texture
  11606. * @param data defines the data to store in the texture
  11607. * @param width defines the width of the texture
  11608. * @param height defines the height of the texture
  11609. * @param format defines the format of the data
  11610. * @param generateMipMaps defines if the engine should generate the mip levels
  11611. * @param invertY defines if data must be stored with Y axis inverted
  11612. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11613. * @param compression defines the compression used (null by default)
  11614. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11615. * @returns the raw texture inside an InternalTexture
  11616. */
  11617. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11618. private _unpackFlipYCached;
  11619. /**
  11620. * In case you are sharing the context with other applications, it might
  11621. * be interested to not cache the unpack flip y state to ensure a consistent
  11622. * value would be set.
  11623. */
  11624. enableUnpackFlipYCached: boolean;
  11625. /** @hidden */
  11626. _unpackFlipY(value: boolean): void;
  11627. /** @hidden */
  11628. _getUnpackAlignement(): number;
  11629. /**
  11630. * Creates a dynamic texture
  11631. * @param width defines the width of the texture
  11632. * @param height defines the height of the texture
  11633. * @param generateMipMaps defines if the engine should generate the mip levels
  11634. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11635. * @returns the dynamic texture inside an InternalTexture
  11636. */
  11637. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11638. /**
  11639. * Update the sampling mode of a given texture
  11640. * @param samplingMode defines the required sampling mode
  11641. * @param texture defines the texture to update
  11642. */
  11643. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11644. /**
  11645. * Update the content of a dynamic texture
  11646. * @param texture defines the texture to update
  11647. * @param canvas defines the canvas containing the source
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. * @param premulAlpha defines if alpha is stored as premultiplied
  11650. * @param format defines the format of the data
  11651. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11652. */
  11653. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11654. /**
  11655. * Update a video texture
  11656. * @param texture defines the texture to update
  11657. * @param video defines the video element to use
  11658. * @param invertY defines if data must be stored with Y axis inverted
  11659. */
  11660. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11661. /**
  11662. * Updates a depth texture Comparison Mode and Function.
  11663. * If the comparison Function is equal to 0, the mode will be set to none.
  11664. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11665. * @param texture The texture to set the comparison function for
  11666. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11667. */
  11668. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11669. private _setupDepthStencilTexture;
  11670. /**
  11671. * Creates a depth stencil texture.
  11672. * This is only available in WebGL 2 or with the depth texture extension available.
  11673. * @param size The size of face edge in the texture.
  11674. * @param options The options defining the texture.
  11675. * @returns The texture
  11676. */
  11677. createDepthStencilTexture(size: number | {
  11678. width: number;
  11679. height: number;
  11680. }, options: DepthTextureCreationOptions): InternalTexture;
  11681. /**
  11682. * Creates a depth stencil texture.
  11683. * This is only available in WebGL 2 or with the depth texture extension available.
  11684. * @param size The size of face edge in the texture.
  11685. * @param options The options defining the texture.
  11686. * @returns The texture
  11687. */
  11688. private _createDepthStencilTexture;
  11689. /**
  11690. * Creates a depth stencil cube texture.
  11691. * This is only available in WebGL 2.
  11692. * @param size The size of face edge in the cube texture.
  11693. * @param options The options defining the cube texture.
  11694. * @returns The cube texture
  11695. */
  11696. private _createDepthStencilCubeTexture;
  11697. /**
  11698. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11699. * @param renderTarget The render target to set the frame buffer for
  11700. */
  11701. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11702. /**
  11703. * Creates a new render target texture
  11704. * @param size defines the size of the texture
  11705. * @param options defines the options used to create the texture
  11706. * @returns a new render target texture stored in an InternalTexture
  11707. */
  11708. createRenderTargetTexture(size: number | {
  11709. width: number;
  11710. height: number;
  11711. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11712. /**
  11713. * Create a multi render target texture
  11714. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11715. * @param size defines the size of the texture
  11716. * @param options defines the creation options
  11717. * @returns the cube texture as an InternalTexture
  11718. */
  11719. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11720. private _setupFramebufferDepthAttachments;
  11721. /**
  11722. * Updates the sample count of a render target texture
  11723. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11724. * @param texture defines the texture to update
  11725. * @param samples defines the sample count to set
  11726. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11727. */
  11728. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11729. /**
  11730. * Update the sample count for a given multiple render target texture
  11731. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11732. * @param textures defines the textures to update
  11733. * @param samples defines the sample count to set
  11734. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11735. */
  11736. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11737. /** @hidden */
  11738. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11739. /** @hidden */
  11740. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11741. /** @hidden */
  11742. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11743. /** @hidden */
  11744. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11745. /**
  11746. * Creates a new render target cube texture
  11747. * @param size defines the size of the texture
  11748. * @param options defines the options used to create the texture
  11749. * @returns a new render target cube texture stored in an InternalTexture
  11750. */
  11751. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11752. /**
  11753. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11754. * @param rootUrl defines the url where the file to load is located
  11755. * @param scene defines the current scene
  11756. * @param lodScale defines scale to apply to the mip map selection
  11757. * @param lodOffset defines offset to apply to the mip map selection
  11758. * @param onLoad defines an optional callback raised when the texture is loaded
  11759. * @param onError defines an optional callback raised if there is an issue to load the texture
  11760. * @param format defines the format of the data
  11761. * @param forcedExtension defines the extension to use to pick the right loader
  11762. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11763. * @returns the cube texture as an InternalTexture
  11764. */
  11765. 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;
  11766. /**
  11767. * Creates a cube texture
  11768. * @param rootUrl defines the url where the files to load is located
  11769. * @param scene defines the current scene
  11770. * @param files defines the list of files to load (1 per face)
  11771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11772. * @param onLoad defines an optional callback raised when the texture is loaded
  11773. * @param onError defines an optional callback raised if there is an issue to load the texture
  11774. * @param format defines the format of the data
  11775. * @param forcedExtension defines the extension to use to pick the right loader
  11776. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11777. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11778. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11779. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11780. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11781. * @returns the cube texture as an InternalTexture
  11782. */
  11783. 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;
  11784. /**
  11785. * @hidden
  11786. */
  11787. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11788. /**
  11789. * Update a raw cube texture
  11790. * @param texture defines the texture to udpdate
  11791. * @param data defines the data to store
  11792. * @param format defines the data format
  11793. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11794. * @param invertY defines if data must be stored with Y axis inverted
  11795. * @param compression defines the compression used (null by default)
  11796. * @param level defines which level of the texture to update
  11797. */
  11798. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11799. /**
  11800. * Creates a new raw cube texture
  11801. * @param data defines the array of data to use to create each face
  11802. * @param size defines the size of the textures
  11803. * @param format defines the format of the data
  11804. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11805. * @param generateMipMaps defines if the engine should generate the mip levels
  11806. * @param invertY defines if data must be stored with Y axis inverted
  11807. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11808. * @param compression defines the compression used (null by default)
  11809. * @returns the cube texture as an InternalTexture
  11810. */
  11811. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11812. /**
  11813. * Creates a new raw cube texture from a specified url
  11814. * @param url defines the url where the data is located
  11815. * @param scene defines the current scene
  11816. * @param size defines the size of the textures
  11817. * @param format defines the format of the data
  11818. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11819. * @param noMipmap defines if the engine should avoid generating the mip levels
  11820. * @param callback defines a callback used to extract texture data from loaded data
  11821. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11822. * @param onLoad defines a callback called when texture is loaded
  11823. * @param onError defines a callback called if there is an error
  11824. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11825. * @param invertY defines if data must be stored with Y axis inverted
  11826. * @returns the cube texture as an InternalTexture
  11827. */
  11828. 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;
  11829. /**
  11830. * Update a raw 3D texture
  11831. * @param texture defines the texture to update
  11832. * @param data defines the data to store
  11833. * @param format defines the data format
  11834. * @param invertY defines if data must be stored with Y axis inverted
  11835. * @param compression defines the used compression (can be null)
  11836. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11837. */
  11838. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11839. /**
  11840. * Creates a new raw 3D texture
  11841. * @param data defines the data used to create the texture
  11842. * @param width defines the width of the texture
  11843. * @param height defines the height of the texture
  11844. * @param depth defines the depth of the texture
  11845. * @param format defines the format of the texture
  11846. * @param generateMipMaps defines if the engine must generate mip levels
  11847. * @param invertY defines if data must be stored with Y axis inverted
  11848. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11849. * @param compression defines the compressed used (can be null)
  11850. * @param textureType defines the compressed used (can be null)
  11851. * @returns a new raw 3D texture (stored in an InternalTexture)
  11852. */
  11853. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11854. private _prepareWebGLTextureContinuation;
  11855. private _prepareWebGLTexture;
  11856. private _convertRGBtoRGBATextureData;
  11857. /** @hidden */
  11858. _releaseFramebufferObjects(texture: InternalTexture): void;
  11859. /** @hidden */
  11860. _releaseTexture(texture: InternalTexture): void;
  11861. private setProgram;
  11862. private _boundUniforms;
  11863. /**
  11864. * Binds an effect to the webGL context
  11865. * @param effect defines the effect to bind
  11866. */
  11867. bindSamplers(effect: Effect): void;
  11868. private _moveBoundTextureOnTop;
  11869. private _getCorrectTextureChannel;
  11870. private _linkTrackers;
  11871. private _removeDesignatedSlot;
  11872. private _activateCurrentTexture;
  11873. /** @hidden */
  11874. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11875. /** @hidden */
  11876. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11877. /**
  11878. * Sets a texture to the webGL context from a postprocess
  11879. * @param channel defines the channel to use
  11880. * @param postProcess defines the source postprocess
  11881. */
  11882. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11883. /**
  11884. * Binds the output of the passed in post process to the texture channel specified
  11885. * @param channel The channel the texture should be bound to
  11886. * @param postProcess The post process which's output should be bound
  11887. */
  11888. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11889. /**
  11890. * Unbind all textures from the webGL context
  11891. */
  11892. unbindAllTextures(): void;
  11893. /**
  11894. * Sets a texture to the according uniform.
  11895. * @param channel The texture channel
  11896. * @param uniform The uniform to set
  11897. * @param texture The texture to apply
  11898. */
  11899. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11900. /**
  11901. * Sets a depth stencil texture from a render target to the according uniform.
  11902. * @param channel The texture channel
  11903. * @param uniform The uniform to set
  11904. * @param texture The render target texture containing the depth stencil texture to apply
  11905. */
  11906. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11907. private _bindSamplerUniformToChannel;
  11908. private _getTextureWrapMode;
  11909. private _setTexture;
  11910. /**
  11911. * Sets an array of texture to the webGL context
  11912. * @param channel defines the channel where the texture array must be set
  11913. * @param uniform defines the associated uniform location
  11914. * @param textures defines the array of textures to bind
  11915. */
  11916. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11917. /** @hidden */
  11918. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11919. private _setTextureParameterFloat;
  11920. private _setTextureParameterInteger;
  11921. /**
  11922. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11923. * @param x defines the x coordinate of the rectangle where pixels must be read
  11924. * @param y defines the y coordinate of the rectangle where pixels must be read
  11925. * @param width defines the width of the rectangle where pixels must be read
  11926. * @param height defines the height of the rectangle where pixels must be read
  11927. * @returns a Uint8Array containing RGBA colors
  11928. */
  11929. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11930. /**
  11931. * Add an externaly attached data from its key.
  11932. * This method call will fail and return false, if such key already exists.
  11933. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11934. * @param key the unique key that identifies the data
  11935. * @param data the data object to associate to the key for this Engine instance
  11936. * @return true if no such key were already present and the data was added successfully, false otherwise
  11937. */
  11938. addExternalData<T>(key: string, data: T): boolean;
  11939. /**
  11940. * Get an externaly attached data from its key
  11941. * @param key the unique key that identifies the data
  11942. * @return the associated data, if present (can be null), or undefined if not present
  11943. */
  11944. getExternalData<T>(key: string): T;
  11945. /**
  11946. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11947. * @param key the unique key that identifies the data
  11948. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11949. * @return the associated data, can be null if the factory returned null.
  11950. */
  11951. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11952. /**
  11953. * Remove an externaly attached data from the Engine instance
  11954. * @param key the unique key that identifies the data
  11955. * @return true if the data was successfully removed, false if it doesn't exist
  11956. */
  11957. removeExternalData(key: string): boolean;
  11958. /**
  11959. * Unbind all vertex attributes from the webGL context
  11960. */
  11961. unbindAllAttributes(): void;
  11962. /**
  11963. * 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
  11964. */
  11965. releaseEffects(): void;
  11966. /**
  11967. * Dispose and release all associated resources
  11968. */
  11969. dispose(): void;
  11970. /**
  11971. * Display the loading screen
  11972. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11973. */
  11974. displayLoadingUI(): void;
  11975. /**
  11976. * Hide the loading screen
  11977. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11978. */
  11979. hideLoadingUI(): void;
  11980. /**
  11981. * Gets the current loading screen object
  11982. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11983. */
  11984. /**
  11985. * Sets the current loading screen object
  11986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11987. */
  11988. loadingScreen: ILoadingScreen;
  11989. /**
  11990. * Sets the current loading screen text
  11991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11992. */
  11993. loadingUIText: string;
  11994. /**
  11995. * Sets the current loading screen background color
  11996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11997. */
  11998. loadingUIBackgroundColor: string;
  11999. /**
  12000. * Attach a new callback raised when context lost event is fired
  12001. * @param callback defines the callback to call
  12002. */
  12003. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12004. /**
  12005. * Attach a new callback raised when context restored event is fired
  12006. * @param callback defines the callback to call
  12007. */
  12008. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12009. /**
  12010. * Gets the source code of the vertex shader associated with a specific webGL program
  12011. * @param program defines the program to use
  12012. * @returns a string containing the source code of the vertex shader associated with the program
  12013. */
  12014. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12015. /**
  12016. * Gets the source code of the fragment shader associated with a specific webGL program
  12017. * @param program defines the program to use
  12018. * @returns a string containing the source code of the fragment shader associated with the program
  12019. */
  12020. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12021. /**
  12022. * Get the current error code of the webGL context
  12023. * @returns the error code
  12024. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12025. */
  12026. getError(): number;
  12027. /**
  12028. * Gets the current framerate
  12029. * @returns a number representing the framerate
  12030. */
  12031. getFps(): number;
  12032. /**
  12033. * Gets the time spent between current and previous frame
  12034. * @returns a number representing the delta time in ms
  12035. */
  12036. getDeltaTime(): number;
  12037. private _measureFps;
  12038. /** @hidden */
  12039. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12040. private _canRenderToFloatFramebuffer;
  12041. private _canRenderToHalfFloatFramebuffer;
  12042. private _canRenderToFramebuffer;
  12043. /** @hidden */
  12044. _getWebGLTextureType(type: number): number;
  12045. private _getInternalFormat;
  12046. /** @hidden */
  12047. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12048. /** @hidden */
  12049. _getRGBAMultiSampleBufferFormat(type: number): number;
  12050. /** @hidden */
  12051. _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;
  12052. /** @hidden */
  12053. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12054. private _partialLoadFile;
  12055. private _cascadeLoadFiles;
  12056. /**
  12057. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12058. * @returns true if the engine can be created
  12059. * @ignorenaming
  12060. */
  12061. static isSupported(): boolean;
  12062. }
  12063. }
  12064. declare module BABYLON {
  12065. /**
  12066. * Options to create the null engine
  12067. */
  12068. class NullEngineOptions {
  12069. /**
  12070. * Render width (Default: 512)
  12071. */
  12072. renderWidth: number;
  12073. /**
  12074. * Render height (Default: 256)
  12075. */
  12076. renderHeight: number;
  12077. /**
  12078. * Texture size (Default: 512)
  12079. */
  12080. textureSize: number;
  12081. /**
  12082. * If delta time between frames should be constant
  12083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12084. */
  12085. deterministicLockstep: boolean;
  12086. /**
  12087. * Maximum about of steps between frames (Default: 4)
  12088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12089. */
  12090. lockstepMaxSteps: number;
  12091. }
  12092. /**
  12093. * The null engine class provides support for headless version of babylon.js.
  12094. * This can be used in server side scenario or for testing purposes
  12095. */
  12096. class NullEngine extends Engine {
  12097. private _options;
  12098. /**
  12099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12100. */
  12101. isDeterministicLockStep(): boolean;
  12102. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12103. getLockstepMaxSteps(): number;
  12104. /**
  12105. * Sets hardware scaling, used to save performance if needed
  12106. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12107. */
  12108. getHardwareScalingLevel(): number;
  12109. constructor(options?: NullEngineOptions);
  12110. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12111. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12112. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12113. getRenderWidth(useScreen?: boolean): number;
  12114. getRenderHeight(useScreen?: boolean): number;
  12115. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12116. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12117. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12118. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12119. bindSamplers(effect: Effect): void;
  12120. enableEffect(effect: Effect): void;
  12121. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12122. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12123. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12124. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12125. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12126. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12127. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12128. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12129. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12130. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12131. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12132. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12133. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12134. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12135. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12136. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12137. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12138. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12139. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12140. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12141. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12142. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12143. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12144. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12145. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12146. bindBuffers(vertexBuffers: {
  12147. [key: string]: VertexBuffer;
  12148. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12149. wipeCaches(bruteForce?: boolean): void;
  12150. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12151. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12152. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12153. /** @hidden */
  12154. _createTexture(): WebGLTexture;
  12155. /** @hidden */
  12156. _releaseTexture(texture: InternalTexture): void;
  12157. 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;
  12158. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12159. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12160. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12161. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12162. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12163. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12164. areAllEffectsReady(): boolean;
  12165. /**
  12166. * @hidden
  12167. * Get the current error code of the webGL context
  12168. * @returns the error code
  12169. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12170. */
  12171. getError(): number;
  12172. /** @hidden */
  12173. _getUnpackAlignement(): number;
  12174. /** @hidden */
  12175. _unpackFlipY(value: boolean): void;
  12176. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12177. /**
  12178. * Updates a dynamic vertex buffer.
  12179. * @param vertexBuffer the vertex buffer to update
  12180. * @param data the data used to update the vertex buffer
  12181. * @param byteOffset the byte offset of the data (optional)
  12182. * @param byteLength the byte length of the data (optional)
  12183. */
  12184. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12185. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12186. /** @hidden */
  12187. _bindTexture(channel: number, texture: InternalTexture): void;
  12188. /** @hidden */
  12189. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12190. releaseEffects(): void;
  12191. displayLoadingUI(): void;
  12192. hideLoadingUI(): void;
  12193. /** @hidden */
  12194. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12195. /** @hidden */
  12196. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12197. /** @hidden */
  12198. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12199. /** @hidden */
  12200. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12201. }
  12202. }
  12203. interface WebGLRenderingContext {
  12204. readonly RASTERIZER_DISCARD: number;
  12205. readonly DEPTH_COMPONENT24: number;
  12206. readonly TEXTURE_3D: number;
  12207. readonly TEXTURE_2D_ARRAY: number;
  12208. readonly TEXTURE_COMPARE_FUNC: number;
  12209. readonly TEXTURE_COMPARE_MODE: number;
  12210. readonly COMPARE_REF_TO_TEXTURE: number;
  12211. readonly TEXTURE_WRAP_R: number;
  12212. readonly HALF_FLOAT: number;
  12213. readonly RGB8: number;
  12214. readonly RED_INTEGER: number;
  12215. readonly RG_INTEGER: number;
  12216. readonly RGB_INTEGER: number;
  12217. readonly RGBA_INTEGER: number;
  12218. readonly R8_SNORM: number;
  12219. readonly RG8_SNORM: number;
  12220. readonly RGB8_SNORM: number;
  12221. readonly RGBA8_SNORM: number;
  12222. readonly R8I: number;
  12223. readonly RG8I: number;
  12224. readonly RGB8I: number;
  12225. readonly RGBA8I: number;
  12226. readonly R8UI: number;
  12227. readonly RG8UI: number;
  12228. readonly RGB8UI: number;
  12229. readonly RGBA8UI: number;
  12230. readonly R16I: number;
  12231. readonly RG16I: number;
  12232. readonly RGB16I: number;
  12233. readonly RGBA16I: number;
  12234. readonly R16UI: number;
  12235. readonly RG16UI: number;
  12236. readonly RGB16UI: number;
  12237. readonly RGBA16UI: number;
  12238. readonly R32I: number;
  12239. readonly RG32I: number;
  12240. readonly RGB32I: number;
  12241. readonly RGBA32I: number;
  12242. readonly R32UI: number;
  12243. readonly RG32UI: number;
  12244. readonly RGB32UI: number;
  12245. readonly RGBA32UI: number;
  12246. readonly RGB10_A2UI: number;
  12247. readonly R11F_G11F_B10F: number;
  12248. readonly RGB9_E5: number;
  12249. readonly RGB10_A2: number;
  12250. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12251. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12252. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12253. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12254. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12255. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12256. 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;
  12257. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12258. readonly TRANSFORM_FEEDBACK: number;
  12259. readonly INTERLEAVED_ATTRIBS: number;
  12260. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12261. createTransformFeedback(): WebGLTransformFeedback;
  12262. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12263. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12264. beginTransformFeedback(primitiveMode: number): void;
  12265. endTransformFeedback(): void;
  12266. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12267. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12268. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12269. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12270. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12271. }
  12272. interface ImageBitmap {
  12273. readonly width: number;
  12274. readonly height: number;
  12275. close(): void;
  12276. }
  12277. interface WebGLQuery extends WebGLObject {
  12278. }
  12279. declare var WebGLQuery: {
  12280. prototype: WebGLQuery;
  12281. new (): WebGLQuery;
  12282. };
  12283. interface WebGLSampler extends WebGLObject {
  12284. }
  12285. declare var WebGLSampler: {
  12286. prototype: WebGLSampler;
  12287. new (): WebGLSampler;
  12288. };
  12289. interface WebGLSync extends WebGLObject {
  12290. }
  12291. declare var WebGLSync: {
  12292. prototype: WebGLSync;
  12293. new (): WebGLSync;
  12294. };
  12295. interface WebGLTransformFeedback extends WebGLObject {
  12296. }
  12297. declare var WebGLTransformFeedback: {
  12298. prototype: WebGLTransformFeedback;
  12299. new (): WebGLTransformFeedback;
  12300. };
  12301. interface WebGLVertexArrayObject extends WebGLObject {
  12302. }
  12303. declare var WebGLVertexArrayObject: {
  12304. prototype: WebGLVertexArrayObject;
  12305. new (): WebGLVertexArrayObject;
  12306. };
  12307. declare module BABYLON {
  12308. /**
  12309. * Gather the list of clipboard event types as constants.
  12310. */
  12311. class ClipboardEventTypes {
  12312. /**
  12313. * The clipboard event is fired when a copy command is active (pressed).
  12314. */
  12315. static readonly COPY: number;
  12316. /**
  12317. * The clipboard event is fired when a cut command is active (pressed).
  12318. */
  12319. static readonly CUT: number;
  12320. /**
  12321. * The clipboard event is fired when a paste command is active (pressed).
  12322. */
  12323. static readonly PASTE: number;
  12324. }
  12325. /**
  12326. * This class is used to store clipboard related info for the onClipboardObservable event.
  12327. */
  12328. class ClipboardInfo {
  12329. /**
  12330. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12331. */
  12332. type: number;
  12333. /**
  12334. * Defines the related dom event
  12335. */
  12336. event: ClipboardEvent;
  12337. /**
  12338. *Creates an instance of ClipboardInfo.
  12339. * @param {number} type
  12340. * @param {ClipboardEvent} event
  12341. */
  12342. constructor(
  12343. /**
  12344. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12345. */
  12346. type: number,
  12347. /**
  12348. * Defines the related dom event
  12349. */
  12350. event: ClipboardEvent);
  12351. /**
  12352. * Get the clipboard event's type from the keycode.
  12353. * @param keyCode Defines the keyCode for the current keyboard event.
  12354. * @return {number}
  12355. */
  12356. static GetTypeFromCharacter(keyCode: number): number;
  12357. }
  12358. }
  12359. declare module BABYLON {
  12360. /**
  12361. * Gather the list of keyboard event types as constants.
  12362. */
  12363. class KeyboardEventTypes {
  12364. /**
  12365. * The keydown event is fired when a key becomes active (pressed).
  12366. */
  12367. static readonly KEYDOWN: number;
  12368. /**
  12369. * The keyup event is fired when a key has been released.
  12370. */
  12371. static readonly KEYUP: number;
  12372. }
  12373. /**
  12374. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12375. */
  12376. class KeyboardInfo {
  12377. /**
  12378. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12379. */
  12380. type: number;
  12381. /**
  12382. * Defines the related dom event
  12383. */
  12384. event: KeyboardEvent;
  12385. /**
  12386. * Instantiates a new keyboard info.
  12387. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12388. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12389. * @param event Defines the related dom event
  12390. */
  12391. constructor(
  12392. /**
  12393. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12394. */
  12395. type: number,
  12396. /**
  12397. * Defines the related dom event
  12398. */
  12399. event: KeyboardEvent);
  12400. }
  12401. /**
  12402. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12403. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12404. */
  12405. class KeyboardInfoPre extends KeyboardInfo {
  12406. /**
  12407. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12408. */
  12409. type: number;
  12410. /**
  12411. * Defines the related dom event
  12412. */
  12413. event: KeyboardEvent;
  12414. /**
  12415. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12416. */
  12417. skipOnPointerObservable: boolean;
  12418. /**
  12419. * Instantiates a new keyboard pre info.
  12420. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12421. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12422. * @param event Defines the related dom event
  12423. */
  12424. constructor(
  12425. /**
  12426. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12427. */
  12428. type: number,
  12429. /**
  12430. * Defines the related dom event
  12431. */
  12432. event: KeyboardEvent);
  12433. }
  12434. }
  12435. declare module BABYLON {
  12436. /**
  12437. * Gather the list of pointer event types as constants.
  12438. */
  12439. class PointerEventTypes {
  12440. /**
  12441. * 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.
  12442. */
  12443. static readonly POINTERDOWN: number;
  12444. /**
  12445. * The pointerup event is fired when a pointer is no longer active.
  12446. */
  12447. static readonly POINTERUP: number;
  12448. /**
  12449. * The pointermove event is fired when a pointer changes coordinates.
  12450. */
  12451. static readonly POINTERMOVE: number;
  12452. /**
  12453. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12454. */
  12455. static readonly POINTERWHEEL: number;
  12456. /**
  12457. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12458. */
  12459. static readonly POINTERPICK: number;
  12460. /**
  12461. * The pointertap event is fired when a the object has been touched and released without drag.
  12462. */
  12463. static readonly POINTERTAP: number;
  12464. /**
  12465. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12466. */
  12467. static readonly POINTERDOUBLETAP: number;
  12468. }
  12469. /**
  12470. * Base class of pointer info types.
  12471. */
  12472. class PointerInfoBase {
  12473. /**
  12474. * Defines the type of event (BABYLON.PointerEventTypes)
  12475. */
  12476. type: number;
  12477. /**
  12478. * Defines the related dom event
  12479. */
  12480. event: PointerEvent | MouseWheelEvent;
  12481. /**
  12482. * Instantiates the base class of pointers info.
  12483. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12484. * @param event Defines the related dom event
  12485. */
  12486. constructor(
  12487. /**
  12488. * Defines the type of event (BABYLON.PointerEventTypes)
  12489. */
  12490. type: number,
  12491. /**
  12492. * Defines the related dom event
  12493. */
  12494. event: PointerEvent | MouseWheelEvent);
  12495. }
  12496. /**
  12497. * This class is used to store pointer related info for the onPrePointerObservable event.
  12498. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12499. */
  12500. class PointerInfoPre extends PointerInfoBase {
  12501. /**
  12502. * Ray from a pointer if availible (eg. 6dof controller)
  12503. */
  12504. ray: Nullable<Ray>;
  12505. /**
  12506. * Defines the local position of the pointer on the canvas.
  12507. */
  12508. localPosition: Vector2;
  12509. /**
  12510. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12511. */
  12512. skipOnPointerObservable: boolean;
  12513. /**
  12514. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12515. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12516. * @param event Defines the related dom event
  12517. * @param localX Defines the local x coordinates of the pointer when the event occured
  12518. * @param localY Defines the local y coordinates of the pointer when the event occured
  12519. */
  12520. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12521. }
  12522. /**
  12523. * This type contains all the data related to a pointer event in Babylon.js.
  12524. * 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.
  12525. */
  12526. class PointerInfo extends PointerInfoBase {
  12527. /**
  12528. * Defines the picking info associated to the info (if any)\
  12529. */
  12530. pickInfo: Nullable<PickingInfo>;
  12531. /**
  12532. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12533. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12534. * @param event Defines the related dom event
  12535. * @param pickInfo Defines the picking info associated to the info (if any)\
  12536. */
  12537. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12538. /**
  12539. * Defines the picking info associated to the info (if any)\
  12540. */
  12541. pickInfo: Nullable<PickingInfo>);
  12542. }
  12543. }
  12544. declare module BABYLON {
  12545. /**
  12546. * Represents a gamepad control stick position
  12547. */
  12548. class StickValues {
  12549. /**
  12550. * The x component of the control stick
  12551. */
  12552. x: number;
  12553. /**
  12554. * The y component of the control stick
  12555. */
  12556. y: number;
  12557. /**
  12558. * Initializes the gamepad x and y control stick values
  12559. * @param x The x component of the gamepad control stick value
  12560. * @param y The y component of the gamepad control stick value
  12561. */
  12562. constructor(
  12563. /**
  12564. * The x component of the control stick
  12565. */
  12566. x: number,
  12567. /**
  12568. * The y component of the control stick
  12569. */
  12570. y: number);
  12571. }
  12572. /**
  12573. * An interface which manages callbacks for gamepad button changes
  12574. */
  12575. interface GamepadButtonChanges {
  12576. /**
  12577. * Called when a gamepad has been changed
  12578. */
  12579. changed: boolean;
  12580. /**
  12581. * Called when a gamepad press event has been triggered
  12582. */
  12583. pressChanged: boolean;
  12584. /**
  12585. * Called when a touch event has been triggered
  12586. */
  12587. touchChanged: boolean;
  12588. /**
  12589. * Called when a value has changed
  12590. */
  12591. valueChanged: boolean;
  12592. }
  12593. /**
  12594. * Represents a gamepad
  12595. */
  12596. class Gamepad {
  12597. /**
  12598. * The id of the gamepad
  12599. */
  12600. id: string;
  12601. /**
  12602. * The index of the gamepad
  12603. */
  12604. index: number;
  12605. /**
  12606. * The browser gamepad
  12607. */
  12608. browserGamepad: any;
  12609. /**
  12610. * Specifies what type of gamepad this represents
  12611. */
  12612. type: number;
  12613. private _leftStick;
  12614. private _rightStick;
  12615. /** @hidden */
  12616. _isConnected: boolean;
  12617. private _leftStickAxisX;
  12618. private _leftStickAxisY;
  12619. private _rightStickAxisX;
  12620. private _rightStickAxisY;
  12621. /**
  12622. * Triggered when the left control stick has been changed
  12623. */
  12624. private _onleftstickchanged;
  12625. /**
  12626. * Triggered when the right control stick has been changed
  12627. */
  12628. private _onrightstickchanged;
  12629. /**
  12630. * Represents a gamepad controller
  12631. */
  12632. static GAMEPAD: number;
  12633. /**
  12634. * Represents a generic controller
  12635. */
  12636. static GENERIC: number;
  12637. /**
  12638. * Represents an XBox controller
  12639. */
  12640. static XBOX: number;
  12641. /**
  12642. * Represents a pose-enabled controller
  12643. */
  12644. static POSE_ENABLED: number;
  12645. /**
  12646. * Specifies whether the left control stick should be Y-inverted
  12647. */
  12648. protected _invertLeftStickY: boolean;
  12649. /**
  12650. * Specifies if the gamepad has been connected
  12651. */
  12652. readonly isConnected: boolean;
  12653. /**
  12654. * Initializes the gamepad
  12655. * @param id The id of the gamepad
  12656. * @param index The index of the gamepad
  12657. * @param browserGamepad The browser gamepad
  12658. * @param leftStickX The x component of the left joystick
  12659. * @param leftStickY The y component of the left joystick
  12660. * @param rightStickX The x component of the right joystick
  12661. * @param rightStickY The y component of the right joystick
  12662. */
  12663. constructor(
  12664. /**
  12665. * The id of the gamepad
  12666. */
  12667. id: string,
  12668. /**
  12669. * The index of the gamepad
  12670. */
  12671. index: number,
  12672. /**
  12673. * The browser gamepad
  12674. */
  12675. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12676. /**
  12677. * Callback triggered when the left joystick has changed
  12678. * @param callback
  12679. */
  12680. onleftstickchanged(callback: (values: StickValues) => void): void;
  12681. /**
  12682. * Callback triggered when the right joystick has changed
  12683. * @param callback
  12684. */
  12685. onrightstickchanged(callback: (values: StickValues) => void): void;
  12686. /**
  12687. * Gets the left joystick
  12688. */
  12689. /**
  12690. * Sets the left joystick values
  12691. */
  12692. leftStick: StickValues;
  12693. /**
  12694. * Gets the right joystick
  12695. */
  12696. /**
  12697. * Sets the right joystick value
  12698. */
  12699. rightStick: StickValues;
  12700. /**
  12701. * Updates the gamepad joystick positions
  12702. */
  12703. update(): void;
  12704. /**
  12705. * Disposes the gamepad
  12706. */
  12707. dispose(): void;
  12708. }
  12709. /**
  12710. * Represents a generic gamepad
  12711. */
  12712. class GenericPad extends Gamepad {
  12713. private _buttons;
  12714. private _onbuttondown;
  12715. private _onbuttonup;
  12716. /**
  12717. * Observable triggered when a button has been pressed
  12718. */
  12719. onButtonDownObservable: Observable<number>;
  12720. /**
  12721. * Observable triggered when a button has been released
  12722. */
  12723. onButtonUpObservable: Observable<number>;
  12724. /**
  12725. * Callback triggered when a button has been pressed
  12726. * @param callback Called when a button has been pressed
  12727. */
  12728. onbuttondown(callback: (buttonPressed: number) => void): void;
  12729. /**
  12730. * Callback triggered when a button has been released
  12731. * @param callback Called when a button has been released
  12732. */
  12733. onbuttonup(callback: (buttonReleased: number) => void): void;
  12734. /**
  12735. * Initializes the generic gamepad
  12736. * @param id The id of the generic gamepad
  12737. * @param index The index of the generic gamepad
  12738. * @param browserGamepad The browser gamepad
  12739. */
  12740. constructor(id: string, index: number, browserGamepad: any);
  12741. private _setButtonValue;
  12742. /**
  12743. * Updates the generic gamepad
  12744. */
  12745. update(): void;
  12746. /**
  12747. * Disposes the generic gamepad
  12748. */
  12749. dispose(): void;
  12750. }
  12751. }
  12752. declare module BABYLON {
  12753. /**
  12754. * Manager for handling gamepads
  12755. */
  12756. class GamepadManager {
  12757. private _scene?;
  12758. private _babylonGamepads;
  12759. private _oneGamepadConnected;
  12760. /** @hidden */
  12761. _isMonitoring: boolean;
  12762. private _gamepadEventSupported;
  12763. private _gamepadSupport;
  12764. /**
  12765. * observable to be triggered when the gamepad controller has been connected
  12766. */
  12767. onGamepadConnectedObservable: Observable<Gamepad>;
  12768. /**
  12769. * observable to be triggered when the gamepad controller has been disconnected
  12770. */
  12771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12772. private _onGamepadConnectedEvent;
  12773. private _onGamepadDisconnectedEvent;
  12774. /**
  12775. * Initializes the gamepad manager
  12776. * @param _scene BabylonJS scene
  12777. */
  12778. constructor(_scene?: Scene | undefined);
  12779. /**
  12780. * The gamepads in the game pad manager
  12781. */
  12782. readonly gamepads: Gamepad[];
  12783. /**
  12784. * Get the gamepad controllers based on type
  12785. * @param type The type of gamepad controller
  12786. * @returns Nullable gamepad
  12787. */
  12788. getGamepadByType(type?: number): Nullable<Gamepad>;
  12789. /**
  12790. * Disposes the gamepad manager
  12791. */
  12792. dispose(): void;
  12793. private _addNewGamepad;
  12794. private _startMonitoringGamepads;
  12795. private _stopMonitoringGamepads;
  12796. /** @hidden */
  12797. _checkGamepadsStatus(): void;
  12798. private _updateGamepadObjects;
  12799. }
  12800. }
  12801. declare module BABYLON {
  12802. interface Scene {
  12803. /** @hidden */
  12804. _gamepadManager: Nullable<GamepadManager>;
  12805. /**
  12806. * Gets the gamepad manager associated with the scene
  12807. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12808. */
  12809. gamepadManager: GamepadManager;
  12810. }
  12811. /**
  12812. * Interface representing a free camera inputs manager
  12813. */
  12814. interface FreeCameraInputsManager {
  12815. /**
  12816. * Adds gamepad input support to the FreeCameraInputsManager.
  12817. * @returns the FreeCameraInputsManager
  12818. */
  12819. addGamepad(): FreeCameraInputsManager;
  12820. }
  12821. /**
  12822. * Interface representing an arc rotate camera inputs manager
  12823. */
  12824. interface ArcRotateCameraInputsManager {
  12825. /**
  12826. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12827. * @returns the camera inputs manager
  12828. */
  12829. addGamepad(): ArcRotateCameraInputsManager;
  12830. }
  12831. /**
  12832. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12833. */
  12834. class GamepadSystemSceneComponent implements ISceneComponent {
  12835. /**
  12836. * The component name helpfull to identify the component in the list of scene components.
  12837. */
  12838. readonly name: string;
  12839. /**
  12840. * The scene the component belongs to.
  12841. */
  12842. scene: Scene;
  12843. /**
  12844. * Creates a new instance of the component for the given scene
  12845. * @param scene Defines the scene to register the component in
  12846. */
  12847. constructor(scene: Scene);
  12848. /**
  12849. * Registers the component in a given scene
  12850. */
  12851. register(): void;
  12852. /**
  12853. * Rebuilds the elements related to this component in case of
  12854. * context lost for instance.
  12855. */
  12856. rebuild(): void;
  12857. /**
  12858. * Disposes the component and the associated ressources
  12859. */
  12860. dispose(): void;
  12861. private _beforeCameraUpdate;
  12862. }
  12863. }
  12864. declare module BABYLON {
  12865. /**
  12866. * Defines supported buttons for XBox360 compatible gamepads
  12867. */
  12868. enum Xbox360Button {
  12869. /** A */
  12870. A = 0,
  12871. /** B */
  12872. B = 1,
  12873. /** X */
  12874. X = 2,
  12875. /** Y */
  12876. Y = 3,
  12877. /** Start */
  12878. Start = 4,
  12879. /** Back */
  12880. Back = 5,
  12881. /** Left button */
  12882. LB = 6,
  12883. /** Right button */
  12884. RB = 7,
  12885. /** Left stick */
  12886. LeftStick = 8,
  12887. /** Right stick */
  12888. RightStick = 9
  12889. }
  12890. /** Defines values for XBox360 DPad */
  12891. enum Xbox360Dpad {
  12892. /** Up */
  12893. Up = 0,
  12894. /** Down */
  12895. Down = 1,
  12896. /** Left */
  12897. Left = 2,
  12898. /** Right */
  12899. Right = 3
  12900. }
  12901. /**
  12902. * Defines a XBox360 gamepad
  12903. */
  12904. class Xbox360Pad extends Gamepad {
  12905. private _leftTrigger;
  12906. private _rightTrigger;
  12907. private _onlefttriggerchanged;
  12908. private _onrighttriggerchanged;
  12909. private _onbuttondown;
  12910. private _onbuttonup;
  12911. private _ondpaddown;
  12912. private _ondpadup;
  12913. /** Observable raised when a button is pressed */
  12914. onButtonDownObservable: Observable<Xbox360Button>;
  12915. /** Observable raised when a button is released */
  12916. onButtonUpObservable: Observable<Xbox360Button>;
  12917. /** Observable raised when a pad is pressed */
  12918. onPadDownObservable: Observable<Xbox360Dpad>;
  12919. /** Observable raised when a pad is released */
  12920. onPadUpObservable: Observable<Xbox360Dpad>;
  12921. private _buttonA;
  12922. private _buttonB;
  12923. private _buttonX;
  12924. private _buttonY;
  12925. private _buttonBack;
  12926. private _buttonStart;
  12927. private _buttonLB;
  12928. private _buttonRB;
  12929. private _buttonLeftStick;
  12930. private _buttonRightStick;
  12931. private _dPadUp;
  12932. private _dPadDown;
  12933. private _dPadLeft;
  12934. private _dPadRight;
  12935. private _isXboxOnePad;
  12936. /**
  12937. * Creates a new XBox360 gamepad object
  12938. * @param id defines the id of this gamepad
  12939. * @param index defines its index
  12940. * @param gamepad defines the internal HTML gamepad object
  12941. * @param xboxOne defines if it is a XBox One gamepad
  12942. */
  12943. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12944. /**
  12945. * Defines the callback to call when left trigger is pressed
  12946. * @param callback defines the callback to use
  12947. */
  12948. onlefttriggerchanged(callback: (value: number) => void): void;
  12949. /**
  12950. * Defines the callback to call when right trigger is pressed
  12951. * @param callback defines the callback to use
  12952. */
  12953. onrighttriggerchanged(callback: (value: number) => void): void;
  12954. /**
  12955. * Gets the left trigger value
  12956. */
  12957. /**
  12958. * Sets the left trigger value
  12959. */
  12960. leftTrigger: number;
  12961. /**
  12962. * Gets the right trigger value
  12963. */
  12964. /**
  12965. * Sets the right trigger value
  12966. */
  12967. rightTrigger: number;
  12968. /**
  12969. * Defines the callback to call when a button is pressed
  12970. * @param callback defines the callback to use
  12971. */
  12972. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12973. /**
  12974. * Defines the callback to call when a button is released
  12975. * @param callback defines the callback to use
  12976. */
  12977. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12978. /**
  12979. * Defines the callback to call when a pad is pressed
  12980. * @param callback defines the callback to use
  12981. */
  12982. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12983. /**
  12984. * Defines the callback to call when a pad is released
  12985. * @param callback defines the callback to use
  12986. */
  12987. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12988. private _setButtonValue;
  12989. private _setDPadValue;
  12990. /**
  12991. * Gets the value of the `A` button
  12992. */
  12993. /**
  12994. * Sets the value of the `A` button
  12995. */
  12996. buttonA: number;
  12997. /**
  12998. * Gets the value of the `B` button
  12999. */
  13000. /**
  13001. * Sets the value of the `B` button
  13002. */
  13003. buttonB: number;
  13004. /**
  13005. * Gets the value of the `X` button
  13006. */
  13007. /**
  13008. * Sets the value of the `X` button
  13009. */
  13010. buttonX: number;
  13011. /**
  13012. * Gets the value of the `Y` button
  13013. */
  13014. /**
  13015. * Sets the value of the `Y` button
  13016. */
  13017. buttonY: number;
  13018. /**
  13019. * Gets the value of the `Start` button
  13020. */
  13021. /**
  13022. * Sets the value of the `Start` button
  13023. */
  13024. buttonStart: number;
  13025. /**
  13026. * Gets the value of the `Back` button
  13027. */
  13028. /**
  13029. * Sets the value of the `Back` button
  13030. */
  13031. buttonBack: number;
  13032. /**
  13033. * Gets the value of the `Left` button
  13034. */
  13035. /**
  13036. * Sets the value of the `Left` button
  13037. */
  13038. buttonLB: number;
  13039. /**
  13040. * Gets the value of the `Right` button
  13041. */
  13042. /**
  13043. * Sets the value of the `Right` button
  13044. */
  13045. buttonRB: number;
  13046. /**
  13047. * Gets the value of the Left joystick
  13048. */
  13049. /**
  13050. * Sets the value of the Left joystick
  13051. */
  13052. buttonLeftStick: number;
  13053. /**
  13054. * Gets the value of the Right joystick
  13055. */
  13056. /**
  13057. * Sets the value of the Right joystick
  13058. */
  13059. buttonRightStick: number;
  13060. /**
  13061. * Gets the value of D-pad up
  13062. */
  13063. /**
  13064. * Sets the value of D-pad up
  13065. */
  13066. dPadUp: number;
  13067. /**
  13068. * Gets the value of D-pad down
  13069. */
  13070. /**
  13071. * Sets the value of D-pad down
  13072. */
  13073. dPadDown: number;
  13074. /**
  13075. * Gets the value of D-pad left
  13076. */
  13077. /**
  13078. * Sets the value of D-pad left
  13079. */
  13080. dPadLeft: number;
  13081. /**
  13082. * Gets the value of D-pad right
  13083. */
  13084. /**
  13085. * Sets the value of D-pad right
  13086. */
  13087. dPadRight: number;
  13088. /**
  13089. * Force the gamepad to synchronize with device values
  13090. */
  13091. update(): void;
  13092. /**
  13093. * Disposes the gamepad
  13094. */
  13095. dispose(): void;
  13096. }
  13097. }
  13098. declare module BABYLON {
  13099. /**
  13100. * Single axis drag gizmo
  13101. */
  13102. class AxisDragGizmo extends Gizmo {
  13103. /**
  13104. * Drag behavior responsible for the gizmos dragging interactions
  13105. */
  13106. dragBehavior: PointerDragBehavior;
  13107. private _pointerObserver;
  13108. /**
  13109. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13110. */
  13111. snapDistance: number;
  13112. /**
  13113. * Event that fires each time the gizmo snaps to a new location.
  13114. * * snapDistance is the the change in distance
  13115. */
  13116. onSnapObservable: Observable<{
  13117. snapDistance: number;
  13118. }>;
  13119. /** @hidden */
  13120. static _CreateArrow(scene: Scene, material: StandardMaterial): AbstractMesh;
  13121. /**
  13122. * Creates an AxisDragGizmo
  13123. * @param gizmoLayer The utility layer the gizmo will be added to
  13124. * @param dragAxis The axis which the gizmo will be able to drag on
  13125. * @param color The color of the gizmo
  13126. */
  13127. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13128. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13129. /**
  13130. * Disposes of the gizmo
  13131. */
  13132. dispose(): void;
  13133. }
  13134. }
  13135. declare module BABYLON {
  13136. /**
  13137. * Single axis scale gizmo
  13138. */
  13139. class AxisScaleGizmo extends Gizmo {
  13140. private _coloredMaterial;
  13141. /**
  13142. * Drag behavior responsible for the gizmos dragging interactions
  13143. */
  13144. dragBehavior: PointerDragBehavior;
  13145. private _pointerObserver;
  13146. /**
  13147. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13148. */
  13149. snapDistance: number;
  13150. /**
  13151. * Event that fires each time the gizmo snaps to a new location.
  13152. * * snapDistance is the the change in distance
  13153. */
  13154. onSnapObservable: Observable<{
  13155. snapDistance: number;
  13156. }>;
  13157. /**
  13158. * If the scaling operation should be done on all axis (default: false)
  13159. */
  13160. uniformScaling: boolean;
  13161. /**
  13162. * Creates an AxisScaleGizmo
  13163. * @param gizmoLayer The utility layer the gizmo will be added to
  13164. * @param dragAxis The axis which the gizmo will be able to scale on
  13165. * @param color The color of the gizmo
  13166. */
  13167. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13168. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13169. /**
  13170. * Disposes of the gizmo
  13171. */
  13172. dispose(): void;
  13173. /**
  13174. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13175. * @param mesh The mesh to replace the default mesh of the gizmo
  13176. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13177. */
  13178. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13179. }
  13180. }
  13181. declare module BABYLON {
  13182. /**
  13183. * Bounding box gizmo
  13184. */
  13185. class BoundingBoxGizmo extends Gizmo {
  13186. private _lineBoundingBox;
  13187. private _rotateSpheresParent;
  13188. private _scaleBoxesParent;
  13189. private _boundingDimensions;
  13190. private _renderObserver;
  13191. private _pointerObserver;
  13192. private _scaleDragSpeed;
  13193. private _tmpQuaternion;
  13194. private _tmpVector;
  13195. private _tmpRotationMatrix;
  13196. /**
  13197. * 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)
  13198. */
  13199. ignoreChildren: boolean;
  13200. /**
  13201. * 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)
  13202. */
  13203. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13204. /**
  13205. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13206. */
  13207. rotationSphereSize: number;
  13208. /**
  13209. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13210. */
  13211. scaleBoxSize: number;
  13212. /**
  13213. * 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)
  13214. */
  13215. fixedDragMeshScreenSize: boolean;
  13216. /**
  13217. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13218. */
  13219. fixedDragMeshScreenSizeDistanceFactor: number;
  13220. /**
  13221. * Fired when a rotation sphere or scale box is dragged
  13222. */
  13223. onDragStartObservable: Observable<{}>;
  13224. /**
  13225. * Fired when a scale box is dragged
  13226. */
  13227. onScaleBoxDragObservable: Observable<{}>;
  13228. /**
  13229. * Fired when a scale box drag is ended
  13230. */
  13231. onScaleBoxDragEndObservable: Observable<{}>;
  13232. /**
  13233. * Fired when a rotation sphere is dragged
  13234. */
  13235. onRotationSphereDragObservable: Observable<{}>;
  13236. /**
  13237. * Fired when a rotation sphere drag is ended
  13238. */
  13239. onRotationSphereDragEndObservable: Observable<{}>;
  13240. /**
  13241. * 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)
  13242. */
  13243. scalePivot: Nullable<Vector3>;
  13244. private _anchorMesh;
  13245. private _existingMeshScale;
  13246. private static _PivotCached;
  13247. private static _OldPivotPoint;
  13248. private static _PivotTranslation;
  13249. private static _PivotTmpVector;
  13250. /** @hidden */
  13251. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13252. /** @hidden */
  13253. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13254. /**
  13255. * Creates an BoundingBoxGizmo
  13256. * @param gizmoLayer The utility layer the gizmo will be added to
  13257. * @param color The color of the gizmo
  13258. */
  13259. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13260. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13261. private _selectNode;
  13262. /**
  13263. * Updates the bounding box information for the Gizmo
  13264. */
  13265. updateBoundingBox(): void;
  13266. private _updateRotationSpheres;
  13267. private _updateScaleBoxes;
  13268. /**
  13269. * Enables rotation on the specified axis and disables rotation on the others
  13270. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13271. */
  13272. setEnabledRotationAxis(axis: string): void;
  13273. /**
  13274. * Disposes of the gizmo
  13275. */
  13276. dispose(): void;
  13277. /**
  13278. * 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)
  13279. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13280. * @returns the bounding box mesh with the passed in mesh as a child
  13281. */
  13282. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13283. /**
  13284. * CustomMeshes are not supported by this gizmo
  13285. * @param mesh The mesh to replace the default mesh of the gizmo
  13286. */
  13287. setCustomMesh(mesh: Mesh): void;
  13288. }
  13289. }
  13290. declare module BABYLON {
  13291. /**
  13292. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13293. */
  13294. class Gizmo implements IDisposable {
  13295. /** The utility layer the gizmo will be added to */
  13296. gizmoLayer: UtilityLayerRenderer;
  13297. /**
  13298. * The root mesh of the gizmo
  13299. */
  13300. protected _rootMesh: Mesh;
  13301. private _attachedMesh;
  13302. /**
  13303. * Ratio for the scale of the gizmo (Default: 1)
  13304. */
  13305. scaleRatio: number;
  13306. private _tmpMatrix;
  13307. /**
  13308. * If a custom mesh has been set (Default: false)
  13309. */
  13310. protected _customMeshSet: boolean;
  13311. /**
  13312. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13313. * * When set, interactions will be enabled
  13314. */
  13315. attachedMesh: Nullable<AbstractMesh>;
  13316. /**
  13317. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13318. * @param mesh The mesh to replace the default mesh of the gizmo
  13319. */
  13320. setCustomMesh(mesh: Mesh): void;
  13321. /**
  13322. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13323. */
  13324. updateGizmoRotationToMatchAttachedMesh: boolean;
  13325. /**
  13326. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13327. */
  13328. updateGizmoPositionToMatchAttachedMesh: boolean;
  13329. /**
  13330. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13331. */
  13332. protected _updateScale: boolean;
  13333. protected _interactionsEnabled: boolean;
  13334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13335. private _beforeRenderObserver;
  13336. /**
  13337. * Creates a gizmo
  13338. * @param gizmoLayer The utility layer the gizmo will be added to
  13339. */
  13340. constructor(
  13341. /** The utility layer the gizmo will be added to */
  13342. gizmoLayer?: UtilityLayerRenderer);
  13343. private _tempVector;
  13344. /**
  13345. * @hidden
  13346. * Updates the gizmo to match the attached mesh's position/rotation
  13347. */
  13348. protected _update(): void;
  13349. /**
  13350. * Disposes of the gizmo
  13351. */
  13352. dispose(): void;
  13353. }
  13354. }
  13355. declare module BABYLON {
  13356. /**
  13357. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13358. */
  13359. class GizmoManager implements IDisposable {
  13360. private scene;
  13361. /**
  13362. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13363. */
  13364. gizmos: {
  13365. positionGizmo: Nullable<PositionGizmo>;
  13366. rotationGizmo: Nullable<RotationGizmo>;
  13367. scaleGizmo: Nullable<ScaleGizmo>;
  13368. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13369. };
  13370. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13371. clearGizmoOnEmptyPointerEvent: boolean;
  13372. /** Fires an event when the manager is attached to a mesh */
  13373. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13374. private _gizmosEnabled;
  13375. private _pointerObserver;
  13376. private _attachedMesh;
  13377. private _boundingBoxColor;
  13378. private _defaultUtilityLayer;
  13379. private _defaultKeepDepthUtilityLayer;
  13380. /**
  13381. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13382. */
  13383. boundingBoxDragBehavior: SixDofDragBehavior;
  13384. /**
  13385. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13386. */
  13387. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13388. /**
  13389. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13390. */
  13391. usePointerToAttachGizmos: boolean;
  13392. /**
  13393. * Instatiates a gizmo manager
  13394. * @param scene the scene to overlay the gizmos on top of
  13395. */
  13396. constructor(scene: Scene);
  13397. /**
  13398. * Attaches a set of gizmos to the specified mesh
  13399. * @param mesh The mesh the gizmo's should be attached to
  13400. */
  13401. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13402. /**
  13403. * If the position gizmo is enabled
  13404. */
  13405. positionGizmoEnabled: boolean;
  13406. /**
  13407. * If the rotation gizmo is enabled
  13408. */
  13409. rotationGizmoEnabled: boolean;
  13410. /**
  13411. * If the scale gizmo is enabled
  13412. */
  13413. scaleGizmoEnabled: boolean;
  13414. /**
  13415. * If the boundingBox gizmo is enabled
  13416. */
  13417. boundingBoxGizmoEnabled: boolean;
  13418. /**
  13419. * Disposes of the gizmo manager
  13420. */
  13421. dispose(): void;
  13422. }
  13423. }
  13424. declare module BABYLON {
  13425. /**
  13426. * Single plane rotation gizmo
  13427. */
  13428. class PlaneRotationGizmo extends Gizmo {
  13429. /**
  13430. * Drag behavior responsible for the gizmos dragging interactions
  13431. */
  13432. dragBehavior: PointerDragBehavior;
  13433. private _pointerObserver;
  13434. /**
  13435. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13436. */
  13437. snapDistance: number;
  13438. /**
  13439. * Event that fires each time the gizmo snaps to a new location.
  13440. * * snapDistance is the the change in distance
  13441. */
  13442. onSnapObservable: Observable<{
  13443. snapDistance: number;
  13444. }>;
  13445. /**
  13446. * Creates a PlaneRotationGizmo
  13447. * @param gizmoLayer The utility layer the gizmo will be added to
  13448. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13449. * @param color The color of the gizmo
  13450. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13451. */
  13452. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13453. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13454. /**
  13455. * Disposes of the gizmo
  13456. */
  13457. dispose(): void;
  13458. }
  13459. }
  13460. declare module BABYLON {
  13461. /**
  13462. * Gizmo that enables dragging a mesh along 3 axis
  13463. */
  13464. class PositionGizmo extends Gizmo {
  13465. /**
  13466. * Internal gizmo used for interactions on the x axis
  13467. */
  13468. xGizmo: AxisDragGizmo;
  13469. /**
  13470. * Internal gizmo used for interactions on the y axis
  13471. */
  13472. yGizmo: AxisDragGizmo;
  13473. /**
  13474. * Internal gizmo used for interactions on the z axis
  13475. */
  13476. zGizmo: AxisDragGizmo;
  13477. /** Fires an event when any of it's sub gizmos are dragged */
  13478. onDragStartObservable: Observable<{}>;
  13479. /** Fires an event when any of it's sub gizmos are released from dragging */
  13480. onDragEndObservable: Observable<{}>;
  13481. attachedMesh: Nullable<AbstractMesh>;
  13482. /**
  13483. * Creates a PositionGizmo
  13484. * @param gizmoLayer The utility layer the gizmo will be added to
  13485. */
  13486. constructor(gizmoLayer?: UtilityLayerRenderer);
  13487. updateGizmoRotationToMatchAttachedMesh: boolean;
  13488. /**
  13489. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13490. */
  13491. snapDistance: number;
  13492. /**
  13493. * Ratio for the scale of the gizmo (Default: 1)
  13494. */
  13495. scaleRatio: number;
  13496. /**
  13497. * Disposes of the gizmo
  13498. */
  13499. dispose(): void;
  13500. /**
  13501. * CustomMeshes are not supported by this gizmo
  13502. * @param mesh The mesh to replace the default mesh of the gizmo
  13503. */
  13504. setCustomMesh(mesh: Mesh): void;
  13505. }
  13506. }
  13507. declare module BABYLON {
  13508. /**
  13509. * Gizmo that enables rotating a mesh along 3 axis
  13510. */
  13511. class RotationGizmo extends Gizmo {
  13512. /**
  13513. * Internal gizmo used for interactions on the x axis
  13514. */
  13515. xGizmo: PlaneRotationGizmo;
  13516. /**
  13517. * Internal gizmo used for interactions on the y axis
  13518. */
  13519. yGizmo: PlaneRotationGizmo;
  13520. /**
  13521. * Internal gizmo used for interactions on the z axis
  13522. */
  13523. zGizmo: PlaneRotationGizmo;
  13524. /** Fires an event when any of it's sub gizmos are dragged */
  13525. onDragStartObservable: Observable<{}>;
  13526. /** Fires an event when any of it's sub gizmos are released from dragging */
  13527. onDragEndObservable: Observable<{}>;
  13528. attachedMesh: Nullable<AbstractMesh>;
  13529. /**
  13530. * Creates a RotationGizmo
  13531. * @param gizmoLayer The utility layer the gizmo will be added to
  13532. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13533. */
  13534. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13535. updateGizmoRotationToMatchAttachedMesh: boolean;
  13536. /**
  13537. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13538. */
  13539. snapDistance: number;
  13540. /**
  13541. * Ratio for the scale of the gizmo (Default: 1)
  13542. */
  13543. scaleRatio: number;
  13544. /**
  13545. * Disposes of the gizmo
  13546. */
  13547. dispose(): void;
  13548. /**
  13549. * CustomMeshes are not supported by this gizmo
  13550. * @param mesh The mesh to replace the default mesh of the gizmo
  13551. */
  13552. setCustomMesh(mesh: Mesh): void;
  13553. }
  13554. }
  13555. declare module BABYLON {
  13556. /**
  13557. * Gizmo that enables scaling a mesh along 3 axis
  13558. */
  13559. class ScaleGizmo extends Gizmo {
  13560. /**
  13561. * Internal gizmo used for interactions on the x axis
  13562. */
  13563. xGizmo: AxisScaleGizmo;
  13564. /**
  13565. * Internal gizmo used for interactions on the y axis
  13566. */
  13567. yGizmo: AxisScaleGizmo;
  13568. /**
  13569. * Internal gizmo used for interactions on the z axis
  13570. */
  13571. zGizmo: AxisScaleGizmo;
  13572. /**
  13573. * Internal gizmo used to scale all axis equally
  13574. */
  13575. uniformScaleGizmo: AxisScaleGizmo;
  13576. /** Fires an event when any of it's sub gizmos are dragged */
  13577. onDragStartObservable: Observable<{}>;
  13578. /** Fires an event when any of it's sub gizmos are released from dragging */
  13579. onDragEndObservable: Observable<{}>;
  13580. attachedMesh: Nullable<AbstractMesh>;
  13581. /**
  13582. * Creates a ScaleGizmo
  13583. * @param gizmoLayer The utility layer the gizmo will be added to
  13584. */
  13585. constructor(gizmoLayer?: UtilityLayerRenderer);
  13586. updateGizmoRotationToMatchAttachedMesh: boolean;
  13587. /**
  13588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13589. */
  13590. snapDistance: number;
  13591. /**
  13592. * Ratio for the scale of the gizmo (Default: 1)
  13593. */
  13594. scaleRatio: number;
  13595. /**
  13596. * Disposes of the gizmo
  13597. */
  13598. dispose(): void;
  13599. }
  13600. }
  13601. declare module BABYLON {
  13602. /**
  13603. * Represents the different options available during the creation of
  13604. * a Environment helper.
  13605. *
  13606. * This can control the default ground, skybox and image processing setup of your scene.
  13607. */
  13608. interface IEnvironmentHelperOptions {
  13609. /**
  13610. * Specifies wether or not to create a ground.
  13611. * True by default.
  13612. */
  13613. createGround: boolean;
  13614. /**
  13615. * Specifies the ground size.
  13616. * 15 by default.
  13617. */
  13618. groundSize: number;
  13619. /**
  13620. * The texture used on the ground for the main color.
  13621. * Comes from the BabylonJS CDN by default.
  13622. *
  13623. * Remarks: Can be either a texture or a url.
  13624. */
  13625. groundTexture: string | BaseTexture;
  13626. /**
  13627. * The color mixed in the ground texture by default.
  13628. * BabylonJS clearColor by default.
  13629. */
  13630. groundColor: Color3;
  13631. /**
  13632. * Specifies the ground opacity.
  13633. * 1 by default.
  13634. */
  13635. groundOpacity: number;
  13636. /**
  13637. * Enables the ground to receive shadows.
  13638. * True by default.
  13639. */
  13640. enableGroundShadow: boolean;
  13641. /**
  13642. * Helps preventing the shadow to be fully black on the ground.
  13643. * 0.5 by default.
  13644. */
  13645. groundShadowLevel: number;
  13646. /**
  13647. * Creates a mirror texture attach to the ground.
  13648. * false by default.
  13649. */
  13650. enableGroundMirror: boolean;
  13651. /**
  13652. * Specifies the ground mirror size ratio.
  13653. * 0.3 by default as the default kernel is 64.
  13654. */
  13655. groundMirrorSizeRatio: number;
  13656. /**
  13657. * Specifies the ground mirror blur kernel size.
  13658. * 64 by default.
  13659. */
  13660. groundMirrorBlurKernel: number;
  13661. /**
  13662. * Specifies the ground mirror visibility amount.
  13663. * 1 by default
  13664. */
  13665. groundMirrorAmount: number;
  13666. /**
  13667. * Specifies the ground mirror reflectance weight.
  13668. * This uses the standard weight of the background material to setup the fresnel effect
  13669. * of the mirror.
  13670. * 1 by default.
  13671. */
  13672. groundMirrorFresnelWeight: number;
  13673. /**
  13674. * Specifies the ground mirror Falloff distance.
  13675. * This can helps reducing the size of the reflection.
  13676. * 0 by Default.
  13677. */
  13678. groundMirrorFallOffDistance: number;
  13679. /**
  13680. * Specifies the ground mirror texture type.
  13681. * Unsigned Int by Default.
  13682. */
  13683. groundMirrorTextureType: number;
  13684. /**
  13685. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13686. * the shown objects.
  13687. */
  13688. groundYBias: number;
  13689. /**
  13690. * Specifies wether or not to create a skybox.
  13691. * True by default.
  13692. */
  13693. createSkybox: boolean;
  13694. /**
  13695. * Specifies the skybox size.
  13696. * 20 by default.
  13697. */
  13698. skyboxSize: number;
  13699. /**
  13700. * The texture used on the skybox for the main color.
  13701. * Comes from the BabylonJS CDN by default.
  13702. *
  13703. * Remarks: Can be either a texture or a url.
  13704. */
  13705. skyboxTexture: string | BaseTexture;
  13706. /**
  13707. * The color mixed in the skybox texture by default.
  13708. * BabylonJS clearColor by default.
  13709. */
  13710. skyboxColor: Color3;
  13711. /**
  13712. * The background rotation around the Y axis of the scene.
  13713. * This helps aligning the key lights of your scene with the background.
  13714. * 0 by default.
  13715. */
  13716. backgroundYRotation: number;
  13717. /**
  13718. * Compute automatically the size of the elements to best fit with the scene.
  13719. */
  13720. sizeAuto: boolean;
  13721. /**
  13722. * Default position of the rootMesh if autoSize is not true.
  13723. */
  13724. rootPosition: Vector3;
  13725. /**
  13726. * Sets up the image processing in the scene.
  13727. * true by default.
  13728. */
  13729. setupImageProcessing: boolean;
  13730. /**
  13731. * The texture used as your environment texture in the scene.
  13732. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13733. *
  13734. * Remarks: Can be either a texture or a url.
  13735. */
  13736. environmentTexture: string | BaseTexture;
  13737. /**
  13738. * The value of the exposure to apply to the scene.
  13739. * 0.6 by default if setupImageProcessing is true.
  13740. */
  13741. cameraExposure: number;
  13742. /**
  13743. * The value of the contrast to apply to the scene.
  13744. * 1.6 by default if setupImageProcessing is true.
  13745. */
  13746. cameraContrast: number;
  13747. /**
  13748. * Specifies wether or not tonemapping should be enabled in the scene.
  13749. * true by default if setupImageProcessing is true.
  13750. */
  13751. toneMappingEnabled: boolean;
  13752. }
  13753. /**
  13754. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13755. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13756. * It also helps with the default setup of your imageProcessing configuration.
  13757. */
  13758. class EnvironmentHelper {
  13759. /**
  13760. * Default ground texture URL.
  13761. */
  13762. private static _groundTextureCDNUrl;
  13763. /**
  13764. * Default skybox texture URL.
  13765. */
  13766. private static _skyboxTextureCDNUrl;
  13767. /**
  13768. * Default environment texture URL.
  13769. */
  13770. private static _environmentTextureCDNUrl;
  13771. /**
  13772. * Creates the default options for the helper.
  13773. */
  13774. private static _getDefaultOptions;
  13775. private _rootMesh;
  13776. /**
  13777. * Gets the root mesh created by the helper.
  13778. */
  13779. readonly rootMesh: Mesh;
  13780. private _skybox;
  13781. /**
  13782. * Gets the skybox created by the helper.
  13783. */
  13784. readonly skybox: Nullable<Mesh>;
  13785. private _skyboxTexture;
  13786. /**
  13787. * Gets the skybox texture created by the helper.
  13788. */
  13789. readonly skyboxTexture: Nullable<BaseTexture>;
  13790. private _skyboxMaterial;
  13791. /**
  13792. * Gets the skybox material created by the helper.
  13793. */
  13794. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13795. private _ground;
  13796. /**
  13797. * Gets the ground mesh created by the helper.
  13798. */
  13799. readonly ground: Nullable<Mesh>;
  13800. private _groundTexture;
  13801. /**
  13802. * Gets the ground texture created by the helper.
  13803. */
  13804. readonly groundTexture: Nullable<BaseTexture>;
  13805. private _groundMirror;
  13806. /**
  13807. * Gets the ground mirror created by the helper.
  13808. */
  13809. readonly groundMirror: Nullable<MirrorTexture>;
  13810. /**
  13811. * Gets the ground mirror render list to helps pushing the meshes
  13812. * you wish in the ground reflection.
  13813. */
  13814. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13815. private _groundMaterial;
  13816. /**
  13817. * Gets the ground material created by the helper.
  13818. */
  13819. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13820. /**
  13821. * Stores the creation options.
  13822. */
  13823. private readonly _scene;
  13824. private _options;
  13825. /**
  13826. * This observable will be notified with any error during the creation of the environment,
  13827. * mainly texture creation errors.
  13828. */
  13829. onErrorObservable: Observable<{
  13830. message?: string;
  13831. exception?: any;
  13832. }>;
  13833. /**
  13834. * constructor
  13835. * @param options
  13836. * @param scene The scene to add the material to
  13837. */
  13838. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13839. /**
  13840. * Updates the background according to the new options
  13841. * @param options
  13842. */
  13843. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13844. /**
  13845. * Sets the primary color of all the available elements.
  13846. * @param color the main color to affect to the ground and the background
  13847. */
  13848. setMainColor(color: Color3): void;
  13849. /**
  13850. * Setup the image processing according to the specified options.
  13851. */
  13852. private _setupImageProcessing;
  13853. /**
  13854. * Setup the environment texture according to the specified options.
  13855. */
  13856. private _setupEnvironmentTexture;
  13857. /**
  13858. * Setup the background according to the specified options.
  13859. */
  13860. private _setupBackground;
  13861. /**
  13862. * Get the scene sizes according to the setup.
  13863. */
  13864. private _getSceneSize;
  13865. /**
  13866. * Setup the ground according to the specified options.
  13867. */
  13868. private _setupGround;
  13869. /**
  13870. * Setup the ground material according to the specified options.
  13871. */
  13872. private _setupGroundMaterial;
  13873. /**
  13874. * Setup the ground diffuse texture according to the specified options.
  13875. */
  13876. private _setupGroundDiffuseTexture;
  13877. /**
  13878. * Setup the ground mirror texture according to the specified options.
  13879. */
  13880. private _setupGroundMirrorTexture;
  13881. /**
  13882. * Setup the ground to receive the mirror texture.
  13883. */
  13884. private _setupMirrorInGroundMaterial;
  13885. /**
  13886. * Setup the skybox according to the specified options.
  13887. */
  13888. private _setupSkybox;
  13889. /**
  13890. * Setup the skybox material according to the specified options.
  13891. */
  13892. private _setupSkyboxMaterial;
  13893. /**
  13894. * Setup the skybox reflection texture according to the specified options.
  13895. */
  13896. private _setupSkyboxReflectionTexture;
  13897. private _errorHandler;
  13898. /**
  13899. * Dispose all the elements created by the Helper.
  13900. */
  13901. dispose(): void;
  13902. }
  13903. }
  13904. declare module BABYLON {
  13905. /**
  13906. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13907. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13908. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13909. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13910. */
  13911. class PhotoDome extends TransformNode {
  13912. private _useDirectMapping;
  13913. /**
  13914. * The texture being displayed on the sphere
  13915. */
  13916. protected _photoTexture: Texture;
  13917. /**
  13918. * Gets or sets the texture being displayed on the sphere
  13919. */
  13920. photoTexture: Texture;
  13921. /**
  13922. * Observable raised when an error occured while loading the 360 image
  13923. */
  13924. onLoadErrorObservable: Observable<string>;
  13925. /**
  13926. * The skybox material
  13927. */
  13928. protected _material: BackgroundMaterial;
  13929. /**
  13930. * The surface used for the skybox
  13931. */
  13932. protected _mesh: Mesh;
  13933. /**
  13934. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13935. * Also see the options.resolution property.
  13936. */
  13937. fovMultiplier: number;
  13938. /**
  13939. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13940. * @param name Element's name, child elements will append suffixes for their own names.
  13941. * @param urlsOfPhoto defines the url of the photo to display
  13942. * @param options defines an object containing optional or exposed sub element properties
  13943. * @param onError defines a callback called when an error occured while loading the texture
  13944. */
  13945. constructor(name: string, urlOfPhoto: string, options: {
  13946. resolution?: number;
  13947. size?: number;
  13948. useDirectMapping?: boolean;
  13949. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13950. /**
  13951. * Releases resources associated with this node.
  13952. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13953. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13954. */
  13955. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13956. }
  13957. }
  13958. declare module BABYLON {
  13959. interface Scene {
  13960. /**
  13961. * Creates a default light for the scene.
  13962. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13963. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13964. */
  13965. createDefaultLight(replace?: boolean): void;
  13966. /**
  13967. * Creates a default camera for the scene.
  13968. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13969. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13970. * @param replace has default false, when true replaces the active camera in the scene
  13971. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13972. */
  13973. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13974. /**
  13975. * Creates a default camera and a default light.
  13976. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13977. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13978. * @param replace has the default false, when true replaces the active camera/light in the scene
  13979. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13980. */
  13981. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13982. /**
  13983. * Creates a new sky box
  13984. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13985. * @param environmentTexture defines the texture to use as environment texture
  13986. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13987. * @param scale defines the overall scale of the skybox
  13988. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13989. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13990. * @returns a new mesh holding the sky box
  13991. */
  13992. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13993. /**
  13994. * Creates a new environment
  13995. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13996. * @param options defines the options you can use to configure the environment
  13997. * @returns the new EnvironmentHelper
  13998. */
  13999. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14000. /**
  14001. * Creates a new VREXperienceHelper
  14002. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14003. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14004. * @returns a new VREXperienceHelper
  14005. */
  14006. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14007. /**
  14008. * Creates a new XREXperienceHelper
  14009. * @see http://doc.babylonjs.com/how_to/webxr
  14010. * @returns a promise for a new XREXperienceHelper
  14011. */
  14012. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14013. }
  14014. }
  14015. declare module BABYLON {
  14016. /**
  14017. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14018. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14019. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14020. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14021. */
  14022. class VideoDome extends TransformNode {
  14023. private _useDirectMapping;
  14024. /**
  14025. * The video texture being displayed on the sphere
  14026. */
  14027. protected _videoTexture: VideoTexture;
  14028. /**
  14029. * Gets the video texture being displayed on the sphere
  14030. */
  14031. readonly videoTexture: VideoTexture;
  14032. /**
  14033. * The skybox material
  14034. */
  14035. protected _material: BackgroundMaterial;
  14036. /**
  14037. * The surface used for the skybox
  14038. */
  14039. protected _mesh: Mesh;
  14040. /**
  14041. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14042. * Also see the options.resolution property.
  14043. */
  14044. fovMultiplier: number;
  14045. /**
  14046. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14047. * @param name Element's name, child elements will append suffixes for their own names.
  14048. * @param urlsOrVideo defines the url(s) or the video element to use
  14049. * @param options An object containing optional or exposed sub element properties
  14050. */
  14051. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14052. resolution?: number;
  14053. clickToPlay?: boolean;
  14054. autoPlay?: boolean;
  14055. loop?: boolean;
  14056. size?: number;
  14057. poster?: string;
  14058. useDirectMapping?: boolean;
  14059. }, scene: Scene);
  14060. /**
  14061. * Releases resources associated with this node.
  14062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14064. */
  14065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14066. }
  14067. }
  14068. declare module BABYLON {
  14069. /**
  14070. * This class can be used to get instrumentation data from a Babylon engine
  14071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14072. */
  14073. class EngineInstrumentation implements IDisposable {
  14074. /**
  14075. * Define the instrumented engine.
  14076. */
  14077. engine: Engine;
  14078. private _captureGPUFrameTime;
  14079. private _gpuFrameTimeToken;
  14080. private _gpuFrameTime;
  14081. private _captureShaderCompilationTime;
  14082. private _shaderCompilationTime;
  14083. private _onBeginFrameObserver;
  14084. private _onEndFrameObserver;
  14085. private _onBeforeShaderCompilationObserver;
  14086. private _onAfterShaderCompilationObserver;
  14087. /**
  14088. * Gets the perf counter used for GPU frame time
  14089. */
  14090. readonly gpuFrameTimeCounter: PerfCounter;
  14091. /**
  14092. * Gets the GPU frame time capture status
  14093. */
  14094. /**
  14095. * Enable or disable the GPU frame time capture
  14096. */
  14097. captureGPUFrameTime: boolean;
  14098. /**
  14099. * Gets the perf counter used for shader compilation time
  14100. */
  14101. readonly shaderCompilationTimeCounter: PerfCounter;
  14102. /**
  14103. * Gets the shader compilation time capture status
  14104. */
  14105. /**
  14106. * Enable or disable the shader compilation time capture
  14107. */
  14108. captureShaderCompilationTime: boolean;
  14109. /**
  14110. * Instantiates a new engine instrumentation.
  14111. * This class can be used to get instrumentation data from a Babylon engine
  14112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14113. * @param engine Defines the engine to instrument
  14114. */
  14115. constructor(
  14116. /**
  14117. * Define the instrumented engine.
  14118. */
  14119. engine: Engine);
  14120. /**
  14121. * Dispose and release associated resources.
  14122. */
  14123. dispose(): void;
  14124. }
  14125. }
  14126. declare module BABYLON {
  14127. /**
  14128. * This class can be used to get instrumentation data from a Babylon engine
  14129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14130. */
  14131. class SceneInstrumentation implements IDisposable {
  14132. /**
  14133. * Defines the scene to instrument
  14134. */
  14135. scene: Scene;
  14136. private _captureActiveMeshesEvaluationTime;
  14137. private _activeMeshesEvaluationTime;
  14138. private _captureRenderTargetsRenderTime;
  14139. private _renderTargetsRenderTime;
  14140. private _captureFrameTime;
  14141. private _frameTime;
  14142. private _captureRenderTime;
  14143. private _renderTime;
  14144. private _captureInterFrameTime;
  14145. private _interFrameTime;
  14146. private _captureParticlesRenderTime;
  14147. private _particlesRenderTime;
  14148. private _captureSpritesRenderTime;
  14149. private _spritesRenderTime;
  14150. private _capturePhysicsTime;
  14151. private _physicsTime;
  14152. private _captureAnimationsTime;
  14153. private _animationsTime;
  14154. private _captureCameraRenderTime;
  14155. private _cameraRenderTime;
  14156. private _onBeforeActiveMeshesEvaluationObserver;
  14157. private _onAfterActiveMeshesEvaluationObserver;
  14158. private _onBeforeRenderTargetsRenderObserver;
  14159. private _onAfterRenderTargetsRenderObserver;
  14160. private _onAfterRenderObserver;
  14161. private _onBeforeDrawPhaseObserver;
  14162. private _onAfterDrawPhaseObserver;
  14163. private _onBeforeAnimationsObserver;
  14164. private _onBeforeParticlesRenderingObserver;
  14165. private _onAfterParticlesRenderingObserver;
  14166. private _onBeforeSpritesRenderingObserver;
  14167. private _onAfterSpritesRenderingObserver;
  14168. private _onBeforePhysicsObserver;
  14169. private _onAfterPhysicsObserver;
  14170. private _onAfterAnimationsObserver;
  14171. private _onBeforeCameraRenderObserver;
  14172. private _onAfterCameraRenderObserver;
  14173. /**
  14174. * Gets the perf counter used for active meshes evaluation time
  14175. */
  14176. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14177. /**
  14178. * Gets the active meshes evaluation time capture status
  14179. */
  14180. /**
  14181. * Enable or disable the active meshes evaluation time capture
  14182. */
  14183. captureActiveMeshesEvaluationTime: boolean;
  14184. /**
  14185. * Gets the perf counter used for render targets render time
  14186. */
  14187. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14188. /**
  14189. * Gets the render targets render time capture status
  14190. */
  14191. /**
  14192. * Enable or disable the render targets render time capture
  14193. */
  14194. captureRenderTargetsRenderTime: boolean;
  14195. /**
  14196. * Gets the perf counter used for particles render time
  14197. */
  14198. readonly particlesRenderTimeCounter: PerfCounter;
  14199. /**
  14200. * Gets the particles render time capture status
  14201. */
  14202. /**
  14203. * Enable or disable the particles render time capture
  14204. */
  14205. captureParticlesRenderTime: boolean;
  14206. /**
  14207. * Gets the perf counter used for sprites render time
  14208. */
  14209. readonly spritesRenderTimeCounter: PerfCounter;
  14210. /**
  14211. * Gets the sprites render time capture status
  14212. */
  14213. /**
  14214. * Enable or disable the sprites render time capture
  14215. */
  14216. captureSpritesRenderTime: boolean;
  14217. /**
  14218. * Gets the perf counter used for physics time
  14219. */
  14220. readonly physicsTimeCounter: PerfCounter;
  14221. /**
  14222. * Gets the physics time capture status
  14223. */
  14224. /**
  14225. * Enable or disable the physics time capture
  14226. */
  14227. capturePhysicsTime: boolean;
  14228. /**
  14229. * Gets the perf counter used for animations time
  14230. */
  14231. readonly animationsTimeCounter: PerfCounter;
  14232. /**
  14233. * Gets the animations time capture status
  14234. */
  14235. /**
  14236. * Enable or disable the animations time capture
  14237. */
  14238. captureAnimationsTime: boolean;
  14239. /**
  14240. * Gets the perf counter used for frame time capture
  14241. */
  14242. readonly frameTimeCounter: PerfCounter;
  14243. /**
  14244. * Gets the frame time capture status
  14245. */
  14246. /**
  14247. * Enable or disable the frame time capture
  14248. */
  14249. captureFrameTime: boolean;
  14250. /**
  14251. * Gets the perf counter used for inter-frames time capture
  14252. */
  14253. readonly interFrameTimeCounter: PerfCounter;
  14254. /**
  14255. * Gets the inter-frames time capture status
  14256. */
  14257. /**
  14258. * Enable or disable the inter-frames time capture
  14259. */
  14260. captureInterFrameTime: boolean;
  14261. /**
  14262. * Gets the perf counter used for render time capture
  14263. */
  14264. readonly renderTimeCounter: PerfCounter;
  14265. /**
  14266. * Gets the render time capture status
  14267. */
  14268. /**
  14269. * Enable or disable the render time capture
  14270. */
  14271. captureRenderTime: boolean;
  14272. /**
  14273. * Gets the perf counter used for camera render time capture
  14274. */
  14275. readonly cameraRenderTimeCounter: PerfCounter;
  14276. /**
  14277. * Gets the camera render time capture status
  14278. */
  14279. /**
  14280. * Enable or disable the camera render time capture
  14281. */
  14282. captureCameraRenderTime: boolean;
  14283. /**
  14284. * Gets the perf counter used for draw calls
  14285. */
  14286. readonly drawCallsCounter: PerfCounter;
  14287. /**
  14288. * Gets the perf counter used for texture collisions
  14289. */
  14290. readonly textureCollisionsCounter: PerfCounter;
  14291. /**
  14292. * Instantiates a new scene instrumentation.
  14293. * This class can be used to get instrumentation data from a Babylon engine
  14294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14295. * @param scene Defines the scene to instrument
  14296. */
  14297. constructor(
  14298. /**
  14299. * Defines the scene to instrument
  14300. */
  14301. scene: Scene);
  14302. /**
  14303. * Dispose and release associated resources.
  14304. */
  14305. dispose(): void;
  14306. }
  14307. }
  14308. declare module BABYLON {
  14309. /**
  14310. * @hidden
  14311. **/
  14312. class _TimeToken {
  14313. _startTimeQuery: Nullable<WebGLQuery>;
  14314. _endTimeQuery: Nullable<WebGLQuery>;
  14315. _timeElapsedQuery: Nullable<WebGLQuery>;
  14316. _timeElapsedQueryEnded: boolean;
  14317. }
  14318. }
  14319. declare module BABYLON {
  14320. /**
  14321. * Effect layer options. This helps customizing the behaviour
  14322. * of the effect layer.
  14323. */
  14324. interface IEffectLayerOptions {
  14325. /**
  14326. * Multiplication factor apply to the canvas size to compute the render target size
  14327. * used to generated the objects (the smaller the faster).
  14328. */
  14329. mainTextureRatio: number;
  14330. /**
  14331. * Enforces a fixed size texture to ensure effect stability across devices.
  14332. */
  14333. mainTextureFixedSize?: number;
  14334. /**
  14335. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14336. */
  14337. alphaBlendingMode: number;
  14338. /**
  14339. * The camera attached to the layer.
  14340. */
  14341. camera: Nullable<Camera>;
  14342. /**
  14343. * The rendering group to draw the layer in.
  14344. */
  14345. renderingGroupId: number;
  14346. }
  14347. /**
  14348. * The effect layer Helps adding post process effect blended with the main pass.
  14349. *
  14350. * This can be for instance use to generate glow or higlight effects on the scene.
  14351. *
  14352. * The effect layer class can not be used directly and is intented to inherited from to be
  14353. * customized per effects.
  14354. */
  14355. abstract class EffectLayer {
  14356. private _vertexBuffers;
  14357. private _indexBuffer;
  14358. private _cachedDefines;
  14359. private _effectLayerMapGenerationEffect;
  14360. private _effectLayerOptions;
  14361. private _mergeEffect;
  14362. protected _scene: Scene;
  14363. protected _engine: Engine;
  14364. protected _maxSize: number;
  14365. protected _mainTextureDesiredSize: ISize;
  14366. protected _mainTexture: RenderTargetTexture;
  14367. protected _shouldRender: boolean;
  14368. protected _postProcesses: PostProcess[];
  14369. protected _textures: BaseTexture[];
  14370. protected _emissiveTextureAndColor: {
  14371. texture: Nullable<BaseTexture>;
  14372. color: Color4;
  14373. };
  14374. /**
  14375. * The name of the layer
  14376. */
  14377. name: string;
  14378. /**
  14379. * The clear color of the texture used to generate the glow map.
  14380. */
  14381. neutralColor: Color4;
  14382. /**
  14383. * Specifies wether the highlight layer is enabled or not.
  14384. */
  14385. isEnabled: boolean;
  14386. /**
  14387. * Gets the camera attached to the layer.
  14388. */
  14389. readonly camera: Nullable<Camera>;
  14390. /**
  14391. * Gets the rendering group id the layer should render in.
  14392. */
  14393. readonly renderingGroupId: number;
  14394. /**
  14395. * An event triggered when the effect layer has been disposed.
  14396. */
  14397. onDisposeObservable: Observable<EffectLayer>;
  14398. /**
  14399. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14400. */
  14401. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14402. /**
  14403. * An event triggered when the generated texture is being merged in the scene.
  14404. */
  14405. onBeforeComposeObservable: Observable<EffectLayer>;
  14406. /**
  14407. * An event triggered when the generated texture has been merged in the scene.
  14408. */
  14409. onAfterComposeObservable: Observable<EffectLayer>;
  14410. /**
  14411. * An event triggered when the efffect layer changes its size.
  14412. */
  14413. onSizeChangedObservable: Observable<EffectLayer>;
  14414. /**
  14415. * Instantiates a new effect Layer and references it in the scene.
  14416. * @param name The name of the layer
  14417. * @param scene The scene to use the layer in
  14418. */
  14419. constructor(
  14420. /** The Friendly of the effect in the scene */
  14421. name: string, scene: Scene);
  14422. /**
  14423. * Get the effect name of the layer.
  14424. * @return The effect name
  14425. */
  14426. abstract getEffectName(): string;
  14427. /**
  14428. * Checks for the readiness of the element composing the layer.
  14429. * @param subMesh the mesh to check for
  14430. * @param useInstances specify wether or not to use instances to render the mesh
  14431. * @return true if ready otherwise, false
  14432. */
  14433. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14434. /**
  14435. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14436. * @returns true if the effect requires stencil during the main canvas render pass.
  14437. */
  14438. abstract needStencil(): boolean;
  14439. /**
  14440. * Create the merge effect. This is the shader use to blit the information back
  14441. * to the main canvas at the end of the scene rendering.
  14442. * @returns The effect containing the shader used to merge the effect on the main canvas
  14443. */
  14444. protected abstract _createMergeEffect(): Effect;
  14445. /**
  14446. * Creates the render target textures and post processes used in the effect layer.
  14447. */
  14448. protected abstract _createTextureAndPostProcesses(): void;
  14449. /**
  14450. * Implementation specific of rendering the generating effect on the main canvas.
  14451. * @param effect The effect used to render through
  14452. */
  14453. protected abstract _internalRender(effect: Effect): void;
  14454. /**
  14455. * Sets the required values for both the emissive texture and and the main color.
  14456. */
  14457. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14458. /**
  14459. * Free any resources and references associated to a mesh.
  14460. * Internal use
  14461. * @param mesh The mesh to free.
  14462. */
  14463. abstract _disposeMesh(mesh: Mesh): void;
  14464. /**
  14465. * Serializes this layer (Glow or Highlight for example)
  14466. * @returns a serialized layer object
  14467. */
  14468. abstract serialize?(): any;
  14469. /**
  14470. * Initializes the effect layer with the required options.
  14471. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14472. */
  14473. protected _init(options: Partial<IEffectLayerOptions>): void;
  14474. /**
  14475. * Generates the index buffer of the full screen quad blending to the main canvas.
  14476. */
  14477. private _generateIndexBuffer;
  14478. /**
  14479. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14480. */
  14481. private _genrateVertexBuffer;
  14482. /**
  14483. * Sets the main texture desired size which is the closest power of two
  14484. * of the engine canvas size.
  14485. */
  14486. private _setMainTextureSize;
  14487. /**
  14488. * Creates the main texture for the effect layer.
  14489. */
  14490. protected _createMainTexture(): void;
  14491. /**
  14492. * Checks for the readiness of the element composing the layer.
  14493. * @param subMesh the mesh to check for
  14494. * @param useInstances specify wether or not to use instances to render the mesh
  14495. * @param emissiveTexture the associated emissive texture used to generate the glow
  14496. * @return true if ready otherwise, false
  14497. */
  14498. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14499. /**
  14500. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14501. */
  14502. render(): void;
  14503. /**
  14504. * Determine if a given mesh will be used in the current effect.
  14505. * @param mesh mesh to test
  14506. * @returns true if the mesh will be used
  14507. */
  14508. hasMesh(mesh: AbstractMesh): boolean;
  14509. /**
  14510. * Returns true if the layer contains information to display, otherwise false.
  14511. * @returns true if the glow layer should be rendered
  14512. */
  14513. shouldRender(): boolean;
  14514. /**
  14515. * Returns true if the mesh should render, otherwise false.
  14516. * @param mesh The mesh to render
  14517. * @returns true if it should render otherwise false
  14518. */
  14519. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14520. /**
  14521. * Returns true if the mesh should render, otherwise false.
  14522. * @param mesh The mesh to render
  14523. * @returns true if it should render otherwise false
  14524. */
  14525. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14526. /**
  14527. * Renders the submesh passed in parameter to the generation map.
  14528. */
  14529. protected _renderSubMesh(subMesh: SubMesh): void;
  14530. /**
  14531. * Rebuild the required buffers.
  14532. * @hidden Internal use only.
  14533. */
  14534. _rebuild(): void;
  14535. /**
  14536. * Dispose only the render target textures and post process.
  14537. */
  14538. private _disposeTextureAndPostProcesses;
  14539. /**
  14540. * Dispose the highlight layer and free resources.
  14541. */
  14542. dispose(): void;
  14543. /**
  14544. * Gets the class name of the effect layer
  14545. * @returns the string with the class name of the effect layer
  14546. */
  14547. getClassName(): string;
  14548. /**
  14549. * Creates an effect layer from parsed effect layer data
  14550. * @param parsedEffectLayer defines effect layer data
  14551. * @param scene defines the current scene
  14552. * @param rootUrl defines the root URL containing the effect layer information
  14553. * @returns a parsed effect Layer
  14554. */
  14555. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14556. }
  14557. }
  14558. declare module BABYLON {
  14559. interface AbstractScene {
  14560. /**
  14561. * The list of effect layers (highlights/glow) added to the scene
  14562. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14563. * @see http://doc.babylonjs.com/how_to/glow_layer
  14564. */
  14565. effectLayers: Array<EffectLayer>;
  14566. /**
  14567. * Removes the given effect layer from this scene.
  14568. * @param toRemove defines the effect layer to remove
  14569. * @returns the index of the removed effect layer
  14570. */
  14571. removeEffectLayer(toRemove: EffectLayer): number;
  14572. /**
  14573. * Adds the given effect layer to this scene
  14574. * @param newEffectLayer defines the effect layer to add
  14575. */
  14576. addEffectLayer(newEffectLayer: EffectLayer): void;
  14577. }
  14578. /**
  14579. * Defines the layer scene component responsible to manage any effect layers
  14580. * in a given scene.
  14581. */
  14582. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14583. /**
  14584. * The component name helpfull to identify the component in the list of scene components.
  14585. */
  14586. readonly name: string;
  14587. /**
  14588. * The scene the component belongs to.
  14589. */
  14590. scene: Scene;
  14591. private _engine;
  14592. private _renderEffects;
  14593. private _needStencil;
  14594. private _previousStencilState;
  14595. /**
  14596. * Creates a new instance of the component for the given scene
  14597. * @param scene Defines the scene to register the component in
  14598. */
  14599. constructor(scene: Scene);
  14600. /**
  14601. * Registers the component in a given scene
  14602. */
  14603. register(): void;
  14604. /**
  14605. * Rebuilds the elements related to this component in case of
  14606. * context lost for instance.
  14607. */
  14608. rebuild(): void;
  14609. /**
  14610. * Serializes the component data to the specified json object
  14611. * @param serializationObject The object to serialize to
  14612. */
  14613. serialize(serializationObject: any): void;
  14614. /**
  14615. * Adds all the element from the container to the scene
  14616. * @param container the container holding the elements
  14617. */
  14618. addFromContainer(container: AbstractScene): void;
  14619. /**
  14620. * Removes all the elements in the container from the scene
  14621. * @param container contains the elements to remove
  14622. */
  14623. removeFromContainer(container: AbstractScene): void;
  14624. /**
  14625. * Disposes the component and the associated ressources.
  14626. */
  14627. dispose(): void;
  14628. private _isReadyForMesh;
  14629. private _renderMainTexture;
  14630. private _setStencil;
  14631. private _setStencilBack;
  14632. private _draw;
  14633. private _drawCamera;
  14634. private _drawRenderingGroup;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. interface AbstractScene {
  14639. /**
  14640. * Return a the first highlight layer of the scene with a given name.
  14641. * @param name The name of the highlight layer to look for.
  14642. * @return The highlight layer if found otherwise null.
  14643. */
  14644. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14645. }
  14646. /**
  14647. * Glow layer options. This helps customizing the behaviour
  14648. * of the glow layer.
  14649. */
  14650. interface IGlowLayerOptions {
  14651. /**
  14652. * Multiplication factor apply to the canvas size to compute the render target size
  14653. * used to generated the glowing objects (the smaller the faster).
  14654. */
  14655. mainTextureRatio: number;
  14656. /**
  14657. * Enforces a fixed size texture to ensure resize independant blur.
  14658. */
  14659. mainTextureFixedSize?: number;
  14660. /**
  14661. * How big is the kernel of the blur texture.
  14662. */
  14663. blurKernelSize: number;
  14664. /**
  14665. * The camera attached to the layer.
  14666. */
  14667. camera: Nullable<Camera>;
  14668. /**
  14669. * Enable MSAA by chosing the number of samples.
  14670. */
  14671. mainTextureSamples?: number;
  14672. /**
  14673. * The rendering group to draw the layer in.
  14674. */
  14675. renderingGroupId: number;
  14676. }
  14677. /**
  14678. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14679. *
  14680. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14681. * glowy meshes to your scene.
  14682. *
  14683. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14684. */
  14685. class GlowLayer extends EffectLayer {
  14686. /**
  14687. * Effect Name of the layer.
  14688. */
  14689. static readonly EffectName: string;
  14690. /**
  14691. * The default blur kernel size used for the glow.
  14692. */
  14693. static DefaultBlurKernelSize: number;
  14694. /**
  14695. * The default texture size ratio used for the glow.
  14696. */
  14697. static DefaultTextureRatio: number;
  14698. /**
  14699. * Sets the kernel size of the blur.
  14700. */
  14701. /**
  14702. * Gets the kernel size of the blur.
  14703. */
  14704. blurKernelSize: number;
  14705. /**
  14706. * Sets the glow intensity.
  14707. */
  14708. /**
  14709. * Gets the glow intensity.
  14710. */
  14711. intensity: number;
  14712. private _options;
  14713. private _intensity;
  14714. private _horizontalBlurPostprocess1;
  14715. private _verticalBlurPostprocess1;
  14716. private _horizontalBlurPostprocess2;
  14717. private _verticalBlurPostprocess2;
  14718. private _blurTexture1;
  14719. private _blurTexture2;
  14720. private _postProcesses1;
  14721. private _postProcesses2;
  14722. private _includedOnlyMeshes;
  14723. private _excludedMeshes;
  14724. /**
  14725. * Callback used to let the user override the color selection on a per mesh basis
  14726. */
  14727. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14728. /**
  14729. * Callback used to let the user override the texture selection on a per mesh basis
  14730. */
  14731. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14732. /**
  14733. * Instantiates a new glow Layer and references it to the scene.
  14734. * @param name The name of the layer
  14735. * @param scene The scene to use the layer in
  14736. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14737. */
  14738. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14739. /**
  14740. * Get the effect name of the layer.
  14741. * @return The effect name
  14742. */
  14743. getEffectName(): string;
  14744. /**
  14745. * Create the merge effect. This is the shader use to blit the information back
  14746. * to the main canvas at the end of the scene rendering.
  14747. */
  14748. protected _createMergeEffect(): Effect;
  14749. /**
  14750. * Creates the render target textures and post processes used in the glow layer.
  14751. */
  14752. protected _createTextureAndPostProcesses(): void;
  14753. /**
  14754. * Checks for the readiness of the element composing the layer.
  14755. * @param subMesh the mesh to check for
  14756. * @param useInstances specify wether or not to use instances to render the mesh
  14757. * @param emissiveTexture the associated emissive texture used to generate the glow
  14758. * @return true if ready otherwise, false
  14759. */
  14760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14761. /**
  14762. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14763. */
  14764. needStencil(): boolean;
  14765. /**
  14766. * Implementation specific of rendering the generating effect on the main canvas.
  14767. * @param effect The effect used to render through
  14768. */
  14769. protected _internalRender(effect: Effect): void;
  14770. /**
  14771. * Sets the required values for both the emissive texture and and the main color.
  14772. */
  14773. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14774. /**
  14775. * Returns true if the mesh should render, otherwise false.
  14776. * @param mesh The mesh to render
  14777. * @returns true if it should render otherwise false
  14778. */
  14779. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14780. /**
  14781. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14782. * @param mesh The mesh to exclude from the glow layer
  14783. */
  14784. addExcludedMesh(mesh: Mesh): void;
  14785. /**
  14786. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14787. * @param mesh The mesh to remove
  14788. */
  14789. removeExcludedMesh(mesh: Mesh): void;
  14790. /**
  14791. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14792. * @param mesh The mesh to include in the glow layer
  14793. */
  14794. addIncludedOnlyMesh(mesh: Mesh): void;
  14795. /**
  14796. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14797. * @param mesh The mesh to remove
  14798. */
  14799. removeIncludedOnlyMesh(mesh: Mesh): void;
  14800. /**
  14801. * Determine if a given mesh will be used in the glow layer
  14802. * @param mesh The mesh to test
  14803. * @returns true if the mesh will be highlighted by the current glow layer
  14804. */
  14805. hasMesh(mesh: AbstractMesh): boolean;
  14806. /**
  14807. * Free any resources and references associated to a mesh.
  14808. * Internal use
  14809. * @param mesh The mesh to free.
  14810. * @hidden
  14811. */
  14812. _disposeMesh(mesh: Mesh): void;
  14813. /**
  14814. * Gets the class name of the effect layer
  14815. * @returns the string with the class name of the effect layer
  14816. */
  14817. getClassName(): string;
  14818. /**
  14819. * Serializes this glow layer
  14820. * @returns a serialized glow layer object
  14821. */
  14822. serialize(): any;
  14823. /**
  14824. * Creates a Glow Layer from parsed glow layer data
  14825. * @param parsedGlowLayer defines glow layer data
  14826. * @param scene defines the current scene
  14827. * @param rootUrl defines the root URL containing the glow layer information
  14828. * @returns a parsed Glow Layer
  14829. */
  14830. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14831. }
  14832. }
  14833. declare module BABYLON {
  14834. interface AbstractScene {
  14835. /**
  14836. * Return a the first highlight layer of the scene with a given name.
  14837. * @param name The name of the highlight layer to look for.
  14838. * @return The highlight layer if found otherwise null.
  14839. */
  14840. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14841. }
  14842. /**
  14843. * Highlight layer options. This helps customizing the behaviour
  14844. * of the highlight layer.
  14845. */
  14846. interface IHighlightLayerOptions {
  14847. /**
  14848. * Multiplication factor apply to the canvas size to compute the render target size
  14849. * used to generated the glowing objects (the smaller the faster).
  14850. */
  14851. mainTextureRatio: number;
  14852. /**
  14853. * Enforces a fixed size texture to ensure resize independant blur.
  14854. */
  14855. mainTextureFixedSize?: number;
  14856. /**
  14857. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14858. * of the picture to blur (the smaller the faster).
  14859. */
  14860. blurTextureSizeRatio: number;
  14861. /**
  14862. * How big in texel of the blur texture is the vertical blur.
  14863. */
  14864. blurVerticalSize: number;
  14865. /**
  14866. * How big in texel of the blur texture is the horizontal blur.
  14867. */
  14868. blurHorizontalSize: number;
  14869. /**
  14870. * Alpha blending mode used to apply the blur. Default is combine.
  14871. */
  14872. alphaBlendingMode: number;
  14873. /**
  14874. * The camera attached to the layer.
  14875. */
  14876. camera: Nullable<Camera>;
  14877. /**
  14878. * Should we display highlight as a solid stroke?
  14879. */
  14880. isStroke?: boolean;
  14881. /**
  14882. * The rendering group to draw the layer in.
  14883. */
  14884. renderingGroupId: number;
  14885. }
  14886. /**
  14887. * The highlight layer Helps adding a glow effect around a mesh.
  14888. *
  14889. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14890. * glowy meshes to your scene.
  14891. *
  14892. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14893. */
  14894. class HighlightLayer extends EffectLayer {
  14895. name: string;
  14896. /**
  14897. * Effect Name of the highlight layer.
  14898. */
  14899. static readonly EffectName: string;
  14900. /**
  14901. * The neutral color used during the preparation of the glow effect.
  14902. * This is black by default as the blend operation is a blend operation.
  14903. */
  14904. static NeutralColor: Color4;
  14905. /**
  14906. * Stencil value used for glowing meshes.
  14907. */
  14908. static GlowingMeshStencilReference: number;
  14909. /**
  14910. * Stencil value used for the other meshes in the scene.
  14911. */
  14912. static NormalMeshStencilReference: number;
  14913. /**
  14914. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14915. */
  14916. innerGlow: boolean;
  14917. /**
  14918. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14919. */
  14920. outerGlow: boolean;
  14921. /**
  14922. * Specifies the horizontal size of the blur.
  14923. */
  14924. /**
  14925. * Gets the horizontal size of the blur.
  14926. */
  14927. blurHorizontalSize: number;
  14928. /**
  14929. * Specifies the vertical size of the blur.
  14930. */
  14931. /**
  14932. * Gets the vertical size of the blur.
  14933. */
  14934. blurVerticalSize: number;
  14935. /**
  14936. * An event triggered when the highlight layer is being blurred.
  14937. */
  14938. onBeforeBlurObservable: Observable<HighlightLayer>;
  14939. /**
  14940. * An event triggered when the highlight layer has been blurred.
  14941. */
  14942. onAfterBlurObservable: Observable<HighlightLayer>;
  14943. private _instanceGlowingMeshStencilReference;
  14944. private _options;
  14945. private _downSamplePostprocess;
  14946. private _horizontalBlurPostprocess;
  14947. private _verticalBlurPostprocess;
  14948. private _blurTexture;
  14949. private _meshes;
  14950. private _excludedMeshes;
  14951. /**
  14952. * Instantiates a new highlight Layer and references it to the scene..
  14953. * @param name The name of the layer
  14954. * @param scene The scene to use the layer in
  14955. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14956. */
  14957. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14958. /**
  14959. * Get the effect name of the layer.
  14960. * @return The effect name
  14961. */
  14962. getEffectName(): string;
  14963. /**
  14964. * Create the merge effect. This is the shader use to blit the information back
  14965. * to the main canvas at the end of the scene rendering.
  14966. */
  14967. protected _createMergeEffect(): Effect;
  14968. /**
  14969. * Creates the render target textures and post processes used in the highlight layer.
  14970. */
  14971. protected _createTextureAndPostProcesses(): void;
  14972. /**
  14973. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14974. */
  14975. needStencil(): boolean;
  14976. /**
  14977. * Checks for the readiness of the element composing the layer.
  14978. * @param subMesh the mesh to check for
  14979. * @param useInstances specify wether or not to use instances to render the mesh
  14980. * @param emissiveTexture the associated emissive texture used to generate the glow
  14981. * @return true if ready otherwise, false
  14982. */
  14983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14984. /**
  14985. * Implementation specific of rendering the generating effect on the main canvas.
  14986. * @param effect The effect used to render through
  14987. */
  14988. protected _internalRender(effect: Effect): void;
  14989. /**
  14990. * Returns true if the layer contains information to display, otherwise false.
  14991. */
  14992. shouldRender(): boolean;
  14993. /**
  14994. * Returns true if the mesh should render, otherwise false.
  14995. * @param mesh The mesh to render
  14996. * @returns true if it should render otherwise false
  14997. */
  14998. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14999. /**
  15000. * Sets the required values for both the emissive texture and and the main color.
  15001. */
  15002. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15003. /**
  15004. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15005. * @param mesh The mesh to exclude from the highlight layer
  15006. */
  15007. addExcludedMesh(mesh: Mesh): void;
  15008. /**
  15009. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15010. * @param mesh The mesh to highlight
  15011. */
  15012. removeExcludedMesh(mesh: Mesh): void;
  15013. /**
  15014. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15015. * @param mesh mesh to test
  15016. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15017. */
  15018. hasMesh(mesh: AbstractMesh): boolean;
  15019. /**
  15020. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15021. * @param mesh The mesh to highlight
  15022. * @param color The color of the highlight
  15023. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15024. */
  15025. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15026. /**
  15027. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15028. * @param mesh The mesh to highlight
  15029. */
  15030. removeMesh(mesh: Mesh): void;
  15031. /**
  15032. * Force the stencil to the normal expected value for none glowing parts
  15033. */
  15034. private _defaultStencilReference;
  15035. /**
  15036. * Free any resources and references associated to a mesh.
  15037. * Internal use
  15038. * @param mesh The mesh to free.
  15039. * @hidden
  15040. */
  15041. _disposeMesh(mesh: Mesh): void;
  15042. /**
  15043. * Dispose the highlight layer and free resources.
  15044. */
  15045. dispose(): void;
  15046. /**
  15047. * Gets the class name of the effect layer
  15048. * @returns the string with the class name of the effect layer
  15049. */
  15050. getClassName(): string;
  15051. /**
  15052. * Serializes this Highlight layer
  15053. * @returns a serialized Highlight layer object
  15054. */
  15055. serialize(): any;
  15056. /**
  15057. * Creates a Highlight layer from parsed Highlight layer data
  15058. * @param parsedHightlightLayer defines the Highlight layer data
  15059. * @param scene defines the current scene
  15060. * @param rootUrl defines the root URL containing the Highlight layer information
  15061. * @returns a parsed Highlight layer
  15062. */
  15063. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15064. }
  15065. }
  15066. declare module BABYLON {
  15067. /**
  15068. * This represents a full screen 2d layer.
  15069. * This can be useful to display a picture in the background of your scene for instance.
  15070. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15071. */
  15072. class Layer {
  15073. /**
  15074. * Define the name of the layer.
  15075. */
  15076. name: string;
  15077. /**
  15078. * Define the texture the layer should display.
  15079. */
  15080. texture: Nullable<Texture>;
  15081. /**
  15082. * Is the layer in background or foreground.
  15083. */
  15084. isBackground: boolean;
  15085. /**
  15086. * Define the color of the layer (instead of texture).
  15087. */
  15088. color: Color4;
  15089. /**
  15090. * Define the scale of the layer in order to zoom in out of the texture.
  15091. */
  15092. scale: Vector2;
  15093. /**
  15094. * Define an offset for the layer in order to shift the texture.
  15095. */
  15096. offset: Vector2;
  15097. /**
  15098. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15099. */
  15100. alphaBlendingMode: number;
  15101. /**
  15102. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15103. * Alpha test will not mix with the background color in case of transparency.
  15104. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15105. */
  15106. alphaTest: boolean;
  15107. /**
  15108. * Define a mask to restrict the layer to only some of the scene cameras.
  15109. */
  15110. layerMask: number;
  15111. /**
  15112. * Define the list of render target the layer is visible into.
  15113. */
  15114. renderTargetTextures: RenderTargetTexture[];
  15115. /**
  15116. * Define if the layer is only used in renderTarget or if it also
  15117. * renders in the main frame buffer of the canvas.
  15118. */
  15119. renderOnlyInRenderTargetTextures: boolean;
  15120. private _scene;
  15121. private _vertexBuffers;
  15122. private _indexBuffer;
  15123. private _effect;
  15124. private _alphaTestEffect;
  15125. /**
  15126. * An event triggered when the layer is disposed.
  15127. */
  15128. onDisposeObservable: Observable<Layer>;
  15129. private _onDisposeObserver;
  15130. /**
  15131. * Back compatibility with callback before the onDisposeObservable existed.
  15132. * The set callback will be triggered when the layer has been disposed.
  15133. */
  15134. onDispose: () => void;
  15135. /**
  15136. * An event triggered before rendering the scene
  15137. */
  15138. onBeforeRenderObservable: Observable<Layer>;
  15139. private _onBeforeRenderObserver;
  15140. /**
  15141. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15142. * The set callback will be triggered just before rendering the layer.
  15143. */
  15144. onBeforeRender: () => void;
  15145. /**
  15146. * An event triggered after rendering the scene
  15147. */
  15148. onAfterRenderObservable: Observable<Layer>;
  15149. private _onAfterRenderObserver;
  15150. /**
  15151. * Back compatibility with callback before the onAfterRenderObservable existed.
  15152. * The set callback will be triggered just after rendering the layer.
  15153. */
  15154. onAfterRender: () => void;
  15155. /**
  15156. * Instantiates a new layer.
  15157. * This represents a full screen 2d layer.
  15158. * This can be useful to display a picture in the background of your scene for instance.
  15159. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15160. * @param name Define the name of the layer in the scene
  15161. * @param imgUrl Define the url of the texture to display in the layer
  15162. * @param scene Define the scene the layer belongs to
  15163. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15164. * @param color Defines a color for the layer
  15165. */
  15166. constructor(
  15167. /**
  15168. * Define the name of the layer.
  15169. */
  15170. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15171. private _createIndexBuffer;
  15172. /** @hidden */
  15173. _rebuild(): void;
  15174. /**
  15175. * Renders the layer in the scene.
  15176. */
  15177. render(): void;
  15178. /**
  15179. * Disposes and releases the associated ressources.
  15180. */
  15181. dispose(): void;
  15182. }
  15183. }
  15184. declare module BABYLON {
  15185. interface AbstractScene {
  15186. /**
  15187. * The list of layers (background and foreground) of the scene
  15188. */
  15189. layers: Array<Layer>;
  15190. }
  15191. /**
  15192. * Defines the layer scene component responsible to manage any layers
  15193. * in a given scene.
  15194. */
  15195. class LayerSceneComponent implements ISceneComponent {
  15196. /**
  15197. * The component name helpfull to identify the component in the list of scene components.
  15198. */
  15199. readonly name: string;
  15200. /**
  15201. * The scene the component belongs to.
  15202. */
  15203. scene: Scene;
  15204. private _engine;
  15205. /**
  15206. * Creates a new instance of the component for the given scene
  15207. * @param scene Defines the scene to register the component in
  15208. */
  15209. constructor(scene: Scene);
  15210. /**
  15211. * Registers the component in a given scene
  15212. */
  15213. register(): void;
  15214. /**
  15215. * Rebuilds the elements related to this component in case of
  15216. * context lost for instance.
  15217. */
  15218. rebuild(): void;
  15219. /**
  15220. * Disposes the component and the associated ressources.
  15221. */
  15222. dispose(): void;
  15223. private _draw;
  15224. private _drawCameraPredicate;
  15225. private _drawCameraBackground;
  15226. private _drawCameraForeground;
  15227. private _drawRenderTargetPredicate;
  15228. private _drawRenderTargetBackground;
  15229. private _drawRenderTargetForeground;
  15230. }
  15231. }
  15232. declare module BABYLON {
  15233. /**
  15234. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15235. * It controls one of the indiviual texture used in the effect.
  15236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15237. */
  15238. class LensFlare {
  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;
  15247. /**
  15248. * Define the lens color.
  15249. */
  15250. color: Color3;
  15251. /**
  15252. * Define the lens texture.
  15253. */
  15254. texture: Nullable<Texture>;
  15255. /**
  15256. * Define the alpha mode to render this particular lens.
  15257. */
  15258. alphaMode: number;
  15259. private _system;
  15260. /**
  15261. * Creates a new Lens Flare.
  15262. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15263. * It controls one of the indiviual texture used in the effect.
  15264. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15265. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15266. * @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.
  15267. * @param color Define the lens color
  15268. * @param imgUrl Define the lens texture url
  15269. * @param system Define the `lensFlareSystem` this flare is part of
  15270. * @returns The newly created Lens Flare
  15271. */
  15272. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15273. /**
  15274. * Instantiates a new Lens Flare.
  15275. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15276. * It controls one of the indiviual texture used in the effect.
  15277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15278. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15279. * @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.
  15280. * @param color Define the lens color
  15281. * @param imgUrl Define the lens texture url
  15282. * @param system Define the `lensFlareSystem` this flare is part of
  15283. */
  15284. constructor(
  15285. /**
  15286. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15287. */
  15288. size: number,
  15289. /**
  15290. * 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.
  15291. */
  15292. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15293. /**
  15294. * Dispose and release the lens flare with its associated resources.
  15295. */
  15296. dispose(): void;
  15297. }
  15298. }
  15299. declare module BABYLON {
  15300. /**
  15301. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15302. * It is usually composed of several `BABYLON.lensFlare`.
  15303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15304. */
  15305. class LensFlareSystem {
  15306. /**
  15307. * Define the name of the lens flare system
  15308. */
  15309. name: string;
  15310. /**
  15311. * List of lens flares used in this system.
  15312. */
  15313. lensFlares: LensFlare[];
  15314. /**
  15315. * Define a limit from the border the lens flare can be visible.
  15316. */
  15317. borderLimit: number;
  15318. /**
  15319. * Define a viewport border we do not want to see the lens flare in.
  15320. */
  15321. viewportBorder: number;
  15322. /**
  15323. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15324. */
  15325. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15326. /**
  15327. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15328. */
  15329. layerMask: number;
  15330. /**
  15331. * Define the id of the lens flare system in the scene.
  15332. * (equal to name by default)
  15333. */
  15334. id: string;
  15335. private _scene;
  15336. private _emitter;
  15337. private _vertexBuffers;
  15338. private _indexBuffer;
  15339. private _effect;
  15340. private _positionX;
  15341. private _positionY;
  15342. private _isEnabled;
  15343. /**
  15344. * Instantiates a lens flare system.
  15345. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15346. * It is usually composed of several `BABYLON.lensFlare`.
  15347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15348. * @param name Define the name of the lens flare system in the scene
  15349. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15350. * @param scene Define the scene the lens flare system belongs to
  15351. */
  15352. constructor(
  15353. /**
  15354. * Define the name of the lens flare system
  15355. */
  15356. name: string, emitter: any, scene: Scene);
  15357. /**
  15358. * Define if the lens flare system is enabled.
  15359. */
  15360. isEnabled: boolean;
  15361. /**
  15362. * Get the scene the effects belongs to.
  15363. * @returns the scene holding the lens flare system
  15364. */
  15365. getScene(): Scene;
  15366. /**
  15367. * Get the emitter of the lens flare system.
  15368. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15369. * @returns the emitter of the lens flare system
  15370. */
  15371. getEmitter(): any;
  15372. /**
  15373. * Set the emitter of the lens flare system.
  15374. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15375. * @param newEmitter Define the new emitter of the system
  15376. */
  15377. setEmitter(newEmitter: any): void;
  15378. /**
  15379. * Get the lens flare system emitter position.
  15380. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15381. * @returns the position
  15382. */
  15383. getEmitterPosition(): Vector3;
  15384. /**
  15385. * @hidden
  15386. */
  15387. computeEffectivePosition(globalViewport: Viewport): boolean;
  15388. /** @hidden */
  15389. _isVisible(): boolean;
  15390. /**
  15391. * @hidden
  15392. */
  15393. render(): boolean;
  15394. /**
  15395. * Dispose and release the lens flare with its associated resources.
  15396. */
  15397. dispose(): void;
  15398. /**
  15399. * Parse a lens flare system from a JSON repressentation
  15400. * @param parsedLensFlareSystem Define the JSON to parse
  15401. * @param scene Define the scene the parsed system should be instantiated in
  15402. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15403. * @returns the parsed system
  15404. */
  15405. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15406. /**
  15407. * Serialize the current Lens Flare System into a JSON representation.
  15408. * @returns the serialized JSON
  15409. */
  15410. serialize(): any;
  15411. }
  15412. }
  15413. declare module BABYLON {
  15414. interface AbstractScene {
  15415. /**
  15416. * The list of lens flare system added to the scene
  15417. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15418. */
  15419. lensFlareSystems: Array<LensFlareSystem>;
  15420. /**
  15421. * Removes the given lens flare system from this scene.
  15422. * @param toRemove The lens flare system to remove
  15423. * @returns The index of the removed lens flare system
  15424. */
  15425. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15426. /**
  15427. * Adds the given lens flare system to this scene
  15428. * @param newLensFlareSystem The lens flare system to add
  15429. */
  15430. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15431. /**
  15432. * Gets a lens flare system using its name
  15433. * @param name defines the name to look for
  15434. * @returns the lens flare system or null if not found
  15435. */
  15436. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15437. /**
  15438. * Gets a lens flare system using its id
  15439. * @param id defines the id to look for
  15440. * @returns the lens flare system or null if not found
  15441. */
  15442. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15443. }
  15444. /**
  15445. * Defines the lens flare scene component responsible to manage any lens flares
  15446. * in a given scene.
  15447. */
  15448. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15449. /**
  15450. * The component name helpfull to identify the component in the list of scene components.
  15451. */
  15452. readonly name: string;
  15453. /**
  15454. * The scene the component belongs to.
  15455. */
  15456. scene: Scene;
  15457. /**
  15458. * Creates a new instance of the component for the given scene
  15459. * @param scene Defines the scene to register the component in
  15460. */
  15461. constructor(scene: Scene);
  15462. /**
  15463. * Registers the component in a given scene
  15464. */
  15465. register(): void;
  15466. /**
  15467. * Rebuilds the elements related to this component in case of
  15468. * context lost for instance.
  15469. */
  15470. rebuild(): void;
  15471. /**
  15472. * Adds all the element from the container to the scene
  15473. * @param container the container holding the elements
  15474. */
  15475. addFromContainer(container: AbstractScene): void;
  15476. /**
  15477. * Removes all the elements in the container from the scene
  15478. * @param container contains the elements to remove
  15479. */
  15480. removeFromContainer(container: AbstractScene): void;
  15481. /**
  15482. * Serializes the component data to the specified json object
  15483. * @param serializationObject The object to serialize to
  15484. */
  15485. serialize(serializationObject: any): void;
  15486. /**
  15487. * Disposes the component and the associated ressources.
  15488. */
  15489. dispose(): void;
  15490. private _draw;
  15491. }
  15492. }
  15493. declare module BABYLON {
  15494. /**
  15495. * A directional light is defined by a direction (what a surprise!).
  15496. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15497. * 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.
  15498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15499. */
  15500. class DirectionalLight extends ShadowLight {
  15501. private _shadowFrustumSize;
  15502. /**
  15503. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15504. */
  15505. /**
  15506. * Specifies a fix frustum size for the shadow generation.
  15507. */
  15508. shadowFrustumSize: number;
  15509. private _shadowOrthoScale;
  15510. /**
  15511. * Gets the shadow projection scale against the optimal computed one.
  15512. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15513. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15514. */
  15515. /**
  15516. * Sets the shadow projection scale against the optimal computed one.
  15517. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15518. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15519. */
  15520. shadowOrthoScale: number;
  15521. /**
  15522. * Automatically compute the projection matrix to best fit (including all the casters)
  15523. * on each frame.
  15524. */
  15525. autoUpdateExtends: boolean;
  15526. private _orthoLeft;
  15527. private _orthoRight;
  15528. private _orthoTop;
  15529. private _orthoBottom;
  15530. /**
  15531. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15532. * The directional light is emitted from everywhere in the given direction.
  15533. * It can cast shadows.
  15534. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15535. * @param name The friendly name of the light
  15536. * @param direction The direction of the light
  15537. * @param scene The scene the light belongs to
  15538. */
  15539. constructor(name: string, direction: Vector3, scene: Scene);
  15540. /**
  15541. * Returns the string "DirectionalLight".
  15542. * @return The class name
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Returns the integer 1.
  15547. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15548. */
  15549. getTypeID(): number;
  15550. /**
  15551. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15552. * Returns the DirectionalLight Shadow projection matrix.
  15553. */
  15554. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15555. /**
  15556. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15557. * Returns the DirectionalLight Shadow projection matrix.
  15558. */
  15559. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15560. /**
  15561. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15562. * Returns the DirectionalLight Shadow projection matrix.
  15563. */
  15564. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15565. protected _buildUniformLayout(): void;
  15566. /**
  15567. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15568. * @param effect The effect to update
  15569. * @param lightIndex The index of the light in the effect to update
  15570. * @returns The directional light
  15571. */
  15572. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15573. /**
  15574. * Gets the minZ used for shadow according to both the scene and the light.
  15575. *
  15576. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15577. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15578. * @param activeCamera The camera we are returning the min for
  15579. * @returns the depth min z
  15580. */
  15581. getDepthMinZ(activeCamera: Camera): number;
  15582. /**
  15583. * Gets the maxZ used for shadow according to both the scene and the light.
  15584. *
  15585. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15586. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15587. * @param activeCamera The camera we are returning the max for
  15588. * @returns the depth max z
  15589. */
  15590. getDepthMaxZ(activeCamera: Camera): number;
  15591. /**
  15592. * Prepares the list of defines specific to the light type.
  15593. * @param defines the list of defines
  15594. * @param lightIndex defines the index of the light for the effect
  15595. */
  15596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15597. }
  15598. }
  15599. declare module BABYLON {
  15600. /**
  15601. * The HemisphericLight simulates the ambient environment light,
  15602. * so the passed direction is the light reflection direction, not the incoming direction.
  15603. */
  15604. class HemisphericLight extends Light {
  15605. /**
  15606. * The groundColor is the light in the opposite direction to the one specified during creation.
  15607. * 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.
  15608. */
  15609. groundColor: Color3;
  15610. /**
  15611. * The light reflection direction, not the incoming direction.
  15612. */
  15613. direction: Vector3;
  15614. /**
  15615. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15616. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15617. * The HemisphericLight can't cast shadows.
  15618. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15619. * @param name The friendly name of the light
  15620. * @param direction The direction of the light reflection
  15621. * @param scene The scene the light belongs to
  15622. */
  15623. constructor(name: string, direction: Vector3, scene: Scene);
  15624. protected _buildUniformLayout(): void;
  15625. /**
  15626. * Returns the string "HemisphericLight".
  15627. * @return The class name
  15628. */
  15629. getClassName(): string;
  15630. /**
  15631. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15632. * Returns the updated direction.
  15633. * @param target The target the direction should point to
  15634. * @return The computed direction
  15635. */
  15636. setDirectionToTarget(target: Vector3): Vector3;
  15637. /**
  15638. * Returns the shadow generator associated to the light.
  15639. * @returns Always null for hemispheric lights because it does not support shadows.
  15640. */
  15641. getShadowGenerator(): Nullable<IShadowGenerator>;
  15642. /**
  15643. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15644. * @param effect The effect to update
  15645. * @param lightIndex The index of the light in the effect to update
  15646. * @returns The hemispheric light
  15647. */
  15648. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15649. /**
  15650. * Computes the world matrix of the node
  15651. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15652. * @param useWasUpdatedFlag defines a reserved property
  15653. * @returns the world matrix
  15654. */
  15655. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15656. /**
  15657. * Returns the integer 3.
  15658. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15659. */
  15660. getTypeID(): number;
  15661. /**
  15662. * Prepares the list of defines specific to the light type.
  15663. * @param defines the list of defines
  15664. * @param lightIndex defines the index of the light for the effect
  15665. */
  15666. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15667. }
  15668. }
  15669. declare module BABYLON {
  15670. /**
  15671. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15672. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15673. * 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.
  15674. */
  15675. abstract class Light extends Node {
  15676. /**
  15677. * Falloff Default: light is falling off following the material specification:
  15678. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15679. */
  15680. static readonly FALLOFF_DEFAULT: number;
  15681. /**
  15682. * Falloff Physical: light is falling off following the inverse squared distance law.
  15683. */
  15684. static readonly FALLOFF_PHYSICAL: number;
  15685. /**
  15686. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15687. * to enhance interoperability with other engines.
  15688. */
  15689. static readonly FALLOFF_GLTF: number;
  15690. /**
  15691. * Falloff Standard: light is falling off like in the standard material
  15692. * to enhance interoperability with other materials.
  15693. */
  15694. static readonly FALLOFF_STANDARD: number;
  15695. /**
  15696. * If every light affecting the material is in this lightmapMode,
  15697. * material.lightmapTexture adds or multiplies
  15698. * (depends on material.useLightmapAsShadowmap)
  15699. * after every other light calculations.
  15700. */
  15701. static readonly LIGHTMAP_DEFAULT: number;
  15702. /**
  15703. * material.lightmapTexture as only diffuse lighting from this light
  15704. * adds only specular lighting from this light
  15705. * adds dynamic shadows
  15706. */
  15707. static readonly LIGHTMAP_SPECULAR: number;
  15708. /**
  15709. * material.lightmapTexture as only lighting
  15710. * no light calculation from this light
  15711. * only adds dynamic shadows from this light
  15712. */
  15713. static readonly LIGHTMAP_SHADOWSONLY: number;
  15714. /**
  15715. * Each light type uses the default quantity according to its type:
  15716. * point/spot lights use luminous intensity
  15717. * directional lights use illuminance
  15718. */
  15719. static readonly INTENSITYMODE_AUTOMATIC: number;
  15720. /**
  15721. * lumen (lm)
  15722. */
  15723. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15724. /**
  15725. * candela (lm/sr)
  15726. */
  15727. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15728. /**
  15729. * lux (lm/m^2)
  15730. */
  15731. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15732. /**
  15733. * nit (cd/m^2)
  15734. */
  15735. static readonly INTENSITYMODE_LUMINANCE: number;
  15736. /**
  15737. * Light type const id of the point light.
  15738. */
  15739. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15740. /**
  15741. * Light type const id of the directional light.
  15742. */
  15743. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15744. /**
  15745. * Light type const id of the spot light.
  15746. */
  15747. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15748. /**
  15749. * Light type const id of the hemispheric light.
  15750. */
  15751. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15752. /**
  15753. * Diffuse gives the basic color to an object.
  15754. */
  15755. diffuse: Color3;
  15756. /**
  15757. * Specular produces a highlight color on an object.
  15758. * Note: This is note affecting PBR materials.
  15759. */
  15760. specular: Color3;
  15761. /**
  15762. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15763. * falling off base on range or angle.
  15764. * This can be set to any values in Light.FALLOFF_x.
  15765. *
  15766. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15767. * other types of materials.
  15768. */
  15769. falloffType: number;
  15770. /**
  15771. * Strength of the light.
  15772. * Note: By default it is define in the framework own unit.
  15773. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15774. */
  15775. intensity: number;
  15776. private _range;
  15777. protected _inverseSquaredRange: number;
  15778. /**
  15779. * Defines how far from the source the light is impacting in scene units.
  15780. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15781. */
  15782. /**
  15783. * Defines how far from the source the light is impacting in scene units.
  15784. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15785. */
  15786. range: number;
  15787. /**
  15788. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15789. * of light.
  15790. */
  15791. private _photometricScale;
  15792. private _intensityMode;
  15793. /**
  15794. * Gets the photometric scale used to interpret the intensity.
  15795. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15796. */
  15797. /**
  15798. * Sets the photometric scale used to interpret the intensity.
  15799. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15800. */
  15801. intensityMode: number;
  15802. private _radius;
  15803. /**
  15804. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15805. */
  15806. /**
  15807. * sets the light radius used by PBR Materials to simulate soft area lights.
  15808. */
  15809. radius: number;
  15810. private _renderPriority;
  15811. /**
  15812. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15813. * exceeding the number allowed of the materials.
  15814. */
  15815. renderPriority: number;
  15816. private _shadowEnabled;
  15817. /**
  15818. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15819. * the current shadow generator.
  15820. */
  15821. /**
  15822. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15823. * the current shadow generator.
  15824. */
  15825. shadowEnabled: boolean;
  15826. private _includedOnlyMeshes;
  15827. /**
  15828. * Gets the only meshes impacted by this light.
  15829. */
  15830. /**
  15831. * Sets the only meshes impacted by this light.
  15832. */
  15833. includedOnlyMeshes: AbstractMesh[];
  15834. private _excludedMeshes;
  15835. /**
  15836. * Gets the meshes not impacted by this light.
  15837. */
  15838. /**
  15839. * Sets the meshes not impacted by this light.
  15840. */
  15841. excludedMeshes: AbstractMesh[];
  15842. private _excludeWithLayerMask;
  15843. /**
  15844. * Gets the layer id use to find what meshes are not impacted by the light.
  15845. * Inactive if 0
  15846. */
  15847. /**
  15848. * Sets the layer id use to find what meshes are not impacted by the light.
  15849. * Inactive if 0
  15850. */
  15851. excludeWithLayerMask: number;
  15852. private _includeOnlyWithLayerMask;
  15853. /**
  15854. * Gets the layer id use to find what meshes are impacted by the light.
  15855. * Inactive if 0
  15856. */
  15857. /**
  15858. * Sets the layer id use to find what meshes are impacted by the light.
  15859. * Inactive if 0
  15860. */
  15861. includeOnlyWithLayerMask: number;
  15862. private _lightmapMode;
  15863. /**
  15864. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15865. */
  15866. /**
  15867. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15868. */
  15869. lightmapMode: number;
  15870. /**
  15871. * Shadow generator associted to the light.
  15872. * @hidden Internal use only.
  15873. */
  15874. _shadowGenerator: Nullable<IShadowGenerator>;
  15875. /**
  15876. * @hidden Internal use only.
  15877. */
  15878. _excludedMeshesIds: string[];
  15879. /**
  15880. * @hidden Internal use only.
  15881. */
  15882. _includedOnlyMeshesIds: string[];
  15883. /**
  15884. * The current light unifom buffer.
  15885. * @hidden Internal use only.
  15886. */
  15887. _uniformBuffer: UniformBuffer;
  15888. /**
  15889. * Creates a Light object in the scene.
  15890. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15891. * @param name The firendly name of the light
  15892. * @param scene The scene the light belongs too
  15893. */
  15894. constructor(name: string, scene: Scene);
  15895. protected abstract _buildUniformLayout(): void;
  15896. /**
  15897. * Sets the passed Effect "effect" with the Light information.
  15898. * @param effect The effect to update
  15899. * @param lightIndex The index of the light in the effect to update
  15900. * @returns The light
  15901. */
  15902. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15903. /**
  15904. * Returns the string "Light".
  15905. * @returns the class name
  15906. */
  15907. getClassName(): string;
  15908. /**
  15909. * Converts the light information to a readable string for debug purpose.
  15910. * @param fullDetails Supports for multiple levels of logging within scene loading
  15911. * @returns the human readable light info
  15912. */
  15913. toString(fullDetails?: boolean): string;
  15914. /** @hidden */
  15915. protected _syncParentEnabledState(): void;
  15916. /**
  15917. * Set the enabled state of this node.
  15918. * @param value - the new enabled state
  15919. */
  15920. setEnabled(value: boolean): void;
  15921. /**
  15922. * Returns the Light associated shadow generator if any.
  15923. * @return the associated shadow generator.
  15924. */
  15925. getShadowGenerator(): Nullable<IShadowGenerator>;
  15926. /**
  15927. * Returns a Vector3, the absolute light position in the World.
  15928. * @returns the world space position of the light
  15929. */
  15930. getAbsolutePosition(): Vector3;
  15931. /**
  15932. * Specifies if the light will affect the passed mesh.
  15933. * @param mesh The mesh to test against the light
  15934. * @return true the mesh is affected otherwise, false.
  15935. */
  15936. canAffectMesh(mesh: AbstractMesh): boolean;
  15937. /**
  15938. * Sort function to order lights for rendering.
  15939. * @param a First Light object to compare to second.
  15940. * @param b Second Light object to compare first.
  15941. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15942. */
  15943. static CompareLightsPriority(a: Light, b: Light): number;
  15944. /**
  15945. * Releases resources associated with this node.
  15946. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15947. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15948. */
  15949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15950. /**
  15951. * Returns the light type ID (integer).
  15952. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15953. */
  15954. getTypeID(): number;
  15955. /**
  15956. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15957. * @returns the scaled intensity in intensity mode unit
  15958. */
  15959. getScaledIntensity(): number;
  15960. /**
  15961. * Returns a new Light object, named "name", from the current one.
  15962. * @param name The name of the cloned light
  15963. * @returns the new created light
  15964. */
  15965. clone(name: string): Nullable<Light>;
  15966. /**
  15967. * Serializes the current light into a Serialization object.
  15968. * @returns the serialized object.
  15969. */
  15970. serialize(): any;
  15971. /**
  15972. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15973. * This new light is named "name" and added to the passed scene.
  15974. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15975. * @param name The friendly name of the light
  15976. * @param scene The scene the new light will belong to
  15977. * @returns the constructor function
  15978. */
  15979. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15980. /**
  15981. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15982. * @param parsedLight The JSON representation of the light
  15983. * @param scene The scene to create the parsed light in
  15984. * @returns the created light after parsing
  15985. */
  15986. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15987. private _hookArrayForExcluded;
  15988. private _hookArrayForIncludedOnly;
  15989. private _resyncMeshes;
  15990. /**
  15991. * Forces the meshes to update their light related information in their rendering used effects
  15992. * @hidden Internal Use Only
  15993. */
  15994. _markMeshesAsLightDirty(): void;
  15995. /**
  15996. * Recomputes the cached photometric scale if needed.
  15997. */
  15998. private _computePhotometricScale;
  15999. /**
  16000. * Returns the Photometric Scale according to the light type and intensity mode.
  16001. */
  16002. private _getPhotometricScale;
  16003. /**
  16004. * Reorder the light in the scene according to their defined priority.
  16005. * @hidden Internal Use Only
  16006. */
  16007. _reorderLightsInScene(): void;
  16008. /**
  16009. * Prepares the list of defines specific to the light type.
  16010. * @param defines the list of defines
  16011. * @param lightIndex defines the index of the light for the effect
  16012. */
  16013. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16014. }
  16015. }
  16016. declare module BABYLON {
  16017. /**
  16018. * A point light is a light defined by an unique point in world space.
  16019. * The light is emitted in every direction from this point.
  16020. * A good example of a point light is a standard light bulb.
  16021. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16022. */
  16023. class PointLight extends ShadowLight {
  16024. private _shadowAngle;
  16025. /**
  16026. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16027. * This specifies what angle the shadow will use to be created.
  16028. *
  16029. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16030. */
  16031. /**
  16032. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16033. * This specifies what angle the shadow will use to be created.
  16034. *
  16035. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16036. */
  16037. shadowAngle: number;
  16038. /**
  16039. * Gets the direction if it has been set.
  16040. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16041. */
  16042. /**
  16043. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16044. */
  16045. direction: Vector3;
  16046. /**
  16047. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16048. * A PointLight emits the light in every direction.
  16049. * It can cast shadows.
  16050. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16051. * ```javascript
  16052. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16053. * ```
  16054. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16055. * @param name The light friendly name
  16056. * @param position The position of the point light in the scene
  16057. * @param scene The scene the lights belongs to
  16058. */
  16059. constructor(name: string, position: Vector3, scene: Scene);
  16060. /**
  16061. * Returns the string "PointLight"
  16062. * @returns the class name
  16063. */
  16064. getClassName(): string;
  16065. /**
  16066. * Returns the integer 0.
  16067. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16068. */
  16069. getTypeID(): number;
  16070. /**
  16071. * Specifies wether or not the shadowmap should be a cube texture.
  16072. * @returns true if the shadowmap needs to be a cube texture.
  16073. */
  16074. needCube(): boolean;
  16075. /**
  16076. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16077. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16078. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16079. */
  16080. getShadowDirection(faceIndex?: number): Vector3;
  16081. /**
  16082. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16083. * - fov = PI / 2
  16084. * - aspect ratio : 1.0
  16085. * - z-near and far equal to the active camera minZ and maxZ.
  16086. * Returns the PointLight.
  16087. */
  16088. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16089. protected _buildUniformLayout(): void;
  16090. /**
  16091. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16092. * @param effect The effect to update
  16093. * @param lightIndex The index of the light in the effect to update
  16094. * @returns The point light
  16095. */
  16096. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16097. /**
  16098. * Prepares the list of defines specific to the light type.
  16099. * @param defines the list of defines
  16100. * @param lightIndex defines the index of the light for the effect
  16101. */
  16102. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16103. }
  16104. }
  16105. declare module BABYLON {
  16106. /**
  16107. * Interface describing all the common properties and methods a shadow light needs to implement.
  16108. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16109. * as well as binding the different shadow properties to the effects.
  16110. */
  16111. interface IShadowLight extends Light {
  16112. /**
  16113. * The light id in the scene (used in scene.findLighById for instance)
  16114. */
  16115. id: string;
  16116. /**
  16117. * The position the shdow will be casted from.
  16118. */
  16119. position: Vector3;
  16120. /**
  16121. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16122. */
  16123. direction: Vector3;
  16124. /**
  16125. * The transformed position. Position of the light in world space taking parenting in account.
  16126. */
  16127. transformedPosition: Vector3;
  16128. /**
  16129. * The transformed direction. Direction of the light in world space taking parenting in account.
  16130. */
  16131. transformedDirection: Vector3;
  16132. /**
  16133. * The friendly name of the light in the scene.
  16134. */
  16135. name: string;
  16136. /**
  16137. * Defines the shadow projection clipping minimum z value.
  16138. */
  16139. shadowMinZ: number;
  16140. /**
  16141. * Defines the shadow projection clipping maximum z value.
  16142. */
  16143. shadowMaxZ: number;
  16144. /**
  16145. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16146. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16147. */
  16148. computeTransformedInformation(): boolean;
  16149. /**
  16150. * Gets the scene the light belongs to.
  16151. * @returns The scene
  16152. */
  16153. getScene(): Scene;
  16154. /**
  16155. * Callback defining a custom Projection Matrix Builder.
  16156. * This can be used to override the default projection matrix computation.
  16157. */
  16158. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16159. /**
  16160. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16161. * @param matrix The materix to updated with the projection information
  16162. * @param viewMatrix The transform matrix of the light
  16163. * @param renderList The list of mesh to render in the map
  16164. * @returns The current light
  16165. */
  16166. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16167. /**
  16168. * Gets the current depth scale used in ESM.
  16169. * @returns The scale
  16170. */
  16171. getDepthScale(): number;
  16172. /**
  16173. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16174. * @returns true if a cube texture needs to be use
  16175. */
  16176. needCube(): boolean;
  16177. /**
  16178. * Detects if the projection matrix requires to be recomputed this frame.
  16179. * @returns true if it requires to be recomputed otherwise, false.
  16180. */
  16181. needProjectionMatrixCompute(): boolean;
  16182. /**
  16183. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16184. */
  16185. forceProjectionMatrixCompute(): void;
  16186. /**
  16187. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16188. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16189. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16190. */
  16191. getShadowDirection(faceIndex?: number): Vector3;
  16192. /**
  16193. * Gets the minZ used for shadow according to both the scene and the light.
  16194. * @param activeCamera The camera we are returning the min for
  16195. * @returns the depth min z
  16196. */
  16197. getDepthMinZ(activeCamera: Camera): number;
  16198. /**
  16199. * Gets the maxZ used for shadow according to both the scene and the light.
  16200. * @param activeCamera The camera we are returning the max for
  16201. * @returns the depth max z
  16202. */
  16203. getDepthMaxZ(activeCamera: Camera): number;
  16204. }
  16205. /**
  16206. * Base implementation IShadowLight
  16207. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16208. */
  16209. abstract class ShadowLight extends Light implements IShadowLight {
  16210. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16211. protected _position: Vector3;
  16212. protected _setPosition(value: Vector3): void;
  16213. /**
  16214. * Sets the position the shadow will be casted from. Also use as the light position for both
  16215. * point and spot lights.
  16216. */
  16217. /**
  16218. * Sets the position the shadow will be casted from. Also use as the light position for both
  16219. * point and spot lights.
  16220. */
  16221. position: Vector3;
  16222. protected _direction: Vector3;
  16223. protected _setDirection(value: Vector3): void;
  16224. /**
  16225. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16226. * Also use as the light direction on spot and directional lights.
  16227. */
  16228. /**
  16229. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16230. * Also use as the light direction on spot and directional lights.
  16231. */
  16232. direction: Vector3;
  16233. private _shadowMinZ;
  16234. /**
  16235. * Gets the shadow projection clipping minimum z value.
  16236. */
  16237. /**
  16238. * Sets the shadow projection clipping minimum z value.
  16239. */
  16240. shadowMinZ: number;
  16241. private _shadowMaxZ;
  16242. /**
  16243. * Sets the shadow projection clipping maximum z value.
  16244. */
  16245. /**
  16246. * Gets the shadow projection clipping maximum z value.
  16247. */
  16248. shadowMaxZ: number;
  16249. /**
  16250. * Callback defining a custom Projection Matrix Builder.
  16251. * This can be used to override the default projection matrix computation.
  16252. */
  16253. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16254. /**
  16255. * The transformed position. Position of the light in world space taking parenting in account.
  16256. */
  16257. transformedPosition: Vector3;
  16258. /**
  16259. * The transformed direction. Direction of the light in world space taking parenting in account.
  16260. */
  16261. transformedDirection: Vector3;
  16262. private _needProjectionMatrixCompute;
  16263. /**
  16264. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16265. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16266. */
  16267. computeTransformedInformation(): boolean;
  16268. /**
  16269. * Return the depth scale used for the shadow map.
  16270. * @returns the depth scale.
  16271. */
  16272. getDepthScale(): number;
  16273. /**
  16274. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16275. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16276. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16277. */
  16278. getShadowDirection(faceIndex?: number): Vector3;
  16279. /**
  16280. * Returns the ShadowLight absolute position in the World.
  16281. * @returns the position vector in world space
  16282. */
  16283. getAbsolutePosition(): Vector3;
  16284. /**
  16285. * Sets the ShadowLight direction toward the passed target.
  16286. * @param target The point tot target in local space
  16287. * @returns the updated ShadowLight direction
  16288. */
  16289. setDirectionToTarget(target: Vector3): Vector3;
  16290. /**
  16291. * Returns the light rotation in euler definition.
  16292. * @returns the x y z rotation in local space.
  16293. */
  16294. getRotation(): Vector3;
  16295. /**
  16296. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16297. * @returns true if a cube texture needs to be use
  16298. */
  16299. needCube(): boolean;
  16300. /**
  16301. * Detects if the projection matrix requires to be recomputed this frame.
  16302. * @returns true if it requires to be recomputed otherwise, false.
  16303. */
  16304. needProjectionMatrixCompute(): boolean;
  16305. /**
  16306. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16307. */
  16308. forceProjectionMatrixCompute(): void;
  16309. /** @hidden */
  16310. _initCache(): void;
  16311. /** @hidden */
  16312. _isSynchronized(): boolean;
  16313. /**
  16314. * Computes the world matrix of the node
  16315. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16316. * @returns the world matrix
  16317. */
  16318. computeWorldMatrix(force?: boolean): Matrix;
  16319. /**
  16320. * Gets the minZ used for shadow according to both the scene and the light.
  16321. * @param activeCamera The camera we are returning the min for
  16322. * @returns the depth min z
  16323. */
  16324. getDepthMinZ(activeCamera: Camera): number;
  16325. /**
  16326. * Gets the maxZ used for shadow according to both the scene and the light.
  16327. * @param activeCamera The camera we are returning the max for
  16328. * @returns the depth max z
  16329. */
  16330. getDepthMaxZ(activeCamera: Camera): number;
  16331. /**
  16332. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16333. * @param matrix The materix to updated with the projection information
  16334. * @param viewMatrix The transform matrix of the light
  16335. * @param renderList The list of mesh to render in the map
  16336. * @returns The current light
  16337. */
  16338. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16339. }
  16340. }
  16341. declare module BABYLON {
  16342. /**
  16343. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16344. * These values define a cone of light starting from the position, emitting toward the direction.
  16345. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16346. * and the exponent defines the speed of the decay of the light with distance (reach).
  16347. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16348. */
  16349. class SpotLight extends ShadowLight {
  16350. private _angle;
  16351. private _innerAngle;
  16352. private _cosHalfAngle;
  16353. private _lightAngleScale;
  16354. private _lightAngleOffset;
  16355. /**
  16356. * Gets the cone angle of the spot light in Radians.
  16357. */
  16358. /**
  16359. * Sets the cone angle of the spot light in Radians.
  16360. */
  16361. angle: number;
  16362. /**
  16363. * Only used in gltf falloff mode, this defines the angle where
  16364. * the directional falloff will start before cutting at angle which could be seen
  16365. * as outer angle.
  16366. */
  16367. /**
  16368. * Only used in gltf falloff mode, this defines the angle where
  16369. * the directional falloff will start before cutting at angle which could be seen
  16370. * as outer angle.
  16371. */
  16372. innerAngle: number;
  16373. private _shadowAngleScale;
  16374. /**
  16375. * Allows scaling the angle of the light for shadow generation only.
  16376. */
  16377. /**
  16378. * Allows scaling the angle of the light for shadow generation only.
  16379. */
  16380. shadowAngleScale: number;
  16381. /**
  16382. * The light decay speed with the distance from the emission spot.
  16383. */
  16384. exponent: number;
  16385. private _projectionTextureMatrix;
  16386. /**
  16387. * Allows reading the projecton texture
  16388. */
  16389. readonly projectionTextureMatrix: Matrix;
  16390. protected _projectionTextureLightNear: number;
  16391. /**
  16392. * Gets the near clip of the Spotlight for texture projection.
  16393. */
  16394. /**
  16395. * Sets the near clip of the Spotlight for texture projection.
  16396. */
  16397. projectionTextureLightNear: number;
  16398. protected _projectionTextureLightFar: number;
  16399. /**
  16400. * Gets the far clip of the Spotlight for texture projection.
  16401. */
  16402. /**
  16403. * Sets the far clip of the Spotlight for texture projection.
  16404. */
  16405. projectionTextureLightFar: number;
  16406. protected _projectionTextureUpDirection: Vector3;
  16407. /**
  16408. * Gets the Up vector of the Spotlight for texture projection.
  16409. */
  16410. /**
  16411. * Sets the Up vector of the Spotlight for texture projection.
  16412. */
  16413. projectionTextureUpDirection: Vector3;
  16414. private _projectionTexture;
  16415. /**
  16416. * Gets the projection texture of the light.
  16417. */
  16418. /**
  16419. * Sets the projection texture of the light.
  16420. */
  16421. projectionTexture: Nullable<BaseTexture>;
  16422. private _projectionTextureViewLightDirty;
  16423. private _projectionTextureProjectionLightDirty;
  16424. private _projectionTextureDirty;
  16425. private _projectionTextureViewTargetVector;
  16426. private _projectionTextureViewLightMatrix;
  16427. private _projectionTextureProjectionLightMatrix;
  16428. private _projectionTextureScalingMatrix;
  16429. /**
  16430. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16431. * It can cast shadows.
  16432. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16433. * @param name The light friendly name
  16434. * @param position The position of the spot light in the scene
  16435. * @param direction The direction of the light in the scene
  16436. * @param angle The cone angle of the light in Radians
  16437. * @param exponent The light decay speed with the distance from the emission spot
  16438. * @param scene The scene the lights belongs to
  16439. */
  16440. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16441. /**
  16442. * Returns the string "SpotLight".
  16443. * @returns the class name
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Returns the integer 2.
  16448. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16449. */
  16450. getTypeID(): number;
  16451. /**
  16452. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16453. */
  16454. protected _setDirection(value: Vector3): void;
  16455. /**
  16456. * Overrides the position setter to recompute the projection texture view light Matrix.
  16457. */
  16458. protected _setPosition(value: Vector3): void;
  16459. /**
  16460. * 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.
  16461. * Returns the SpotLight.
  16462. */
  16463. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16464. protected _computeProjectionTextureViewLightMatrix(): void;
  16465. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16466. /**
  16467. * Main function for light texture projection matrix computing.
  16468. */
  16469. protected _computeProjectionTextureMatrix(): void;
  16470. protected _buildUniformLayout(): void;
  16471. private _computeAngleValues;
  16472. /**
  16473. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16474. * @param effect The effect to update
  16475. * @param lightIndex The index of the light in the effect to update
  16476. * @returns The spot light
  16477. */
  16478. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16479. /**
  16480. * Disposes the light and the associated resources.
  16481. */
  16482. dispose(): void;
  16483. /**
  16484. * Prepares the list of defines specific to the light type.
  16485. * @param defines the list of defines
  16486. * @param lightIndex defines the index of the light for the effect
  16487. */
  16488. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16489. }
  16490. }
  16491. declare module BABYLON {
  16492. /**
  16493. * Interface used to present a loading screen while loading a scene
  16494. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16495. */
  16496. interface ILoadingScreen {
  16497. /**
  16498. * Function called to display the loading screen
  16499. */
  16500. displayLoadingUI: () => void;
  16501. /**
  16502. * Function called to hide the loading screen
  16503. */
  16504. hideLoadingUI: () => void;
  16505. /**
  16506. * Gets or sets the color to use for the background
  16507. */
  16508. loadingUIBackgroundColor: string;
  16509. /**
  16510. * Gets or sets the text to display while loading
  16511. */
  16512. loadingUIText: string;
  16513. }
  16514. /**
  16515. * Class used for the default loading screen
  16516. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16517. */
  16518. class DefaultLoadingScreen implements ILoadingScreen {
  16519. private _renderingCanvas;
  16520. private _loadingText;
  16521. private _loadingDivBackgroundColor;
  16522. private _loadingDiv;
  16523. private _loadingTextDiv;
  16524. /**
  16525. * Creates a new default loading screen
  16526. * @param _renderingCanvas defines the canvas used to render the scene
  16527. * @param _loadingText defines the default text to display
  16528. * @param _loadingDivBackgroundColor defines the default background color
  16529. */
  16530. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16531. /**
  16532. * Function called to display the loading screen
  16533. */
  16534. displayLoadingUI(): void;
  16535. /**
  16536. * Function called to hide the loading screen
  16537. */
  16538. hideLoadingUI(): void;
  16539. /**
  16540. * Gets or sets the text to display while loading
  16541. */
  16542. loadingUIText: string;
  16543. /**
  16544. * Gets or sets the color to use for the background
  16545. */
  16546. loadingUIBackgroundColor: string;
  16547. private _resizeLoadingUI;
  16548. }
  16549. }
  16550. declare module BABYLON {
  16551. /**
  16552. * Class used to represent data loading progression
  16553. */
  16554. class SceneLoaderProgressEvent {
  16555. /** defines if data length to load can be evaluated */
  16556. readonly lengthComputable: boolean;
  16557. /** defines the loaded data length */
  16558. readonly loaded: number;
  16559. /** defines the data length to load */
  16560. readonly total: number;
  16561. /**
  16562. * Create a new progress event
  16563. * @param lengthComputable defines if data length to load can be evaluated
  16564. * @param loaded defines the loaded data length
  16565. * @param total defines the data length to load
  16566. */
  16567. constructor(
  16568. /** defines if data length to load can be evaluated */
  16569. lengthComputable: boolean,
  16570. /** defines the loaded data length */
  16571. loaded: number,
  16572. /** defines the data length to load */
  16573. total: number);
  16574. /**
  16575. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16576. * @param event defines the source event
  16577. * @returns a new SceneLoaderProgressEvent
  16578. */
  16579. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16580. }
  16581. /**
  16582. * Interface used by SceneLoader plugins to define supported file extensions
  16583. */
  16584. interface ISceneLoaderPluginExtensions {
  16585. /**
  16586. * Defines the list of supported extensions
  16587. */
  16588. [extension: string]: {
  16589. isBinary: boolean;
  16590. };
  16591. }
  16592. /**
  16593. * Interface used by SceneLoader plugin factory
  16594. */
  16595. interface ISceneLoaderPluginFactory {
  16596. /**
  16597. * Defines the name of the factory
  16598. */
  16599. name: string;
  16600. /**
  16601. * Function called to create a new plugin
  16602. * @return the new plugin
  16603. */
  16604. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16605. /**
  16606. * Boolean indicating if the plugin can direct load specific data
  16607. */
  16608. canDirectLoad?: (data: string) => boolean;
  16609. }
  16610. /**
  16611. * Interface used to define a SceneLoader plugin
  16612. */
  16613. interface ISceneLoaderPlugin {
  16614. /**
  16615. * The friendly name of this plugin.
  16616. */
  16617. name: string;
  16618. /**
  16619. * The file extensions supported by this plugin.
  16620. */
  16621. extensions: string | ISceneLoaderPluginExtensions;
  16622. /**
  16623. * Import meshes into a scene.
  16624. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16625. * @param scene The scene to import into
  16626. * @param data The data to import
  16627. * @param rootUrl The root url for scene and resources
  16628. * @param meshes The meshes array to import into
  16629. * @param particleSystems The particle systems array to import into
  16630. * @param skeletons The skeletons array to import into
  16631. * @param onError The callback when import fails
  16632. * @returns True if successful or false otherwise
  16633. */
  16634. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16635. /**
  16636. * Load into a scene.
  16637. * @param scene The scene to load into
  16638. * @param data The data to import
  16639. * @param rootUrl The root url for scene and resources
  16640. * @param onError The callback when import fails
  16641. * @returns true if successful or false otherwise
  16642. */
  16643. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16644. /**
  16645. * The callback that returns true if the data can be directly loaded.
  16646. */
  16647. canDirectLoad?: (data: string) => boolean;
  16648. /**
  16649. * The callback that allows custom handling of the root url based on the response url.
  16650. */
  16651. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16652. /**
  16653. * Load into an asset container.
  16654. * @param scene The scene to load into
  16655. * @param data The data to import
  16656. * @param rootUrl The root url for scene and resources
  16657. * @param onError The callback when import fails
  16658. * @returns The loaded asset container
  16659. */
  16660. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16661. }
  16662. /**
  16663. * Interface used to define an async SceneLoader plugin
  16664. */
  16665. interface ISceneLoaderPluginAsync {
  16666. /**
  16667. * The friendly name of this plugin.
  16668. */
  16669. name: string;
  16670. /**
  16671. * The file extensions supported by this plugin.
  16672. */
  16673. extensions: string | ISceneLoaderPluginExtensions;
  16674. /**
  16675. * Import meshes into a scene.
  16676. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16677. * @param scene The scene to import into
  16678. * @param data The data to import
  16679. * @param rootUrl The root url for scene and resources
  16680. * @param onProgress The callback when the load progresses
  16681. * @param fileName Defines the name of the file to load
  16682. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16683. */
  16684. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16685. meshes: AbstractMesh[];
  16686. particleSystems: IParticleSystem[];
  16687. skeletons: Skeleton[];
  16688. animationGroups: AnimationGroup[];
  16689. }>;
  16690. /**
  16691. * Load into a scene.
  16692. * @param scene The scene to load into
  16693. * @param data The data to import
  16694. * @param rootUrl The root url for scene and resources
  16695. * @param onProgress The callback when the load progresses
  16696. * @param fileName Defines the name of the file to load
  16697. * @returns Nothing
  16698. */
  16699. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16700. /**
  16701. * The callback that returns true if the data can be directly loaded.
  16702. */
  16703. canDirectLoad?: (data: string) => boolean;
  16704. /**
  16705. * The callback that allows custom handling of the root url based on the response url.
  16706. */
  16707. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16708. /**
  16709. * Load into an asset container.
  16710. * @param scene The scene to load into
  16711. * @param data The data to import
  16712. * @param rootUrl The root url for scene and resources
  16713. * @param onProgress The callback when the load progresses
  16714. * @param fileName Defines the name of the file to load
  16715. * @returns The loaded asset container
  16716. */
  16717. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16718. }
  16719. /**
  16720. * Class used to load scene from various file formats using registered plugins
  16721. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16722. */
  16723. class SceneLoader {
  16724. private static _ForceFullSceneLoadingForIncremental;
  16725. private static _ShowLoadingScreen;
  16726. private static _CleanBoneMatrixWeights;
  16727. /**
  16728. * No logging while loading
  16729. */
  16730. static readonly NO_LOGGING: number;
  16731. /**
  16732. * Minimal logging while loading
  16733. */
  16734. static readonly MINIMAL_LOGGING: number;
  16735. /**
  16736. * Summary logging while loading
  16737. */
  16738. static readonly SUMMARY_LOGGING: number;
  16739. /**
  16740. * Detailled logging while loading
  16741. */
  16742. static readonly DETAILED_LOGGING: number;
  16743. private static _loggingLevel;
  16744. /**
  16745. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16746. */
  16747. static ForceFullSceneLoadingForIncremental: boolean;
  16748. /**
  16749. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16750. */
  16751. static ShowLoadingScreen: boolean;
  16752. /**
  16753. * Defines the current logging level (while loading the scene)
  16754. * @ignorenaming
  16755. */
  16756. static loggingLevel: number;
  16757. /**
  16758. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16759. */
  16760. static CleanBoneMatrixWeights: boolean;
  16761. /**
  16762. * Event raised when a plugin is used to load a scene
  16763. */
  16764. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16765. private static _registeredPlugins;
  16766. private static _getDefaultPlugin;
  16767. private static _getPluginForExtension;
  16768. private static _getPluginForDirectLoad;
  16769. private static _getPluginForFilename;
  16770. private static _getDirectLoad;
  16771. private static _loadData;
  16772. private static _getFileInfo;
  16773. /**
  16774. * Gets a plugin that can load the given extension
  16775. * @param extension defines the extension to load
  16776. * @returns a plugin or null if none works
  16777. */
  16778. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16779. /**
  16780. * Gets a boolean indicating that the given extension can be loaded
  16781. * @param extension defines the extension to load
  16782. * @returns true if the extension is supported
  16783. */
  16784. static IsPluginForExtensionAvailable(extension: string): boolean;
  16785. /**
  16786. * Adds a new plugin to the list of registered plugins
  16787. * @param plugin defines the plugin to add
  16788. */
  16789. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16790. /**
  16791. * Import meshes into a scene
  16792. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16793. * @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)
  16794. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16795. * @param scene the instance of BABYLON.Scene to append to
  16796. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16797. * @param onProgress a callback with a progress event for each file being loaded
  16798. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16799. * @param pluginExtension the extension used to determine the plugin
  16800. * @returns The loaded plugin
  16801. */
  16802. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16803. /**
  16804. * Import meshes into a scene
  16805. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16806. * @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)
  16807. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16808. * @param scene the instance of BABYLON.Scene to append to
  16809. * @param onProgress a callback with a progress event for each file being loaded
  16810. * @param pluginExtension the extension used to determine the plugin
  16811. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16812. */
  16813. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16814. meshes: AbstractMesh[];
  16815. particleSystems: IParticleSystem[];
  16816. skeletons: Skeleton[];
  16817. animationGroups: AnimationGroup[];
  16818. }>;
  16819. /**
  16820. * Load a scene
  16821. * @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)
  16822. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16823. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16824. * @param onSuccess a callback with the scene when import succeeds
  16825. * @param onProgress a callback with a progress event for each file being loaded
  16826. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16827. * @param pluginExtension the extension used to determine the plugin
  16828. * @returns The loaded plugin
  16829. */
  16830. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16831. /**
  16832. * Load a scene
  16833. * @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)
  16834. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16835. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16836. * @param onProgress a callback with a progress event for each file being loaded
  16837. * @param pluginExtension the extension used to determine the plugin
  16838. * @returns The loaded scene
  16839. */
  16840. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16841. /**
  16842. * Append a scene
  16843. * @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)
  16844. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16845. * @param scene is the instance of BABYLON.Scene to append to
  16846. * @param onSuccess a callback with the scene when import succeeds
  16847. * @param onProgress a callback with a progress event for each file being loaded
  16848. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16849. * @param pluginExtension the extension used to determine the plugin
  16850. * @returns The loaded plugin
  16851. */
  16852. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16853. /**
  16854. * Append a scene
  16855. * @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)
  16856. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16857. * @param scene is the instance of BABYLON.Scene to append to
  16858. * @param onProgress a callback with a progress event for each file being loaded
  16859. * @param pluginExtension the extension used to determine the plugin
  16860. * @returns The given scene
  16861. */
  16862. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16863. /**
  16864. * Load a scene into an asset container
  16865. * @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)
  16866. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16867. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16868. * @param onSuccess a callback with the scene when import succeeds
  16869. * @param onProgress a callback with a progress event for each file being loaded
  16870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16871. * @param pluginExtension the extension used to determine the plugin
  16872. * @returns The loaded plugin
  16873. */
  16874. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16875. /**
  16876. * Load a scene into an asset container
  16877. * @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)
  16878. * @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)
  16879. * @param scene is the instance of BABYLON.Scene to append to
  16880. * @param onProgress a callback with a progress event for each file being loaded
  16881. * @param pluginExtension the extension used to determine the plugin
  16882. * @returns The loaded asset container
  16883. */
  16884. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16885. }
  16886. }
  16887. declare module BABYLON {
  16888. /**
  16889. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16890. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16891. * 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;
  16892. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16893. */
  16894. class ColorCurves {
  16895. private _dirty;
  16896. private _tempColor;
  16897. private _globalCurve;
  16898. private _highlightsCurve;
  16899. private _midtonesCurve;
  16900. private _shadowsCurve;
  16901. private _positiveCurve;
  16902. private _negativeCurve;
  16903. private _globalHue;
  16904. private _globalDensity;
  16905. private _globalSaturation;
  16906. private _globalExposure;
  16907. /**
  16908. * Gets the global 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. /**
  16912. * Sets the global Hue value.
  16913. * 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).
  16914. */
  16915. globalHue: number;
  16916. /**
  16917. * Gets the global Density value.
  16918. * 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.
  16919. * Values less than zero provide a filter of opposite hue.
  16920. */
  16921. /**
  16922. * Sets the global Density value.
  16923. * 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.
  16924. * Values less than zero provide a filter of opposite hue.
  16925. */
  16926. globalDensity: number;
  16927. /**
  16928. * Gets the global 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. /**
  16932. * Sets the global Saturation value.
  16933. * 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.
  16934. */
  16935. globalSaturation: number;
  16936. /**
  16937. * Gets the global 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. /**
  16941. * Sets the global Exposure value.
  16942. * 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.
  16943. */
  16944. globalExposure: number;
  16945. private _highlightsHue;
  16946. private _highlightsDensity;
  16947. private _highlightsSaturation;
  16948. private _highlightsExposure;
  16949. /**
  16950. * Gets the highlights 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. /**
  16954. * Sets the highlights Hue value.
  16955. * 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).
  16956. */
  16957. highlightsHue: number;
  16958. /**
  16959. * Gets the highlights Density value.
  16960. * 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.
  16961. * Values less than zero provide a filter of opposite hue.
  16962. */
  16963. /**
  16964. * Sets the highlights Density value.
  16965. * 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.
  16966. * Values less than zero provide a filter of opposite hue.
  16967. */
  16968. highlightsDensity: number;
  16969. /**
  16970. * Gets the highlights 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. /**
  16974. * Sets the highlights Saturation value.
  16975. * 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.
  16976. */
  16977. highlightsSaturation: number;
  16978. /**
  16979. * Gets the highlights 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. /**
  16983. * Sets the highlights Exposure value.
  16984. * 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.
  16985. */
  16986. highlightsExposure: number;
  16987. private _midtonesHue;
  16988. private _midtonesDensity;
  16989. private _midtonesSaturation;
  16990. private _midtonesExposure;
  16991. /**
  16992. * Gets the midtones 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. /**
  16996. * Sets the midtones Hue value.
  16997. * 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).
  16998. */
  16999. midtonesHue: number;
  17000. /**
  17001. * Gets the midtones Density value.
  17002. * 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.
  17003. * Values less than zero provide a filter of opposite hue.
  17004. */
  17005. /**
  17006. * Sets the midtones Density value.
  17007. * 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.
  17008. * Values less than zero provide a filter of opposite hue.
  17009. */
  17010. midtonesDensity: number;
  17011. /**
  17012. * Gets the midtones 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. /**
  17016. * Sets the midtones Saturation value.
  17017. * 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.
  17018. */
  17019. midtonesSaturation: number;
  17020. /**
  17021. * Gets the midtones 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. /**
  17025. * Sets the midtones Exposure value.
  17026. * 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.
  17027. */
  17028. midtonesExposure: number;
  17029. private _shadowsHue;
  17030. private _shadowsDensity;
  17031. private _shadowsSaturation;
  17032. private _shadowsExposure;
  17033. /**
  17034. * Gets the shadows Hue value.
  17035. * 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).
  17036. */
  17037. /**
  17038. * Sets the shadows Hue value.
  17039. * 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).
  17040. */
  17041. shadowsHue: number;
  17042. /**
  17043. * Gets the shadows Density value.
  17044. * 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.
  17045. * Values less than zero provide a filter of opposite hue.
  17046. */
  17047. /**
  17048. * Sets the shadows Density value.
  17049. * 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.
  17050. * Values less than zero provide a filter of opposite hue.
  17051. */
  17052. shadowsDensity: number;
  17053. /**
  17054. * Gets the shadows Saturation value.
  17055. * 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.
  17056. */
  17057. /**
  17058. * Sets the shadows Saturation value.
  17059. * 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.
  17060. */
  17061. shadowsSaturation: number;
  17062. /**
  17063. * Gets the shadows Exposure value.
  17064. * 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.
  17065. */
  17066. /**
  17067. * Sets the shadows Exposure value.
  17068. * 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.
  17069. */
  17070. shadowsExposure: number;
  17071. /**
  17072. * Returns the class name
  17073. * @returns The class name
  17074. */
  17075. getClassName(): string;
  17076. /**
  17077. * Binds the color curves to the shader.
  17078. * @param colorCurves The color curve to bind
  17079. * @param effect The effect to bind to
  17080. * @param positiveUniform The positive uniform shader parameter
  17081. * @param neutralUniform The neutral uniform shader parameter
  17082. * @param negativeUniform The negative uniform shader parameter
  17083. */
  17084. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17085. /**
  17086. * Prepare the list of uniforms associated with the ColorCurves effects.
  17087. * @param uniformsList The list of uniforms used in the effect
  17088. */
  17089. static PrepareUniforms(uniformsList: string[]): void;
  17090. /**
  17091. * Returns color grading data based on a hue, density, saturation and exposure value.
  17092. * @param filterHue The hue of the color filter.
  17093. * @param filterDensity The density of the color filter.
  17094. * @param saturation The saturation.
  17095. * @param exposure The exposure.
  17096. * @param result The result data container.
  17097. */
  17098. private getColorGradingDataToRef;
  17099. /**
  17100. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17101. * @param value The input slider value in range [-100,100].
  17102. * @returns Adjusted value.
  17103. */
  17104. private static applyColorGradingSliderNonlinear;
  17105. /**
  17106. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17107. * @param hue The hue (H) input.
  17108. * @param saturation The saturation (S) input.
  17109. * @param brightness The brightness (B) input.
  17110. * @result An RGBA color represented as Vector4.
  17111. */
  17112. private static fromHSBToRef;
  17113. /**
  17114. * Returns a value clamped between min and max
  17115. * @param value The value to clamp
  17116. * @param min The minimum of value
  17117. * @param max The maximum of value
  17118. * @returns The clamped value.
  17119. */
  17120. private static clamp;
  17121. /**
  17122. * Clones the current color curve instance.
  17123. * @return The cloned curves
  17124. */
  17125. clone(): ColorCurves;
  17126. /**
  17127. * Serializes the current color curve instance to a json representation.
  17128. * @return a JSON representation
  17129. */
  17130. serialize(): any;
  17131. /**
  17132. * Parses the color curve from a json representation.
  17133. * @param source the JSON source to parse
  17134. * @return The parsed curves
  17135. */
  17136. static Parse(source: any): ColorCurves;
  17137. }
  17138. }
  17139. declare module BABYLON {
  17140. /**
  17141. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17142. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17143. */
  17144. class EffectFallbacks {
  17145. private _defines;
  17146. private _currentRank;
  17147. private _maxRank;
  17148. private _mesh;
  17149. /**
  17150. * Removes the fallback from the bound mesh.
  17151. */
  17152. unBindMesh(): void;
  17153. /**
  17154. * Adds a fallback on the specified property.
  17155. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17156. * @param define The name of the define in the shader
  17157. */
  17158. addFallback(rank: number, define: string): void;
  17159. /**
  17160. * Sets the mesh to use CPU skinning when needing to fallback.
  17161. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17162. * @param mesh The mesh to use the fallbacks.
  17163. */
  17164. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17165. /**
  17166. * Checks to see if more fallbacks are still availible.
  17167. */
  17168. readonly isMoreFallbacks: boolean;
  17169. /**
  17170. * Removes the defines that shoould be removed when falling back.
  17171. * @param currentDefines defines the current define statements for the shader.
  17172. * @param effect defines the current effect we try to compile
  17173. * @returns The resulting defines with defines of the current rank removed.
  17174. */
  17175. reduce(currentDefines: string, effect: Effect): string;
  17176. }
  17177. /**
  17178. * Options to be used when creating an effect.
  17179. */
  17180. class EffectCreationOptions {
  17181. /**
  17182. * Atrributes that will be used in the shader.
  17183. */
  17184. attributes: string[];
  17185. /**
  17186. * Uniform varible names that will be set in the shader.
  17187. */
  17188. uniformsNames: string[];
  17189. /**
  17190. * Uniform buffer varible names that will be set in the shader.
  17191. */
  17192. uniformBuffersNames: string[];
  17193. /**
  17194. * Sampler texture variable names that will be set in the shader.
  17195. */
  17196. samplers: string[];
  17197. /**
  17198. * Define statements that will be set in the shader.
  17199. */
  17200. defines: any;
  17201. /**
  17202. * Possible fallbacks for this effect to improve performance when needed.
  17203. */
  17204. fallbacks: Nullable<EffectFallbacks>;
  17205. /**
  17206. * Callback that will be called when the shader is compiled.
  17207. */
  17208. onCompiled: Nullable<(effect: Effect) => void>;
  17209. /**
  17210. * Callback that will be called if an error occurs during shader compilation.
  17211. */
  17212. onError: Nullable<(effect: Effect, errors: string) => void>;
  17213. /**
  17214. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17215. */
  17216. indexParameters: any;
  17217. /**
  17218. * Max number of lights that can be used in the shader.
  17219. */
  17220. maxSimultaneousLights: number;
  17221. /**
  17222. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17223. */
  17224. transformFeedbackVaryings: Nullable<string[]>;
  17225. }
  17226. /**
  17227. * Effect containing vertex and fragment shader that can be executed on an object.
  17228. */
  17229. class Effect {
  17230. /**
  17231. * Name of the effect.
  17232. */
  17233. name: any;
  17234. /**
  17235. * String container all the define statements that should be set on the shader.
  17236. */
  17237. defines: string;
  17238. /**
  17239. * Callback that will be called when the shader is compiled.
  17240. */
  17241. onCompiled: Nullable<(effect: Effect) => void>;
  17242. /**
  17243. * Callback that will be called if an error occurs during shader compilation.
  17244. */
  17245. onError: Nullable<(effect: Effect, errors: string) => void>;
  17246. /**
  17247. * Callback that will be called when effect is bound.
  17248. */
  17249. onBind: Nullable<(effect: Effect) => void>;
  17250. /**
  17251. * Unique ID of the effect.
  17252. */
  17253. uniqueId: number;
  17254. /**
  17255. * Observable that will be called when the shader is compiled.
  17256. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17257. */
  17258. onCompileObservable: Observable<Effect>;
  17259. /**
  17260. * Observable that will be called if an error occurs during shader compilation.
  17261. */
  17262. onErrorObservable: Observable<Effect>;
  17263. /** @hidden */
  17264. _onBindObservable: Nullable<Observable<Effect>>;
  17265. /**
  17266. * Observable that will be called when effect is bound.
  17267. */
  17268. readonly onBindObservable: Observable<Effect>;
  17269. /** @hidden */
  17270. _bonesComputationForcedToCPU: boolean;
  17271. private static _uniqueIdSeed;
  17272. private _engine;
  17273. private _uniformBuffersNames;
  17274. private _uniformsNames;
  17275. private _samplers;
  17276. private _isReady;
  17277. private _compilationError;
  17278. private _attributesNames;
  17279. private _attributes;
  17280. private _uniforms;
  17281. /**
  17282. * Key for the effect.
  17283. * @hidden
  17284. */
  17285. _key: string;
  17286. private _indexParameters;
  17287. private _fallbacks;
  17288. private _vertexSourceCode;
  17289. private _fragmentSourceCode;
  17290. private _vertexSourceCodeOverride;
  17291. private _fragmentSourceCodeOverride;
  17292. private _transformFeedbackVaryings;
  17293. /**
  17294. * Compiled shader to webGL program.
  17295. * @hidden
  17296. */
  17297. _program: WebGLProgram;
  17298. private _valueCache;
  17299. private static _baseCache;
  17300. /**
  17301. * Instantiates an effect.
  17302. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17303. * @param baseName Name of the effect.
  17304. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17305. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17306. * @param samplers List of sampler variables that will be passed to the shader.
  17307. * @param engine Engine to be used to render the effect
  17308. * @param defines Define statements to be added to the shader.
  17309. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17310. * @param onCompiled Callback that will be called when the shader is compiled.
  17311. * @param onError Callback that will be called if an error occurs during shader compilation.
  17312. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17313. */
  17314. 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);
  17315. /**
  17316. * Unique key for this effect
  17317. */
  17318. readonly key: string;
  17319. /**
  17320. * If the effect has been compiled and prepared.
  17321. * @returns if the effect is compiled and prepared.
  17322. */
  17323. isReady(): boolean;
  17324. /**
  17325. * The engine the effect was initialized with.
  17326. * @returns the engine.
  17327. */
  17328. getEngine(): Engine;
  17329. /**
  17330. * The compiled webGL program for the effect
  17331. * @returns the webGL program.
  17332. */
  17333. getProgram(): WebGLProgram;
  17334. /**
  17335. * The set of names of attribute variables for the shader.
  17336. * @returns An array of attribute names.
  17337. */
  17338. getAttributesNames(): string[];
  17339. /**
  17340. * Returns the attribute at the given index.
  17341. * @param index The index of the attribute.
  17342. * @returns The location of the attribute.
  17343. */
  17344. getAttributeLocation(index: number): number;
  17345. /**
  17346. * Returns the attribute based on the name of the variable.
  17347. * @param name of the attribute to look up.
  17348. * @returns the attribute location.
  17349. */
  17350. getAttributeLocationByName(name: string): number;
  17351. /**
  17352. * The number of attributes.
  17353. * @returns the numnber of attributes.
  17354. */
  17355. getAttributesCount(): number;
  17356. /**
  17357. * Gets the index of a uniform variable.
  17358. * @param uniformName of the uniform to look up.
  17359. * @returns the index.
  17360. */
  17361. getUniformIndex(uniformName: string): number;
  17362. /**
  17363. * Returns the attribute based on the name of the variable.
  17364. * @param uniformName of the uniform to look up.
  17365. * @returns the location of the uniform.
  17366. */
  17367. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17368. /**
  17369. * Returns an array of sampler variable names
  17370. * @returns The array of sampler variable neames.
  17371. */
  17372. getSamplers(): string[];
  17373. /**
  17374. * The error from the last compilation.
  17375. * @returns the error string.
  17376. */
  17377. getCompilationError(): string;
  17378. /**
  17379. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17380. * @param func The callback to be used.
  17381. */
  17382. executeWhenCompiled(func: (effect: Effect) => void): void;
  17383. private _checkIsReady;
  17384. /** @hidden */
  17385. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17386. /** @hidden */
  17387. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17388. /** @hidden */
  17389. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17390. private _processShaderConversion;
  17391. private _processIncludes;
  17392. private _processPrecision;
  17393. /**
  17394. * Recompiles the webGL program
  17395. * @param vertexSourceCode The source code for the vertex shader.
  17396. * @param fragmentSourceCode The source code for the fragment shader.
  17397. * @param onCompiled Callback called when completed.
  17398. * @param onError Callback called on error.
  17399. * @hidden
  17400. */
  17401. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17402. /**
  17403. * Gets the uniform locations of the the specified variable names
  17404. * @param names THe names of the variables to lookup.
  17405. * @returns Array of locations in the same order as variable names.
  17406. */
  17407. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17408. /**
  17409. * Prepares the effect
  17410. * @hidden
  17411. */
  17412. _prepareEffect(): void;
  17413. /**
  17414. * Checks if the effect is supported. (Must be called after compilation)
  17415. */
  17416. readonly isSupported: boolean;
  17417. /**
  17418. * Binds a texture to the engine to be used as output of the shader.
  17419. * @param channel Name of the output variable.
  17420. * @param texture Texture to bind.
  17421. * @hidden
  17422. */
  17423. _bindTexture(channel: string, texture: InternalTexture): void;
  17424. /**
  17425. * Sets a texture on the engine to be used in the shader.
  17426. * @param channel Name of the sampler variable.
  17427. * @param texture Texture to set.
  17428. */
  17429. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17430. /**
  17431. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17432. * @param channel Name of the sampler variable.
  17433. * @param texture Texture to set.
  17434. */
  17435. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17436. /**
  17437. * Sets an array of textures on the engine to be used in the shader.
  17438. * @param channel Name of the variable.
  17439. * @param textures Textures to set.
  17440. */
  17441. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17442. /**
  17443. * 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)
  17444. * @param channel Name of the sampler variable.
  17445. * @param postProcess Post process to get the input texture from.
  17446. */
  17447. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17448. /**
  17449. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17450. * 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)
  17451. * @param channel Name of the sampler variable.
  17452. * @param postProcess Post process to get the output texture from.
  17453. */
  17454. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17455. /** @hidden */
  17456. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17457. /** @hidden */
  17458. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17459. /** @hidden */
  17460. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17461. /** @hidden */
  17462. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17463. /**
  17464. * Binds a buffer to a uniform.
  17465. * @param buffer Buffer to bind.
  17466. * @param name Name of the uniform variable to bind to.
  17467. */
  17468. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17469. /**
  17470. * Binds block to a uniform.
  17471. * @param blockName Name of the block to bind.
  17472. * @param index Index to bind.
  17473. */
  17474. bindUniformBlock(blockName: string, index: number): void;
  17475. /**
  17476. * Sets an interger value on a uniform variable.
  17477. * @param uniformName Name of the variable.
  17478. * @param value Value to be set.
  17479. * @returns this effect.
  17480. */
  17481. setInt(uniformName: string, value: number): Effect;
  17482. /**
  17483. * Sets an int array on a uniform variable.
  17484. * @param uniformName Name of the variable.
  17485. * @param array array to be set.
  17486. * @returns this effect.
  17487. */
  17488. setIntArray(uniformName: string, array: Int32Array): Effect;
  17489. /**
  17490. * 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)
  17491. * @param uniformName Name of the variable.
  17492. * @param array array to be set.
  17493. * @returns this effect.
  17494. */
  17495. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17496. /**
  17497. * 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)
  17498. * @param uniformName Name of the variable.
  17499. * @param array array to be set.
  17500. * @returns this effect.
  17501. */
  17502. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17503. /**
  17504. * 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)
  17505. * @param uniformName Name of the variable.
  17506. * @param array array to be set.
  17507. * @returns this effect.
  17508. */
  17509. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17510. /**
  17511. * Sets an float array on a uniform variable.
  17512. * @param uniformName Name of the variable.
  17513. * @param array array to be set.
  17514. * @returns this effect.
  17515. */
  17516. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17517. /**
  17518. * 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)
  17519. * @param uniformName Name of the variable.
  17520. * @param array array to be set.
  17521. * @returns this effect.
  17522. */
  17523. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17524. /**
  17525. * 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)
  17526. * @param uniformName Name of the variable.
  17527. * @param array array to be set.
  17528. * @returns this effect.
  17529. */
  17530. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17531. /**
  17532. * 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)
  17533. * @param uniformName Name of the variable.
  17534. * @param array array to be set.
  17535. * @returns this effect.
  17536. */
  17537. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17538. /**
  17539. * Sets an array on a uniform variable.
  17540. * @param uniformName Name of the variable.
  17541. * @param array array to be set.
  17542. * @returns this effect.
  17543. */
  17544. setArray(uniformName: string, array: number[]): Effect;
  17545. /**
  17546. * 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)
  17547. * @param uniformName Name of the variable.
  17548. * @param array array to be set.
  17549. * @returns this effect.
  17550. */
  17551. setArray2(uniformName: string, array: number[]): Effect;
  17552. /**
  17553. * 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)
  17554. * @param uniformName Name of the variable.
  17555. * @param array array to be set.
  17556. * @returns this effect.
  17557. */
  17558. setArray3(uniformName: string, array: number[]): Effect;
  17559. /**
  17560. * 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)
  17561. * @param uniformName Name of the variable.
  17562. * @param array array to be set.
  17563. * @returns this effect.
  17564. */
  17565. setArray4(uniformName: string, array: number[]): Effect;
  17566. /**
  17567. * Sets matrices on a uniform variable.
  17568. * @param uniformName Name of the variable.
  17569. * @param matrices matrices to be set.
  17570. * @returns this effect.
  17571. */
  17572. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17573. /**
  17574. * Sets matrix on a uniform variable.
  17575. * @param uniformName Name of the variable.
  17576. * @param matrix matrix to be set.
  17577. * @returns this effect.
  17578. */
  17579. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17580. /**
  17581. * 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)
  17582. * @param uniformName Name of the variable.
  17583. * @param matrix matrix to be set.
  17584. * @returns this effect.
  17585. */
  17586. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17587. /**
  17588. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17589. * @param uniformName Name of the variable.
  17590. * @param matrix matrix to be set.
  17591. * @returns this effect.
  17592. */
  17593. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17594. /**
  17595. * Sets a float on a uniform variable.
  17596. * @param uniformName Name of the variable.
  17597. * @param value value to be set.
  17598. * @returns this effect.
  17599. */
  17600. setFloat(uniformName: string, value: number): Effect;
  17601. /**
  17602. * Sets a boolean on a uniform variable.
  17603. * @param uniformName Name of the variable.
  17604. * @param bool value to be set.
  17605. * @returns this effect.
  17606. */
  17607. setBool(uniformName: string, bool: boolean): Effect;
  17608. /**
  17609. * Sets a Vector2 on a uniform variable.
  17610. * @param uniformName Name of the variable.
  17611. * @param vector2 vector2 to be set.
  17612. * @returns this effect.
  17613. */
  17614. setVector2(uniformName: string, vector2: Vector2): Effect;
  17615. /**
  17616. * Sets a float2 on a uniform variable.
  17617. * @param uniformName Name of the variable.
  17618. * @param x First float in float2.
  17619. * @param y Second float in float2.
  17620. * @returns this effect.
  17621. */
  17622. setFloat2(uniformName: string, x: number, y: number): Effect;
  17623. /**
  17624. * Sets a Vector3 on a uniform variable.
  17625. * @param uniformName Name of the variable.
  17626. * @param vector3 Value to be set.
  17627. * @returns this effect.
  17628. */
  17629. setVector3(uniformName: string, vector3: Vector3): Effect;
  17630. /**
  17631. * Sets a float3 on a uniform variable.
  17632. * @param uniformName Name of the variable.
  17633. * @param x First float in float3.
  17634. * @param y Second float in float3.
  17635. * @param z Third float in float3.
  17636. * @returns this effect.
  17637. */
  17638. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17639. /**
  17640. * Sets a Vector4 on a uniform variable.
  17641. * @param uniformName Name of the variable.
  17642. * @param vector4 Value to be set.
  17643. * @returns this effect.
  17644. */
  17645. setVector4(uniformName: string, vector4: Vector4): Effect;
  17646. /**
  17647. * Sets a float4 on a uniform variable.
  17648. * @param uniformName Name of the variable.
  17649. * @param x First float in float4.
  17650. * @param y Second float in float4.
  17651. * @param z Third float in float4.
  17652. * @param w Fourth float in float4.
  17653. * @returns this effect.
  17654. */
  17655. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17656. /**
  17657. * Sets a Color3 on a uniform variable.
  17658. * @param uniformName Name of the variable.
  17659. * @param color3 Value to be set.
  17660. * @returns this effect.
  17661. */
  17662. setColor3(uniformName: string, color3: Color3): Effect;
  17663. /**
  17664. * Sets a Color4 on a uniform variable.
  17665. * @param uniformName Name of the variable.
  17666. * @param color3 Value to be set.
  17667. * @param alpha Alpha value to be set.
  17668. * @returns this effect.
  17669. */
  17670. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17671. /**
  17672. * Sets a Color4 on a uniform variable
  17673. * @param uniformName defines the name of the variable
  17674. * @param color4 defines the value to be set
  17675. * @returns this effect.
  17676. */
  17677. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17678. /**
  17679. * This function will add a new shader to the shader store
  17680. * @param name the name of the shader
  17681. * @param pixelShader optional pixel shader content
  17682. * @param vertexShader optional vertex shader content
  17683. */
  17684. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17685. /**
  17686. * Store of each shader (The can be looked up using effect.key)
  17687. */
  17688. static ShadersStore: {
  17689. [key: string]: string;
  17690. };
  17691. /**
  17692. * Store of each included file for a shader (The can be looked up using effect.key)
  17693. */
  17694. static IncludesShadersStore: {
  17695. [key: string]: string;
  17696. };
  17697. /**
  17698. * Resets the cache of effects.
  17699. */
  17700. static ResetCache(): void;
  17701. }
  17702. }
  17703. declare module BABYLON {
  17704. /**
  17705. * This represents all the required information to add a fresnel effect on a material:
  17706. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17707. */
  17708. class FresnelParameters {
  17709. private _isEnabled;
  17710. /**
  17711. * Define if the fresnel effect is enable or not.
  17712. */
  17713. isEnabled: boolean;
  17714. /**
  17715. * Define the color used on edges (grazing angle)
  17716. */
  17717. leftColor: Color3;
  17718. /**
  17719. * Define the color used on center
  17720. */
  17721. rightColor: Color3;
  17722. /**
  17723. * Define bias applied to computed fresnel term
  17724. */
  17725. bias: number;
  17726. /**
  17727. * Defined the power exponent applied to fresnel term
  17728. */
  17729. power: number;
  17730. /**
  17731. * Clones the current fresnel and its valuues
  17732. * @returns a clone fresnel configuration
  17733. */
  17734. clone(): FresnelParameters;
  17735. /**
  17736. * Serializes the current fresnel parameters to a JSON representation.
  17737. * @return the JSON serialization
  17738. */
  17739. serialize(): any;
  17740. /**
  17741. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17742. * @param parsedFresnelParameters Define the JSON representation
  17743. * @returns the parsed parameters
  17744. */
  17745. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17746. }
  17747. }
  17748. declare module BABYLON {
  17749. /**
  17750. * Interface to follow in your material defines to integrate easily the
  17751. * Image proccessing functions.
  17752. * @hidden
  17753. */
  17754. interface IImageProcessingConfigurationDefines {
  17755. IMAGEPROCESSING: boolean;
  17756. VIGNETTE: boolean;
  17757. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17758. VIGNETTEBLENDMODEOPAQUE: boolean;
  17759. TONEMAPPING: boolean;
  17760. TONEMAPPING_ACES: boolean;
  17761. CONTRAST: boolean;
  17762. EXPOSURE: boolean;
  17763. COLORCURVES: boolean;
  17764. COLORGRADING: boolean;
  17765. COLORGRADING3D: boolean;
  17766. SAMPLER3DGREENDEPTH: boolean;
  17767. SAMPLER3DBGRMAP: boolean;
  17768. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17769. }
  17770. /**
  17771. * @hidden
  17772. */
  17773. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17774. IMAGEPROCESSING: boolean;
  17775. VIGNETTE: boolean;
  17776. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17777. VIGNETTEBLENDMODEOPAQUE: boolean;
  17778. TONEMAPPING: boolean;
  17779. TONEMAPPING_ACES: boolean;
  17780. CONTRAST: boolean;
  17781. COLORCURVES: boolean;
  17782. COLORGRADING: boolean;
  17783. COLORGRADING3D: boolean;
  17784. SAMPLER3DGREENDEPTH: boolean;
  17785. SAMPLER3DBGRMAP: boolean;
  17786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17787. EXPOSURE: boolean;
  17788. constructor();
  17789. }
  17790. /**
  17791. * This groups together the common properties used for image processing either in direct forward pass
  17792. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17793. * or not.
  17794. */
  17795. class ImageProcessingConfiguration {
  17796. /**
  17797. * Default tone mapping applied in BabylonJS.
  17798. */
  17799. static readonly TONEMAPPING_STANDARD: number;
  17800. /**
  17801. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17802. * to other engines rendering to increase portability.
  17803. */
  17804. static readonly TONEMAPPING_ACES: number;
  17805. /**
  17806. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17807. */
  17808. colorCurves: Nullable<ColorCurves>;
  17809. private _colorCurvesEnabled;
  17810. /**
  17811. * Gets wether the color curves effect is enabled.
  17812. */
  17813. /**
  17814. * Sets wether the color curves effect is enabled.
  17815. */
  17816. colorCurvesEnabled: boolean;
  17817. private _colorGradingTexture;
  17818. /**
  17819. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17820. */
  17821. /**
  17822. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17823. */
  17824. colorGradingTexture: Nullable<BaseTexture>;
  17825. private _colorGradingEnabled;
  17826. /**
  17827. * Gets wether the color grading effect is enabled.
  17828. */
  17829. /**
  17830. * Sets wether the color grading effect is enabled.
  17831. */
  17832. colorGradingEnabled: boolean;
  17833. private _colorGradingWithGreenDepth;
  17834. /**
  17835. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17836. */
  17837. /**
  17838. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17839. */
  17840. colorGradingWithGreenDepth: boolean;
  17841. private _colorGradingBGR;
  17842. /**
  17843. * Gets wether the color grading texture contains BGR values.
  17844. */
  17845. /**
  17846. * Sets wether the color grading texture contains BGR values.
  17847. */
  17848. colorGradingBGR: boolean;
  17849. /** @hidden */
  17850. _exposure: number;
  17851. /**
  17852. * Gets the Exposure used in the effect.
  17853. */
  17854. /**
  17855. * Sets the Exposure used in the effect.
  17856. */
  17857. exposure: number;
  17858. private _toneMappingEnabled;
  17859. /**
  17860. * Gets wether the tone mapping effect is enabled.
  17861. */
  17862. /**
  17863. * Sets wether the tone mapping effect is enabled.
  17864. */
  17865. toneMappingEnabled: boolean;
  17866. private _toneMappingType;
  17867. /**
  17868. * Gets the type of tone mapping effect.
  17869. */
  17870. /**
  17871. * Sets the type of tone mapping effect used in BabylonJS.
  17872. */
  17873. toneMappingType: number;
  17874. protected _contrast: number;
  17875. /**
  17876. * Gets the contrast used in the effect.
  17877. */
  17878. /**
  17879. * Sets the contrast used in the effect.
  17880. */
  17881. contrast: number;
  17882. /**
  17883. * Vignette stretch size.
  17884. */
  17885. vignetteStretch: number;
  17886. /**
  17887. * Vignette centre X Offset.
  17888. */
  17889. vignetteCentreX: number;
  17890. /**
  17891. * Vignette centre Y Offset.
  17892. */
  17893. vignetteCentreY: number;
  17894. /**
  17895. * Vignette weight or intensity of the vignette effect.
  17896. */
  17897. vignetteWeight: number;
  17898. /**
  17899. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17900. * if vignetteEnabled is set to true.
  17901. */
  17902. vignetteColor: Color4;
  17903. /**
  17904. * Camera field of view used by the Vignette effect.
  17905. */
  17906. vignetteCameraFov: number;
  17907. private _vignetteBlendMode;
  17908. /**
  17909. * Gets the vignette blend mode allowing different kind of effect.
  17910. */
  17911. /**
  17912. * Sets the vignette blend mode allowing different kind of effect.
  17913. */
  17914. vignetteBlendMode: number;
  17915. private _vignetteEnabled;
  17916. /**
  17917. * Gets wether the vignette effect is enabled.
  17918. */
  17919. /**
  17920. * Sets wether the vignette effect is enabled.
  17921. */
  17922. vignetteEnabled: boolean;
  17923. private _applyByPostProcess;
  17924. /**
  17925. * Gets wether the image processing is applied through a post process or not.
  17926. */
  17927. /**
  17928. * Sets wether the image processing is applied through a post process or not.
  17929. */
  17930. applyByPostProcess: boolean;
  17931. private _isEnabled;
  17932. /**
  17933. * Gets wether the image processing is enabled or not.
  17934. */
  17935. /**
  17936. * Sets wether the image processing is enabled or not.
  17937. */
  17938. isEnabled: boolean;
  17939. /**
  17940. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17941. */
  17942. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17943. /**
  17944. * Method called each time the image processing information changes requires to recompile the effect.
  17945. */
  17946. protected _updateParameters(): void;
  17947. /**
  17948. * Gets the current class name.
  17949. * @return "ImageProcessingConfiguration"
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * Prepare the list of uniforms associated with the Image Processing effects.
  17954. * @param uniforms The list of uniforms used in the effect
  17955. * @param defines the list of defines currently in use
  17956. */
  17957. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17958. /**
  17959. * Prepare the list of samplers associated with the Image Processing effects.
  17960. * @param samplersList The list of uniforms used in the effect
  17961. * @param defines the list of defines currently in use
  17962. */
  17963. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17964. /**
  17965. * Prepare the list of defines associated to the shader.
  17966. * @param defines the list of defines to complete
  17967. * @param forPostProcess Define if we are currently in post process mode or not
  17968. */
  17969. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17970. /**
  17971. * Returns true if all the image processing information are ready.
  17972. * @returns True if ready, otherwise, false
  17973. */
  17974. isReady(): boolean;
  17975. /**
  17976. * Binds the image processing to the shader.
  17977. * @param effect The effect to bind to
  17978. * @param aspectRatio Define the current aspect ratio of the effect
  17979. */
  17980. bind(effect: Effect, aspectRatio?: number): void;
  17981. /**
  17982. * Clones the current image processing instance.
  17983. * @return The cloned image processing
  17984. */
  17985. clone(): ImageProcessingConfiguration;
  17986. /**
  17987. * Serializes the current image processing instance to a json representation.
  17988. * @return a JSON representation
  17989. */
  17990. serialize(): any;
  17991. /**
  17992. * Parses the image processing from a json representation.
  17993. * @param source the JSON source to parse
  17994. * @return The parsed image processing
  17995. */
  17996. static Parse(source: any): ImageProcessingConfiguration;
  17997. private static _VIGNETTEMODE_MULTIPLY;
  17998. private static _VIGNETTEMODE_OPAQUE;
  17999. /**
  18000. * Used to apply the vignette as a mix with the pixel color.
  18001. */
  18002. static readonly VIGNETTEMODE_MULTIPLY: number;
  18003. /**
  18004. * Used to apply the vignette as a replacement of the pixel color.
  18005. */
  18006. static readonly VIGNETTEMODE_OPAQUE: number;
  18007. }
  18008. }
  18009. declare module BABYLON {
  18010. /**
  18011. * Manages the defines for the Material
  18012. */
  18013. class MaterialDefines {
  18014. private _keys;
  18015. private _isDirty;
  18016. /** @hidden */
  18017. _renderId: number;
  18018. /** @hidden */
  18019. _areLightsDirty: boolean;
  18020. /** @hidden */
  18021. _areAttributesDirty: boolean;
  18022. /** @hidden */
  18023. _areTexturesDirty: boolean;
  18024. /** @hidden */
  18025. _areFresnelDirty: boolean;
  18026. /** @hidden */
  18027. _areMiscDirty: boolean;
  18028. /** @hidden */
  18029. _areImageProcessingDirty: boolean;
  18030. /** @hidden */
  18031. _normals: boolean;
  18032. /** @hidden */
  18033. _uvs: boolean;
  18034. /** @hidden */
  18035. _needNormals: boolean;
  18036. /** @hidden */
  18037. _needUVs: boolean;
  18038. /**
  18039. * Specifies if the material needs to be re-calculated
  18040. */
  18041. readonly isDirty: boolean;
  18042. /**
  18043. * Marks the material to indicate that it has been re-calculated
  18044. */
  18045. markAsProcessed(): void;
  18046. /**
  18047. * Marks the material to indicate that it needs to be re-calculated
  18048. */
  18049. markAsUnprocessed(): void;
  18050. /**
  18051. * Marks the material to indicate all of its defines need to be re-calculated
  18052. */
  18053. markAllAsDirty(): void;
  18054. /**
  18055. * Marks the material to indicate that image processing needs to be re-calculated
  18056. */
  18057. markAsImageProcessingDirty(): void;
  18058. /**
  18059. * Marks the material to indicate the lights need to be re-calculated
  18060. */
  18061. markAsLightDirty(): void;
  18062. /**
  18063. * Marks the attribute state as changed
  18064. */
  18065. markAsAttributesDirty(): void;
  18066. /**
  18067. * Marks the texture state as changed
  18068. */
  18069. markAsTexturesDirty(): void;
  18070. /**
  18071. * Marks the fresnel state as changed
  18072. */
  18073. markAsFresnelDirty(): void;
  18074. /**
  18075. * Marks the misc state as changed
  18076. */
  18077. markAsMiscDirty(): void;
  18078. /**
  18079. * Rebuilds the material defines
  18080. */
  18081. rebuild(): void;
  18082. /**
  18083. * Specifies if two material defines are equal
  18084. * @param other - A material define instance to compare to
  18085. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18086. */
  18087. isEqual(other: MaterialDefines): boolean;
  18088. /**
  18089. * Clones this instance's defines to another instance
  18090. * @param other - material defines to clone values to
  18091. */
  18092. cloneTo(other: MaterialDefines): void;
  18093. /**
  18094. * Resets the material define values
  18095. */
  18096. reset(): void;
  18097. /**
  18098. * Converts the material define values to a string
  18099. * @returns - String of material define information
  18100. */
  18101. toString(): string;
  18102. }
  18103. /**
  18104. * Base class for the main features of a material in Babylon.js
  18105. */
  18106. class Material implements IAnimatable {
  18107. private static _TriangleFillMode;
  18108. private static _WireFrameFillMode;
  18109. private static _PointFillMode;
  18110. private static _PointListDrawMode;
  18111. private static _LineListDrawMode;
  18112. private static _LineLoopDrawMode;
  18113. private static _LineStripDrawMode;
  18114. private static _TriangleStripDrawMode;
  18115. private static _TriangleFanDrawMode;
  18116. /**
  18117. * Returns the triangle fill mode
  18118. */
  18119. static readonly TriangleFillMode: number;
  18120. /**
  18121. * Returns the wireframe mode
  18122. */
  18123. static readonly WireFrameFillMode: number;
  18124. /**
  18125. * Returns the point fill mode
  18126. */
  18127. static readonly PointFillMode: number;
  18128. /**
  18129. * Returns the point list draw mode
  18130. */
  18131. static readonly PointListDrawMode: number;
  18132. /**
  18133. * Returns the line list draw mode
  18134. */
  18135. static readonly LineListDrawMode: number;
  18136. /**
  18137. * Returns the line loop draw mode
  18138. */
  18139. static readonly LineLoopDrawMode: number;
  18140. /**
  18141. * Returns the line strip draw mode
  18142. */
  18143. static readonly LineStripDrawMode: number;
  18144. /**
  18145. * Returns the triangle strip draw mode
  18146. */
  18147. static readonly TriangleStripDrawMode: number;
  18148. /**
  18149. * Returns the triangle fan draw mode
  18150. */
  18151. static readonly TriangleFanDrawMode: number;
  18152. /**
  18153. * Stores the clock-wise side orientation
  18154. */
  18155. private static _ClockWiseSideOrientation;
  18156. /**
  18157. * Stores the counter clock-wise side orientation
  18158. */
  18159. private static _CounterClockWiseSideOrientation;
  18160. /**
  18161. * Returns the clock-wise side orientation
  18162. */
  18163. static readonly ClockWiseSideOrientation: number;
  18164. /**
  18165. * Returns the counter clock-wise side orientation
  18166. */
  18167. static readonly CounterClockWiseSideOrientation: number;
  18168. /**
  18169. * The dirty texture flag value
  18170. */
  18171. static readonly TextureDirtyFlag: number;
  18172. /**
  18173. * The dirty light flag value
  18174. */
  18175. static readonly LightDirtyFlag: number;
  18176. /**
  18177. * The dirty fresnel flag value
  18178. */
  18179. static readonly FresnelDirtyFlag: number;
  18180. /**
  18181. * The dirty attribute flag value
  18182. */
  18183. static readonly AttributesDirtyFlag: number;
  18184. /**
  18185. * The dirty misc flag value
  18186. */
  18187. static readonly MiscDirtyFlag: number;
  18188. /**
  18189. * The all dirty flag value
  18190. */
  18191. static readonly AllDirtyFlag: number;
  18192. /**
  18193. * The ID of the material
  18194. */
  18195. id: string;
  18196. /**
  18197. * Gets or sets the unique id of the material
  18198. */
  18199. uniqueId: number;
  18200. /**
  18201. * The name of the material
  18202. */
  18203. name: string;
  18204. /**
  18205. * Gets or sets user defined metadata
  18206. */
  18207. metadata: any;
  18208. /**
  18209. * For internal use only. Please do not use.
  18210. */
  18211. reservedDataStore: any;
  18212. /**
  18213. * Specifies if the ready state should be checked on each call
  18214. */
  18215. checkReadyOnEveryCall: boolean;
  18216. /**
  18217. * Specifies if the ready state should be checked once
  18218. */
  18219. checkReadyOnlyOnce: boolean;
  18220. /**
  18221. * The state of the material
  18222. */
  18223. state: string;
  18224. /**
  18225. * The alpha value of the material
  18226. */
  18227. protected _alpha: number;
  18228. /**
  18229. * Sets the alpha value of the material
  18230. */
  18231. /**
  18232. * Gets the alpha value of the material
  18233. */
  18234. alpha: number;
  18235. /**
  18236. * Specifies if back face culling is enabled
  18237. */
  18238. protected _backFaceCulling: boolean;
  18239. /**
  18240. * Sets the back-face culling state
  18241. */
  18242. /**
  18243. * Gets the back-face culling state
  18244. */
  18245. backFaceCulling: boolean;
  18246. /**
  18247. * Stores the value for side orientation
  18248. */
  18249. sideOrientation: number;
  18250. /**
  18251. * Callback triggered when the material is compiled
  18252. */
  18253. onCompiled: (effect: Effect) => void;
  18254. /**
  18255. * Callback triggered when an error occurs
  18256. */
  18257. onError: (effect: Effect, errors: string) => void;
  18258. /**
  18259. * Callback triggered to get the render target textures
  18260. */
  18261. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18262. /**
  18263. * Gets a boolean indicating that current material needs to register RTT
  18264. */
  18265. readonly hasRenderTargetTextures: boolean;
  18266. /**
  18267. * Specifies if the material should be serialized
  18268. */
  18269. doNotSerialize: boolean;
  18270. /**
  18271. * @hidden
  18272. */
  18273. _storeEffectOnSubMeshes: boolean;
  18274. /**
  18275. * Stores the animations for the material
  18276. */
  18277. animations: Array<Animation>;
  18278. /**
  18279. * An event triggered when the material is disposed
  18280. */
  18281. onDisposeObservable: Observable<Material>;
  18282. /**
  18283. * An observer which watches for dispose events
  18284. */
  18285. private _onDisposeObserver;
  18286. private _onUnBindObservable;
  18287. /**
  18288. * Called during a dispose event
  18289. */
  18290. onDispose: () => void;
  18291. private _onBindObservable;
  18292. /**
  18293. * An event triggered when the material is bound
  18294. */
  18295. readonly onBindObservable: Observable<AbstractMesh>;
  18296. /**
  18297. * An observer which watches for bind events
  18298. */
  18299. private _onBindObserver;
  18300. /**
  18301. * Called during a bind event
  18302. */
  18303. onBind: (Mesh: AbstractMesh) => void;
  18304. /**
  18305. * An event triggered when the material is unbound
  18306. */
  18307. readonly onUnBindObservable: Observable<Material>;
  18308. /**
  18309. * Stores the value of the alpha mode
  18310. */
  18311. private _alphaMode;
  18312. /**
  18313. * Sets the value of the alpha mode.
  18314. *
  18315. * | Value | Type | Description |
  18316. * | --- | --- | --- |
  18317. * | 0 | ALPHA_DISABLE | |
  18318. * | 1 | ALPHA_ADD | |
  18319. * | 2 | ALPHA_COMBINE | |
  18320. * | 3 | ALPHA_SUBTRACT | |
  18321. * | 4 | ALPHA_MULTIPLY | |
  18322. * | 5 | ALPHA_MAXIMIZED | |
  18323. * | 6 | ALPHA_ONEONE | |
  18324. * | 7 | ALPHA_PREMULTIPLIED | |
  18325. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18326. * | 9 | ALPHA_INTERPOLATE | |
  18327. * | 10 | ALPHA_SCREENMODE | |
  18328. *
  18329. */
  18330. /**
  18331. * Gets the value of the alpha mode
  18332. */
  18333. alphaMode: number;
  18334. /**
  18335. * Stores the state of the need depth pre-pass value
  18336. */
  18337. private _needDepthPrePass;
  18338. /**
  18339. * Sets the need depth pre-pass value
  18340. */
  18341. /**
  18342. * Gets the depth pre-pass value
  18343. */
  18344. needDepthPrePass: boolean;
  18345. /**
  18346. * Specifies if depth writing should be disabled
  18347. */
  18348. disableDepthWrite: boolean;
  18349. /**
  18350. * Specifies if depth writing should be forced
  18351. */
  18352. forceDepthWrite: boolean;
  18353. /**
  18354. * Specifies if there should be a separate pass for culling
  18355. */
  18356. separateCullingPass: boolean;
  18357. /**
  18358. * Stores the state specifing if fog should be enabled
  18359. */
  18360. private _fogEnabled;
  18361. /**
  18362. * Sets the state for enabling fog
  18363. */
  18364. /**
  18365. * Gets the value of the fog enabled state
  18366. */
  18367. fogEnabled: boolean;
  18368. /**
  18369. * Stores the size of points
  18370. */
  18371. pointSize: number;
  18372. /**
  18373. * Stores the z offset value
  18374. */
  18375. zOffset: number;
  18376. /**
  18377. * Gets a value specifying if wireframe mode is enabled
  18378. */
  18379. /**
  18380. * Sets the state of wireframe mode
  18381. */
  18382. wireframe: boolean;
  18383. /**
  18384. * Gets the value specifying if point clouds are enabled
  18385. */
  18386. /**
  18387. * Sets the state of point cloud mode
  18388. */
  18389. pointsCloud: boolean;
  18390. /**
  18391. * Gets the material fill mode
  18392. */
  18393. /**
  18394. * Sets the material fill mode
  18395. */
  18396. fillMode: number;
  18397. /**
  18398. * @hidden
  18399. * Stores the effects for the material
  18400. */
  18401. _effect: Nullable<Effect>;
  18402. /**
  18403. * @hidden
  18404. * Specifies if the material was previously ready
  18405. */
  18406. _wasPreviouslyReady: boolean;
  18407. /**
  18408. * Specifies if uniform buffers should be used
  18409. */
  18410. private _useUBO;
  18411. /**
  18412. * Stores a reference to the scene
  18413. */
  18414. private _scene;
  18415. /**
  18416. * Stores the fill mode state
  18417. */
  18418. private _fillMode;
  18419. /**
  18420. * Specifies if the depth write state should be cached
  18421. */
  18422. private _cachedDepthWriteState;
  18423. /**
  18424. * Stores the uniform buffer
  18425. */
  18426. protected _uniformBuffer: UniformBuffer;
  18427. /** @hidden */
  18428. _indexInSceneMaterialArray: number;
  18429. /** @hidden */
  18430. meshMap: Nullable<{
  18431. [id: string]: AbstractMesh | undefined;
  18432. }>;
  18433. /**
  18434. * Creates a material instance
  18435. * @param name defines the name of the material
  18436. * @param scene defines the scene to reference
  18437. * @param doNotAdd specifies if the material should be added to the scene
  18438. */
  18439. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18440. /**
  18441. * Returns a string representation of the current material
  18442. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18443. * @returns a string with material information
  18444. */
  18445. toString(fullDetails?: boolean): string;
  18446. /**
  18447. * Gets the class name of the material
  18448. * @returns a string with the class name of the material
  18449. */
  18450. getClassName(): string;
  18451. /**
  18452. * Specifies if updates for the material been locked
  18453. */
  18454. readonly isFrozen: boolean;
  18455. /**
  18456. * Locks updates for the material
  18457. */
  18458. freeze(): void;
  18459. /**
  18460. * Unlocks updates for the material
  18461. */
  18462. unfreeze(): void;
  18463. /**
  18464. * Specifies if the material is ready to be used
  18465. * @param mesh defines the mesh to check
  18466. * @param useInstances specifies if instances should be used
  18467. * @returns a boolean indicating if the material is ready to be used
  18468. */
  18469. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18470. /**
  18471. * Specifies that the submesh is ready to be used
  18472. * @param mesh defines the mesh to check
  18473. * @param subMesh defines which submesh to check
  18474. * @param useInstances specifies that instances should be used
  18475. * @returns a boolean indicating that the submesh is ready or not
  18476. */
  18477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18478. /**
  18479. * Returns the material effect
  18480. * @returns the effect associated with the material
  18481. */
  18482. getEffect(): Nullable<Effect>;
  18483. /**
  18484. * Returns the current scene
  18485. * @returns a Scene
  18486. */
  18487. getScene(): Scene;
  18488. /**
  18489. * Specifies if the material will require alpha blending
  18490. * @returns a boolean specifying if alpha blending is needed
  18491. */
  18492. needAlphaBlending(): boolean;
  18493. /**
  18494. * Specifies if the mesh will require alpha blending
  18495. * @param mesh defines the mesh to check
  18496. * @returns a boolean specifying if alpha blending is needed for the mesh
  18497. */
  18498. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18499. /**
  18500. * Specifies if this material should be rendered in alpha test mode
  18501. * @returns a boolean specifying if an alpha test is needed.
  18502. */
  18503. needAlphaTesting(): boolean;
  18504. /**
  18505. * Gets the texture used for the alpha test
  18506. * @returns the texture to use for alpha testing
  18507. */
  18508. getAlphaTestTexture(): Nullable<BaseTexture>;
  18509. /**
  18510. * Marks the material to indicate that it needs to be re-calculated
  18511. */
  18512. markDirty(): void;
  18513. /** @hidden */
  18514. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18515. /**
  18516. * Binds the material to the mesh
  18517. * @param world defines the world transformation matrix
  18518. * @param mesh defines the mesh to bind the material to
  18519. */
  18520. bind(world: Matrix, mesh?: Mesh): void;
  18521. /**
  18522. * Binds the submesh to the material
  18523. * @param world defines the world transformation matrix
  18524. * @param mesh defines the mesh containing the submesh
  18525. * @param subMesh defines the submesh to bind the material to
  18526. */
  18527. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18528. /**
  18529. * Binds the world matrix to the material
  18530. * @param world defines the world transformation matrix
  18531. */
  18532. bindOnlyWorldMatrix(world: Matrix): void;
  18533. /**
  18534. * Binds the scene's uniform buffer to the effect.
  18535. * @param effect defines the effect to bind to the scene uniform buffer
  18536. * @param sceneUbo defines the uniform buffer storing scene data
  18537. */
  18538. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18539. /**
  18540. * Binds the view matrix to the effect
  18541. * @param effect defines the effect to bind the view matrix to
  18542. */
  18543. bindView(effect: Effect): void;
  18544. /**
  18545. * Binds the view projection matrix to the effect
  18546. * @param effect defines the effect to bind the view projection matrix to
  18547. */
  18548. bindViewProjection(effect: Effect): void;
  18549. /**
  18550. * Specifies if material alpha testing should be turned on for the mesh
  18551. * @param mesh defines the mesh to check
  18552. */
  18553. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18554. /**
  18555. * Processes to execute after binding the material to a mesh
  18556. * @param mesh defines the rendered mesh
  18557. */
  18558. protected _afterBind(mesh?: Mesh): void;
  18559. /**
  18560. * Unbinds the material from the mesh
  18561. */
  18562. unbind(): void;
  18563. /**
  18564. * Gets the active textures from the material
  18565. * @returns an array of textures
  18566. */
  18567. getActiveTextures(): BaseTexture[];
  18568. /**
  18569. * Specifies if the material uses a texture
  18570. * @param texture defines the texture to check against the material
  18571. * @returns a boolean specifying if the material uses the texture
  18572. */
  18573. hasTexture(texture: BaseTexture): boolean;
  18574. /**
  18575. * Makes a duplicate of the material, and gives it a new name
  18576. * @param name defines the new name for the duplicated material
  18577. * @returns the cloned material
  18578. */
  18579. clone(name: string): Nullable<Material>;
  18580. /**
  18581. * Gets the meshes bound to the material
  18582. * @returns an array of meshes bound to the material
  18583. */
  18584. getBindedMeshes(): AbstractMesh[];
  18585. /**
  18586. * Force shader compilation
  18587. * @param mesh defines the mesh associated with this material
  18588. * @param onCompiled defines a function to execute once the material is compiled
  18589. * @param options defines the options to configure the compilation
  18590. */
  18591. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18592. clipPlane: boolean;
  18593. }>): void;
  18594. /**
  18595. * Force shader compilation
  18596. * @param mesh defines the mesh that will use this material
  18597. * @param options defines additional options for compiling the shaders
  18598. * @returns a promise that resolves when the compilation completes
  18599. */
  18600. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18601. clipPlane: boolean;
  18602. }>): Promise<void>;
  18603. private static readonly _ImageProcessingDirtyCallBack;
  18604. private static readonly _TextureDirtyCallBack;
  18605. private static readonly _FresnelDirtyCallBack;
  18606. private static readonly _MiscDirtyCallBack;
  18607. private static readonly _LightsDirtyCallBack;
  18608. private static readonly _AttributeDirtyCallBack;
  18609. private static _FresnelAndMiscDirtyCallBack;
  18610. private static _TextureAndMiscDirtyCallBack;
  18611. private static readonly _DirtyCallbackArray;
  18612. private static readonly _RunDirtyCallBacks;
  18613. /**
  18614. * Marks a define in the material to indicate that it needs to be re-computed
  18615. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18616. */
  18617. markAsDirty(flag: number): void;
  18618. /**
  18619. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18620. * @param func defines a function which checks material defines against the submeshes
  18621. */
  18622. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18623. /**
  18624. * Indicates that image processing needs to be re-calculated for all submeshes
  18625. */
  18626. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18627. /**
  18628. * Indicates that textures need to be re-calculated for all submeshes
  18629. */
  18630. protected _markAllSubMeshesAsTexturesDirty(): void;
  18631. /**
  18632. * Indicates that fresnel needs to be re-calculated for all submeshes
  18633. */
  18634. protected _markAllSubMeshesAsFresnelDirty(): void;
  18635. /**
  18636. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18637. */
  18638. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18639. /**
  18640. * Indicates that lights need to be re-calculated for all submeshes
  18641. */
  18642. protected _markAllSubMeshesAsLightsDirty(): void;
  18643. /**
  18644. * Indicates that attributes need to be re-calculated for all submeshes
  18645. */
  18646. protected _markAllSubMeshesAsAttributesDirty(): void;
  18647. /**
  18648. * Indicates that misc needs to be re-calculated for all submeshes
  18649. */
  18650. protected _markAllSubMeshesAsMiscDirty(): void;
  18651. /**
  18652. * Indicates that textures and misc need to be re-calculated for all submeshes
  18653. */
  18654. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18655. /**
  18656. * Disposes the material
  18657. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18658. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18659. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18660. */
  18661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18662. /** @hidden */
  18663. private releaseVertexArrayObject;
  18664. /**
  18665. * Serializes this material
  18666. * @returns the serialized material object
  18667. */
  18668. serialize(): any;
  18669. /**
  18670. * Creates a MultiMaterial from parsed MultiMaterial data.
  18671. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18672. * @param scene defines the hosting scene
  18673. * @returns a new MultiMaterial
  18674. */
  18675. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18676. /**
  18677. * Creates a material from parsed material data
  18678. * @param parsedMaterial defines parsed material data
  18679. * @param scene defines the hosting scene
  18680. * @param rootUrl defines the root URL to use to load textures
  18681. * @returns a new material
  18682. */
  18683. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18684. }
  18685. }
  18686. declare module BABYLON {
  18687. /**
  18688. * "Static Class" containing the most commonly used helper while dealing with material for
  18689. * rendering purpose.
  18690. *
  18691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18692. *
  18693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18694. */
  18695. class MaterialHelper {
  18696. /**
  18697. * Bind the current view position to an effect.
  18698. * @param effect The effect to be bound
  18699. * @param scene The scene the eyes position is used from
  18700. */
  18701. static BindEyePosition(effect: Effect, scene: Scene): void;
  18702. /**
  18703. * Helps preparing the defines values about the UVs in used in the effect.
  18704. * UVs are shared as much as we can accross channels in the shaders.
  18705. * @param texture The texture we are preparing the UVs for
  18706. * @param defines The defines to update
  18707. * @param key The channel key "diffuse", "specular"... used in the shader
  18708. */
  18709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18710. /**
  18711. * Binds a texture matrix value to its corrsponding uniform
  18712. * @param texture The texture to bind the matrix for
  18713. * @param uniformBuffer The uniform buffer receivin the data
  18714. * @param key The channel key "diffuse", "specular"... used in the shader
  18715. */
  18716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18717. /**
  18718. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18719. * @param mesh defines the current mesh
  18720. * @param scene defines the current scene
  18721. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18722. * @param pointsCloud defines if point cloud rendering has to be turned on
  18723. * @param fogEnabled defines if fog has to be turned on
  18724. * @param alphaTest defines if alpha testing has to be turned on
  18725. * @param defines defines the current list of defines
  18726. */
  18727. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18728. /**
  18729. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18730. * @param scene defines the current scene
  18731. * @param engine defines the current engine
  18732. * @param defines specifies the list of active defines
  18733. * @param useInstances defines if instances have to be turned on
  18734. * @param useClipPlane defines if clip plane have to be turned on
  18735. */
  18736. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18737. /**
  18738. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18739. * @param mesh The mesh containing the geometry data we will draw
  18740. * @param defines The defines to update
  18741. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18742. * @param useBones Precise whether bones should be used or not (override mesh info)
  18743. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18744. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18745. * @returns false if defines are considered not dirty and have not been checked
  18746. */
  18747. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18748. /**
  18749. * Prepares the defines related to the light information passed in parameter
  18750. * @param scene The scene we are intending to draw
  18751. * @param mesh The mesh the effect is compiling for
  18752. * @param defines The defines to update
  18753. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18754. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18755. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18756. * @returns true if normals will be required for the rest of the effect
  18757. */
  18758. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18759. /**
  18760. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18761. * that won t be acctive due to defines being turned off.
  18762. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18763. * @param samplersList The samplers list
  18764. * @param defines The defines helping in the list generation
  18765. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18766. */
  18767. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18768. /**
  18769. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18770. * @param defines The defines to update while falling back
  18771. * @param fallbacks The authorized effect fallbacks
  18772. * @param maxSimultaneousLights The maximum number of lights allowed
  18773. * @param rank the current rank of the Effect
  18774. * @returns The newly affected rank
  18775. */
  18776. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18777. /**
  18778. * Prepares the list of attributes required for morph targets according to the effect defines.
  18779. * @param attribs The current list of supported attribs
  18780. * @param mesh The mesh to prepare the morph targets attributes for
  18781. * @param defines The current Defines of the effect
  18782. */
  18783. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18784. /**
  18785. * Prepares the list of attributes required for bones according to the effect defines.
  18786. * @param attribs The current list of supported attribs
  18787. * @param mesh The mesh to prepare the bones attributes for
  18788. * @param defines The current Defines of the effect
  18789. * @param fallbacks The current efffect fallback strategy
  18790. */
  18791. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18792. /**
  18793. * Prepares the list of attributes required for instances according to the effect defines.
  18794. * @param attribs The current list of supported attribs
  18795. * @param defines The current Defines of the effect
  18796. */
  18797. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18798. /**
  18799. * Binds the light shadow information to the effect for the given mesh.
  18800. * @param light The light containing the generator
  18801. * @param scene The scene the lights belongs to
  18802. * @param mesh The mesh we are binding the information to render
  18803. * @param lightIndex The light index in the effect used to render the mesh
  18804. * @param effect The effect we are binding the data to
  18805. */
  18806. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18807. /**
  18808. * Binds the light information to the effect.
  18809. * @param light The light containing the generator
  18810. * @param effect The effect we are binding the data to
  18811. * @param lightIndex The light index in the effect used to render
  18812. */
  18813. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18814. /**
  18815. * Binds the lights information from the scene to the effect for the given mesh.
  18816. * @param scene The scene the lights belongs to
  18817. * @param mesh The mesh we are binding the information to render
  18818. * @param effect The effect we are binding the data to
  18819. * @param defines The generated defines for the effect
  18820. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18821. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18822. */
  18823. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18824. private static _tempFogColor;
  18825. /**
  18826. * Binds the fog information from the scene to the effect for the given mesh.
  18827. * @param scene The scene the lights belongs to
  18828. * @param mesh The mesh we are binding the information to render
  18829. * @param effect The effect we are binding the data to
  18830. * @param linearSpace Defines if the fog effect is applied in linear space
  18831. */
  18832. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18833. /**
  18834. * Binds the bones information from the mesh to the effect.
  18835. * @param mesh The mesh we are binding the information to render
  18836. * @param effect The effect we are binding the data to
  18837. */
  18838. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18839. /**
  18840. * Binds the morph targets information from the mesh to the effect.
  18841. * @param abstractMesh The mesh we are binding the information to render
  18842. * @param effect The effect we are binding the data to
  18843. */
  18844. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18845. /**
  18846. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18847. * @param defines The generated defines used in the effect
  18848. * @param effect The effect we are binding the data to
  18849. * @param scene The scene we are willing to render with logarithmic scale for
  18850. */
  18851. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18852. /**
  18853. * Binds the clip plane information from the scene to the effect.
  18854. * @param scene The scene the clip plane information are extracted from
  18855. * @param effect The effect we are binding the data to
  18856. */
  18857. static BindClipPlane(effect: Effect, scene: Scene): void;
  18858. }
  18859. }
  18860. declare module BABYLON {
  18861. /**
  18862. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18863. * separate meshes. This can be use to improve performances.
  18864. * @see http://doc.babylonjs.com/how_to/multi_materials
  18865. */
  18866. class MultiMaterial extends Material {
  18867. private _subMaterials;
  18868. /**
  18869. * Gets or Sets the list of Materials used within the multi material.
  18870. * They need to be ordered according to the submeshes order in the associated mesh
  18871. */
  18872. subMaterials: Nullable<Material>[];
  18873. /**
  18874. * Function used to align with Node.getChildren()
  18875. * @returns the list of Materials used within the multi material
  18876. */
  18877. getChildren(): Nullable<Material>[];
  18878. /**
  18879. * Instantiates a new Multi Material
  18880. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18881. * separate meshes. This can be use to improve performances.
  18882. * @see http://doc.babylonjs.com/how_to/multi_materials
  18883. * @param name Define the name in the scene
  18884. * @param scene Define the scene the material belongs to
  18885. */
  18886. constructor(name: string, scene: Scene);
  18887. private _hookArray;
  18888. /**
  18889. * Get one of the submaterial by its index in the submaterials array
  18890. * @param index The index to look the sub material at
  18891. * @returns The Material if the index has been defined
  18892. */
  18893. getSubMaterial(index: number): Nullable<Material>;
  18894. /**
  18895. * Get the list of active textures for the whole sub materials list.
  18896. * @returns All the textures that will be used during the rendering
  18897. */
  18898. getActiveTextures(): BaseTexture[];
  18899. /**
  18900. * Gets the current class name of the material e.g. "MultiMaterial"
  18901. * Mainly use in serialization.
  18902. * @returns the class name
  18903. */
  18904. getClassName(): string;
  18905. /**
  18906. * Checks if the material is ready to render the requested sub mesh
  18907. * @param mesh Define the mesh the submesh belongs to
  18908. * @param subMesh Define the sub mesh to look readyness for
  18909. * @param useInstances Define whether or not the material is used with instances
  18910. * @returns true if ready, otherwise false
  18911. */
  18912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18913. /**
  18914. * Clones the current material and its related sub materials
  18915. * @param name Define the name of the newly cloned material
  18916. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18917. * @returns the cloned material
  18918. */
  18919. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18920. /**
  18921. * Serializes the materials into a JSON representation.
  18922. * @returns the JSON representation
  18923. */
  18924. serialize(): any;
  18925. /**
  18926. * Dispose the material and release its associated resources
  18927. * @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)
  18928. * @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)
  18929. */
  18930. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18931. }
  18932. }
  18933. declare module BABYLON {
  18934. /**
  18935. * Base class of materials working in push mode in babylon JS
  18936. * @hidden
  18937. */
  18938. class PushMaterial extends Material {
  18939. protected _activeEffect: Effect;
  18940. protected _normalMatrix: Matrix;
  18941. /**
  18942. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18943. * This means that the material can keep using a previous shader while a new one is being compiled.
  18944. * This is mostly used when shader parallel compilation is supported (true by default)
  18945. */
  18946. allowShaderHotSwapping: boolean;
  18947. constructor(name: string, scene: Scene);
  18948. getEffect(): Effect;
  18949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18950. /**
  18951. * Binds the given world matrix to the active effect
  18952. *
  18953. * @param world the matrix to bind
  18954. */
  18955. bindOnlyWorldMatrix(world: Matrix): void;
  18956. /**
  18957. * Binds the given normal matrix to the active effect
  18958. *
  18959. * @param normalMatrix the matrix to bind
  18960. */
  18961. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18962. bind(world: Matrix, mesh?: Mesh): void;
  18963. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18964. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18965. }
  18966. }
  18967. declare module BABYLON {
  18968. /**
  18969. * Defines the options associated with the creation of a shader material.
  18970. */
  18971. interface IShaderMaterialOptions {
  18972. /**
  18973. * Does the material work in alpha blend mode
  18974. */
  18975. needAlphaBlending: boolean;
  18976. /**
  18977. * Does the material work in alpha test mode
  18978. */
  18979. needAlphaTesting: boolean;
  18980. /**
  18981. * The list of attribute names used in the shader
  18982. */
  18983. attributes: string[];
  18984. /**
  18985. * The list of unifrom names used in the shader
  18986. */
  18987. uniforms: string[];
  18988. /**
  18989. * The list of UBO names used in the shader
  18990. */
  18991. uniformBuffers: string[];
  18992. /**
  18993. * The list of sampler names used in the shader
  18994. */
  18995. samplers: string[];
  18996. /**
  18997. * The list of defines used in the shader
  18998. */
  18999. defines: string[];
  19000. }
  19001. /**
  19002. * 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.
  19003. *
  19004. * This returned material effects how the mesh will look based on the code in the shaders.
  19005. *
  19006. * @see http://doc.babylonjs.com/how_to/shader_material
  19007. */
  19008. class ShaderMaterial extends Material {
  19009. private _shaderPath;
  19010. private _options;
  19011. private _textures;
  19012. private _textureArrays;
  19013. private _floats;
  19014. private _ints;
  19015. private _floatsArrays;
  19016. private _colors3;
  19017. private _colors3Arrays;
  19018. private _colors4;
  19019. private _vectors2;
  19020. private _vectors3;
  19021. private _vectors4;
  19022. private _matrices;
  19023. private _matrices3x3;
  19024. private _matrices2x2;
  19025. private _vectors2Arrays;
  19026. private _vectors3Arrays;
  19027. private _cachedWorldViewMatrix;
  19028. private _renderId;
  19029. /**
  19030. * Instantiate a new shader material.
  19031. * 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.
  19032. * This returned material effects how the mesh will look based on the code in the shaders.
  19033. * @see http://doc.babylonjs.com/how_to/shader_material
  19034. * @param name Define the name of the material in the scene
  19035. * @param scene Define the scene the material belongs to
  19036. * @param shaderPath Defines the route to the shader code in one of three ways:
  19037. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19038. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19039. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19040. * @param options Define the options used to create the shader
  19041. */
  19042. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19043. /**
  19044. * Gets the current class name of the material e.g. "ShaderMaterial"
  19045. * Mainly use in serialization.
  19046. * @returns the class name
  19047. */
  19048. getClassName(): string;
  19049. /**
  19050. * Specifies if the material will require alpha blending
  19051. * @returns a boolean specifying if alpha blending is needed
  19052. */
  19053. needAlphaBlending(): boolean;
  19054. /**
  19055. * Specifies if this material should be rendered in alpha test mode
  19056. * @returns a boolean specifying if an alpha test is needed.
  19057. */
  19058. needAlphaTesting(): boolean;
  19059. private _checkUniform;
  19060. /**
  19061. * Set a texture in the shader.
  19062. * @param name Define the name of the uniform samplers as defined in the shader
  19063. * @param texture Define the texture to bind to this sampler
  19064. * @return the material itself allowing "fluent" like uniform updates
  19065. */
  19066. setTexture(name: string, texture: Texture): ShaderMaterial;
  19067. /**
  19068. * Set a texture array in the shader.
  19069. * @param name Define the name of the uniform sampler array as defined in the shader
  19070. * @param textures Define the list of textures to bind to this sampler
  19071. * @return the material itself allowing "fluent" like uniform updates
  19072. */
  19073. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19074. /**
  19075. * Set a float in the shader.
  19076. * @param name Define the name of the uniform as defined in the shader
  19077. * @param value Define the value to give to the uniform
  19078. * @return the material itself allowing "fluent" like uniform updates
  19079. */
  19080. setFloat(name: string, value: number): ShaderMaterial;
  19081. /**
  19082. * Set a int in the shader.
  19083. * @param name Define the name of the uniform as defined in the shader
  19084. * @param value Define the value to give to the uniform
  19085. * @return the material itself allowing "fluent" like uniform updates
  19086. */
  19087. setInt(name: string, value: number): ShaderMaterial;
  19088. /**
  19089. * Set an array of floats in the shader.
  19090. * @param name Define the name of the uniform as defined in the shader
  19091. * @param value Define the value to give to the uniform
  19092. * @return the material itself allowing "fluent" like uniform updates
  19093. */
  19094. setFloats(name: string, value: number[]): ShaderMaterial;
  19095. /**
  19096. * Set a vec3 in the shader from a Color3.
  19097. * @param name Define the name of the uniform as defined in the shader
  19098. * @param value Define the value to give to the uniform
  19099. * @return the material itself allowing "fluent" like uniform updates
  19100. */
  19101. setColor3(name: string, value: Color3): ShaderMaterial;
  19102. /**
  19103. * Set a vec3 array in the shader from a Color3 array.
  19104. * @param name Define the name of the uniform as defined in the shader
  19105. * @param value Define the value to give to the uniform
  19106. * @return the material itself allowing "fluent" like uniform updates
  19107. */
  19108. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19109. /**
  19110. * Set a vec4 in the shader from a Color4.
  19111. * @param name Define the name of the uniform as defined in the shader
  19112. * @param value Define the value to give to the uniform
  19113. * @return the material itself allowing "fluent" like uniform updates
  19114. */
  19115. setColor4(name: string, value: Color4): ShaderMaterial;
  19116. /**
  19117. * Set a vec2 in the shader from a Vector2.
  19118. * @param name Define the name of the uniform as defined in the shader
  19119. * @param value Define the value to give to the uniform
  19120. * @return the material itself allowing "fluent" like uniform updates
  19121. */
  19122. setVector2(name: string, value: Vector2): ShaderMaterial;
  19123. /**
  19124. * Set a vec3 in the shader from a Vector3.
  19125. * @param name Define the name of the uniform as defined in the shader
  19126. * @param value Define the value to give to the uniform
  19127. * @return the material itself allowing "fluent" like uniform updates
  19128. */
  19129. setVector3(name: string, value: Vector3): ShaderMaterial;
  19130. /**
  19131. * Set a vec4 in the shader from a Vector4.
  19132. * @param name Define the name of the uniform as defined in the shader
  19133. * @param value Define the value to give to the uniform
  19134. * @return the material itself allowing "fluent" like uniform updates
  19135. */
  19136. setVector4(name: string, value: Vector4): ShaderMaterial;
  19137. /**
  19138. * Set a mat4 in the shader from a Matrix.
  19139. * @param name Define the name of the uniform as defined in the shader
  19140. * @param value Define the value to give to the uniform
  19141. * @return the material itself allowing "fluent" like uniform updates
  19142. */
  19143. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19144. /**
  19145. * Set a mat3 in the shader from a Float32Array.
  19146. * @param name Define the name of the uniform as defined in the shader
  19147. * @param value Define the value to give to the uniform
  19148. * @return the material itself allowing "fluent" like uniform updates
  19149. */
  19150. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19151. /**
  19152. * Set a mat2 in the shader from a Float32Array.
  19153. * @param name Define the name of the uniform as defined in the shader
  19154. * @param value Define the value to give to the uniform
  19155. * @return the material itself allowing "fluent" like uniform updates
  19156. */
  19157. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19158. /**
  19159. * Set a vec2 array in the shader from a number array.
  19160. * @param name Define the name of the uniform as defined in the shader
  19161. * @param value Define the value to give to the uniform
  19162. * @return the material itself allowing "fluent" like uniform updates
  19163. */
  19164. setArray2(name: string, value: number[]): ShaderMaterial;
  19165. /**
  19166. * Set a vec3 array in the shader from a number array.
  19167. * @param name Define the name of the uniform as defined in the shader
  19168. * @param value Define the value to give to the uniform
  19169. * @return the material itself allowing "fluent" like uniform updates
  19170. */
  19171. setArray3(name: string, value: number[]): ShaderMaterial;
  19172. private _checkCache;
  19173. /**
  19174. * Checks if the material is ready to render the requested mesh
  19175. * @param mesh Define the mesh to render
  19176. * @param useInstances Define whether or not the material is used with instances
  19177. * @returns true if ready, otherwise false
  19178. */
  19179. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19180. /**
  19181. * Binds the world matrix to the material
  19182. * @param world defines the world transformation matrix
  19183. */
  19184. bindOnlyWorldMatrix(world: Matrix): void;
  19185. /**
  19186. * Binds the material to the mesh
  19187. * @param world defines the world transformation matrix
  19188. * @param mesh defines the mesh to bind the material to
  19189. */
  19190. bind(world: Matrix, mesh?: Mesh): void;
  19191. /**
  19192. * Gets the active textures from the material
  19193. * @returns an array of textures
  19194. */
  19195. getActiveTextures(): BaseTexture[];
  19196. /**
  19197. * Specifies if the material uses a texture
  19198. * @param texture defines the texture to check against the material
  19199. * @returns a boolean specifying if the material uses the texture
  19200. */
  19201. hasTexture(texture: BaseTexture): boolean;
  19202. /**
  19203. * Makes a duplicate of the material, and gives it a new name
  19204. * @param name defines the new name for the duplicated material
  19205. * @returns the cloned material
  19206. */
  19207. clone(name: string): ShaderMaterial;
  19208. /**
  19209. * Disposes the material
  19210. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19211. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19212. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19213. */
  19214. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19215. /**
  19216. * Serializes this material in a JSON representation
  19217. * @returns the serialized material object
  19218. */
  19219. serialize(): any;
  19220. /**
  19221. * Creates a shader material from parsed shader material data
  19222. * @param source defines the JSON represnetation of the material
  19223. * @param scene defines the hosting scene
  19224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19225. * @returns a new material
  19226. */
  19227. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19228. }
  19229. }
  19230. declare module BABYLON {
  19231. /** @hidden */
  19232. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19233. MAINUV1: boolean;
  19234. MAINUV2: boolean;
  19235. DIFFUSE: boolean;
  19236. DIFFUSEDIRECTUV: number;
  19237. AMBIENT: boolean;
  19238. AMBIENTDIRECTUV: number;
  19239. OPACITY: boolean;
  19240. OPACITYDIRECTUV: number;
  19241. OPACITYRGB: boolean;
  19242. REFLECTION: boolean;
  19243. EMISSIVE: boolean;
  19244. EMISSIVEDIRECTUV: number;
  19245. SPECULAR: boolean;
  19246. SPECULARDIRECTUV: number;
  19247. BUMP: boolean;
  19248. BUMPDIRECTUV: number;
  19249. PARALLAX: boolean;
  19250. PARALLAXOCCLUSION: boolean;
  19251. SPECULAROVERALPHA: boolean;
  19252. CLIPPLANE: boolean;
  19253. CLIPPLANE2: boolean;
  19254. CLIPPLANE3: boolean;
  19255. CLIPPLANE4: boolean;
  19256. ALPHATEST: boolean;
  19257. DEPTHPREPASS: boolean;
  19258. ALPHAFROMDIFFUSE: boolean;
  19259. POINTSIZE: boolean;
  19260. FOG: boolean;
  19261. SPECULARTERM: boolean;
  19262. DIFFUSEFRESNEL: boolean;
  19263. OPACITYFRESNEL: boolean;
  19264. REFLECTIONFRESNEL: boolean;
  19265. REFRACTIONFRESNEL: boolean;
  19266. EMISSIVEFRESNEL: boolean;
  19267. FRESNEL: boolean;
  19268. NORMAL: boolean;
  19269. UV1: boolean;
  19270. UV2: boolean;
  19271. VERTEXCOLOR: boolean;
  19272. VERTEXALPHA: boolean;
  19273. NUM_BONE_INFLUENCERS: number;
  19274. BonesPerMesh: number;
  19275. BONETEXTURE: boolean;
  19276. INSTANCES: boolean;
  19277. GLOSSINESS: boolean;
  19278. ROUGHNESS: boolean;
  19279. EMISSIVEASILLUMINATION: boolean;
  19280. LINKEMISSIVEWITHDIFFUSE: boolean;
  19281. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19282. LIGHTMAP: boolean;
  19283. LIGHTMAPDIRECTUV: number;
  19284. OBJECTSPACE_NORMALMAP: boolean;
  19285. USELIGHTMAPASSHADOWMAP: boolean;
  19286. REFLECTIONMAP_3D: boolean;
  19287. REFLECTIONMAP_SPHERICAL: boolean;
  19288. REFLECTIONMAP_PLANAR: boolean;
  19289. REFLECTIONMAP_CUBIC: boolean;
  19290. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19291. REFLECTIONMAP_PROJECTION: boolean;
  19292. REFLECTIONMAP_SKYBOX: boolean;
  19293. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19294. REFLECTIONMAP_EXPLICIT: boolean;
  19295. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19296. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19297. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19298. INVERTCUBICMAP: boolean;
  19299. LOGARITHMICDEPTH: boolean;
  19300. REFRACTION: boolean;
  19301. REFRACTIONMAP_3D: boolean;
  19302. REFLECTIONOVERALPHA: boolean;
  19303. TWOSIDEDLIGHTING: boolean;
  19304. SHADOWFLOAT: boolean;
  19305. MORPHTARGETS: boolean;
  19306. MORPHTARGETS_NORMAL: boolean;
  19307. MORPHTARGETS_TANGENT: boolean;
  19308. NUM_MORPH_INFLUENCERS: number;
  19309. NONUNIFORMSCALING: boolean;
  19310. PREMULTIPLYALPHA: boolean;
  19311. IMAGEPROCESSING: boolean;
  19312. VIGNETTE: boolean;
  19313. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19314. VIGNETTEBLENDMODEOPAQUE: boolean;
  19315. TONEMAPPING: boolean;
  19316. TONEMAPPING_ACES: boolean;
  19317. CONTRAST: boolean;
  19318. COLORCURVES: boolean;
  19319. COLORGRADING: boolean;
  19320. COLORGRADING3D: boolean;
  19321. SAMPLER3DGREENDEPTH: boolean;
  19322. SAMPLER3DBGRMAP: boolean;
  19323. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19324. /**
  19325. * If the reflection texture on this material is in linear color space
  19326. * @hidden
  19327. */
  19328. IS_REFLECTION_LINEAR: boolean;
  19329. /**
  19330. * If the refraction texture on this material is in linear color space
  19331. * @hidden
  19332. */
  19333. IS_REFRACTION_LINEAR: boolean;
  19334. EXPOSURE: boolean;
  19335. constructor();
  19336. setReflectionMode(modeToEnable: string): void;
  19337. }
  19338. /**
  19339. * This is the default material used in Babylon. It is the best trade off between quality
  19340. * and performances.
  19341. * @see http://doc.babylonjs.com/babylon101/materials
  19342. */
  19343. class StandardMaterial extends PushMaterial {
  19344. private _diffuseTexture;
  19345. /**
  19346. * The basic texture of the material as viewed under a light.
  19347. */
  19348. diffuseTexture: Nullable<BaseTexture>;
  19349. private _ambientTexture;
  19350. /**
  19351. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19352. */
  19353. ambientTexture: Nullable<BaseTexture>;
  19354. private _opacityTexture;
  19355. /**
  19356. * Define the transparency of the material from a texture.
  19357. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19358. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19359. */
  19360. opacityTexture: Nullable<BaseTexture>;
  19361. private _reflectionTexture;
  19362. /**
  19363. * Define the texture used to display the reflection.
  19364. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19365. */
  19366. reflectionTexture: Nullable<BaseTexture>;
  19367. private _emissiveTexture;
  19368. /**
  19369. * Define texture of the material as if self lit.
  19370. * This will be mixed in the final result even in the absence of light.
  19371. */
  19372. emissiveTexture: Nullable<BaseTexture>;
  19373. private _specularTexture;
  19374. /**
  19375. * Define how the color and intensity of the highlight given by the light in the material.
  19376. */
  19377. specularTexture: Nullable<BaseTexture>;
  19378. private _bumpTexture;
  19379. /**
  19380. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19381. * 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.
  19382. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19383. */
  19384. bumpTexture: Nullable<BaseTexture>;
  19385. private _lightmapTexture;
  19386. /**
  19387. * Complex lighting can be computationally expensive to compute at runtime.
  19388. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19389. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19390. */
  19391. lightmapTexture: Nullable<BaseTexture>;
  19392. private _refractionTexture;
  19393. /**
  19394. * Define the texture used to display the refraction.
  19395. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19396. */
  19397. refractionTexture: Nullable<BaseTexture>;
  19398. /**
  19399. * The color of the material lit by the environmental background lighting.
  19400. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19401. */
  19402. ambientColor: Color3;
  19403. /**
  19404. * The basic color of the material as viewed under a light.
  19405. */
  19406. diffuseColor: Color3;
  19407. /**
  19408. * Define how the color and intensity of the highlight given by the light in the material.
  19409. */
  19410. specularColor: Color3;
  19411. /**
  19412. * Define the color of the material as if self lit.
  19413. * This will be mixed in the final result even in the absence of light.
  19414. */
  19415. emissiveColor: Color3;
  19416. /**
  19417. * Defines how sharp are the highlights in the material.
  19418. * The bigger the value the sharper giving a more glossy feeling to the result.
  19419. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19420. */
  19421. specularPower: number;
  19422. private _useAlphaFromDiffuseTexture;
  19423. /**
  19424. * Does the transparency come from the diffuse texture alpha channel.
  19425. */
  19426. useAlphaFromDiffuseTexture: boolean;
  19427. private _useEmissiveAsIllumination;
  19428. /**
  19429. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19430. */
  19431. useEmissiveAsIllumination: boolean;
  19432. private _linkEmissiveWithDiffuse;
  19433. /**
  19434. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19435. * the emissive level when the final color is close to one.
  19436. */
  19437. linkEmissiveWithDiffuse: boolean;
  19438. private _useSpecularOverAlpha;
  19439. /**
  19440. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19441. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19442. */
  19443. useSpecularOverAlpha: boolean;
  19444. private _useReflectionOverAlpha;
  19445. /**
  19446. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19447. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19448. */
  19449. useReflectionOverAlpha: boolean;
  19450. private _disableLighting;
  19451. /**
  19452. * Does lights from the scene impacts this material.
  19453. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19454. */
  19455. disableLighting: boolean;
  19456. private _useObjectSpaceNormalMap;
  19457. /**
  19458. * Allows using an object space normal map (instead of tangent space).
  19459. */
  19460. useObjectSpaceNormalMap: boolean;
  19461. private _useParallax;
  19462. /**
  19463. * Is parallax enabled or not.
  19464. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19465. */
  19466. useParallax: boolean;
  19467. private _useParallaxOcclusion;
  19468. /**
  19469. * Is parallax occlusion enabled or not.
  19470. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19471. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19472. */
  19473. useParallaxOcclusion: boolean;
  19474. /**
  19475. * 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.
  19476. */
  19477. parallaxScaleBias: number;
  19478. private _roughness;
  19479. /**
  19480. * Helps to define how blurry the reflections should appears in the material.
  19481. */
  19482. roughness: number;
  19483. /**
  19484. * In case of refraction, define the value of the indice of refraction.
  19485. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19486. */
  19487. indexOfRefraction: number;
  19488. /**
  19489. * Invert the refraction texture alongside the y axis.
  19490. * It can be useful with procedural textures or probe for instance.
  19491. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19492. */
  19493. invertRefractionY: boolean;
  19494. /**
  19495. * Defines the alpha limits in alpha test mode.
  19496. */
  19497. alphaCutOff: number;
  19498. private _useLightmapAsShadowmap;
  19499. /**
  19500. * In case of light mapping, define whether the map contains light or shadow informations.
  19501. */
  19502. useLightmapAsShadowmap: boolean;
  19503. private _diffuseFresnelParameters;
  19504. /**
  19505. * Define the diffuse fresnel parameters of the material.
  19506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19507. */
  19508. diffuseFresnelParameters: FresnelParameters;
  19509. private _opacityFresnelParameters;
  19510. /**
  19511. * Define the opacity fresnel parameters of the material.
  19512. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19513. */
  19514. opacityFresnelParameters: FresnelParameters;
  19515. private _reflectionFresnelParameters;
  19516. /**
  19517. * Define the reflection fresnel parameters of the material.
  19518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19519. */
  19520. reflectionFresnelParameters: FresnelParameters;
  19521. private _refractionFresnelParameters;
  19522. /**
  19523. * Define the refraction fresnel parameters of the material.
  19524. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19525. */
  19526. refractionFresnelParameters: FresnelParameters;
  19527. private _emissiveFresnelParameters;
  19528. /**
  19529. * Define the emissive fresnel parameters of the material.
  19530. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19531. */
  19532. emissiveFresnelParameters: FresnelParameters;
  19533. private _useReflectionFresnelFromSpecular;
  19534. /**
  19535. * If true automatically deducts the fresnels values from the material specularity.
  19536. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19537. */
  19538. useReflectionFresnelFromSpecular: boolean;
  19539. private _useGlossinessFromSpecularMapAlpha;
  19540. /**
  19541. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19542. */
  19543. useGlossinessFromSpecularMapAlpha: boolean;
  19544. private _maxSimultaneousLights;
  19545. /**
  19546. * Defines the maximum number of lights that can be used in the material
  19547. */
  19548. maxSimultaneousLights: number;
  19549. private _invertNormalMapX;
  19550. /**
  19551. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19552. */
  19553. invertNormalMapX: boolean;
  19554. private _invertNormalMapY;
  19555. /**
  19556. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19557. */
  19558. invertNormalMapY: boolean;
  19559. private _twoSidedLighting;
  19560. /**
  19561. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19562. */
  19563. twoSidedLighting: boolean;
  19564. /**
  19565. * Default configuration related to image processing available in the standard Material.
  19566. */
  19567. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19568. /**
  19569. * Gets the image processing configuration used either in this material.
  19570. */
  19571. /**
  19572. * Sets the Default image processing configuration used either in the this material.
  19573. *
  19574. * If sets to null, the scene one is in use.
  19575. */
  19576. imageProcessingConfiguration: ImageProcessingConfiguration;
  19577. /**
  19578. * Keep track of the image processing observer to allow dispose and replace.
  19579. */
  19580. private _imageProcessingObserver;
  19581. /**
  19582. * Attaches a new image processing configuration to the Standard Material.
  19583. * @param configuration
  19584. */
  19585. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19586. /**
  19587. * Gets wether the color curves effect is enabled.
  19588. */
  19589. /**
  19590. * Sets wether the color curves effect is enabled.
  19591. */
  19592. cameraColorCurvesEnabled: boolean;
  19593. /**
  19594. * Gets wether the color grading effect is enabled.
  19595. */
  19596. /**
  19597. * Gets wether the color grading effect is enabled.
  19598. */
  19599. cameraColorGradingEnabled: boolean;
  19600. /**
  19601. * Gets wether tonemapping is enabled or not.
  19602. */
  19603. /**
  19604. * Sets wether tonemapping is enabled or not
  19605. */
  19606. cameraToneMappingEnabled: boolean;
  19607. /**
  19608. * The camera exposure used on this material.
  19609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19610. * This corresponds to a photographic exposure.
  19611. */
  19612. /**
  19613. * The camera exposure used on this material.
  19614. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19615. * This corresponds to a photographic exposure.
  19616. */
  19617. cameraExposure: number;
  19618. /**
  19619. * Gets The camera contrast used on this material.
  19620. */
  19621. /**
  19622. * Sets The camera contrast used on this material.
  19623. */
  19624. cameraContrast: number;
  19625. /**
  19626. * Gets the Color Grading 2D Lookup Texture.
  19627. */
  19628. /**
  19629. * Sets the Color Grading 2D Lookup Texture.
  19630. */
  19631. cameraColorGradingTexture: Nullable<BaseTexture>;
  19632. /**
  19633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19635. * 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;
  19636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19637. */
  19638. /**
  19639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19641. * 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;
  19642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19643. */
  19644. cameraColorCurves: Nullable<ColorCurves>;
  19645. /**
  19646. * Custom callback helping to override the default shader used in the material.
  19647. */
  19648. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19649. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19650. protected _worldViewProjectionMatrix: Matrix;
  19651. protected _globalAmbientColor: Color3;
  19652. protected _useLogarithmicDepth: boolean;
  19653. /**
  19654. * Instantiates a new standard material.
  19655. * This is the default material used in Babylon. It is the best trade off between quality
  19656. * and performances.
  19657. * @see http://doc.babylonjs.com/babylon101/materials
  19658. * @param name Define the name of the material in the scene
  19659. * @param scene Define the scene the material belong to
  19660. */
  19661. constructor(name: string, scene: Scene);
  19662. /**
  19663. * Gets a boolean indicating that current material needs to register RTT
  19664. */
  19665. readonly hasRenderTargetTextures: boolean;
  19666. /**
  19667. * Gets the current class name of the material e.g. "StandardMaterial"
  19668. * Mainly use in serialization.
  19669. * @returns the class name
  19670. */
  19671. getClassName(): string;
  19672. /**
  19673. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19674. * You can try switching to logarithmic depth.
  19675. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19676. */
  19677. useLogarithmicDepth: boolean;
  19678. /**
  19679. * Specifies if the material will require alpha blending
  19680. * @returns a boolean specifying if alpha blending is needed
  19681. */
  19682. needAlphaBlending(): boolean;
  19683. /**
  19684. * Specifies if this material should be rendered in alpha test mode
  19685. * @returns a boolean specifying if an alpha test is needed.
  19686. */
  19687. needAlphaTesting(): boolean;
  19688. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19689. /**
  19690. * Get the texture used for alpha test purpose.
  19691. * @returns the diffuse texture in case of the standard material.
  19692. */
  19693. getAlphaTestTexture(): Nullable<BaseTexture>;
  19694. /**
  19695. * Get if the submesh is ready to be used and all its information available.
  19696. * Child classes can use it to update shaders
  19697. * @param mesh defines the mesh to check
  19698. * @param subMesh defines which submesh to check
  19699. * @param useInstances specifies that instances should be used
  19700. * @returns a boolean indicating that the submesh is ready or not
  19701. */
  19702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19703. /**
  19704. * Builds the material UBO layouts.
  19705. * Used internally during the effect preparation.
  19706. */
  19707. buildUniformLayout(): void;
  19708. /**
  19709. * Unbinds the material from the mesh
  19710. */
  19711. unbind(): void;
  19712. /**
  19713. * Binds the submesh to this material by preparing the effect and shader to draw
  19714. * @param world defines the world transformation matrix
  19715. * @param mesh defines the mesh containing the submesh
  19716. * @param subMesh defines the submesh to bind the material to
  19717. */
  19718. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19719. /**
  19720. * Get the list of animatables in the material.
  19721. * @returns the list of animatables object used in the material
  19722. */
  19723. getAnimatables(): IAnimatable[];
  19724. /**
  19725. * Gets the active textures from the material
  19726. * @returns an array of textures
  19727. */
  19728. getActiveTextures(): BaseTexture[];
  19729. /**
  19730. * Specifies if the material uses a texture
  19731. * @param texture defines the texture to check against the material
  19732. * @returns a boolean specifying if the material uses the texture
  19733. */
  19734. hasTexture(texture: BaseTexture): boolean;
  19735. /**
  19736. * Disposes the material
  19737. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19738. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19739. */
  19740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19741. /**
  19742. * Makes a duplicate of the material, and gives it a new name
  19743. * @param name defines the new name for the duplicated material
  19744. * @returns the cloned material
  19745. */
  19746. clone(name: string): StandardMaterial;
  19747. /**
  19748. * Serializes this material in a JSON representation
  19749. * @returns the serialized material object
  19750. */
  19751. serialize(): any;
  19752. /**
  19753. * Creates a standard material from parsed material data
  19754. * @param source defines the JSON represnetation of the material
  19755. * @param scene defines the hosting scene
  19756. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19757. * @returns a new material
  19758. */
  19759. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19760. private static _DiffuseTextureEnabled;
  19761. /**
  19762. * Are diffuse textures enabled in the application.
  19763. */
  19764. static DiffuseTextureEnabled: boolean;
  19765. private static _AmbientTextureEnabled;
  19766. /**
  19767. * Are ambient textures enabled in the application.
  19768. */
  19769. static AmbientTextureEnabled: boolean;
  19770. private static _OpacityTextureEnabled;
  19771. /**
  19772. * Are opacity textures enabled in the application.
  19773. */
  19774. static OpacityTextureEnabled: boolean;
  19775. private static _ReflectionTextureEnabled;
  19776. /**
  19777. * Are reflection textures enabled in the application.
  19778. */
  19779. static ReflectionTextureEnabled: boolean;
  19780. private static _EmissiveTextureEnabled;
  19781. /**
  19782. * Are emissive textures enabled in the application.
  19783. */
  19784. static EmissiveTextureEnabled: boolean;
  19785. private static _SpecularTextureEnabled;
  19786. /**
  19787. * Are specular textures enabled in the application.
  19788. */
  19789. static SpecularTextureEnabled: boolean;
  19790. private static _BumpTextureEnabled;
  19791. /**
  19792. * Are bump textures enabled in the application.
  19793. */
  19794. static BumpTextureEnabled: boolean;
  19795. private static _LightmapTextureEnabled;
  19796. /**
  19797. * Are lightmap textures enabled in the application.
  19798. */
  19799. static LightmapTextureEnabled: boolean;
  19800. private static _RefractionTextureEnabled;
  19801. /**
  19802. * Are refraction textures enabled in the application.
  19803. */
  19804. static RefractionTextureEnabled: boolean;
  19805. private static _ColorGradingTextureEnabled;
  19806. /**
  19807. * Are color grading textures enabled in the application.
  19808. */
  19809. static ColorGradingTextureEnabled: boolean;
  19810. private static _FresnelEnabled;
  19811. /**
  19812. * Are fresnels enabled in the application.
  19813. */
  19814. static FresnelEnabled: boolean;
  19815. }
  19816. }
  19817. declare module BABYLON {
  19818. /**
  19819. * Uniform buffer objects.
  19820. *
  19821. * Handles blocks of uniform on the GPU.
  19822. *
  19823. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19824. *
  19825. * For more information, please refer to :
  19826. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19827. */
  19828. class UniformBuffer {
  19829. private _engine;
  19830. private _buffer;
  19831. private _data;
  19832. private _bufferData;
  19833. private _dynamic?;
  19834. private _uniformLocations;
  19835. private _uniformSizes;
  19836. private _uniformLocationPointer;
  19837. private _needSync;
  19838. private _noUBO;
  19839. private _currentEffect;
  19840. private static _MAX_UNIFORM_SIZE;
  19841. private static _tempBuffer;
  19842. /**
  19843. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19844. * This is dynamic to allow compat with webgl 1 and 2.
  19845. * You will need to pass the name of the uniform as well as the value.
  19846. */
  19847. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19848. /**
  19849. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19850. * This is dynamic to allow compat with webgl 1 and 2.
  19851. * You will need to pass the name of the uniform as well as the value.
  19852. */
  19853. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19854. /**
  19855. * Lambda to Update a single float in a uniform buffer.
  19856. * This is dynamic to allow compat with webgl 1 and 2.
  19857. * You will need to pass the name of the uniform as well as the value.
  19858. */
  19859. updateFloat: (name: string, x: number) => void;
  19860. /**
  19861. * Lambda to Update a vec2 of float in a uniform buffer.
  19862. * This is dynamic to allow compat with webgl 1 and 2.
  19863. * You will need to pass the name of the uniform as well as the value.
  19864. */
  19865. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19866. /**
  19867. * Lambda to Update a vec3 of float in a uniform buffer.
  19868. * This is dynamic to allow compat with webgl 1 and 2.
  19869. * You will need to pass the name of the uniform as well as the value.
  19870. */
  19871. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19872. /**
  19873. * Lambda to Update a vec4 of float in a uniform buffer.
  19874. * This is dynamic to allow compat with webgl 1 and 2.
  19875. * You will need to pass the name of the uniform as well as the value.
  19876. */
  19877. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19878. /**
  19879. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19880. * This is dynamic to allow compat with webgl 1 and 2.
  19881. * You will need to pass the name of the uniform as well as the value.
  19882. */
  19883. updateMatrix: (name: string, mat: Matrix) => void;
  19884. /**
  19885. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19886. * This is dynamic to allow compat with webgl 1 and 2.
  19887. * You will need to pass the name of the uniform as well as the value.
  19888. */
  19889. updateVector3: (name: string, vector: Vector3) => void;
  19890. /**
  19891. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19892. * This is dynamic to allow compat with webgl 1 and 2.
  19893. * You will need to pass the name of the uniform as well as the value.
  19894. */
  19895. updateVector4: (name: string, vector: Vector4) => void;
  19896. /**
  19897. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19898. * This is dynamic to allow compat with webgl 1 and 2.
  19899. * You will need to pass the name of the uniform as well as the value.
  19900. */
  19901. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19902. /**
  19903. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19904. * This is dynamic to allow compat with webgl 1 and 2.
  19905. * You will need to pass the name of the uniform as well as the value.
  19906. */
  19907. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19908. /**
  19909. * Instantiates a new Uniform buffer objects.
  19910. *
  19911. * Handles blocks of uniform on the GPU.
  19912. *
  19913. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19914. *
  19915. * For more information, please refer to :
  19916. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19917. * @param engine Define the engine the buffer is associated with
  19918. * @param data Define the data contained in the buffer
  19919. * @param dynamic Define if the buffer is updatable
  19920. */
  19921. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19922. /**
  19923. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19924. * or just falling back on setUniformXXX calls.
  19925. */
  19926. readonly useUbo: boolean;
  19927. /**
  19928. * Indicates if the WebGL underlying uniform buffer is in sync
  19929. * with the javascript cache data.
  19930. */
  19931. readonly isSync: boolean;
  19932. /**
  19933. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19934. * Also, a dynamic UniformBuffer will disable cache verification and always
  19935. * update the underlying WebGL uniform buffer to the GPU.
  19936. * @returns if Dynamic, otherwise false
  19937. */
  19938. isDynamic(): boolean;
  19939. /**
  19940. * The data cache on JS side.
  19941. * @returns the underlying data as a float array
  19942. */
  19943. getData(): Float32Array;
  19944. /**
  19945. * The underlying WebGL Uniform buffer.
  19946. * @returns the webgl buffer
  19947. */
  19948. getBuffer(): Nullable<WebGLBuffer>;
  19949. /**
  19950. * std140 layout specifies how to align data within an UBO structure.
  19951. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19952. * for specs.
  19953. */
  19954. private _fillAlignment;
  19955. /**
  19956. * Adds an uniform in the buffer.
  19957. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19958. * for the layout to be correct !
  19959. * @param name Name of the uniform, as used in the uniform block in the shader.
  19960. * @param size Data size, or data directly.
  19961. */
  19962. addUniform(name: string, size: number | number[]): void;
  19963. /**
  19964. * Adds a Matrix 4x4 to the uniform buffer.
  19965. * @param name Name of the uniform, as used in the uniform block in the shader.
  19966. * @param mat A 4x4 matrix.
  19967. */
  19968. addMatrix(name: string, mat: Matrix): void;
  19969. /**
  19970. * Adds a vec2 to the uniform buffer.
  19971. * @param name Name of the uniform, as used in the uniform block in the shader.
  19972. * @param x Define the x component value of the vec2
  19973. * @param y Define the y component value of the vec2
  19974. */
  19975. addFloat2(name: string, x: number, y: number): void;
  19976. /**
  19977. * Adds a vec3 to the uniform buffer.
  19978. * @param name Name of the uniform, as used in the uniform block in the shader.
  19979. * @param x Define the x component value of the vec3
  19980. * @param y Define the y component value of the vec3
  19981. * @param z Define the z component value of the vec3
  19982. */
  19983. addFloat3(name: string, x: number, y: number, z: number): void;
  19984. /**
  19985. * Adds a vec3 to the uniform buffer.
  19986. * @param name Name of the uniform, as used in the uniform block in the shader.
  19987. * @param color Define the vec3 from a Color
  19988. */
  19989. addColor3(name: string, color: Color3): void;
  19990. /**
  19991. * Adds a vec4 to the uniform buffer.
  19992. * @param name Name of the uniform, as used in the uniform block in the shader.
  19993. * @param color Define the rgb components from a Color
  19994. * @param alpha Define the a component of the vec4
  19995. */
  19996. addColor4(name: string, color: Color3, alpha: number): void;
  19997. /**
  19998. * Adds a vec3 to the uniform buffer.
  19999. * @param name Name of the uniform, as used in the uniform block in the shader.
  20000. * @param vector Define the vec3 components from a Vector
  20001. */
  20002. addVector3(name: string, vector: Vector3): void;
  20003. /**
  20004. * Adds a Matrix 3x3 to the uniform buffer.
  20005. * @param name Name of the uniform, as used in the uniform block in the shader.
  20006. */
  20007. addMatrix3x3(name: string): void;
  20008. /**
  20009. * Adds a Matrix 2x2 to the uniform buffer.
  20010. * @param name Name of the uniform, as used in the uniform block in the shader.
  20011. */
  20012. addMatrix2x2(name: string): void;
  20013. /**
  20014. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20015. */
  20016. create(): void;
  20017. /** @hidden */
  20018. _rebuild(): void;
  20019. /**
  20020. * Updates the WebGL Uniform Buffer on the GPU.
  20021. * If the `dynamic` flag is set to true, no cache comparison is done.
  20022. * Otherwise, the buffer will be updated only if the cache differs.
  20023. */
  20024. update(): void;
  20025. /**
  20026. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20027. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20028. * @param data Define the flattened data
  20029. * @param size Define the size of the data.
  20030. */
  20031. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20032. private _updateMatrix3x3ForUniform;
  20033. private _updateMatrix3x3ForEffect;
  20034. private _updateMatrix2x2ForEffect;
  20035. private _updateMatrix2x2ForUniform;
  20036. private _updateFloatForEffect;
  20037. private _updateFloatForUniform;
  20038. private _updateFloat2ForEffect;
  20039. private _updateFloat2ForUniform;
  20040. private _updateFloat3ForEffect;
  20041. private _updateFloat3ForUniform;
  20042. private _updateFloat4ForEffect;
  20043. private _updateFloat4ForUniform;
  20044. private _updateMatrixForEffect;
  20045. private _updateMatrixForUniform;
  20046. private _updateVector3ForEffect;
  20047. private _updateVector3ForUniform;
  20048. private _updateVector4ForEffect;
  20049. private _updateVector4ForUniform;
  20050. private _updateColor3ForEffect;
  20051. private _updateColor3ForUniform;
  20052. private _updateColor4ForEffect;
  20053. private _updateColor4ForUniform;
  20054. /**
  20055. * Sets a sampler uniform on the effect.
  20056. * @param name Define the name of the sampler.
  20057. * @param texture Define the texture to set in the sampler
  20058. */
  20059. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20060. /**
  20061. * Directly updates the value of the uniform in the cache AND on the GPU.
  20062. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20063. * @param data Define the flattened data
  20064. */
  20065. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20066. /**
  20067. * Binds this uniform buffer to an effect.
  20068. * @param effect Define the effect to bind the buffer to
  20069. * @param name Name of the uniform block in the shader.
  20070. */
  20071. bindToEffect(effect: Effect, name: string): void;
  20072. /**
  20073. * Disposes the uniform buffer.
  20074. */
  20075. dispose(): void;
  20076. }
  20077. }
  20078. declare module BABYLON {
  20079. /**
  20080. * Scalar computation library
  20081. */
  20082. class Scalar {
  20083. /**
  20084. * Two pi constants convenient for computation.
  20085. */
  20086. static TwoPi: number;
  20087. /**
  20088. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20089. * @param a number
  20090. * @param b number
  20091. * @param epsilon (default = 1.401298E-45)
  20092. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20093. */
  20094. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20095. /**
  20096. * Returns a string : the upper case translation of the number i to hexadecimal.
  20097. * @param i number
  20098. * @returns the upper case translation of the number i to hexadecimal.
  20099. */
  20100. static ToHex(i: number): string;
  20101. /**
  20102. * Returns -1 if value is negative and +1 is value is positive.
  20103. * @param value the value
  20104. * @returns the value itself if it's equal to zero.
  20105. */
  20106. static Sign(value: number): number;
  20107. /**
  20108. * Returns the value itself if it's between min and max.
  20109. * Returns min if the value is lower than min.
  20110. * Returns max if the value is greater than max.
  20111. * @param value the value to clmap
  20112. * @param min the min value to clamp to (default: 0)
  20113. * @param max the max value to clamp to (default: 1)
  20114. * @returns the clamped value
  20115. */
  20116. static Clamp(value: number, min?: number, max?: number): number;
  20117. /**
  20118. * the log2 of value.
  20119. * @param value the value to compute log2 of
  20120. * @returns the log2 of value.
  20121. */
  20122. static Log2(value: number): number;
  20123. /**
  20124. * Loops the value, so that it is never larger than length and never smaller than 0.
  20125. *
  20126. * This is similar to the modulo operator but it works with floating point numbers.
  20127. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20128. * With t = 5 and length = 2.5, the result would be 0.0.
  20129. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20130. * @param value the value
  20131. * @param length the length
  20132. * @returns the looped value
  20133. */
  20134. static Repeat(value: number, length: number): number;
  20135. /**
  20136. * Normalize the value between 0.0 and 1.0 using min and max values
  20137. * @param value value to normalize
  20138. * @param min max to normalize between
  20139. * @param max min to normalize between
  20140. * @returns the normalized value
  20141. */
  20142. static Normalize(value: number, min: number, max: number): number;
  20143. /**
  20144. * Denormalize the value from 0.0 and 1.0 using min and max values
  20145. * @param normalized value to denormalize
  20146. * @param min max to denormalize between
  20147. * @param max min to denormalize between
  20148. * @returns the denormalized value
  20149. */
  20150. static Denormalize(normalized: number, min: number, max: number): number;
  20151. /**
  20152. * Calculates the shortest difference between two given angles given in degrees.
  20153. * @param current current angle in degrees
  20154. * @param target target angle in degrees
  20155. * @returns the delta
  20156. */
  20157. static DeltaAngle(current: number, target: number): number;
  20158. /**
  20159. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20160. * @param tx value
  20161. * @param length length
  20162. * @returns The returned value will move back and forth between 0 and length
  20163. */
  20164. static PingPong(tx: number, length: number): number;
  20165. /**
  20166. * Interpolates between min and max with smoothing at the limits.
  20167. *
  20168. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20169. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20170. * @param from from
  20171. * @param to to
  20172. * @param tx value
  20173. * @returns the smooth stepped value
  20174. */
  20175. static SmoothStep(from: number, to: number, tx: number): number;
  20176. /**
  20177. * Moves a value current towards target.
  20178. *
  20179. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20180. * Negative values of maxDelta pushes the value away from target.
  20181. * @param current current value
  20182. * @param target target value
  20183. * @param maxDelta max distance to move
  20184. * @returns resulting value
  20185. */
  20186. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20187. /**
  20188. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20189. *
  20190. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20191. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20192. * @param current current value
  20193. * @param target target value
  20194. * @param maxDelta max distance to move
  20195. * @returns resulting angle
  20196. */
  20197. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20198. /**
  20199. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20200. * @param start start value
  20201. * @param end target value
  20202. * @param amount amount to lerp between
  20203. * @returns the lerped value
  20204. */
  20205. static Lerp(start: number, end: number, amount: number): number;
  20206. /**
  20207. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20208. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20209. * @param start start value
  20210. * @param end target value
  20211. * @param amount amount to lerp between
  20212. * @returns the lerped value
  20213. */
  20214. static LerpAngle(start: number, end: number, amount: number): number;
  20215. /**
  20216. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20217. * @param a start value
  20218. * @param b target value
  20219. * @param value value between a and b
  20220. * @returns the inverseLerp value
  20221. */
  20222. static InverseLerp(a: number, b: number, value: number): number;
  20223. /**
  20224. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20225. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20226. * @param value1 spline value
  20227. * @param tangent1 spline value
  20228. * @param value2 spline value
  20229. * @param tangent2 spline value
  20230. * @param amount input value
  20231. * @returns hermite result
  20232. */
  20233. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20234. /**
  20235. * Returns a random float number between and min and max values
  20236. * @param min min value of random
  20237. * @param max max value of random
  20238. * @returns random value
  20239. */
  20240. static RandomRange(min: number, max: number): number;
  20241. /**
  20242. * This function returns percentage of a number in a given range.
  20243. *
  20244. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20245. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20246. * @param number to convert to percentage
  20247. * @param min min range
  20248. * @param max max range
  20249. * @returns the percentage
  20250. */
  20251. static RangeToPercent(number: number, min: number, max: number): number;
  20252. /**
  20253. * This function returns number that corresponds to the percentage in a given range.
  20254. *
  20255. * PercentToRange(0.34,0,100) will return 34.
  20256. * @param percent to convert to number
  20257. * @param min min range
  20258. * @param max max range
  20259. * @returns the number
  20260. */
  20261. static PercentToRange(percent: number, min: number, max: number): number;
  20262. /**
  20263. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20264. * @param angle The angle to normalize in radian.
  20265. * @return The converted angle.
  20266. */
  20267. static NormalizeRadians(angle: number): number;
  20268. }
  20269. }
  20270. declare module BABYLON {
  20271. /**
  20272. * Constant used to convert a value to gamma space
  20273. * @ignorenaming
  20274. */
  20275. const ToGammaSpace: number;
  20276. /**
  20277. * Constant used to convert a value to linear space
  20278. * @ignorenaming
  20279. */
  20280. const ToLinearSpace = 2.2;
  20281. /**
  20282. * Constant used to define the minimal number value in Babylon.js
  20283. * @ignorenaming
  20284. */
  20285. const Epsilon = 0.001;
  20286. /**
  20287. * Class used to hold a RBG color
  20288. */
  20289. class Color3 {
  20290. /**
  20291. * Defines the red component (between 0 and 1, default is 0)
  20292. */
  20293. r: number;
  20294. /**
  20295. * Defines the green component (between 0 and 1, default is 0)
  20296. */
  20297. g: number;
  20298. /**
  20299. * Defines the blue component (between 0 and 1, default is 0)
  20300. */
  20301. b: number;
  20302. /**
  20303. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20304. * @param r defines the red component (between 0 and 1, default is 0)
  20305. * @param g defines the green component (between 0 and 1, default is 0)
  20306. * @param b defines the blue component (between 0 and 1, default is 0)
  20307. */
  20308. constructor(
  20309. /**
  20310. * Defines the red component (between 0 and 1, default is 0)
  20311. */
  20312. r?: number,
  20313. /**
  20314. * Defines the green component (between 0 and 1, default is 0)
  20315. */
  20316. g?: number,
  20317. /**
  20318. * Defines the blue component (between 0 and 1, default is 0)
  20319. */
  20320. b?: number);
  20321. /**
  20322. * Creates a string with the Color3 current values
  20323. * @returns the string representation of the Color3 object
  20324. */
  20325. toString(): string;
  20326. /**
  20327. * Returns the string "Color3"
  20328. * @returns "Color3"
  20329. */
  20330. getClassName(): string;
  20331. /**
  20332. * Compute the Color3 hash code
  20333. * @returns an unique number that can be used to hash Color3 objects
  20334. */
  20335. getHashCode(): number;
  20336. /**
  20337. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20338. * @param array defines the array where to store the r,g,b components
  20339. * @param index defines an optional index in the target array to define where to start storing values
  20340. * @returns the current Color3 object
  20341. */
  20342. toArray(array: FloatArray, index?: number): Color3;
  20343. /**
  20344. * Returns a new Color4 object from the current Color3 and the given alpha
  20345. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20346. * @returns a new Color4 object
  20347. */
  20348. toColor4(alpha?: number): Color4;
  20349. /**
  20350. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20351. * @returns the new array
  20352. */
  20353. asArray(): number[];
  20354. /**
  20355. * Returns the luminance value
  20356. * @returns a float value
  20357. */
  20358. toLuminance(): number;
  20359. /**
  20360. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20361. * @param otherColor defines the second operand
  20362. * @returns the new Color3 object
  20363. */
  20364. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20365. /**
  20366. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20367. * @param otherColor defines the second operand
  20368. * @param result defines the Color3 object where to store the result
  20369. * @returns the current Color3
  20370. */
  20371. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20372. /**
  20373. * Determines equality between Color3 objects
  20374. * @param otherColor defines the second operand
  20375. * @returns true if the rgb values are equal to the given ones
  20376. */
  20377. equals(otherColor: DeepImmutable<Color3>): boolean;
  20378. /**
  20379. * Determines equality between the current Color3 object and a set of r,b,g values
  20380. * @param r defines the red component to check
  20381. * @param g defines the green component to check
  20382. * @param b defines the blue component to check
  20383. * @returns true if the rgb values are equal to the given ones
  20384. */
  20385. equalsFloats(r: number, g: number, b: number): boolean;
  20386. /**
  20387. * Multiplies in place each rgb value by scale
  20388. * @param scale defines the scaling factor
  20389. * @returns the updated Color3
  20390. */
  20391. scale(scale: number): Color3;
  20392. /**
  20393. * Multiplies the rgb values by scale and stores the result into "result"
  20394. * @param scale defines the scaling factor
  20395. * @param result defines the Color3 object where to store the result
  20396. * @returns the unmodified current Color3
  20397. */
  20398. scaleToRef(scale: number, result: Color3): Color3;
  20399. /**
  20400. * Scale the current Color3 values by a factor and add the result to a given Color3
  20401. * @param scale defines the scale factor
  20402. * @param result defines color to store the result into
  20403. * @returns the unmodified current Color3
  20404. */
  20405. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20406. /**
  20407. * Clamps the rgb values by the min and max values and stores the result into "result"
  20408. * @param min defines minimum clamping value (default is 0)
  20409. * @param max defines maximum clamping value (default is 1)
  20410. * @param result defines color to store the result into
  20411. * @returns the original Color3
  20412. */
  20413. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20414. /**
  20415. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20416. * @param otherColor defines the second operand
  20417. * @returns the new Color3
  20418. */
  20419. add(otherColor: DeepImmutable<Color3>): Color3;
  20420. /**
  20421. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20422. * @param otherColor defines the second operand
  20423. * @param result defines Color3 object to store the result into
  20424. * @returns the unmodified current Color3
  20425. */
  20426. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20427. /**
  20428. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20429. * @param otherColor defines the second operand
  20430. * @returns the new Color3
  20431. */
  20432. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20433. /**
  20434. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20435. * @param otherColor defines the second operand
  20436. * @param result defines Color3 object to store the result into
  20437. * @returns the unmodified current Color3
  20438. */
  20439. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20440. /**
  20441. * Copy the current object
  20442. * @returns a new Color3 copied the current one
  20443. */
  20444. clone(): Color3;
  20445. /**
  20446. * Copies the rgb values from the source in the current Color3
  20447. * @param source defines the source Color3 object
  20448. * @returns the updated Color3 object
  20449. */
  20450. copyFrom(source: DeepImmutable<Color3>): Color3;
  20451. /**
  20452. * Updates the Color3 rgb values from the given floats
  20453. * @param r defines the red component to read from
  20454. * @param g defines the green component to read from
  20455. * @param b defines the blue component to read from
  20456. * @returns the current Color3 object
  20457. */
  20458. copyFromFloats(r: number, g: number, b: number): Color3;
  20459. /**
  20460. * Updates the Color3 rgb values from the given floats
  20461. * @param r defines the red component to read from
  20462. * @param g defines the green component to read from
  20463. * @param b defines the blue component to read from
  20464. * @returns the current Color3 object
  20465. */
  20466. set(r: number, g: number, b: number): Color3;
  20467. /**
  20468. * Compute the Color3 hexadecimal code as a string
  20469. * @returns a string containing the hexadecimal representation of the Color3 object
  20470. */
  20471. toHexString(): string;
  20472. /**
  20473. * Computes a new Color3 converted from the current one to linear space
  20474. * @returns a new Color3 object
  20475. */
  20476. toLinearSpace(): Color3;
  20477. /**
  20478. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20479. * @param convertedColor defines the Color3 object where to store the linear space version
  20480. * @returns the unmodified Color3
  20481. */
  20482. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20483. /**
  20484. * Computes a new Color3 converted from the current one to gamma space
  20485. * @returns a new Color3 object
  20486. */
  20487. toGammaSpace(): Color3;
  20488. /**
  20489. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20490. * @param convertedColor defines the Color3 object where to store the gamma space version
  20491. * @returns the unmodified Color3
  20492. */
  20493. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20494. /**
  20495. * Creates a new Color3 from the string containing valid hexadecimal values
  20496. * @param hex defines a string containing valid hexadecimal values
  20497. * @returns a new Color3 object
  20498. */
  20499. static FromHexString(hex: string): Color3;
  20500. /**
  20501. * Creates a new Vector3 from the starting index of the given array
  20502. * @param array defines the source array
  20503. * @param offset defines an offset in the source array
  20504. * @returns a new Color3 object
  20505. */
  20506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20507. /**
  20508. * Creates a new Color3 from integer values (< 256)
  20509. * @param r defines the red component to read from (value between 0 and 255)
  20510. * @param g defines the green component to read from (value between 0 and 255)
  20511. * @param b defines the blue component to read from (value between 0 and 255)
  20512. * @returns a new Color3 object
  20513. */
  20514. static FromInts(r: number, g: number, b: number): Color3;
  20515. /**
  20516. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20517. * @param start defines the start Color3 value
  20518. * @param end defines the end Color3 value
  20519. * @param amount defines the gradient value between start and end
  20520. * @returns a new Color3 object
  20521. */
  20522. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20523. /**
  20524. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20525. * @param left defines the start value
  20526. * @param right defines the end value
  20527. * @param amount defines the gradient factor
  20528. * @param result defines the Color3 object where to store the result
  20529. */
  20530. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20531. /**
  20532. * Returns a Color3 value containing a red color
  20533. * @returns a new Color3 object
  20534. */
  20535. static Red(): Color3;
  20536. /**
  20537. * Returns a Color3 value containing a green color
  20538. * @returns a new Color3 object
  20539. */
  20540. static Green(): Color3;
  20541. /**
  20542. * Returns a Color3 value containing a blue color
  20543. * @returns a new Color3 object
  20544. */
  20545. static Blue(): Color3;
  20546. /**
  20547. * Returns a Color3 value containing a black color
  20548. * @returns a new Color3 object
  20549. */
  20550. static Black(): Color3;
  20551. /**
  20552. * Returns a Color3 value containing a white color
  20553. * @returns a new Color3 object
  20554. */
  20555. static White(): Color3;
  20556. /**
  20557. * Returns a Color3 value containing a purple color
  20558. * @returns a new Color3 object
  20559. */
  20560. static Purple(): Color3;
  20561. /**
  20562. * Returns a Color3 value containing a magenta color
  20563. * @returns a new Color3 object
  20564. */
  20565. static Magenta(): Color3;
  20566. /**
  20567. * Returns a Color3 value containing a yellow color
  20568. * @returns a new Color3 object
  20569. */
  20570. static Yellow(): Color3;
  20571. /**
  20572. * Returns a Color3 value containing a gray color
  20573. * @returns a new Color3 object
  20574. */
  20575. static Gray(): Color3;
  20576. /**
  20577. * Returns a Color3 value containing a teal color
  20578. * @returns a new Color3 object
  20579. */
  20580. static Teal(): Color3;
  20581. /**
  20582. * Returns a Color3 value containing a random color
  20583. * @returns a new Color3 object
  20584. */
  20585. static Random(): Color3;
  20586. }
  20587. /**
  20588. * Class used to hold a RBGA color
  20589. */
  20590. class Color4 {
  20591. /**
  20592. * Defines the red component (between 0 and 1, default is 0)
  20593. */
  20594. r: number;
  20595. /**
  20596. * Defines the green component (between 0 and 1, default is 0)
  20597. */
  20598. g: number;
  20599. /**
  20600. * Defines the blue component (between 0 and 1, default is 0)
  20601. */
  20602. b: number;
  20603. /**
  20604. * Defines the alpha component (between 0 and 1, default is 1)
  20605. */
  20606. a: number;
  20607. /**
  20608. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20609. * @param r defines the red component (between 0 and 1, default is 0)
  20610. * @param g defines the green component (between 0 and 1, default is 0)
  20611. * @param b defines the blue component (between 0 and 1, default is 0)
  20612. * @param a defines the alpha component (between 0 and 1, default is 1)
  20613. */
  20614. constructor(
  20615. /**
  20616. * Defines the red component (between 0 and 1, default is 0)
  20617. */
  20618. r?: number,
  20619. /**
  20620. * Defines the green component (between 0 and 1, default is 0)
  20621. */
  20622. g?: number,
  20623. /**
  20624. * Defines the blue component (between 0 and 1, default is 0)
  20625. */
  20626. b?: number,
  20627. /**
  20628. * Defines the alpha component (between 0 and 1, default is 1)
  20629. */
  20630. a?: number);
  20631. /**
  20632. * Adds in place the given Color4 values to the current Color4 object
  20633. * @param right defines the second operand
  20634. * @returns the current updated Color4 object
  20635. */
  20636. addInPlace(right: DeepImmutable<Color4>): Color4;
  20637. /**
  20638. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20639. * @returns the new array
  20640. */
  20641. asArray(): number[];
  20642. /**
  20643. * Stores from the starting index in the given array the Color4 successive values
  20644. * @param array defines the array where to store the r,g,b components
  20645. * @param index defines an optional index in the target array to define where to start storing values
  20646. * @returns the current Color4 object
  20647. */
  20648. toArray(array: number[], index?: number): Color4;
  20649. /**
  20650. * Determines equality between Color4 objects
  20651. * @param otherColor defines the second operand
  20652. * @returns true if the rgba values are equal to the given ones
  20653. */
  20654. equals(otherColor: DeepImmutable<Color4>): boolean;
  20655. /**
  20656. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20657. * @param right defines the second operand
  20658. * @returns a new Color4 object
  20659. */
  20660. add(right: DeepImmutable<Color4>): Color4;
  20661. /**
  20662. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20663. * @param right defines the second operand
  20664. * @returns a new Color4 object
  20665. */
  20666. subtract(right: DeepImmutable<Color4>): Color4;
  20667. /**
  20668. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20669. * @param right defines the second operand
  20670. * @param result defines the Color4 object where to store the result
  20671. * @returns the current Color4 object
  20672. */
  20673. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20674. /**
  20675. * Creates a new Color4 with the current Color4 values multiplied by scale
  20676. * @param scale defines the scaling factor to apply
  20677. * @returns a new Color4 object
  20678. */
  20679. scale(scale: number): Color4;
  20680. /**
  20681. * Multiplies the current Color4 values by scale and stores the result in "result"
  20682. * @param scale defines the scaling factor to apply
  20683. * @param result defines the Color4 object where to store the result
  20684. * @returns the current unmodified Color4
  20685. */
  20686. scaleToRef(scale: number, result: Color4): Color4;
  20687. /**
  20688. * Scale the current Color4 values by a factor and add the result to a given Color4
  20689. * @param scale defines the scale factor
  20690. * @param result defines the Color4 object where to store the result
  20691. * @returns the unmodified current Color4
  20692. */
  20693. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20694. /**
  20695. * Clamps the rgb values by the min and max values and stores the result into "result"
  20696. * @param min defines minimum clamping value (default is 0)
  20697. * @param max defines maximum clamping value (default is 1)
  20698. * @param result defines color to store the result into.
  20699. * @returns the cuurent Color4
  20700. */
  20701. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20702. /**
  20703. * Multipy an Color4 value by another and return a new Color4 object
  20704. * @param color defines the Color4 value to multiply by
  20705. * @returns a new Color4 object
  20706. */
  20707. multiply(color: Color4): Color4;
  20708. /**
  20709. * Multipy a Color4 value by another and push the result in a reference value
  20710. * @param color defines the Color4 value to multiply by
  20711. * @param result defines the Color4 to fill the result in
  20712. * @returns the result Color4
  20713. */
  20714. multiplyToRef(color: Color4, result: Color4): Color4;
  20715. /**
  20716. * Creates a string with the Color4 current values
  20717. * @returns the string representation of the Color4 object
  20718. */
  20719. toString(): string;
  20720. /**
  20721. * Returns the string "Color4"
  20722. * @returns "Color4"
  20723. */
  20724. getClassName(): string;
  20725. /**
  20726. * Compute the Color4 hash code
  20727. * @returns an unique number that can be used to hash Color4 objects
  20728. */
  20729. getHashCode(): number;
  20730. /**
  20731. * Creates a new Color4 copied from the current one
  20732. * @returns a new Color4 object
  20733. */
  20734. clone(): Color4;
  20735. /**
  20736. * Copies the given Color4 values into the current one
  20737. * @param source defines the source Color4 object
  20738. * @returns the current updated Color4 object
  20739. */
  20740. copyFrom(source: Color4): Color4;
  20741. /**
  20742. * Copies the given float values into the current one
  20743. * @param r defines the red component to read from
  20744. * @param g defines the green component to read from
  20745. * @param b defines the blue component to read from
  20746. * @param a defines the alpha component to read from
  20747. * @returns the current updated Color4 object
  20748. */
  20749. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20750. /**
  20751. * Copies the given float values into the current one
  20752. * @param r defines the red component to read from
  20753. * @param g defines the green component to read from
  20754. * @param b defines the blue component to read from
  20755. * @param a defines the alpha component to read from
  20756. * @returns the current updated Color4 object
  20757. */
  20758. set(r: number, g: number, b: number, a: number): Color4;
  20759. /**
  20760. * Compute the Color4 hexadecimal code as a string
  20761. * @returns a string containing the hexadecimal representation of the Color4 object
  20762. */
  20763. toHexString(): string;
  20764. /**
  20765. * Computes a new Color4 converted from the current one to linear space
  20766. * @returns a new Color4 object
  20767. */
  20768. toLinearSpace(): Color4;
  20769. /**
  20770. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20771. * @param convertedColor defines the Color4 object where to store the linear space version
  20772. * @returns the unmodified Color4
  20773. */
  20774. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20775. /**
  20776. * Computes a new Color4 converted from the current one to gamma space
  20777. * @returns a new Color4 object
  20778. */
  20779. toGammaSpace(): Color4;
  20780. /**
  20781. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20782. * @param convertedColor defines the Color4 object where to store the gamma space version
  20783. * @returns the unmodified Color4
  20784. */
  20785. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20786. /**
  20787. * Creates a new Color4 from the string containing valid hexadecimal values
  20788. * @param hex defines a string containing valid hexadecimal values
  20789. * @returns a new Color4 object
  20790. */
  20791. static FromHexString(hex: string): Color4;
  20792. /**
  20793. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20794. * @param left defines the start value
  20795. * @param right defines the end value
  20796. * @param amount defines the gradient factor
  20797. * @returns a new Color4 object
  20798. */
  20799. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20800. /**
  20801. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20802. * @param left defines the start value
  20803. * @param right defines the end value
  20804. * @param amount defines the gradient factor
  20805. * @param result defines the Color4 object where to store data
  20806. */
  20807. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20808. /**
  20809. * Creates a new Color4 from a Color3 and an alpha value
  20810. * @param color3 defines the source Color3 to read from
  20811. * @param alpha defines the alpha component (1.0 by default)
  20812. * @returns a new Color4 object
  20813. */
  20814. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20815. /**
  20816. * Creates a new Color4 from the starting index element of the given array
  20817. * @param array defines the source array to read from
  20818. * @param offset defines the offset in the source array
  20819. * @returns a new Color4 object
  20820. */
  20821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20822. /**
  20823. * Creates a new Color3 from integer values (< 256)
  20824. * @param r defines the red component to read from (value between 0 and 255)
  20825. * @param g defines the green component to read from (value between 0 and 255)
  20826. * @param b defines the blue component to read from (value between 0 and 255)
  20827. * @param a defines the alpha component to read from (value between 0 and 255)
  20828. * @returns a new Color3 object
  20829. */
  20830. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20831. /**
  20832. * Check the content of a given array and convert it to an array containing RGBA data
  20833. * If the original array was already containing count * 4 values then it is returned directly
  20834. * @param colors defines the array to check
  20835. * @param count defines the number of RGBA data to expect
  20836. * @returns an array containing count * 4 values (RGBA)
  20837. */
  20838. static CheckColors4(colors: number[], count: number): number[];
  20839. }
  20840. /**
  20841. * Class representing a vector containing 2 coordinates
  20842. */
  20843. class Vector2 {
  20844. /** defines the first coordinate */
  20845. x: number;
  20846. /** defines the second coordinate */
  20847. y: number;
  20848. /**
  20849. * Creates a new Vector2 from the given x and y coordinates
  20850. * @param x defines the first coordinate
  20851. * @param y defines the second coordinate
  20852. */
  20853. constructor(
  20854. /** defines the first coordinate */
  20855. x?: number,
  20856. /** defines the second coordinate */
  20857. y?: number);
  20858. /**
  20859. * Gets a string with the Vector2 coordinates
  20860. * @returns a string with the Vector2 coordinates
  20861. */
  20862. toString(): string;
  20863. /**
  20864. * Gets class name
  20865. * @returns the string "Vector2"
  20866. */
  20867. getClassName(): string;
  20868. /**
  20869. * Gets current vector hash code
  20870. * @returns the Vector2 hash code as a number
  20871. */
  20872. getHashCode(): number;
  20873. /**
  20874. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20875. * @param array defines the source array
  20876. * @param index defines the offset in source array
  20877. * @returns the current Vector2
  20878. */
  20879. toArray(array: FloatArray, index?: number): Vector2;
  20880. /**
  20881. * Copy the current vector to an array
  20882. * @returns a new array with 2 elements: the Vector2 coordinates.
  20883. */
  20884. asArray(): number[];
  20885. /**
  20886. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20887. * @param source defines the source Vector2
  20888. * @returns the current updated Vector2
  20889. */
  20890. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20891. /**
  20892. * Sets the Vector2 coordinates with the given floats
  20893. * @param x defines the first coordinate
  20894. * @param y defines the second coordinate
  20895. * @returns the current updated Vector2
  20896. */
  20897. copyFromFloats(x: number, y: number): Vector2;
  20898. /**
  20899. * Sets the Vector2 coordinates with the given floats
  20900. * @param x defines the first coordinate
  20901. * @param y defines the second coordinate
  20902. * @returns the current updated Vector2
  20903. */
  20904. set(x: number, y: number): Vector2;
  20905. /**
  20906. * Add another vector with the current one
  20907. * @param otherVector defines the other vector
  20908. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20909. */
  20910. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20911. /**
  20912. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20913. * @param otherVector defines the other vector
  20914. * @param result defines the target vector
  20915. * @returns the unmodified current Vector2
  20916. */
  20917. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20918. /**
  20919. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20920. * @param otherVector defines the other vector
  20921. * @returns the current updated Vector2
  20922. */
  20923. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20924. /**
  20925. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20926. * @param otherVector defines the other vector
  20927. * @returns a new Vector2
  20928. */
  20929. addVector3(otherVector: Vector3): Vector2;
  20930. /**
  20931. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20932. * @param otherVector defines the other vector
  20933. * @returns a new Vector2
  20934. */
  20935. subtract(otherVector: Vector2): Vector2;
  20936. /**
  20937. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20938. * @param otherVector defines the other vector
  20939. * @param result defines the target vector
  20940. * @returns the unmodified current Vector2
  20941. */
  20942. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20943. /**
  20944. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20945. * @param otherVector defines the other vector
  20946. * @returns the current updated Vector2
  20947. */
  20948. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20949. /**
  20950. * Multiplies in place the current Vector2 coordinates by the given ones
  20951. * @param otherVector defines the other vector
  20952. * @returns the current updated Vector2
  20953. */
  20954. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20955. /**
  20956. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20957. * @param otherVector defines the other vector
  20958. * @returns a new Vector2
  20959. */
  20960. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20961. /**
  20962. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20963. * @param otherVector defines the other vector
  20964. * @param result defines the target vector
  20965. * @returns the unmodified current Vector2
  20966. */
  20967. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20968. /**
  20969. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20970. * @param x defines the first coordinate
  20971. * @param y defines the second coordinate
  20972. * @returns a new Vector2
  20973. */
  20974. multiplyByFloats(x: number, y: number): Vector2;
  20975. /**
  20976. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20977. * @param otherVector defines the other vector
  20978. * @returns a new Vector2
  20979. */
  20980. divide(otherVector: Vector2): Vector2;
  20981. /**
  20982. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20983. * @param otherVector defines the other vector
  20984. * @param result defines the target vector
  20985. * @returns the unmodified current Vector2
  20986. */
  20987. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20988. /**
  20989. * Divides the current Vector2 coordinates by the given ones
  20990. * @param otherVector defines the other vector
  20991. * @returns the current updated Vector2
  20992. */
  20993. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20994. /**
  20995. * Gets a new Vector2 with current Vector2 negated coordinates
  20996. * @returns a new Vector2
  20997. */
  20998. negate(): Vector2;
  20999. /**
  21000. * Multiply the Vector2 coordinates by scale
  21001. * @param scale defines the scaling factor
  21002. * @returns the current updated Vector2
  21003. */
  21004. scaleInPlace(scale: number): Vector2;
  21005. /**
  21006. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21007. * @param scale defines the scaling factor
  21008. * @returns a new Vector2
  21009. */
  21010. scale(scale: number): Vector2;
  21011. /**
  21012. * Scale the current Vector2 values by a factor to a given Vector2
  21013. * @param scale defines the scale factor
  21014. * @param result defines the Vector2 object where to store the result
  21015. * @returns the unmodified current Vector2
  21016. */
  21017. scaleToRef(scale: number, result: Vector2): Vector2;
  21018. /**
  21019. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21020. * @param scale defines the scale factor
  21021. * @param result defines the Vector2 object where to store the result
  21022. * @returns the unmodified current Vector2
  21023. */
  21024. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21025. /**
  21026. * Gets a boolean if two vectors are equals
  21027. * @param otherVector defines the other vector
  21028. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21029. */
  21030. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21031. /**
  21032. * Gets a boolean if two vectors are equals (using an epsilon value)
  21033. * @param otherVector defines the other vector
  21034. * @param epsilon defines the minimal distance to consider equality
  21035. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21036. */
  21037. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21038. /**
  21039. * Gets a new Vector2 from current Vector2 floored values
  21040. * @returns a new Vector2
  21041. */
  21042. floor(): Vector2;
  21043. /**
  21044. * Gets a new Vector2 from current Vector2 floored values
  21045. * @returns a new Vector2
  21046. */
  21047. fract(): Vector2;
  21048. /**
  21049. * Gets the length of the vector
  21050. * @returns the vector length (float)
  21051. */
  21052. length(): number;
  21053. /**
  21054. * Gets the vector squared length
  21055. * @returns the vector squared length (float)
  21056. */
  21057. lengthSquared(): number;
  21058. /**
  21059. * Normalize the vector
  21060. * @returns the current updated Vector2
  21061. */
  21062. normalize(): Vector2;
  21063. /**
  21064. * Gets a new Vector2 copied from the Vector2
  21065. * @returns a new Vector2
  21066. */
  21067. clone(): Vector2;
  21068. /**
  21069. * Gets a new Vector2(0, 0)
  21070. * @returns a new Vector2
  21071. */
  21072. static Zero(): Vector2;
  21073. /**
  21074. * Gets a new Vector2(1, 1)
  21075. * @returns a new Vector2
  21076. */
  21077. static One(): Vector2;
  21078. /**
  21079. * Gets a new Vector2 set from the given index element of the given array
  21080. * @param array defines the data source
  21081. * @param offset defines the offset in the data source
  21082. * @returns a new Vector2
  21083. */
  21084. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21085. /**
  21086. * Sets "result" from the given index element of the given array
  21087. * @param array defines the data source
  21088. * @param offset defines the offset in the data source
  21089. * @param result defines the target vector
  21090. */
  21091. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21092. /**
  21093. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21094. * @param value1 defines 1st point of control
  21095. * @param value2 defines 2nd point of control
  21096. * @param value3 defines 3rd point of control
  21097. * @param value4 defines 4th point of control
  21098. * @param amount defines the interpolation factor
  21099. * @returns a new Vector2
  21100. */
  21101. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21102. /**
  21103. * 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".
  21104. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21105. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21106. * @param value defines the value to clamp
  21107. * @param min defines the lower limit
  21108. * @param max defines the upper limit
  21109. * @returns a new Vector2
  21110. */
  21111. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21112. /**
  21113. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21114. * @param value1 defines the 1st control point
  21115. * @param tangent1 defines the outgoing tangent
  21116. * @param value2 defines the 2nd control point
  21117. * @param tangent2 defines the incoming tangent
  21118. * @param amount defines the interpolation factor
  21119. * @returns a new Vector2
  21120. */
  21121. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21122. /**
  21123. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21124. * @param start defines the start vector
  21125. * @param end defines the end vector
  21126. * @param amount defines the interpolation factor
  21127. * @returns a new Vector2
  21128. */
  21129. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21130. /**
  21131. * Gets the dot product of the vector "left" and the vector "right"
  21132. * @param left defines first vector
  21133. * @param right defines second vector
  21134. * @returns the dot product (float)
  21135. */
  21136. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21137. /**
  21138. * Returns a new Vector2 equal to the normalized given vector
  21139. * @param vector defines the vector to normalize
  21140. * @returns a new Vector2
  21141. */
  21142. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21143. /**
  21144. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21145. * @param left defines 1st vector
  21146. * @param right defines 2nd vector
  21147. * @returns a new Vector2
  21148. */
  21149. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21150. /**
  21151. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21152. * @param left defines 1st vector
  21153. * @param right defines 2nd vector
  21154. * @returns a new Vector2
  21155. */
  21156. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21157. /**
  21158. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21159. * @param vector defines the vector to transform
  21160. * @param transformation defines the matrix to apply
  21161. * @returns a new Vector2
  21162. */
  21163. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21164. /**
  21165. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21166. * @param vector defines the vector to transform
  21167. * @param transformation defines the matrix to apply
  21168. * @param result defines the target vector
  21169. */
  21170. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21171. /**
  21172. * Determines if a given vector is included in a triangle
  21173. * @param p defines the vector to test
  21174. * @param p0 defines 1st triangle point
  21175. * @param p1 defines 2nd triangle point
  21176. * @param p2 defines 3rd triangle point
  21177. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21178. */
  21179. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21180. /**
  21181. * Gets the distance between the vectors "value1" and "value2"
  21182. * @param value1 defines first vector
  21183. * @param value2 defines second vector
  21184. * @returns the distance between vectors
  21185. */
  21186. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21187. /**
  21188. * Returns the squared distance between the vectors "value1" and "value2"
  21189. * @param value1 defines first vector
  21190. * @param value2 defines second vector
  21191. * @returns the squared distance between vectors
  21192. */
  21193. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21194. /**
  21195. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21196. * @param value1 defines first vector
  21197. * @param value2 defines second vector
  21198. * @returns a new Vector2
  21199. */
  21200. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21201. /**
  21202. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21203. * @param p defines the middle point
  21204. * @param segA defines one point of the segment
  21205. * @param segB defines the other point of the segment
  21206. * @returns the shortest distance
  21207. */
  21208. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21209. }
  21210. /**
  21211. * Classed used to store (x,y,z) vector representation
  21212. * A Vector3 is the main object used in 3D geometry
  21213. * It can represent etiher the coordinates of a point the space, either a direction
  21214. * Reminder: Babylon.js uses a left handed forward facing system
  21215. */
  21216. class Vector3 {
  21217. /**
  21218. * Defines the first coordinates (on X axis)
  21219. */
  21220. x: number;
  21221. /**
  21222. * Defines the second coordinates (on Y axis)
  21223. */
  21224. y: number;
  21225. /**
  21226. * Defines the third coordinates (on Z axis)
  21227. */
  21228. z: number;
  21229. /**
  21230. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21231. * @param x defines the first coordinates (on X axis)
  21232. * @param y defines the second coordinates (on Y axis)
  21233. * @param z defines the third coordinates (on Z axis)
  21234. */
  21235. constructor(
  21236. /**
  21237. * Defines the first coordinates (on X axis)
  21238. */
  21239. x?: number,
  21240. /**
  21241. * Defines the second coordinates (on Y axis)
  21242. */
  21243. y?: number,
  21244. /**
  21245. * Defines the third coordinates (on Z axis)
  21246. */
  21247. z?: number);
  21248. /**
  21249. * Creates a string representation of the Vector3
  21250. * @returns a string with the Vector3 coordinates.
  21251. */
  21252. toString(): string;
  21253. /**
  21254. * Gets the class name
  21255. * @returns the string "Vector3"
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Creates the Vector3 hash code
  21260. * @returns a number which tends to be unique between Vector3 instances
  21261. */
  21262. getHashCode(): number;
  21263. /**
  21264. * Creates an array containing three elements : the coordinates of the Vector3
  21265. * @returns a new array of numbers
  21266. */
  21267. asArray(): number[];
  21268. /**
  21269. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21270. * @param array defines the destination array
  21271. * @param index defines the offset in the destination array
  21272. * @returns the current Vector3
  21273. */
  21274. toArray(array: FloatArray, index?: number): Vector3;
  21275. /**
  21276. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21277. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21278. */
  21279. toQuaternion(): Quaternion;
  21280. /**
  21281. * Adds the given vector to the current Vector3
  21282. * @param otherVector defines the second operand
  21283. * @returns the current updated Vector3
  21284. */
  21285. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21286. /**
  21287. * Adds the given coordinates to the current Vector3
  21288. * @param x defines the x coordinate of the operand
  21289. * @param y defines the y coordinate of the operand
  21290. * @param z defines the z coordinate of the operand
  21291. * @returns the current updated Vector3
  21292. */
  21293. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21294. /**
  21295. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21296. * @param otherVector defines the second operand
  21297. * @returns the resulting Vector3
  21298. */
  21299. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21300. /**
  21301. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21302. * @param otherVector defines the second operand
  21303. * @param result defines the Vector3 object where to store the result
  21304. * @returns the current Vector3
  21305. */
  21306. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21307. /**
  21308. * Subtract the given vector from the current Vector3
  21309. * @param otherVector defines the second operand
  21310. * @returns the current updated Vector3
  21311. */
  21312. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21313. /**
  21314. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21315. * @param otherVector defines the second operand
  21316. * @returns the resulting Vector3
  21317. */
  21318. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21319. /**
  21320. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21321. * @param otherVector defines the second operand
  21322. * @param result defines the Vector3 object where to store the result
  21323. * @returns the current Vector3
  21324. */
  21325. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21326. /**
  21327. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21328. * @param x defines the x coordinate of the operand
  21329. * @param y defines the y coordinate of the operand
  21330. * @param z defines the z coordinate of the operand
  21331. * @returns the resulting Vector3
  21332. */
  21333. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21334. /**
  21335. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21336. * @param x defines the x coordinate of the operand
  21337. * @param y defines the y coordinate of the operand
  21338. * @param z defines the z coordinate of the operand
  21339. * @param result defines the Vector3 object where to store the result
  21340. * @returns the current Vector3
  21341. */
  21342. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21343. /**
  21344. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21345. * @returns a new Vector3
  21346. */
  21347. negate(): Vector3;
  21348. /**
  21349. * Multiplies the Vector3 coordinates by the float "scale"
  21350. * @param scale defines the multiplier factor
  21351. * @returns the current updated Vector3
  21352. */
  21353. scaleInPlace(scale: number): Vector3;
  21354. /**
  21355. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21356. * @param scale defines the multiplier factor
  21357. * @returns a new Vector3
  21358. */
  21359. scale(scale: number): Vector3;
  21360. /**
  21361. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21362. * @param scale defines the multiplier factor
  21363. * @param result defines the Vector3 object where to store the result
  21364. * @returns the current Vector3
  21365. */
  21366. scaleToRef(scale: number, result: Vector3): Vector3;
  21367. /**
  21368. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21369. * @param scale defines the scale factor
  21370. * @param result defines the Vector3 object where to store the result
  21371. * @returns the unmodified current Vector3
  21372. */
  21373. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21374. /**
  21375. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21376. * @param otherVector defines the second operand
  21377. * @returns true if both vectors are equals
  21378. */
  21379. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21380. /**
  21381. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21382. * @param otherVector defines the second operand
  21383. * @param epsilon defines the minimal distance to define values as equals
  21384. * @returns true if both vectors are distant less than epsilon
  21385. */
  21386. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21387. /**
  21388. * Returns true if the current Vector3 coordinates equals the given floats
  21389. * @param x defines the x coordinate of the operand
  21390. * @param y defines the y coordinate of the operand
  21391. * @param z defines the z coordinate of the operand
  21392. * @returns true if both vectors are equals
  21393. */
  21394. equalsToFloats(x: number, y: number, z: number): boolean;
  21395. /**
  21396. * Multiplies the current Vector3 coordinates by the given ones
  21397. * @param otherVector defines the second operand
  21398. * @returns the current updated Vector3
  21399. */
  21400. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21401. /**
  21402. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21403. * @param otherVector defines the second operand
  21404. * @returns the new Vector3
  21405. */
  21406. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21407. /**
  21408. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21409. * @param otherVector defines the second operand
  21410. * @param result defines the Vector3 object where to store the result
  21411. * @returns the current Vector3
  21412. */
  21413. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21414. /**
  21415. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21416. * @param x defines the x coordinate of the operand
  21417. * @param y defines the y coordinate of the operand
  21418. * @param z defines the z coordinate of the operand
  21419. * @returns the new Vector3
  21420. */
  21421. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21422. /**
  21423. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21424. * @param otherVector defines the second operand
  21425. * @returns the new Vector3
  21426. */
  21427. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21428. /**
  21429. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21430. * @param otherVector defines the second operand
  21431. * @param result defines the Vector3 object where to store the result
  21432. * @returns the current Vector3
  21433. */
  21434. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21435. /**
  21436. * Divides the current Vector3 coordinates by the given ones.
  21437. * @param otherVector defines the second operand
  21438. * @returns the current updated Vector3
  21439. */
  21440. divideInPlace(otherVector: Vector3): Vector3;
  21441. /**
  21442. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21443. * @param other defines the second operand
  21444. * @returns the current updated Vector3
  21445. */
  21446. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21447. /**
  21448. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21449. * @param other defines the second operand
  21450. * @returns the current updated Vector3
  21451. */
  21452. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21453. /**
  21454. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21455. * @param x defines the x coordinate of the operand
  21456. * @param y defines the y coordinate of the operand
  21457. * @param z defines the z coordinate of the operand
  21458. * @returns the current updated Vector3
  21459. */
  21460. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21461. /**
  21462. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21463. * @param x defines the x coordinate of the operand
  21464. * @param y defines the y coordinate of the operand
  21465. * @param z defines the z coordinate of the operand
  21466. * @returns the current updated Vector3
  21467. */
  21468. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21469. /**
  21470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21471. */
  21472. readonly isNonUniform: boolean;
  21473. /**
  21474. * Gets a new Vector3 from current Vector3 floored values
  21475. * @returns a new Vector3
  21476. */
  21477. floor(): Vector3;
  21478. /**
  21479. * Gets a new Vector3 from current Vector3 floored values
  21480. * @returns a new Vector3
  21481. */
  21482. fract(): Vector3;
  21483. /**
  21484. * Gets the length of the Vector3
  21485. * @returns the length of the Vecto3
  21486. */
  21487. length(): number;
  21488. /**
  21489. * Gets the squared length of the Vector3
  21490. * @returns squared length of the Vector3
  21491. */
  21492. lengthSquared(): number;
  21493. /**
  21494. * Normalize the current Vector3.
  21495. * Please note that this is an in place operation.
  21496. * @returns the current updated Vector3
  21497. */
  21498. normalize(): Vector3;
  21499. /**
  21500. * Reorders the x y z properties of the vector in place
  21501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21502. * @returns the current updated vector
  21503. */
  21504. reorderInPlace(order: string): this;
  21505. /**
  21506. * Rotates the vector around 0,0,0 by a quaternion
  21507. * @param quaternion the rotation quaternion
  21508. * @param result vector to store the result
  21509. * @returns the resulting vector
  21510. */
  21511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21512. /**
  21513. * Rotates a vector around a given point
  21514. * @param quaternion the rotation quaternion
  21515. * @param point the point to rotate around
  21516. * @param result vector to store the result
  21517. * @returns the resulting vector
  21518. */
  21519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21520. /**
  21521. * Normalize the current Vector3 with the given input length.
  21522. * Please note that this is an in place operation.
  21523. * @param len the length of the vector
  21524. * @returns the current updated Vector3
  21525. */
  21526. normalizeFromLength(len: number): Vector3;
  21527. /**
  21528. * Normalize the current Vector3 to a new vector
  21529. * @returns the new Vector3
  21530. */
  21531. normalizeToNew(): Vector3;
  21532. /**
  21533. * Normalize the current Vector3 to the reference
  21534. * @param reference define the Vector3 to update
  21535. * @returns the updated Vector3
  21536. */
  21537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21538. /**
  21539. * Creates a new Vector3 copied from the current Vector3
  21540. * @returns the new Vector3
  21541. */
  21542. clone(): Vector3;
  21543. /**
  21544. * Copies the given vector coordinates to the current Vector3 ones
  21545. * @param source defines the source Vector3
  21546. * @returns the current updated Vector3
  21547. */
  21548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21549. /**
  21550. * Copies the given floats to the current Vector3 coordinates
  21551. * @param x defines the x coordinate of the operand
  21552. * @param y defines the y coordinate of the operand
  21553. * @param z defines the z coordinate of the operand
  21554. * @returns the current updated Vector3
  21555. */
  21556. copyFromFloats(x: number, y: number, z: number): Vector3;
  21557. /**
  21558. * Copies the given floats to the current Vector3 coordinates
  21559. * @param x defines the x coordinate of the operand
  21560. * @param y defines the y coordinate of the operand
  21561. * @param z defines the z coordinate of the operand
  21562. * @returns the current updated Vector3
  21563. */
  21564. set(x: number, y: number, z: number): Vector3;
  21565. /**
  21566. * Copies the given float to the current Vector3 coordinates
  21567. * @param v defines the x, y and z coordinates of the operand
  21568. * @returns the current updated Vector3
  21569. */
  21570. setAll(v: number): Vector3;
  21571. /**
  21572. * Get the clip factor between two vectors
  21573. * @param vector0 defines the first operand
  21574. * @param vector1 defines the second operand
  21575. * @param axis defines the axis to use
  21576. * @param size defines the size along the axis
  21577. * @returns the clip factor
  21578. */
  21579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21580. /**
  21581. * Get angle between two vectors
  21582. * @param vector0 angle between vector0 and vector1
  21583. * @param vector1 angle between vector0 and vector1
  21584. * @param normal direction of the normal
  21585. * @return the angle between vector0 and vector1
  21586. */
  21587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21588. /**
  21589. * Returns a new Vector3 set from the index "offset" of the given array
  21590. * @param array defines the source array
  21591. * @param offset defines the offset in the source array
  21592. * @returns the new Vector3
  21593. */
  21594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21595. /**
  21596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21597. * This function is deprecated. Use FromArray instead
  21598. * @param array defines the source array
  21599. * @param offset defines the offset in the source array
  21600. * @returns the new Vector3
  21601. */
  21602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21603. /**
  21604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21605. * @param array defines the source array
  21606. * @param offset defines the offset in the source array
  21607. * @param result defines the Vector3 where to store the result
  21608. */
  21609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21610. /**
  21611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21612. * This function is deprecated. Use FromArrayToRef instead.
  21613. * @param array defines the source array
  21614. * @param offset defines the offset in the source array
  21615. * @param result defines the Vector3 where to store the result
  21616. */
  21617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21618. /**
  21619. * Sets the given vector "result" with the given floats.
  21620. * @param x defines the x coordinate of the source
  21621. * @param y defines the y coordinate of the source
  21622. * @param z defines the z coordinate of the source
  21623. * @param result defines the Vector3 where to store the result
  21624. */
  21625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21626. /**
  21627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21628. * @returns a new empty Vector3
  21629. */
  21630. static Zero(): Vector3;
  21631. /**
  21632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21633. * @returns a new unit Vector3
  21634. */
  21635. static One(): Vector3;
  21636. /**
  21637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21638. * @returns a new up Vector3
  21639. */
  21640. static Up(): Vector3;
  21641. /**
  21642. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21643. * @returns a new down Vector3
  21644. */
  21645. static Down(): Vector3;
  21646. /**
  21647. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21648. * @returns a new forward Vector3
  21649. */
  21650. static Forward(): Vector3;
  21651. /**
  21652. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21653. * @returns a new forward Vector3
  21654. */
  21655. static Backward(): Vector3;
  21656. /**
  21657. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21658. * @returns a new right Vector3
  21659. */
  21660. static Right(): Vector3;
  21661. /**
  21662. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21663. * @returns a new left Vector3
  21664. */
  21665. static Left(): Vector3;
  21666. /**
  21667. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21668. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21669. * @param vector defines the Vector3 to transform
  21670. * @param transformation defines the transformation matrix
  21671. * @returns the transformed Vector3
  21672. */
  21673. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21674. /**
  21675. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21676. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21677. * @param vector defines the Vector3 to transform
  21678. * @param transformation defines the transformation matrix
  21679. * @param result defines the Vector3 where to store the result
  21680. */
  21681. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21682. /**
  21683. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21684. * This method computes tranformed coordinates only, not transformed direction vectors
  21685. * @param x define the x coordinate of the source vector
  21686. * @param y define the y coordinate of the source vector
  21687. * @param z define the z coordinate of the source vector
  21688. * @param transformation defines the transformation matrix
  21689. * @param result defines the Vector3 where to store the result
  21690. */
  21691. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21692. /**
  21693. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21694. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21695. * @param vector defines the Vector3 to transform
  21696. * @param transformation defines the transformation matrix
  21697. * @returns the new Vector3
  21698. */
  21699. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21700. /**
  21701. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21702. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21703. * @param vector defines the Vector3 to transform
  21704. * @param transformation defines the transformation matrix
  21705. * @param result defines the Vector3 where to store the result
  21706. */
  21707. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21708. /**
  21709. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21710. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21711. * @param x define the x coordinate of the source vector
  21712. * @param y define the y coordinate of the source vector
  21713. * @param z define the z coordinate of the source vector
  21714. * @param transformation defines the transformation matrix
  21715. * @param result defines the Vector3 where to store the result
  21716. */
  21717. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21718. /**
  21719. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21720. * @param value1 defines the first control point
  21721. * @param value2 defines the second control point
  21722. * @param value3 defines the third control point
  21723. * @param value4 defines the fourth control point
  21724. * @param amount defines the amount on the spline to use
  21725. * @returns the new Vector3
  21726. */
  21727. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21728. /**
  21729. * 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"
  21730. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21731. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21732. * @param value defines the current value
  21733. * @param min defines the lower range value
  21734. * @param max defines the upper range value
  21735. * @returns the new Vector3
  21736. */
  21737. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21738. /**
  21739. * 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"
  21740. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21741. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21742. * @param value defines the current value
  21743. * @param min defines the lower range value
  21744. * @param max defines the upper range value
  21745. * @param result defines the Vector3 where to store the result
  21746. */
  21747. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21748. /**
  21749. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21750. * @param value1 defines the first control point
  21751. * @param tangent1 defines the first tangent vector
  21752. * @param value2 defines the second control point
  21753. * @param tangent2 defines the second tangent vector
  21754. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21755. * @returns the new Vector3
  21756. */
  21757. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21758. /**
  21759. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21760. * @param start defines the start value
  21761. * @param end defines the end value
  21762. * @param amount max defines amount between both (between 0 and 1)
  21763. * @returns the new Vector3
  21764. */
  21765. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21766. /**
  21767. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21768. * @param start defines the start value
  21769. * @param end defines the end value
  21770. * @param amount max defines amount between both (between 0 and 1)
  21771. * @param result defines the Vector3 where to store the result
  21772. */
  21773. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21774. /**
  21775. * Returns the dot product (float) between the vectors "left" and "right"
  21776. * @param left defines the left operand
  21777. * @param right defines the right operand
  21778. * @returns the dot product
  21779. */
  21780. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21781. /**
  21782. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21783. * The cross product is then orthogonal to both "left" and "right"
  21784. * @param left defines the left operand
  21785. * @param right defines the right operand
  21786. * @returns the cross product
  21787. */
  21788. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21789. /**
  21790. * Sets the given vector "result" with the cross product of "left" and "right"
  21791. * The cross product is then orthogonal to both "left" and "right"
  21792. * @param left defines the left operand
  21793. * @param right defines the right operand
  21794. * @param result defines the Vector3 where to store the result
  21795. */
  21796. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21797. /**
  21798. * Returns a new Vector3 as the normalization of the given vector
  21799. * @param vector defines the Vector3 to normalize
  21800. * @returns the new Vector3
  21801. */
  21802. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21803. /**
  21804. * Sets the given vector "result" with the normalization of the given first vector
  21805. * @param vector defines the Vector3 to normalize
  21806. * @param result defines the Vector3 where to store the result
  21807. */
  21808. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21809. /**
  21810. * Project a Vector3 onto screen space
  21811. * @param vector defines the Vector3 to project
  21812. * @param world defines the world matrix to use
  21813. * @param transform defines the transform (view x projection) matrix to use
  21814. * @param viewport defines the screen viewport to use
  21815. * @returns the new Vector3
  21816. */
  21817. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21818. /** @hidden */
  21819. private static UnprojectFromInvertedMatrixToRef;
  21820. /**
  21821. * Unproject from screen space to object space
  21822. * @param source defines the screen space Vector3 to use
  21823. * @param viewportWidth defines the current width of the viewport
  21824. * @param viewportHeight defines the current height of the viewport
  21825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21826. * @param transform defines the transform (view x projection) matrix to use
  21827. * @returns the new Vector3
  21828. */
  21829. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21830. /**
  21831. * Unproject from screen space to object space
  21832. * @param source defines the screen space Vector3 to use
  21833. * @param viewportWidth defines the current width of the viewport
  21834. * @param viewportHeight defines the current height of the viewport
  21835. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21836. * @param view defines the view matrix to use
  21837. * @param projection defines the projection matrix to use
  21838. * @returns the new Vector3
  21839. */
  21840. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21841. /**
  21842. * Unproject from screen space to object space
  21843. * @param source defines the screen space Vector3 to use
  21844. * @param viewportWidth defines the current width of the viewport
  21845. * @param viewportHeight defines the current height of the viewport
  21846. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21847. * @param view defines the view matrix to use
  21848. * @param projection defines the projection matrix to use
  21849. * @param result defines the Vector3 where to store the result
  21850. */
  21851. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21852. /**
  21853. * Unproject from screen space to object space
  21854. * @param sourceX defines the screen space x coordinate to use
  21855. * @param sourceY defines the screen space y coordinate to use
  21856. * @param sourceZ defines the screen space z coordinate to use
  21857. * @param viewportWidth defines the current width of the viewport
  21858. * @param viewportHeight defines the current height of the viewport
  21859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21860. * @param view defines the view matrix to use
  21861. * @param projection defines the projection matrix to use
  21862. * @param result defines the Vector3 where to store the result
  21863. */
  21864. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21865. /**
  21866. * Unproject a ray from screen space to object space
  21867. * @param sourceX defines the screen space x coordinate to use
  21868. * @param sourceY defines the screen space y coordinate to use
  21869. * @param viewportWidth defines the current width of the viewport
  21870. * @param viewportHeight defines the current height of the viewport
  21871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21872. * @param view defines the view matrix to use
  21873. * @param projection defines the projection matrix to use
  21874. * @param ray defines the Ray where to store the result
  21875. */
  21876. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21877. /**
  21878. * Gets the minimal coordinate values between two Vector3
  21879. * @param left defines the first operand
  21880. * @param right defines the second operand
  21881. * @returns the new Vector3
  21882. */
  21883. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21884. /**
  21885. * Gets the maximal coordinate values between two Vector3
  21886. * @param left defines the first operand
  21887. * @param right defines the second operand
  21888. * @returns the new Vector3
  21889. */
  21890. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21891. /**
  21892. * Returns the distance between the vectors "value1" and "value2"
  21893. * @param value1 defines the first operand
  21894. * @param value2 defines the second operand
  21895. * @returns the distance
  21896. */
  21897. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21898. /**
  21899. * Returns the squared distance between the vectors "value1" and "value2"
  21900. * @param value1 defines the first operand
  21901. * @param value2 defines the second operand
  21902. * @returns the squared distance
  21903. */
  21904. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21905. /**
  21906. * Returns a new Vector3 located at the center between "value1" and "value2"
  21907. * @param value1 defines the first operand
  21908. * @param value2 defines the second operand
  21909. * @returns the new Vector3
  21910. */
  21911. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21912. /**
  21913. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21914. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21915. * to something in order to rotate it from its local system to the given target system
  21916. * Note: axis1, axis2 and axis3 are normalized during this operation
  21917. * @param axis1 defines the first axis
  21918. * @param axis2 defines the second axis
  21919. * @param axis3 defines the third axis
  21920. * @returns a new Vector3
  21921. */
  21922. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21923. /**
  21924. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21925. * @param axis1 defines the first axis
  21926. * @param axis2 defines the second axis
  21927. * @param axis3 defines the third axis
  21928. * @param ref defines the Vector3 where to store the result
  21929. */
  21930. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21931. }
  21932. /**
  21933. * Vector4 class created for EulerAngle class conversion to Quaternion
  21934. */
  21935. class Vector4 {
  21936. /** x value of the vector */
  21937. x: number;
  21938. /** y value of the vector */
  21939. y: number;
  21940. /** z value of the vector */
  21941. z: number;
  21942. /** w value of the vector */
  21943. w: number;
  21944. /**
  21945. * Creates a Vector4 object from the given floats.
  21946. * @param x x value of the vector
  21947. * @param y y value of the vector
  21948. * @param z z value of the vector
  21949. * @param w w value of the vector
  21950. */
  21951. constructor(
  21952. /** x value of the vector */
  21953. x: number,
  21954. /** y value of the vector */
  21955. y: number,
  21956. /** z value of the vector */
  21957. z: number,
  21958. /** w value of the vector */
  21959. w: number);
  21960. /**
  21961. * Returns the string with the Vector4 coordinates.
  21962. * @returns a string containing all the vector values
  21963. */
  21964. toString(): string;
  21965. /**
  21966. * Returns the string "Vector4".
  21967. * @returns "Vector4"
  21968. */
  21969. getClassName(): string;
  21970. /**
  21971. * Returns the Vector4 hash code.
  21972. * @returns a unique hash code
  21973. */
  21974. getHashCode(): number;
  21975. /**
  21976. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21977. * @returns the resulting array
  21978. */
  21979. asArray(): number[];
  21980. /**
  21981. * Populates the given array from the given index with the Vector4 coordinates.
  21982. * @param array array to populate
  21983. * @param index index of the array to start at (default: 0)
  21984. * @returns the Vector4.
  21985. */
  21986. toArray(array: FloatArray, index?: number): Vector4;
  21987. /**
  21988. * Adds the given vector to the current Vector4.
  21989. * @param otherVector the vector to add
  21990. * @returns the updated Vector4.
  21991. */
  21992. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21993. /**
  21994. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21995. * @param otherVector the vector to add
  21996. * @returns the resulting vector
  21997. */
  21998. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21999. /**
  22000. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22001. * @param otherVector the vector to add
  22002. * @param result the vector to store the result
  22003. * @returns the current Vector4.
  22004. */
  22005. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22006. /**
  22007. * Subtract in place the given vector from the current Vector4.
  22008. * @param otherVector the vector to subtract
  22009. * @returns the updated Vector4.
  22010. */
  22011. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22012. /**
  22013. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22014. * @param otherVector the vector to add
  22015. * @returns the new vector with the result
  22016. */
  22017. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22018. /**
  22019. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22020. * @param otherVector the vector to subtract
  22021. * @param result the vector to store the result
  22022. * @returns the current Vector4.
  22023. */
  22024. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22025. /**
  22026. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22027. */
  22028. /**
  22029. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22030. * @param x value to subtract
  22031. * @param y value to subtract
  22032. * @param z value to subtract
  22033. * @param w value to subtract
  22034. * @returns new vector containing the result
  22035. */
  22036. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22037. /**
  22038. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22039. * @param x value to subtract
  22040. * @param y value to subtract
  22041. * @param z value to subtract
  22042. * @param w value to subtract
  22043. * @param result the vector to store the result in
  22044. * @returns the current Vector4.
  22045. */
  22046. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22047. /**
  22048. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22049. * @returns a new vector with the negated values
  22050. */
  22051. negate(): Vector4;
  22052. /**
  22053. * Multiplies the current Vector4 coordinates by scale (float).
  22054. * @param scale the number to scale with
  22055. * @returns the updated Vector4.
  22056. */
  22057. scaleInPlace(scale: number): Vector4;
  22058. /**
  22059. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22060. * @param scale the number to scale with
  22061. * @returns a new vector with the result
  22062. */
  22063. scale(scale: number): Vector4;
  22064. /**
  22065. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22066. * @param scale the number to scale with
  22067. * @param result a vector to store the result in
  22068. * @returns the current Vector4.
  22069. */
  22070. scaleToRef(scale: number, result: Vector4): Vector4;
  22071. /**
  22072. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22073. * @param scale defines the scale factor
  22074. * @param result defines the Vector4 object where to store the result
  22075. * @returns the unmodified current Vector4
  22076. */
  22077. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22078. /**
  22079. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22080. * @param otherVector the vector to compare against
  22081. * @returns true if they are equal
  22082. */
  22083. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22084. /**
  22085. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22086. * @param otherVector vector to compare against
  22087. * @param epsilon (Default: very small number)
  22088. * @returns true if they are equal
  22089. */
  22090. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22091. /**
  22092. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22093. * @param x x value to compare against
  22094. * @param y y value to compare against
  22095. * @param z z value to compare against
  22096. * @param w w value to compare against
  22097. * @returns true if equal
  22098. */
  22099. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22100. /**
  22101. * Multiplies in place the current Vector4 by the given one.
  22102. * @param otherVector vector to multiple with
  22103. * @returns the updated Vector4.
  22104. */
  22105. multiplyInPlace(otherVector: Vector4): Vector4;
  22106. /**
  22107. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22108. * @param otherVector vector to multiple with
  22109. * @returns resulting new vector
  22110. */
  22111. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22112. /**
  22113. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22114. * @param otherVector vector to multiple with
  22115. * @param result vector to store the result
  22116. * @returns the current Vector4.
  22117. */
  22118. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22119. /**
  22120. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22121. * @param x x value multiply with
  22122. * @param y y value multiply with
  22123. * @param z z value multiply with
  22124. * @param w w value multiply with
  22125. * @returns resulting new vector
  22126. */
  22127. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22128. /**
  22129. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22130. * @param otherVector vector to devide with
  22131. * @returns resulting new vector
  22132. */
  22133. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22134. /**
  22135. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22136. * @param otherVector vector to devide with
  22137. * @param result vector to store the result
  22138. * @returns the current Vector4.
  22139. */
  22140. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22141. /**
  22142. * Divides the current Vector3 coordinates by the given ones.
  22143. * @param otherVector vector to devide with
  22144. * @returns the updated Vector3.
  22145. */
  22146. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22147. /**
  22148. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22149. * @param other defines the second operand
  22150. * @returns the current updated Vector4
  22151. */
  22152. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22153. /**
  22154. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22155. * @param other defines the second operand
  22156. * @returns the current updated Vector4
  22157. */
  22158. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22159. /**
  22160. * Gets a new Vector4 from current Vector4 floored values
  22161. * @returns a new Vector4
  22162. */
  22163. floor(): Vector4;
  22164. /**
  22165. * Gets a new Vector4 from current Vector3 floored values
  22166. * @returns a new Vector4
  22167. */
  22168. fract(): Vector4;
  22169. /**
  22170. * Returns the Vector4 length (float).
  22171. * @returns the length
  22172. */
  22173. length(): number;
  22174. /**
  22175. * Returns the Vector4 squared length (float).
  22176. * @returns the length squared
  22177. */
  22178. lengthSquared(): number;
  22179. /**
  22180. * Normalizes in place the Vector4.
  22181. * @returns the updated Vector4.
  22182. */
  22183. normalize(): Vector4;
  22184. /**
  22185. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22186. * @returns this converted to a new vector3
  22187. */
  22188. toVector3(): Vector3;
  22189. /**
  22190. * Returns a new Vector4 copied from the current one.
  22191. * @returns the new cloned vector
  22192. */
  22193. clone(): Vector4;
  22194. /**
  22195. * Updates the current Vector4 with the given one coordinates.
  22196. * @param source the source vector to copy from
  22197. * @returns the updated Vector4.
  22198. */
  22199. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22200. /**
  22201. * Updates the current Vector4 coordinates with the given floats.
  22202. * @param x float to copy from
  22203. * @param y float to copy from
  22204. * @param z float to copy from
  22205. * @param w float to copy from
  22206. * @returns the updated Vector4.
  22207. */
  22208. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22209. /**
  22210. * Updates the current Vector4 coordinates with the given floats.
  22211. * @param x float to set from
  22212. * @param y float to set from
  22213. * @param z float to set from
  22214. * @param w float to set from
  22215. * @returns the updated Vector4.
  22216. */
  22217. set(x: number, y: number, z: number, w: number): Vector4;
  22218. /**
  22219. * Copies the given float to the current Vector3 coordinates
  22220. * @param v defines the x, y, z and w coordinates of the operand
  22221. * @returns the current updated Vector3
  22222. */
  22223. setAll(v: number): Vector4;
  22224. /**
  22225. * Returns a new Vector4 set from the starting index of the given array.
  22226. * @param array the array to pull values from
  22227. * @param offset the offset into the array to start at
  22228. * @returns the new vector
  22229. */
  22230. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22231. /**
  22232. * Updates the given vector "result" from the starting index of the given array.
  22233. * @param array the array to pull values from
  22234. * @param offset the offset into the array to start at
  22235. * @param result the vector to store the result in
  22236. */
  22237. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22238. /**
  22239. * Updates the given vector "result" from the starting index of the given Float32Array.
  22240. * @param array the array to pull values from
  22241. * @param offset the offset into the array to start at
  22242. * @param result the vector to store the result in
  22243. */
  22244. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22245. /**
  22246. * Updates the given vector "result" coordinates from the given floats.
  22247. * @param x float to set from
  22248. * @param y float to set from
  22249. * @param z float to set from
  22250. * @param w float to set from
  22251. * @param result the vector to the floats in
  22252. */
  22253. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22254. /**
  22255. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22256. * @returns the new vector
  22257. */
  22258. static Zero(): Vector4;
  22259. /**
  22260. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22261. * @returns the new vector
  22262. */
  22263. static One(): Vector4;
  22264. /**
  22265. * Returns a new normalized Vector4 from the given one.
  22266. * @param vector the vector to normalize
  22267. * @returns the vector
  22268. */
  22269. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22270. /**
  22271. * Updates the given vector "result" from the normalization of the given one.
  22272. * @param vector the vector to normalize
  22273. * @param result the vector to store the result in
  22274. */
  22275. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22276. /**
  22277. * Returns a vector with the minimum values from the left and right vectors
  22278. * @param left left vector to minimize
  22279. * @param right right vector to minimize
  22280. * @returns a new vector with the minimum of the left and right vector values
  22281. */
  22282. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22283. /**
  22284. * Returns a vector with the maximum values from the left and right vectors
  22285. * @param left left vector to maximize
  22286. * @param right right vector to maximize
  22287. * @returns a new vector with the maximum of the left and right vector values
  22288. */
  22289. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22290. /**
  22291. * Returns the distance (float) between the vectors "value1" and "value2".
  22292. * @param value1 value to calulate the distance between
  22293. * @param value2 value to calulate the distance between
  22294. * @return the distance between the two vectors
  22295. */
  22296. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22297. /**
  22298. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22299. * @param value1 value to calulate the distance between
  22300. * @param value2 value to calulate the distance between
  22301. * @return the distance between the two vectors squared
  22302. */
  22303. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22304. /**
  22305. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22306. * @param value1 value to calulate the center between
  22307. * @param value2 value to calulate the center between
  22308. * @return the center between the two vectors
  22309. */
  22310. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22311. /**
  22312. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22313. * This methods computes transformed normalized direction vectors only.
  22314. * @param vector the vector to transform
  22315. * @param transformation the transformation matrix to apply
  22316. * @returns the new vector
  22317. */
  22318. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22319. /**
  22320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22321. * This methods computes transformed normalized direction vectors only.
  22322. * @param vector the vector to transform
  22323. * @param transformation the transformation matrix to apply
  22324. * @param result the vector to store the result in
  22325. */
  22326. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22327. /**
  22328. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22329. * This methods computes transformed normalized direction vectors only.
  22330. * @param x value to transform
  22331. * @param y value to transform
  22332. * @param z value to transform
  22333. * @param w value to transform
  22334. * @param transformation the transformation matrix to apply
  22335. * @param result the vector to store the results in
  22336. */
  22337. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22338. }
  22339. /**
  22340. * Interface for the size containing width and height
  22341. */
  22342. interface ISize {
  22343. /**
  22344. * Width
  22345. */
  22346. width: number;
  22347. /**
  22348. * Heighht
  22349. */
  22350. height: number;
  22351. }
  22352. /**
  22353. * Size containing widht and height
  22354. */
  22355. class Size implements ISize {
  22356. /**
  22357. * Width
  22358. */
  22359. width: number;
  22360. /**
  22361. * Height
  22362. */
  22363. height: number;
  22364. /**
  22365. * Creates a Size object from the given width and height (floats).
  22366. * @param width width of the new size
  22367. * @param height height of the new size
  22368. */
  22369. constructor(width: number, height: number);
  22370. /**
  22371. * Returns a string with the Size width and height
  22372. * @returns a string with the Size width and height
  22373. */
  22374. toString(): string;
  22375. /**
  22376. * "Size"
  22377. * @returns the string "Size"
  22378. */
  22379. getClassName(): string;
  22380. /**
  22381. * Returns the Size hash code.
  22382. * @returns a hash code for a unique width and height
  22383. */
  22384. getHashCode(): number;
  22385. /**
  22386. * Updates the current size from the given one.
  22387. * @param src the given size
  22388. */
  22389. copyFrom(src: Size): void;
  22390. /**
  22391. * Updates in place the current Size from the given floats.
  22392. * @param width width of the new size
  22393. * @param height height of the new size
  22394. * @returns the updated Size.
  22395. */
  22396. copyFromFloats(width: number, height: number): Size;
  22397. /**
  22398. * Updates in place the current Size from the given floats.
  22399. * @param width width to set
  22400. * @param height height to set
  22401. * @returns the updated Size.
  22402. */
  22403. set(width: number, height: number): Size;
  22404. /**
  22405. * Multiplies the width and height by numbers
  22406. * @param w factor to multiple the width by
  22407. * @param h factor to multiple the height by
  22408. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22409. */
  22410. multiplyByFloats(w: number, h: number): Size;
  22411. /**
  22412. * Clones the size
  22413. * @returns a new Size copied from the given one.
  22414. */
  22415. clone(): Size;
  22416. /**
  22417. * True if the current Size and the given one width and height are strictly equal.
  22418. * @param other the other size to compare against
  22419. * @returns True if the current Size and the given one width and height are strictly equal.
  22420. */
  22421. equals(other: Size): boolean;
  22422. /**
  22423. * The surface of the Size : width * height (float).
  22424. */
  22425. readonly surface: number;
  22426. /**
  22427. * Create a new size of zero
  22428. * @returns a new Size set to (0.0, 0.0)
  22429. */
  22430. static Zero(): Size;
  22431. /**
  22432. * Sums the width and height of two sizes
  22433. * @param otherSize size to add to this size
  22434. * @returns a new Size set as the addition result of the current Size and the given one.
  22435. */
  22436. add(otherSize: Size): Size;
  22437. /**
  22438. * Subtracts the width and height of two
  22439. * @param otherSize size to subtract to this size
  22440. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22441. */
  22442. subtract(otherSize: Size): Size;
  22443. /**
  22444. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22445. * @param start starting size to lerp between
  22446. * @param end end size to lerp between
  22447. * @param amount amount to lerp between the start and end values
  22448. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22449. */
  22450. static Lerp(start: Size, end: Size, amount: number): Size;
  22451. }
  22452. /**
  22453. * Class used to store quaternion data
  22454. * @see https://en.wikipedia.org/wiki/Quaternion
  22455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22456. */
  22457. class Quaternion {
  22458. /** defines the first component (0 by default) */
  22459. x: number;
  22460. /** defines the second component (0 by default) */
  22461. y: number;
  22462. /** defines the third component (0 by default) */
  22463. z: number;
  22464. /** defines the fourth component (1.0 by default) */
  22465. w: number;
  22466. /**
  22467. * Creates a new Quaternion from the given floats
  22468. * @param x defines the first component (0 by default)
  22469. * @param y defines the second component (0 by default)
  22470. * @param z defines the third component (0 by default)
  22471. * @param w defines the fourth component (1.0 by default)
  22472. */
  22473. constructor(
  22474. /** defines the first component (0 by default) */
  22475. x?: number,
  22476. /** defines the second component (0 by default) */
  22477. y?: number,
  22478. /** defines the third component (0 by default) */
  22479. z?: number,
  22480. /** defines the fourth component (1.0 by default) */
  22481. w?: number);
  22482. /**
  22483. * Gets a string representation for the current quaternion
  22484. * @returns a string with the Quaternion coordinates
  22485. */
  22486. toString(): string;
  22487. /**
  22488. * Gets the class name of the quaternion
  22489. * @returns the string "Quaternion"
  22490. */
  22491. getClassName(): string;
  22492. /**
  22493. * Gets a hash code for this quaternion
  22494. * @returns the quaternion hash code
  22495. */
  22496. getHashCode(): number;
  22497. /**
  22498. * Copy the quaternion to an array
  22499. * @returns a new array populated with 4 elements from the quaternion coordinates
  22500. */
  22501. asArray(): number[];
  22502. /**
  22503. * Check if two quaternions are equals
  22504. * @param otherQuaternion defines the second operand
  22505. * @return true if the current quaternion and the given one coordinates are strictly equals
  22506. */
  22507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22508. /**
  22509. * Clone the current quaternion
  22510. * @returns a new quaternion copied from the current one
  22511. */
  22512. clone(): Quaternion;
  22513. /**
  22514. * Copy a quaternion to the current one
  22515. * @param other defines the other quaternion
  22516. * @returns the updated current quaternion
  22517. */
  22518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22519. /**
  22520. * Updates the current quaternion with the given float coordinates
  22521. * @param x defines the x coordinate
  22522. * @param y defines the y coordinate
  22523. * @param z defines the z coordinate
  22524. * @param w defines the w coordinate
  22525. * @returns the updated current quaternion
  22526. */
  22527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22528. /**
  22529. * Updates the current quaternion from the given float coordinates
  22530. * @param x defines the x coordinate
  22531. * @param y defines the y coordinate
  22532. * @param z defines the z coordinate
  22533. * @param w defines the w coordinate
  22534. * @returns the updated current quaternion
  22535. */
  22536. set(x: number, y: number, z: number, w: number): Quaternion;
  22537. /**
  22538. * Adds two quaternions
  22539. * @param other defines the second operand
  22540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22541. */
  22542. add(other: DeepImmutable<Quaternion>): Quaternion;
  22543. /**
  22544. * Add a quaternion to the current one
  22545. * @param other defines the quaternion to add
  22546. * @returns the current quaternion
  22547. */
  22548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22549. /**
  22550. * Subtract two quaternions
  22551. * @param other defines the second operand
  22552. * @returns a new quaternion as the subtraction result of the given one from the current one
  22553. */
  22554. subtract(other: Quaternion): Quaternion;
  22555. /**
  22556. * Multiplies the current quaternion by a scale factor
  22557. * @param value defines the scale factor
  22558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22559. */
  22560. scale(value: number): Quaternion;
  22561. /**
  22562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22563. * @param scale defines the scale factor
  22564. * @param result defines the Quaternion object where to store the result
  22565. * @returns the unmodified current quaternion
  22566. */
  22567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22568. /**
  22569. * Multiplies in place the current quaternion by a scale factor
  22570. * @param value defines the scale factor
  22571. * @returns the current modified quaternion
  22572. */
  22573. scaleInPlace(value: number): Quaternion;
  22574. /**
  22575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22576. * @param scale defines the scale factor
  22577. * @param result defines the Quaternion object where to store the result
  22578. * @returns the unmodified current quaternion
  22579. */
  22580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22581. /**
  22582. * Multiplies two quaternions
  22583. * @param q1 defines the second operand
  22584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22585. */
  22586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22587. /**
  22588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22589. * @param q1 defines the second operand
  22590. * @param result defines the target quaternion
  22591. * @returns the current quaternion
  22592. */
  22593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22594. /**
  22595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22596. * @param q1 defines the second operand
  22597. * @returns the currentupdated quaternion
  22598. */
  22599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22600. /**
  22601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22602. * @param ref defines the target quaternion
  22603. * @returns the current quaternion
  22604. */
  22605. conjugateToRef(ref: Quaternion): Quaternion;
  22606. /**
  22607. * Conjugates in place (1-q) the current quaternion
  22608. * @returns the current updated quaternion
  22609. */
  22610. conjugateInPlace(): Quaternion;
  22611. /**
  22612. * Conjugates in place (1-q) the current quaternion
  22613. * @returns a new quaternion
  22614. */
  22615. conjugate(): Quaternion;
  22616. /**
  22617. * Gets length of current quaternion
  22618. * @returns the quaternion length (float)
  22619. */
  22620. length(): number;
  22621. /**
  22622. * Normalize in place the current quaternion
  22623. * @returns the current updated quaternion
  22624. */
  22625. normalize(): Quaternion;
  22626. /**
  22627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22628. * @param order is a reserved parameter and is ignore for now
  22629. * @returns a new Vector3 containing the Euler angles
  22630. */
  22631. toEulerAngles(order?: string): Vector3;
  22632. /**
  22633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22634. * @param result defines the vector which will be filled with the Euler angles
  22635. * @param order is a reserved parameter and is ignore for now
  22636. * @returns the current unchanged quaternion
  22637. */
  22638. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22639. /**
  22640. * Updates the given rotation matrix with the current quaternion values
  22641. * @param result defines the target matrix
  22642. * @returns the current unchanged quaternion
  22643. */
  22644. toRotationMatrix(result: Matrix): Quaternion;
  22645. /**
  22646. * Updates the current quaternion from the given rotation matrix values
  22647. * @param matrix defines the source matrix
  22648. * @returns the current updated quaternion
  22649. */
  22650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22651. /**
  22652. * Creates a new quaternion from a rotation matrix
  22653. * @param matrix defines the source matrix
  22654. * @returns a new quaternion created from the given rotation matrix values
  22655. */
  22656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22657. /**
  22658. * Updates the given quaternion with the given rotation matrix values
  22659. * @param matrix defines the source matrix
  22660. * @param result defines the target quaternion
  22661. */
  22662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22663. /**
  22664. * Returns the dot product (float) between the quaternions "left" and "right"
  22665. * @param left defines the left operand
  22666. * @param right defines the right operand
  22667. * @returns the dot product
  22668. */
  22669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22670. /**
  22671. * Checks if the two quaternions are close to each other
  22672. * @param quat0 defines the first quaternion to check
  22673. * @param quat1 defines the second quaternion to check
  22674. * @returns true if the two quaternions are close to each other
  22675. */
  22676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22677. /**
  22678. * Creates an empty quaternion
  22679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22680. */
  22681. static Zero(): Quaternion;
  22682. /**
  22683. * Inverse a given quaternion
  22684. * @param q defines the source quaternion
  22685. * @returns a new quaternion as the inverted current quaternion
  22686. */
  22687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22688. /**
  22689. * Inverse a given quaternion
  22690. * @param q defines the source quaternion
  22691. * @param result the quaternion the result will be stored in
  22692. * @returns the result quaternion
  22693. */
  22694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22695. /**
  22696. * Creates an identity quaternion
  22697. * @returns the identity quaternion
  22698. */
  22699. static Identity(): Quaternion;
  22700. /**
  22701. * Gets a boolean indicating if the given quaternion is identity
  22702. * @param quaternion defines the quaternion to check
  22703. * @returns true if the quaternion is identity
  22704. */
  22705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22706. /**
  22707. * Creates a quaternion from a rotation around an axis
  22708. * @param axis defines the axis to use
  22709. * @param angle defines the angle to use
  22710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22711. */
  22712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22713. /**
  22714. * Creates a rotation around an axis and stores it into the given quaternion
  22715. * @param axis defines the axis to use
  22716. * @param angle defines the angle to use
  22717. * @param result defines the target quaternion
  22718. * @returns the target quaternion
  22719. */
  22720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22721. /**
  22722. * Creates a new quaternion from data stored into an array
  22723. * @param array defines the data source
  22724. * @param offset defines the offset in the source array where the data starts
  22725. * @returns a new quaternion
  22726. */
  22727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22728. /**
  22729. * Create a quaternion from Euler rotation angles
  22730. * @param x Pitch
  22731. * @param y Yaw
  22732. * @param z Roll
  22733. * @returns the new Quaternion
  22734. */
  22735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22736. /**
  22737. * Updates a quaternion from Euler rotation angles
  22738. * @param x Pitch
  22739. * @param y Yaw
  22740. * @param z Roll
  22741. * @param result the quaternion to store the result
  22742. * @returns the updated quaternion
  22743. */
  22744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22745. /**
  22746. * Create a quaternion from Euler rotation vector
  22747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22748. * @returns the new Quaternion
  22749. */
  22750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22751. /**
  22752. * Updates a quaternion from Euler rotation vector
  22753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22754. * @param result the quaternion to store the result
  22755. * @returns the updated quaternion
  22756. */
  22757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22758. /**
  22759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22760. * @param yaw defines the rotation around Y axis
  22761. * @param pitch defines the rotation around X axis
  22762. * @param roll defines the rotation around Z axis
  22763. * @returns the new quaternion
  22764. */
  22765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22766. /**
  22767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22768. * @param yaw defines the rotation around Y axis
  22769. * @param pitch defines the rotation around X axis
  22770. * @param roll defines the rotation around Z axis
  22771. * @param result defines the target quaternion
  22772. */
  22773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22774. /**
  22775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22776. * @param alpha defines the rotation around first axis
  22777. * @param beta defines the rotation around second axis
  22778. * @param gamma defines the rotation around third axis
  22779. * @returns the new quaternion
  22780. */
  22781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22782. /**
  22783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22784. * @param alpha defines the rotation around first axis
  22785. * @param beta defines the rotation around second axis
  22786. * @param gamma defines the rotation around third axis
  22787. * @param result defines the target quaternion
  22788. */
  22789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22790. /**
  22791. * 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)
  22792. * @param axis1 defines the first axis
  22793. * @param axis2 defines the second axis
  22794. * @param axis3 defines the third axis
  22795. * @returns the new quaternion
  22796. */
  22797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22798. /**
  22799. * 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
  22800. * @param axis1 defines the first axis
  22801. * @param axis2 defines the second axis
  22802. * @param axis3 defines the third axis
  22803. * @param ref defines the target quaternion
  22804. */
  22805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22806. /**
  22807. * Interpolates between two quaternions
  22808. * @param left defines first quaternion
  22809. * @param right defines second quaternion
  22810. * @param amount defines the gradient to use
  22811. * @returns the new interpolated quaternion
  22812. */
  22813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22814. /**
  22815. * Interpolates between two quaternions and stores it into a target quaternion
  22816. * @param left defines first quaternion
  22817. * @param right defines second quaternion
  22818. * @param amount defines the gradient to use
  22819. * @param result defines the target quaternion
  22820. */
  22821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22822. /**
  22823. * Interpolate between two quaternions using Hermite interpolation
  22824. * @param value1 defines first quaternion
  22825. * @param tangent1 defines the incoming tangent
  22826. * @param value2 defines second quaternion
  22827. * @param tangent2 defines the outgoing tangent
  22828. * @param amount defines the target quaternion
  22829. * @returns the new interpolated quaternion
  22830. */
  22831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22832. }
  22833. /**
  22834. * Class used to store matrix data (4x4)
  22835. */
  22836. class Matrix {
  22837. private static _updateFlagSeed;
  22838. private static _identityReadOnly;
  22839. private _isIdentity;
  22840. private _isIdentityDirty;
  22841. private _isIdentity3x2;
  22842. private _isIdentity3x2Dirty;
  22843. /**
  22844. * Gets the update flag of the matrix which is an unique number for the matrix.
  22845. * It will be incremented every time the matrix data change.
  22846. * You can use it to speed the comparison between two versions of the same matrix.
  22847. */
  22848. updateFlag: number;
  22849. private readonly _m;
  22850. /**
  22851. * Gets the internal data of the matrix
  22852. */
  22853. readonly m: DeepImmutable<Float32Array>;
  22854. /** @hidden */
  22855. _markAsUpdated(): void;
  22856. /** @hidden */
  22857. private _updateIdentityStatus;
  22858. /**
  22859. * Creates an empty matrix (filled with zeros)
  22860. */
  22861. constructor();
  22862. /**
  22863. * Check if the current matrix is identity
  22864. * @returns true is the matrix is the identity matrix
  22865. */
  22866. isIdentity(): boolean;
  22867. /**
  22868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22869. * @returns true is the matrix is the identity matrix
  22870. */
  22871. isIdentityAs3x2(): boolean;
  22872. /**
  22873. * Gets the determinant of the matrix
  22874. * @returns the matrix determinant
  22875. */
  22876. determinant(): number;
  22877. /**
  22878. * Returns the matrix as a Float32Array
  22879. * @returns the matrix underlying array
  22880. */
  22881. toArray(): DeepImmutable<Float32Array>;
  22882. /**
  22883. * Returns the matrix as a Float32Array
  22884. * @returns the matrix underlying array.
  22885. */
  22886. asArray(): DeepImmutable<Float32Array>;
  22887. /**
  22888. * Inverts the current matrix in place
  22889. * @returns the current inverted matrix
  22890. */
  22891. invert(): Matrix;
  22892. /**
  22893. * Sets all the matrix elements to zero
  22894. * @returns the current matrix
  22895. */
  22896. reset(): Matrix;
  22897. /**
  22898. * Adds the current matrix with a second one
  22899. * @param other defines the matrix to add
  22900. * @returns a new matrix as the addition of the current matrix and the given one
  22901. */
  22902. add(other: DeepImmutable<Matrix>): Matrix;
  22903. /**
  22904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22905. * @param other defines the matrix to add
  22906. * @param result defines the target matrix
  22907. * @returns the current matrix
  22908. */
  22909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22910. /**
  22911. * Adds in place the given matrix to the current matrix
  22912. * @param other defines the second operand
  22913. * @returns the current updated matrix
  22914. */
  22915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22916. /**
  22917. * Sets the given matrix to the current inverted Matrix
  22918. * @param other defines the target matrix
  22919. * @returns the unmodified current matrix
  22920. */
  22921. invertToRef(other: Matrix): Matrix;
  22922. /**
  22923. * add a value at the specified position in the current Matrix
  22924. * @param index the index of the value within the matrix. between 0 and 15.
  22925. * @param value the value to be added
  22926. * @returns the current updated matrix
  22927. */
  22928. addAtIndex(index: number, value: number): Matrix;
  22929. /**
  22930. * mutiply the specified position in the current Matrix by a value
  22931. * @param index the index of the value within the matrix. between 0 and 15.
  22932. * @param value the value to be added
  22933. * @returns the current updated matrix
  22934. */
  22935. multiplyAtIndex(index: number, value: number): Matrix;
  22936. /**
  22937. * Inserts the translation vector (using 3 floats) in the current matrix
  22938. * @param x defines the 1st component of the translation
  22939. * @param y defines the 2nd component of the translation
  22940. * @param z defines the 3rd component of the translation
  22941. * @returns the current updated matrix
  22942. */
  22943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22944. /**
  22945. * Inserts the translation vector in the current matrix
  22946. * @param vector3 defines the translation to insert
  22947. * @returns the current updated matrix
  22948. */
  22949. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22950. /**
  22951. * Gets the translation value of the current matrix
  22952. * @returns a new Vector3 as the extracted translation from the matrix
  22953. */
  22954. getTranslation(): Vector3;
  22955. /**
  22956. * Fill a Vector3 with the extracted translation from the matrix
  22957. * @param result defines the Vector3 where to store the translation
  22958. * @returns the current matrix
  22959. */
  22960. getTranslationToRef(result: Vector3): Matrix;
  22961. /**
  22962. * Remove rotation and scaling part from the matrix
  22963. * @returns the updated matrix
  22964. */
  22965. removeRotationAndScaling(): Matrix;
  22966. /**
  22967. * Multiply two matrices
  22968. * @param other defines the second operand
  22969. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22970. */
  22971. multiply(other: DeepImmutable<Matrix>): Matrix;
  22972. /**
  22973. * Copy the current matrix from the given one
  22974. * @param other defines the source matrix
  22975. * @returns the current updated matrix
  22976. */
  22977. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22978. /**
  22979. * Populates the given array from the starting index with the current matrix values
  22980. * @param array defines the target array
  22981. * @param offset defines the offset in the target array where to start storing values
  22982. * @returns the current matrix
  22983. */
  22984. copyToArray(array: Float32Array, offset?: number): Matrix;
  22985. /**
  22986. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22987. * @param other defines the second operand
  22988. * @param result defines the matrix where to store the multiplication
  22989. * @returns the current matrix
  22990. */
  22991. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22992. /**
  22993. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22994. * @param other defines the second operand
  22995. * @param result defines the array where to store the multiplication
  22996. * @param offset defines the offset in the target array where to start storing values
  22997. * @returns the current matrix
  22998. */
  22999. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23000. /**
  23001. * Check equality between this matrix and a second one
  23002. * @param value defines the second matrix to compare
  23003. * @returns true is the current matrix and the given one values are strictly equal
  23004. */
  23005. equals(value: DeepImmutable<Matrix>): boolean;
  23006. /**
  23007. * Clone the current matrix
  23008. * @returns a new matrix from the current matrix
  23009. */
  23010. clone(): Matrix;
  23011. /**
  23012. * Returns the name of the current matrix class
  23013. * @returns the string "Matrix"
  23014. */
  23015. getClassName(): string;
  23016. /**
  23017. * Gets the hash code of the current matrix
  23018. * @returns the hash code
  23019. */
  23020. getHashCode(): number;
  23021. /**
  23022. * Decomposes the current Matrix into a translation, rotation and scaling components
  23023. * @param scale defines the scale vector3 given as a reference to update
  23024. * @param rotation defines the rotation quaternion given as a reference to update
  23025. * @param translation defines the translation vector3 given as a reference to update
  23026. * @returns true if operation was successful
  23027. */
  23028. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23029. /**
  23030. * Gets specific row of the matrix
  23031. * @param index defines the number of the row to get
  23032. * @returns the index-th row of the current matrix as a new Vector4
  23033. */
  23034. getRow(index: number): Nullable<Vector4>;
  23035. /**
  23036. * Sets the index-th row of the current matrix to the vector4 values
  23037. * @param index defines the number of the row to set
  23038. * @param row defines the target vector4
  23039. * @returns the updated current matrix
  23040. */
  23041. setRow(index: number, row: Vector4): Matrix;
  23042. /**
  23043. * Compute the transpose of the matrix
  23044. * @returns the new transposed matrix
  23045. */
  23046. transpose(): Matrix;
  23047. /**
  23048. * Compute the transpose of the matrix and store it in a given matrix
  23049. * @param result defines the target matrix
  23050. * @returns the current matrix
  23051. */
  23052. transposeToRef(result: Matrix): Matrix;
  23053. /**
  23054. * Sets the index-th row of the current matrix with the given 4 x float values
  23055. * @param index defines the row index
  23056. * @param x defines the x component to set
  23057. * @param y defines the y component to set
  23058. * @param z defines the z component to set
  23059. * @param w defines the w component to set
  23060. * @returns the updated current matrix
  23061. */
  23062. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23063. /**
  23064. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23065. * @param scale defines the scale factor
  23066. * @returns a new matrix
  23067. */
  23068. scale(scale: number): Matrix;
  23069. /**
  23070. * Scale the current matrix values by a factor to a given result matrix
  23071. * @param scale defines the scale factor
  23072. * @param result defines the matrix to store the result
  23073. * @returns the current matrix
  23074. */
  23075. scaleToRef(scale: number, result: Matrix): Matrix;
  23076. /**
  23077. * Scale the current matrix values by a factor and add the result to a given matrix
  23078. * @param scale defines the scale factor
  23079. * @param result defines the Matrix to store the result
  23080. * @returns the current matrix
  23081. */
  23082. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23083. /**
  23084. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23085. * @param ref matrix to store the result
  23086. */
  23087. toNormalMatrix(ref: Matrix): void;
  23088. /**
  23089. * Gets only rotation part of the current matrix
  23090. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23091. */
  23092. getRotationMatrix(): Matrix;
  23093. /**
  23094. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23095. * @param result defines the target matrix to store data to
  23096. * @returns the current matrix
  23097. */
  23098. getRotationMatrixToRef(result: Matrix): Matrix;
  23099. /**
  23100. * Toggles model matrix from being right handed to left handed in place and vice versa
  23101. */
  23102. toggleModelMatrixHandInPlace(): void;
  23103. /**
  23104. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23105. */
  23106. toggleProjectionMatrixHandInPlace(): void;
  23107. /**
  23108. * Creates a matrix from an array
  23109. * @param array defines the source array
  23110. * @param offset defines an offset in the source array
  23111. * @returns a new Matrix set from the starting index of the given array
  23112. */
  23113. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23114. /**
  23115. * Copy the content of an array into a given matrix
  23116. * @param array defines the source array
  23117. * @param offset defines an offset in the source array
  23118. * @param result defines the target matrix
  23119. */
  23120. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23121. /**
  23122. * Stores an array into a matrix after having multiplied each component by a given factor
  23123. * @param array defines the source array
  23124. * @param offset defines the offset in the source array
  23125. * @param scale defines the scaling factor
  23126. * @param result defines the target matrix
  23127. */
  23128. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23129. /**
  23130. * Gets an identity matrix that must not be updated
  23131. */
  23132. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23133. /**
  23134. * Stores a list of values (16) inside a given matrix
  23135. * @param initialM11 defines 1st value of 1st row
  23136. * @param initialM12 defines 2nd value of 1st row
  23137. * @param initialM13 defines 3rd value of 1st row
  23138. * @param initialM14 defines 4th value of 1st row
  23139. * @param initialM21 defines 1st value of 2nd row
  23140. * @param initialM22 defines 2nd value of 2nd row
  23141. * @param initialM23 defines 3rd value of 2nd row
  23142. * @param initialM24 defines 4th value of 2nd row
  23143. * @param initialM31 defines 1st value of 3rd row
  23144. * @param initialM32 defines 2nd value of 3rd row
  23145. * @param initialM33 defines 3rd value of 3rd row
  23146. * @param initialM34 defines 4th value of 3rd row
  23147. * @param initialM41 defines 1st value of 4th row
  23148. * @param initialM42 defines 2nd value of 4th row
  23149. * @param initialM43 defines 3rd value of 4th row
  23150. * @param initialM44 defines 4th value of 4th row
  23151. * @param result defines the target matrix
  23152. */
  23153. 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;
  23154. /**
  23155. * Creates new matrix from a list of values (16)
  23156. * @param initialM11 defines 1st value of 1st row
  23157. * @param initialM12 defines 2nd value of 1st row
  23158. * @param initialM13 defines 3rd value of 1st row
  23159. * @param initialM14 defines 4th value of 1st row
  23160. * @param initialM21 defines 1st value of 2nd row
  23161. * @param initialM22 defines 2nd value of 2nd row
  23162. * @param initialM23 defines 3rd value of 2nd row
  23163. * @param initialM24 defines 4th value of 2nd row
  23164. * @param initialM31 defines 1st value of 3rd row
  23165. * @param initialM32 defines 2nd value of 3rd row
  23166. * @param initialM33 defines 3rd value of 3rd row
  23167. * @param initialM34 defines 4th value of 3rd row
  23168. * @param initialM41 defines 1st value of 4th row
  23169. * @param initialM42 defines 2nd value of 4th row
  23170. * @param initialM43 defines 3rd value of 4th row
  23171. * @param initialM44 defines 4th value of 4th row
  23172. * @returns the new matrix
  23173. */
  23174. 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;
  23175. /**
  23176. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23177. * @param scale defines the scale vector3
  23178. * @param rotation defines the rotation quaternion
  23179. * @param translation defines the translation vector3
  23180. * @returns a new matrix
  23181. */
  23182. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23183. /**
  23184. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23185. * @param scale defines the scale vector3
  23186. * @param rotation defines the rotation quaternion
  23187. * @param translation defines the translation vector3
  23188. * @param result defines the target matrix
  23189. */
  23190. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23191. /**
  23192. * Creates a new identity matrix
  23193. * @returns a new identity matrix
  23194. */
  23195. static Identity(): Matrix;
  23196. /**
  23197. * Creates a new identity matrix and stores the result in a given matrix
  23198. * @param result defines the target matrix
  23199. */
  23200. static IdentityToRef(result: Matrix): void;
  23201. /**
  23202. * Creates a new zero matrix
  23203. * @returns a new zero matrix
  23204. */
  23205. static Zero(): Matrix;
  23206. /**
  23207. * Creates a new rotation matrix for "angle" radians around the X axis
  23208. * @param angle defines the angle (in radians) to use
  23209. * @return the new matrix
  23210. */
  23211. static RotationX(angle: number): Matrix;
  23212. /**
  23213. * Creates a new matrix as the invert of a given matrix
  23214. * @param source defines the source matrix
  23215. * @returns the new matrix
  23216. */
  23217. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23218. /**
  23219. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23220. * @param angle defines the angle (in radians) to use
  23221. * @param result defines the target matrix
  23222. */
  23223. static RotationXToRef(angle: number, result: Matrix): void;
  23224. /**
  23225. * Creates a new rotation matrix for "angle" radians around the Y axis
  23226. * @param angle defines the angle (in radians) to use
  23227. * @return the new matrix
  23228. */
  23229. static RotationY(angle: number): Matrix;
  23230. /**
  23231. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23232. * @param angle defines the angle (in radians) to use
  23233. * @param result defines the target matrix
  23234. */
  23235. static RotationYToRef(angle: number, result: Matrix): void;
  23236. /**
  23237. * Creates a new rotation matrix for "angle" radians around the Z axis
  23238. * @param angle defines the angle (in radians) to use
  23239. * @return the new matrix
  23240. */
  23241. static RotationZ(angle: number): Matrix;
  23242. /**
  23243. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23244. * @param angle defines the angle (in radians) to use
  23245. * @param result defines the target matrix
  23246. */
  23247. static RotationZToRef(angle: number, result: Matrix): void;
  23248. /**
  23249. * Creates a new rotation matrix for "angle" radians around the given axis
  23250. * @param axis defines the axis to use
  23251. * @param angle defines the angle (in radians) to use
  23252. * @return the new matrix
  23253. */
  23254. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23255. /**
  23256. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23257. * @param axis defines the axis to use
  23258. * @param angle defines the angle (in radians) to use
  23259. * @param result defines the target matrix
  23260. */
  23261. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23262. /**
  23263. * Creates a rotation matrix
  23264. * @param yaw defines the yaw angle in radians (Y axis)
  23265. * @param pitch defines the pitch angle in radians (X axis)
  23266. * @param roll defines the roll angle in radians (X axis)
  23267. * @returns the new rotation matrix
  23268. */
  23269. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23270. /**
  23271. * Creates a rotation matrix and stores it in a given matrix
  23272. * @param yaw defines the yaw angle in radians (Y axis)
  23273. * @param pitch defines the pitch angle in radians (X axis)
  23274. * @param roll defines the roll angle in radians (X axis)
  23275. * @param result defines the target matrix
  23276. */
  23277. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23278. /**
  23279. * Creates a scaling matrix
  23280. * @param x defines the scale factor on X axis
  23281. * @param y defines the scale factor on Y axis
  23282. * @param z defines the scale factor on Z axis
  23283. * @returns the new matrix
  23284. */
  23285. static Scaling(x: number, y: number, z: number): Matrix;
  23286. /**
  23287. * Creates a scaling matrix and stores it in a given matrix
  23288. * @param x defines the scale factor on X axis
  23289. * @param y defines the scale factor on Y axis
  23290. * @param z defines the scale factor on Z axis
  23291. * @param result defines the target matrix
  23292. */
  23293. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23294. /**
  23295. * Creates a translation matrix
  23296. * @param x defines the translation on X axis
  23297. * @param y defines the translation on Y axis
  23298. * @param z defines the translationon Z axis
  23299. * @returns the new matrix
  23300. */
  23301. static Translation(x: number, y: number, z: number): Matrix;
  23302. /**
  23303. * Creates a translation matrix and stores it in a given matrix
  23304. * @param x defines the translation on X axis
  23305. * @param y defines the translation on Y axis
  23306. * @param z defines the translationon Z axis
  23307. * @param result defines the target matrix
  23308. */
  23309. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23310. /**
  23311. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23312. * @param startValue defines the start value
  23313. * @param endValue defines the end value
  23314. * @param gradient defines the gradient factor
  23315. * @returns the new matrix
  23316. */
  23317. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23318. /**
  23319. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23320. * @param startValue defines the start value
  23321. * @param endValue defines the end value
  23322. * @param gradient defines the gradient factor
  23323. * @param result defines the Matrix object where to store data
  23324. */
  23325. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23326. /**
  23327. * Builds a new matrix whose values are computed by:
  23328. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23329. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23330. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23331. * @param startValue defines the first matrix
  23332. * @param endValue defines the second matrix
  23333. * @param gradient defines the gradient between the two matrices
  23334. * @returns the new matrix
  23335. */
  23336. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23337. /**
  23338. * Update a matrix to values which are computed by:
  23339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23342. * @param startValue defines the first matrix
  23343. * @param endValue defines the second matrix
  23344. * @param gradient defines the gradient between the two matrices
  23345. * @param result defines the target matrix
  23346. */
  23347. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23348. /**
  23349. * 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"
  23350. * This function works in left handed mode
  23351. * @param eye defines the final position of the entity
  23352. * @param target defines where the entity should look at
  23353. * @param up defines the up vector for the entity
  23354. * @returns the new matrix
  23355. */
  23356. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23357. /**
  23358. * 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".
  23359. * This function works in left handed mode
  23360. * @param eye defines the final position of the entity
  23361. * @param target defines where the entity should look at
  23362. * @param up defines the up vector for the entity
  23363. * @param result defines the target matrix
  23364. */
  23365. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23366. /**
  23367. * 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"
  23368. * This function works in right handed mode
  23369. * @param eye defines the final position of the entity
  23370. * @param target defines where the entity should look at
  23371. * @param up defines the up vector for the entity
  23372. * @returns the new matrix
  23373. */
  23374. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23375. /**
  23376. * 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".
  23377. * This function works in right handed mode
  23378. * @param eye defines the final position of the entity
  23379. * @param target defines where the entity should look at
  23380. * @param up defines the up vector for the entity
  23381. * @param result defines the target matrix
  23382. */
  23383. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23384. /**
  23385. * Create a left-handed orthographic projection matrix
  23386. * @param width defines the viewport width
  23387. * @param height defines the viewport height
  23388. * @param znear defines the near clip plane
  23389. * @param zfar defines the far clip plane
  23390. * @returns a new matrix as a left-handed orthographic projection matrix
  23391. */
  23392. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23393. /**
  23394. * Store a left-handed orthographic projection to a given matrix
  23395. * @param width defines the viewport width
  23396. * @param height defines the viewport height
  23397. * @param znear defines the near clip plane
  23398. * @param zfar defines the far clip plane
  23399. * @param result defines the target matrix
  23400. */
  23401. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23402. /**
  23403. * Create a left-handed orthographic projection matrix
  23404. * @param left defines the viewport left coordinate
  23405. * @param right defines the viewport right coordinate
  23406. * @param bottom defines the viewport bottom coordinate
  23407. * @param top defines the viewport top coordinate
  23408. * @param znear defines the near clip plane
  23409. * @param zfar defines the far clip plane
  23410. * @returns a new matrix as a left-handed orthographic projection matrix
  23411. */
  23412. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23413. /**
  23414. * Stores a left-handed orthographic projection into a given matrix
  23415. * @param left defines the viewport left coordinate
  23416. * @param right defines the viewport right coordinate
  23417. * @param bottom defines the viewport bottom coordinate
  23418. * @param top defines the viewport top coordinate
  23419. * @param znear defines the near clip plane
  23420. * @param zfar defines the far clip plane
  23421. * @param result defines the target matrix
  23422. */
  23423. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23424. /**
  23425. * Creates a right-handed orthographic projection matrix
  23426. * @param left defines the viewport left coordinate
  23427. * @param right defines the viewport right coordinate
  23428. * @param bottom defines the viewport bottom coordinate
  23429. * @param top defines the viewport top coordinate
  23430. * @param znear defines the near clip plane
  23431. * @param zfar defines the far clip plane
  23432. * @returns a new matrix as a right-handed orthographic projection matrix
  23433. */
  23434. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23435. /**
  23436. * Stores a right-handed orthographic projection into a given matrix
  23437. * @param left defines the viewport left coordinate
  23438. * @param right defines the viewport right coordinate
  23439. * @param bottom defines the viewport bottom coordinate
  23440. * @param top defines the viewport top coordinate
  23441. * @param znear defines the near clip plane
  23442. * @param zfar defines the far clip plane
  23443. * @param result defines the target matrix
  23444. */
  23445. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23446. /**
  23447. * Creates a left-handed perspective projection matrix
  23448. * @param width defines the viewport width
  23449. * @param height defines the viewport height
  23450. * @param znear defines the near clip plane
  23451. * @param zfar defines the far clip plane
  23452. * @returns a new matrix as a left-handed perspective projection matrix
  23453. */
  23454. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23455. /**
  23456. * Creates a left-handed perspective projection matrix
  23457. * @param fov defines the horizontal field of view
  23458. * @param aspect defines the aspect ratio
  23459. * @param znear defines the near clip plane
  23460. * @param zfar defines the far clip plane
  23461. * @returns a new matrix as a left-handed perspective projection matrix
  23462. */
  23463. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23464. /**
  23465. * Stores a left-handed perspective projection into a given matrix
  23466. * @param fov defines the horizontal field of view
  23467. * @param aspect defines the aspect ratio
  23468. * @param znear defines the near clip plane
  23469. * @param zfar defines the far clip plane
  23470. * @param result defines the target matrix
  23471. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23472. */
  23473. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23474. /**
  23475. * Creates a right-handed perspective projection matrix
  23476. * @param fov defines the horizontal field of view
  23477. * @param aspect defines the aspect ratio
  23478. * @param znear defines the near clip plane
  23479. * @param zfar defines the far clip plane
  23480. * @returns a new matrix as a right-handed perspective projection matrix
  23481. */
  23482. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23483. /**
  23484. * Stores a right-handed perspective projection into a given matrix
  23485. * @param fov defines the horizontal field of view
  23486. * @param aspect defines the aspect ratio
  23487. * @param znear defines the near clip plane
  23488. * @param zfar defines the far clip plane
  23489. * @param result defines the target matrix
  23490. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23491. */
  23492. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23493. /**
  23494. * Stores a perspective projection for WebVR info a given matrix
  23495. * @param fov defines the field of view
  23496. * @param znear defines the near clip plane
  23497. * @param zfar defines the far clip plane
  23498. * @param result defines the target matrix
  23499. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23500. */
  23501. static PerspectiveFovWebVRToRef(fov: {
  23502. upDegrees: number;
  23503. downDegrees: number;
  23504. leftDegrees: number;
  23505. rightDegrees: number;
  23506. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23507. /**
  23508. * Computes a complete transformation matrix
  23509. * @param viewport defines the viewport to use
  23510. * @param world defines the world matrix
  23511. * @param view defines the view matrix
  23512. * @param projection defines the projection matrix
  23513. * @param zmin defines the near clip plane
  23514. * @param zmax defines the far clip plane
  23515. * @returns the transformation matrix
  23516. */
  23517. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23518. /**
  23519. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23520. * @param matrix defines the matrix to use
  23521. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23522. */
  23523. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23524. /**
  23525. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23526. * @param matrix defines the matrix to use
  23527. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23528. */
  23529. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23530. /**
  23531. * Compute the transpose of a given matrix
  23532. * @param matrix defines the matrix to transpose
  23533. * @returns the new matrix
  23534. */
  23535. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23536. /**
  23537. * Compute the transpose of a matrix and store it in a target matrix
  23538. * @param matrix defines the matrix to transpose
  23539. * @param result defines the target matrix
  23540. */
  23541. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23542. /**
  23543. * Computes a reflection matrix from a plane
  23544. * @param plane defines the reflection plane
  23545. * @returns a new matrix
  23546. */
  23547. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23548. /**
  23549. * Computes a reflection matrix from a plane
  23550. * @param plane defines the reflection plane
  23551. * @param result defines the target matrix
  23552. */
  23553. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23554. /**
  23555. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23556. * @param xaxis defines the value of the 1st axis
  23557. * @param yaxis defines the value of the 2nd axis
  23558. * @param zaxis defines the value of the 3rd axis
  23559. * @param result defines the target matrix
  23560. */
  23561. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23562. /**
  23563. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23564. * @param quat defines the quaternion to use
  23565. * @param result defines the target matrix
  23566. */
  23567. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23568. }
  23569. /**
  23570. * Represens a plane by the equation ax + by + cz + d = 0
  23571. */
  23572. class Plane {
  23573. /**
  23574. * Normal of the plane (a,b,c)
  23575. */
  23576. normal: Vector3;
  23577. /**
  23578. * d component of the plane
  23579. */
  23580. d: number;
  23581. /**
  23582. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23583. * @param a a component of the plane
  23584. * @param b b component of the plane
  23585. * @param c c component of the plane
  23586. * @param d d component of the plane
  23587. */
  23588. constructor(a: number, b: number, c: number, d: number);
  23589. /**
  23590. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23591. */
  23592. asArray(): number[];
  23593. /**
  23594. * @returns a new plane copied from the current Plane.
  23595. */
  23596. clone(): Plane;
  23597. /**
  23598. * @returns the string "Plane".
  23599. */
  23600. getClassName(): string;
  23601. /**
  23602. * @returns the Plane hash code.
  23603. */
  23604. getHashCode(): number;
  23605. /**
  23606. * Normalize the current Plane in place.
  23607. * @returns the updated Plane.
  23608. */
  23609. normalize(): Plane;
  23610. /**
  23611. * Applies a transformation the plane and returns the result
  23612. * @param transformation the transformation matrix to be applied to the plane
  23613. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23614. */
  23615. transform(transformation: DeepImmutable<Matrix>): Plane;
  23616. /**
  23617. * Calcualtte the dot product between the point and the plane normal
  23618. * @param point point to calculate the dot product with
  23619. * @returns the dot product (float) of the point coordinates and the plane normal.
  23620. */
  23621. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23622. /**
  23623. * Updates the current Plane from the plane defined by the three given points.
  23624. * @param point1 one of the points used to contruct the plane
  23625. * @param point2 one of the points used to contruct the plane
  23626. * @param point3 one of the points used to contruct the plane
  23627. * @returns the updated Plane.
  23628. */
  23629. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23630. /**
  23631. * Checks if the plane is facing a given direction
  23632. * @param direction the direction to check if the plane is facing
  23633. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23634. * @returns True is the vector "direction" is the same side than the plane normal.
  23635. */
  23636. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23637. /**
  23638. * Calculates the distance to a point
  23639. * @param point point to calculate distance to
  23640. * @returns the signed distance (float) from the given point to the Plane.
  23641. */
  23642. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23643. /**
  23644. * Creates a plane from an array
  23645. * @param array the array to create a plane from
  23646. * @returns a new Plane from the given array.
  23647. */
  23648. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23649. /**
  23650. * Creates a plane from three points
  23651. * @param point1 point used to create the plane
  23652. * @param point2 point used to create the plane
  23653. * @param point3 point used to create the plane
  23654. * @returns a new Plane defined by the three given points.
  23655. */
  23656. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23657. /**
  23658. * Creates a plane from an origin point and a normal
  23659. * @param origin origin of the plane to be constructed
  23660. * @param normal normal of the plane to be constructed
  23661. * @returns a new Plane the normal vector to this plane at the given origin point.
  23662. * Note : the vector "normal" is updated because normalized.
  23663. */
  23664. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23665. /**
  23666. * Calculates the distance from a plane and a point
  23667. * @param origin origin of the plane to be constructed
  23668. * @param normal normal of the plane to be constructed
  23669. * @param point point to calculate distance to
  23670. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23671. */
  23672. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23673. }
  23674. /**
  23675. * Class used to represent a viewport on screen
  23676. */
  23677. class Viewport {
  23678. /** viewport left coordinate */
  23679. x: number;
  23680. /** viewport top coordinate */
  23681. y: number;
  23682. /**viewport width */
  23683. width: number;
  23684. /** viewport height */
  23685. height: number;
  23686. /**
  23687. * Creates a Viewport object located at (x, y) and sized (width, height)
  23688. * @param x defines viewport left coordinate
  23689. * @param y defines viewport top coordinate
  23690. * @param width defines the viewport width
  23691. * @param height defines the viewport height
  23692. */
  23693. constructor(
  23694. /** viewport left coordinate */
  23695. x: number,
  23696. /** viewport top coordinate */
  23697. y: number,
  23698. /**viewport width */
  23699. width: number,
  23700. /** viewport height */
  23701. height: number);
  23702. /**
  23703. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23704. * @param renderWidthOrEngine defines either an engine or the rendering width
  23705. * @param renderHeight defines the rendering height
  23706. * @returns a new Viewport
  23707. */
  23708. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23709. /**
  23710. * Returns a new Viewport copied from the current one
  23711. * @returns a new Viewport
  23712. */
  23713. clone(): Viewport;
  23714. }
  23715. /**
  23716. * Reprasents a camera frustum
  23717. */
  23718. class Frustum {
  23719. /**
  23720. * Gets the planes representing the frustum
  23721. * @param transform matrix to be applied to the returned planes
  23722. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23723. */
  23724. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23725. /**
  23726. * Gets the near frustum plane transformed by the transform matrix
  23727. * @param transform transformation matrix to be applied to the resulting frustum plane
  23728. * @param frustumPlane the resuling frustum plane
  23729. */
  23730. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23731. /**
  23732. * Gets the far frustum plane transformed by the transform matrix
  23733. * @param transform transformation matrix to be applied to the resulting frustum plane
  23734. * @param frustumPlane the resuling frustum plane
  23735. */
  23736. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23737. /**
  23738. * Gets the left frustum plane transformed by the transform matrix
  23739. * @param transform transformation matrix to be applied to the resulting frustum plane
  23740. * @param frustumPlane the resuling frustum plane
  23741. */
  23742. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23743. /**
  23744. * Gets the right frustum plane transformed by the transform matrix
  23745. * @param transform transformation matrix to be applied to the resulting frustum plane
  23746. * @param frustumPlane the resuling frustum plane
  23747. */
  23748. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23749. /**
  23750. * Gets the top frustum plane transformed by the transform matrix
  23751. * @param transform transformation matrix to be applied to the resulting frustum plane
  23752. * @param frustumPlane the resuling frustum plane
  23753. */
  23754. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23755. /**
  23756. * Gets the bottom frustum plane transformed by the transform matrix
  23757. * @param transform transformation matrix to be applied to the resulting frustum plane
  23758. * @param frustumPlane the resuling frustum plane
  23759. */
  23760. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23761. /**
  23762. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23763. * @param transform transformation matrix to be applied to the resulting frustum planes
  23764. * @param frustumPlanes the resuling frustum planes
  23765. */
  23766. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23767. }
  23768. /** Defines supported spaces */
  23769. enum Space {
  23770. /** Local (object) space */
  23771. LOCAL = 0,
  23772. /** World space */
  23773. WORLD = 1,
  23774. /** Bone space */
  23775. BONE = 2
  23776. }
  23777. /** Defines the 3 main axes */
  23778. class Axis {
  23779. /** X axis */
  23780. static X: Vector3;
  23781. /** Y axis */
  23782. static Y: Vector3;
  23783. /** Z axis */
  23784. static Z: Vector3;
  23785. }
  23786. /** Class used to represent a Bezier curve */
  23787. class BezierCurve {
  23788. /**
  23789. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23790. * @param t defines the time
  23791. * @param x1 defines the left coordinate on X axis
  23792. * @param y1 defines the left coordinate on Y axis
  23793. * @param x2 defines the right coordinate on X axis
  23794. * @param y2 defines the right coordinate on Y axis
  23795. * @returns the interpolated value
  23796. */
  23797. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23798. }
  23799. /**
  23800. * Defines potential orientation for back face culling
  23801. */
  23802. enum Orientation {
  23803. /**
  23804. * Clockwise
  23805. */
  23806. CW = 0,
  23807. /** Counter clockwise */
  23808. CCW = 1
  23809. }
  23810. /**
  23811. * Defines angle representation
  23812. */
  23813. class Angle {
  23814. private _radians;
  23815. /**
  23816. * Creates an Angle object of "radians" radians (float).
  23817. */
  23818. constructor(radians: number);
  23819. /**
  23820. * Get value in degrees
  23821. * @returns the Angle value in degrees (float)
  23822. */
  23823. degrees(): number;
  23824. /**
  23825. * Get value in radians
  23826. * @returns the Angle value in radians (float)
  23827. */
  23828. radians(): number;
  23829. /**
  23830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23831. * @param a defines first vector
  23832. * @param b defines second vector
  23833. * @returns a new Angle
  23834. */
  23835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23836. /**
  23837. * Gets a new Angle object from the given float in radians
  23838. * @param radians defines the angle value in radians
  23839. * @returns a new Angle
  23840. */
  23841. static FromRadians(radians: number): Angle;
  23842. /**
  23843. * Gets a new Angle object from the given float in degrees
  23844. * @param degrees defines the angle value in degrees
  23845. * @returns a new Angle
  23846. */
  23847. static FromDegrees(degrees: number): Angle;
  23848. }
  23849. /**
  23850. * This represents an arc in a 2d space.
  23851. */
  23852. class Arc2 {
  23853. /** Defines the start point of the arc */
  23854. startPoint: Vector2;
  23855. /** Defines the mid point of the arc */
  23856. midPoint: Vector2;
  23857. /** Defines the end point of the arc */
  23858. endPoint: Vector2;
  23859. /**
  23860. * Defines the center point of the arc.
  23861. */
  23862. centerPoint: Vector2;
  23863. /**
  23864. * Defines the radius of the arc.
  23865. */
  23866. radius: number;
  23867. /**
  23868. * Defines the angle of the arc (from mid point to end point).
  23869. */
  23870. angle: Angle;
  23871. /**
  23872. * Defines the start angle of the arc (from start point to middle point).
  23873. */
  23874. startAngle: Angle;
  23875. /**
  23876. * Defines the orientation of the arc (clock wise/counter clock wise).
  23877. */
  23878. orientation: Orientation;
  23879. /**
  23880. * Creates an Arc object from the three given points : start, middle and end.
  23881. * @param startPoint Defines the start point of the arc
  23882. * @param midPoint Defines the midlle point of the arc
  23883. * @param endPoint Defines the end point of the arc
  23884. */
  23885. constructor(
  23886. /** Defines the start point of the arc */
  23887. startPoint: Vector2,
  23888. /** Defines the mid point of the arc */
  23889. midPoint: Vector2,
  23890. /** Defines the end point of the arc */
  23891. endPoint: Vector2);
  23892. }
  23893. /**
  23894. * Represents a 2D path made up of multiple 2D points
  23895. */
  23896. class Path2 {
  23897. private _points;
  23898. private _length;
  23899. /**
  23900. * If the path start and end point are the same
  23901. */
  23902. closed: boolean;
  23903. /**
  23904. * Creates a Path2 object from the starting 2D coordinates x and y.
  23905. * @param x the starting points x value
  23906. * @param y the starting points y value
  23907. */
  23908. constructor(x: number, y: number);
  23909. /**
  23910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23911. * @param x the added points x value
  23912. * @param y the added points y value
  23913. * @returns the updated Path2.
  23914. */
  23915. addLineTo(x: number, y: number): Path2;
  23916. /**
  23917. * 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.
  23918. * @param midX middle point x value
  23919. * @param midY middle point y value
  23920. * @param endX end point x value
  23921. * @param endY end point y value
  23922. * @param numberOfSegments (default: 36)
  23923. * @returns the updated Path2.
  23924. */
  23925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23926. /**
  23927. * Closes the Path2.
  23928. * @returns the Path2.
  23929. */
  23930. close(): Path2;
  23931. /**
  23932. * Gets the sum of the distance between each sequential point in the path
  23933. * @returns the Path2 total length (float).
  23934. */
  23935. length(): number;
  23936. /**
  23937. * Gets the points which construct the path
  23938. * @returns the Path2 internal array of points.
  23939. */
  23940. getPoints(): Vector2[];
  23941. /**
  23942. * Retreives the point at the distance aways from the starting point
  23943. * @param normalizedLengthPosition the length along the path to retreive the point from
  23944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23945. */
  23946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23947. /**
  23948. * Creates a new path starting from an x and y position
  23949. * @param x starting x value
  23950. * @param y starting y value
  23951. * @returns a new Path2 starting at the coordinates (x, y).
  23952. */
  23953. static StartingAt(x: number, y: number): Path2;
  23954. }
  23955. /**
  23956. * Represents a 3D path made up of multiple 3D points
  23957. */
  23958. class Path3D {
  23959. /**
  23960. * an array of Vector3, the curve axis of the Path3D
  23961. */
  23962. path: Vector3[];
  23963. private _curve;
  23964. private _distances;
  23965. private _tangents;
  23966. private _normals;
  23967. private _binormals;
  23968. private _raw;
  23969. /**
  23970. * new Path3D(path, normal, raw)
  23971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  23973. * @param path an array of Vector3, the curve axis of the Path3D
  23974. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23976. */
  23977. constructor(
  23978. /**
  23979. * an array of Vector3, the curve axis of the Path3D
  23980. */
  23981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23982. /**
  23983. * Returns the Path3D array of successive Vector3 designing its curve.
  23984. * @returns the Path3D array of successive Vector3 designing its curve.
  23985. */
  23986. getCurve(): Vector3[];
  23987. /**
  23988. * Returns an array populated with tangent vectors on each Path3D curve point.
  23989. * @returns an array populated with tangent vectors on each Path3D curve point.
  23990. */
  23991. getTangents(): Vector3[];
  23992. /**
  23993. * Returns an array populated with normal vectors on each Path3D curve point.
  23994. * @returns an array populated with normal vectors on each Path3D curve point.
  23995. */
  23996. getNormals(): Vector3[];
  23997. /**
  23998. * Returns an array populated with binormal vectors on each Path3D curve point.
  23999. * @returns an array populated with binormal vectors on each Path3D curve point.
  24000. */
  24001. getBinormals(): Vector3[];
  24002. /**
  24003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24005. */
  24006. getDistances(): number[];
  24007. /**
  24008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24009. * @param path path which all values are copied into the curves points
  24010. * @param firstNormal which should be projected onto the curve
  24011. * @returns the same object updated.
  24012. */
  24013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24014. private _compute;
  24015. private _getFirstNonNullVector;
  24016. private _getLastNonNullVector;
  24017. private _normalVector;
  24018. }
  24019. /**
  24020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24021. * A Curve3 is designed from a series of successive Vector3.
  24022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24023. */
  24024. class Curve3 {
  24025. private _points;
  24026. private _length;
  24027. /**
  24028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24030. * @param v1 (Vector3) the control point
  24031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24032. * @param nbPoints (integer) the wanted number of points in the curve
  24033. * @returns the created Curve3
  24034. */
  24035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24036. /**
  24037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24039. * @param v1 (Vector3) the first control point
  24040. * @param v2 (Vector3) the second control point
  24041. * @param v3 (Vector3) the end point of the Cubic Bezier
  24042. * @param nbPoints (integer) the wanted number of points in the curve
  24043. * @returns the created Curve3
  24044. */
  24045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24046. /**
  24047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24048. * @param p1 (Vector3) the origin point of the Hermite Spline
  24049. * @param t1 (Vector3) the tangent vector at the origin point
  24050. * @param p2 (Vector3) the end point of the Hermite Spline
  24051. * @param t2 (Vector3) the tangent vector at the end point
  24052. * @param nbPoints (integer) the wanted number of points in the curve
  24053. * @returns the created Curve3
  24054. */
  24055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24056. /**
  24057. * Returns a Curve3 object along a CatmullRom Spline curve :
  24058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24059. * @param nbPoints (integer) the wanted number of points between each curve control points
  24060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24061. * @returns the created Curve3
  24062. */
  24063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24064. /**
  24065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24066. * A Curve3 is designed from a series of successive Vector3.
  24067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24068. * @param points points which make up the curve
  24069. */
  24070. constructor(points: Vector3[]);
  24071. /**
  24072. * @returns the Curve3 stored array of successive Vector3
  24073. */
  24074. getPoints(): Vector3[];
  24075. /**
  24076. * @returns the computed length (float) of the curve.
  24077. */
  24078. length(): number;
  24079. /**
  24080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24082. * curveA and curveB keep unchanged.
  24083. * @param curve the curve to continue from this curve
  24084. * @returns the newly constructed curve
  24085. */
  24086. continue(curve: DeepImmutable<Curve3>): Curve3;
  24087. private _computeLength;
  24088. }
  24089. /**
  24090. * Contains position and normal vectors for a vertex
  24091. */
  24092. class PositionNormalVertex {
  24093. /** the position of the vertex (defaut: 0,0,0) */
  24094. position: Vector3;
  24095. /** the normal of the vertex (defaut: 0,1,0) */
  24096. normal: Vector3;
  24097. /**
  24098. * Creates a PositionNormalVertex
  24099. * @param position the position of the vertex (defaut: 0,0,0)
  24100. * @param normal the normal of the vertex (defaut: 0,1,0)
  24101. */
  24102. constructor(
  24103. /** the position of the vertex (defaut: 0,0,0) */
  24104. position?: Vector3,
  24105. /** the normal of the vertex (defaut: 0,1,0) */
  24106. normal?: Vector3);
  24107. /**
  24108. * Clones the PositionNormalVertex
  24109. * @returns the cloned PositionNormalVertex
  24110. */
  24111. clone(): PositionNormalVertex;
  24112. }
  24113. /**
  24114. * Contains position, normal and uv vectors for a vertex
  24115. */
  24116. class PositionNormalTextureVertex {
  24117. /** the position of the vertex (defaut: 0,0,0) */
  24118. position: Vector3;
  24119. /** the normal of the vertex (defaut: 0,1,0) */
  24120. normal: Vector3;
  24121. /** the uv of the vertex (default: 0,0) */
  24122. uv: Vector2;
  24123. /**
  24124. * Creates a PositionNormalTextureVertex
  24125. * @param position the position of the vertex (defaut: 0,0,0)
  24126. * @param normal the normal of the vertex (defaut: 0,1,0)
  24127. * @param uv the uv of the vertex (default: 0,0)
  24128. */
  24129. constructor(
  24130. /** the position of the vertex (defaut: 0,0,0) */
  24131. position?: Vector3,
  24132. /** the normal of the vertex (defaut: 0,1,0) */
  24133. normal?: Vector3,
  24134. /** the uv of the vertex (default: 0,0) */
  24135. uv?: Vector2);
  24136. /**
  24137. * Clones the PositionNormalTextureVertex
  24138. * @returns the cloned PositionNormalTextureVertex
  24139. */
  24140. clone(): PositionNormalTextureVertex;
  24141. }
  24142. /**
  24143. * @hidden
  24144. */
  24145. class Tmp {
  24146. static Color3: Color3[];
  24147. static Color4: Color4[];
  24148. static Vector2: Vector2[];
  24149. static Vector3: Vector3[];
  24150. static Vector4: Vector4[];
  24151. static Quaternion: Quaternion[];
  24152. static Matrix: Matrix[];
  24153. }
  24154. }
  24155. declare module BABYLON {
  24156. /**
  24157. * Class representing spherical polynomial coefficients to the 3rd degree
  24158. */
  24159. class SphericalPolynomial {
  24160. /**
  24161. * The x coefficients of the spherical polynomial
  24162. */
  24163. x: Vector3;
  24164. /**
  24165. * The y coefficients of the spherical polynomial
  24166. */
  24167. y: Vector3;
  24168. /**
  24169. * The z coefficients of the spherical polynomial
  24170. */
  24171. z: Vector3;
  24172. /**
  24173. * The xx coefficients of the spherical polynomial
  24174. */
  24175. xx: Vector3;
  24176. /**
  24177. * The yy coefficients of the spherical polynomial
  24178. */
  24179. yy: Vector3;
  24180. /**
  24181. * The zz coefficients of the spherical polynomial
  24182. */
  24183. zz: Vector3;
  24184. /**
  24185. * The xy coefficients of the spherical polynomial
  24186. */
  24187. xy: Vector3;
  24188. /**
  24189. * The yz coefficients of the spherical polynomial
  24190. */
  24191. yz: Vector3;
  24192. /**
  24193. * The zx coefficients of the spherical polynomial
  24194. */
  24195. zx: Vector3;
  24196. /**
  24197. * Adds an ambient color to the spherical polynomial
  24198. * @param color the color to add
  24199. */
  24200. addAmbient(color: Color3): void;
  24201. /**
  24202. * Scales the spherical polynomial by the given amount
  24203. * @param scale the amount to scale
  24204. */
  24205. scale(scale: number): void;
  24206. /**
  24207. * Gets the spherical polynomial from harmonics
  24208. * @param harmonics the spherical harmonics
  24209. * @returns the spherical polynomial
  24210. */
  24211. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24212. /**
  24213. * Constructs a spherical polynomial from an array.
  24214. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24215. * @returns the spherical polynomial
  24216. */
  24217. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24218. }
  24219. /**
  24220. * Class representing spherical harmonics coefficients to the 3rd degree
  24221. */
  24222. class SphericalHarmonics {
  24223. /**
  24224. * The l0,0 coefficients of the spherical harmonics
  24225. */
  24226. l00: Vector3;
  24227. /**
  24228. * The l1,-1 coefficients of the spherical harmonics
  24229. */
  24230. l1_1: Vector3;
  24231. /**
  24232. * The l1,0 coefficients of the spherical harmonics
  24233. */
  24234. l10: Vector3;
  24235. /**
  24236. * The l1,1 coefficients of the spherical harmonics
  24237. */
  24238. l11: Vector3;
  24239. /**
  24240. * The l2,-2 coefficients of the spherical harmonics
  24241. */
  24242. l2_2: Vector3;
  24243. /**
  24244. * The l2,-1 coefficients of the spherical harmonics
  24245. */
  24246. l2_1: Vector3;
  24247. /**
  24248. * The l2,0 coefficients of the spherical harmonics
  24249. */
  24250. l20: Vector3;
  24251. /**
  24252. * The l2,1 coefficients of the spherical harmonics
  24253. */
  24254. l21: Vector3;
  24255. /**
  24256. * The l2,2 coefficients of the spherical harmonics
  24257. */
  24258. lL22: Vector3;
  24259. /**
  24260. * Adds a light to the spherical harmonics
  24261. * @param direction the direction of the light
  24262. * @param color the color of the light
  24263. * @param deltaSolidAngle the delta solid angle of the light
  24264. */
  24265. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24266. /**
  24267. * Scales the spherical harmonics by the given amount
  24268. * @param scale the amount to scale
  24269. */
  24270. scale(scale: number): void;
  24271. /**
  24272. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24273. *
  24274. * ```
  24275. * E_lm = A_l * L_lm
  24276. * ```
  24277. *
  24278. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24279. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24280. * the scaling factors are given in equation 9.
  24281. */
  24282. convertIncidentRadianceToIrradiance(): void;
  24283. /**
  24284. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24285. *
  24286. * ```
  24287. * L = (1/pi) * E * rho
  24288. * ```
  24289. *
  24290. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24291. */
  24292. convertIrradianceToLambertianRadiance(): void;
  24293. /**
  24294. * Gets the spherical harmonics from polynomial
  24295. * @param polynomial the spherical polynomial
  24296. * @returns the spherical harmonics
  24297. */
  24298. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24299. /**
  24300. * Constructs a spherical harmonics from an array.
  24301. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24302. * @returns the spherical harmonics
  24303. */
  24304. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24305. }
  24306. }
  24307. declare module BABYLON {
  24308. /**
  24309. * Class used to store all common mesh properties
  24310. */
  24311. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24312. /** No occlusion */
  24313. static OCCLUSION_TYPE_NONE: number;
  24314. /** Occlusion set to optimisitic */
  24315. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24316. /** Occlusion set to strict */
  24317. static OCCLUSION_TYPE_STRICT: number;
  24318. /** Use an accurante occlusion algorithm */
  24319. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24320. /** Use a conservative occlusion algorithm */
  24321. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24322. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24323. static readonly CULLINGSTRATEGY_STANDARD: number;
  24324. /** Culling strategy with bounding sphere only and then frustum culling */
  24325. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24326. /**
  24327. * No billboard
  24328. */
  24329. static readonly BILLBOARDMODE_NONE: number;
  24330. /** Billboard on X axis */
  24331. static readonly BILLBOARDMODE_X: number;
  24332. /** Billboard on Y axis */
  24333. static readonly BILLBOARDMODE_Y: number;
  24334. /** Billboard on Z axis */
  24335. static readonly BILLBOARDMODE_Z: number;
  24336. /** Billboard on all axes */
  24337. static readonly BILLBOARDMODE_ALL: number;
  24338. private _facetData;
  24339. /** Gets ot sets the culling strategy to use to find visible meshes */
  24340. cullingStrategy: number;
  24341. /**
  24342. * Gets the number of facets in the mesh
  24343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24344. */
  24345. readonly facetNb: number;
  24346. /**
  24347. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24349. */
  24350. partitioningSubdivisions: number;
  24351. /**
  24352. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24353. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24355. */
  24356. partitioningBBoxRatio: number;
  24357. /**
  24358. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24359. * Works only for updatable meshes.
  24360. * Doesn't work with multi-materials
  24361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24362. */
  24363. mustDepthSortFacets: boolean;
  24364. /**
  24365. * The location (Vector3) where the facet depth sort must be computed from.
  24366. * By default, the active camera position.
  24367. * Used only when facet depth sort is enabled
  24368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24369. */
  24370. facetDepthSortFrom: Vector3;
  24371. /**
  24372. * gets a boolean indicating if facetData is enabled
  24373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24374. */
  24375. readonly isFacetDataEnabled: boolean;
  24376. /** @hidden */
  24377. _updateNonUniformScalingState(value: boolean): boolean;
  24378. /**
  24379. * An event triggered when this mesh collides with another one
  24380. */
  24381. onCollideObservable: Observable<AbstractMesh>;
  24382. private _onCollideObserver;
  24383. /** Set a function to call when this mesh collides with another one */
  24384. onCollide: () => void;
  24385. /**
  24386. * An event triggered when the collision's position changes
  24387. */
  24388. onCollisionPositionChangeObservable: Observable<Vector3>;
  24389. private _onCollisionPositionChangeObserver;
  24390. /** Set a function to call when the collision's position changes */
  24391. onCollisionPositionChange: () => void;
  24392. /**
  24393. * An event triggered when material is changed
  24394. */
  24395. onMaterialChangedObservable: Observable<AbstractMesh>;
  24396. /**
  24397. * Gets or sets the orientation for POV movement & rotation
  24398. */
  24399. definedFacingForward: boolean;
  24400. /** @hidden */
  24401. _occlusionQuery: Nullable<WebGLQuery>;
  24402. private _visibility;
  24403. /**
  24404. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24405. */
  24406. /**
  24407. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24408. */
  24409. visibility: number;
  24410. /** Gets or sets the alpha index used to sort transparent meshes
  24411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24412. */
  24413. alphaIndex: number;
  24414. /**
  24415. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24416. */
  24417. isVisible: boolean;
  24418. /**
  24419. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24420. */
  24421. isPickable: boolean;
  24422. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24423. showSubMeshesBoundingBox: boolean;
  24424. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24425. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24426. */
  24427. isBlocker: boolean;
  24428. /**
  24429. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24430. */
  24431. enablePointerMoveEvents: boolean;
  24432. /**
  24433. * Specifies the rendering group id for this mesh (0 by default)
  24434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24435. */
  24436. renderingGroupId: number;
  24437. private _material;
  24438. /** Gets or sets current material */
  24439. material: Nullable<Material>;
  24440. private _receiveShadows;
  24441. /**
  24442. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24443. * @see http://doc.babylonjs.com/babylon101/shadows
  24444. */
  24445. receiveShadows: boolean;
  24446. /** Defines color to use when rendering outline */
  24447. outlineColor: Color3;
  24448. /** Define width to use when rendering outline */
  24449. outlineWidth: number;
  24450. /** Defines color to use when rendering overlay */
  24451. overlayColor: Color3;
  24452. /** Defines alpha to use when rendering overlay */
  24453. overlayAlpha: number;
  24454. private _hasVertexAlpha;
  24455. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24456. hasVertexAlpha: boolean;
  24457. private _useVertexColors;
  24458. /** 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) */
  24459. useVertexColors: boolean;
  24460. private _computeBonesUsingShaders;
  24461. /**
  24462. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24463. */
  24464. computeBonesUsingShaders: boolean;
  24465. private _numBoneInfluencers;
  24466. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24467. numBoneInfluencers: number;
  24468. private _applyFog;
  24469. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24470. applyFog: boolean;
  24471. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24472. useOctreeForRenderingSelection: boolean;
  24473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24474. useOctreeForPicking: boolean;
  24475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24476. useOctreeForCollisions: boolean;
  24477. private _layerMask;
  24478. /**
  24479. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24480. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24481. */
  24482. layerMask: number;
  24483. /**
  24484. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24485. */
  24486. alwaysSelectAsActiveMesh: boolean;
  24487. /**
  24488. * Gets or sets the current action manager
  24489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24490. */
  24491. actionManager: Nullable<ActionManager>;
  24492. private _checkCollisions;
  24493. private _collisionMask;
  24494. private _collisionGroup;
  24495. /**
  24496. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24498. */
  24499. ellipsoid: Vector3;
  24500. /**
  24501. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24503. */
  24504. ellipsoidOffset: Vector3;
  24505. private _collider;
  24506. private _oldPositionForCollisions;
  24507. private _diffPositionForCollisions;
  24508. /**
  24509. * Gets or sets a collision mask used to mask collisions (default is -1).
  24510. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24511. */
  24512. collisionMask: number;
  24513. /**
  24514. * Gets or sets the current collision group mask (-1 by default).
  24515. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24516. */
  24517. collisionGroup: number;
  24518. /**
  24519. * Defines edge width used when edgesRenderer is enabled
  24520. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24521. */
  24522. edgesWidth: number;
  24523. /**
  24524. * Defines edge color used when edgesRenderer is enabled
  24525. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24526. */
  24527. edgesColor: Color4;
  24528. /** @hidden */
  24529. _edgesRenderer: Nullable<IEdgesRenderer>;
  24530. /** @hidden */
  24531. _masterMesh: Nullable<AbstractMesh>;
  24532. /** @hidden */
  24533. _boundingInfo: Nullable<BoundingInfo>;
  24534. /** @hidden */
  24535. _renderId: number;
  24536. /**
  24537. * Gets or sets the list of subMeshes
  24538. * @see http://doc.babylonjs.com/how_to/multi_materials
  24539. */
  24540. subMeshes: SubMesh[];
  24541. /** @hidden */
  24542. _intersectionsInProgress: AbstractMesh[];
  24543. /** @hidden */
  24544. _unIndexed: boolean;
  24545. /** @hidden */
  24546. _lightSources: Light[];
  24547. /** @hidden */
  24548. readonly _positions: Nullable<Vector3[]>;
  24549. /** @hidden */
  24550. _waitingActions: any;
  24551. /** @hidden */
  24552. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24553. private _skeleton;
  24554. /** @hidden */
  24555. _bonesTransformMatrices: Nullable<Float32Array>;
  24556. /**
  24557. * Gets or sets a skeleton to apply skining transformations
  24558. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24559. */
  24560. skeleton: Nullable<Skeleton>;
  24561. /**
  24562. * An event triggered when the mesh is rebuilt.
  24563. */
  24564. onRebuildObservable: Observable<AbstractMesh>;
  24565. /**
  24566. * Creates a new AbstractMesh
  24567. * @param name defines the name of the mesh
  24568. * @param scene defines the hosting scene
  24569. */
  24570. constructor(name: string, scene?: Nullable<Scene>);
  24571. /**
  24572. * Returns the string "AbstractMesh"
  24573. * @returns "AbstractMesh"
  24574. */
  24575. getClassName(): string;
  24576. /**
  24577. * Gets a string representation of the current mesh
  24578. * @param fullDetails defines a boolean indicating if full details must be included
  24579. * @returns a string representation of the current mesh
  24580. */
  24581. toString(fullDetails?: boolean): string;
  24582. /** @hidden */
  24583. _rebuild(): void;
  24584. /** @hidden */
  24585. _resyncLightSources(): void;
  24586. /** @hidden */
  24587. _resyncLighSource(light: Light): void;
  24588. /** @hidden */
  24589. _unBindEffect(): void;
  24590. /** @hidden */
  24591. _removeLightSource(light: Light): void;
  24592. private _markSubMeshesAsDirty;
  24593. /** @hidden */
  24594. _markSubMeshesAsLightDirty(): void;
  24595. /** @hidden */
  24596. _markSubMeshesAsAttributesDirty(): void;
  24597. /** @hidden */
  24598. _markSubMeshesAsMiscDirty(): void;
  24599. /**
  24600. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24601. */
  24602. scaling: Vector3;
  24603. /**
  24604. * Returns true if the mesh is blocked. Implemented by child classes
  24605. */
  24606. readonly isBlocked: boolean;
  24607. /**
  24608. * Returns the mesh itself by default. Implemented by child classes
  24609. * @param camera defines the camera to use to pick the right LOD level
  24610. * @returns the currentAbstractMesh
  24611. */
  24612. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24613. /**
  24614. * Returns 0 by default. Implemented by child classes
  24615. * @returns an integer
  24616. */
  24617. getTotalVertices(): number;
  24618. /**
  24619. * Returns a positive integer : the total number of indices in this mesh geometry.
  24620. * @returns the numner of indices or zero if the mesh has no geometry.
  24621. */
  24622. getTotalIndices(): number;
  24623. /**
  24624. * Returns null by default. Implemented by child classes
  24625. * @returns null
  24626. */
  24627. getIndices(): Nullable<IndicesArray>;
  24628. /**
  24629. * Returns the array of the requested vertex data kind. Implemented by child classes
  24630. * @param kind defines the vertex data kind to use
  24631. * @returns null
  24632. */
  24633. getVerticesData(kind: string): Nullable<FloatArray>;
  24634. /**
  24635. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24636. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24637. * Note that a new underlying VertexBuffer object is created each call.
  24638. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24639. * @param kind defines vertex data kind:
  24640. * * BABYLON.VertexBuffer.PositionKind
  24641. * * BABYLON.VertexBuffer.UVKind
  24642. * * BABYLON.VertexBuffer.UV2Kind
  24643. * * BABYLON.VertexBuffer.UV3Kind
  24644. * * BABYLON.VertexBuffer.UV4Kind
  24645. * * BABYLON.VertexBuffer.UV5Kind
  24646. * * BABYLON.VertexBuffer.UV6Kind
  24647. * * BABYLON.VertexBuffer.ColorKind
  24648. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24649. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24650. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24651. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24652. * @param data defines the data source
  24653. * @param updatable defines if the data must be flagged as updatable (or static)
  24654. * @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
  24655. * @returns the current mesh
  24656. */
  24657. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24658. /**
  24659. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24660. * If the mesh has no geometry, it is simply returned as it is.
  24661. * @param kind defines vertex data kind:
  24662. * * BABYLON.VertexBuffer.PositionKind
  24663. * * BABYLON.VertexBuffer.UVKind
  24664. * * BABYLON.VertexBuffer.UV2Kind
  24665. * * BABYLON.VertexBuffer.UV3Kind
  24666. * * BABYLON.VertexBuffer.UV4Kind
  24667. * * BABYLON.VertexBuffer.UV5Kind
  24668. * * BABYLON.VertexBuffer.UV6Kind
  24669. * * BABYLON.VertexBuffer.ColorKind
  24670. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24671. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24672. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24673. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24674. * @param data defines the data source
  24675. * @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
  24676. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24677. * @returns the current mesh
  24678. */
  24679. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24680. /**
  24681. * Sets the mesh indices,
  24682. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24683. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24684. * @param totalVertices Defines the total number of vertices
  24685. * @returns the current mesh
  24686. */
  24687. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24688. /**
  24689. * Gets a boolean indicating if specific vertex data is present
  24690. * @param kind defines the vertex data kind to use
  24691. * @returns true is data kind is present
  24692. */
  24693. isVerticesDataPresent(kind: string): boolean;
  24694. /**
  24695. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24696. * @returns a BoundingInfo
  24697. */
  24698. getBoundingInfo(): BoundingInfo;
  24699. /**
  24700. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24701. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24702. * @returns the current mesh
  24703. */
  24704. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24705. /**
  24706. * Overwrite the current bounding info
  24707. * @param boundingInfo defines the new bounding info
  24708. * @returns the current mesh
  24709. */
  24710. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24711. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24712. readonly useBones: boolean;
  24713. /** @hidden */
  24714. _preActivate(): void;
  24715. /** @hidden */
  24716. _preActivateForIntermediateRendering(renderId: number): void;
  24717. /** @hidden */
  24718. _activate(renderId: number): void;
  24719. /**
  24720. * Gets the current world matrix
  24721. * @returns a Matrix
  24722. */
  24723. getWorldMatrix(): Matrix;
  24724. /** @hidden */
  24725. _getWorldMatrixDeterminant(): number;
  24726. /**
  24727. * Perform relative position change from the point of view of behind the front of the mesh.
  24728. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24729. * Supports definition of mesh facing forward or backward
  24730. * @param amountRight defines the distance on the right axis
  24731. * @param amountUp defines the distance on the up axis
  24732. * @param amountForward defines the distance on the forward axis
  24733. * @returns the current mesh
  24734. */
  24735. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24736. /**
  24737. * Calculate relative position change from the point of view of behind the front of the mesh.
  24738. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24739. * Supports definition of mesh facing forward or backward
  24740. * @param amountRight defines the distance on the right axis
  24741. * @param amountUp defines the distance on the up axis
  24742. * @param amountForward defines the distance on the forward axis
  24743. * @returns the new displacement vector
  24744. */
  24745. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24746. /**
  24747. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24748. * Supports definition of mesh facing forward or backward
  24749. * @param flipBack defines the flip
  24750. * @param twirlClockwise defines the twirl
  24751. * @param tiltRight defines the tilt
  24752. * @returns the current mesh
  24753. */
  24754. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24755. /**
  24756. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24757. * Supports definition of mesh facing forward or backward.
  24758. * @param flipBack defines the flip
  24759. * @param twirlClockwise defines the twirl
  24760. * @param tiltRight defines the tilt
  24761. * @returns the new rotation vector
  24762. */
  24763. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24764. /**
  24765. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24766. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24767. * @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
  24768. * @returns the new bounding vectors
  24769. */
  24770. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24771. min: Vector3;
  24772. max: Vector3;
  24773. };
  24774. /**
  24775. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24776. * This means the mesh underlying bounding box and sphere are recomputed.
  24777. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24778. * @returns the current mesh
  24779. */
  24780. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24781. /** @hidden */
  24782. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24783. /** @hidden */
  24784. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24785. /** @hidden */
  24786. _updateBoundingInfo(): AbstractMesh;
  24787. /** @hidden */
  24788. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24789. /** @hidden */
  24790. protected _afterComputeWorldMatrix(): void;
  24791. /**
  24792. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24793. * A mesh is in the frustum if its bounding box intersects the frustum
  24794. * @param frustumPlanes defines the frustum to test
  24795. * @returns true if the mesh is in the frustum planes
  24796. */
  24797. isInFrustum(frustumPlanes: Plane[]): boolean;
  24798. /**
  24799. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24800. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24801. * @param frustumPlanes defines the frustum to test
  24802. * @returns true if the mesh is completely in the frustum planes
  24803. */
  24804. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24805. /**
  24806. * True if the mesh intersects another mesh or a SolidParticle object
  24807. * @param mesh defines a target mesh or SolidParticle to test
  24808. * @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)
  24809. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24810. * @returns true if there is an intersection
  24811. */
  24812. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24813. /**
  24814. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24815. * @param point defines the point to test
  24816. * @returns true if there is an intersection
  24817. */
  24818. intersectsPoint(point: Vector3): boolean;
  24819. /**
  24820. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24822. */
  24823. checkCollisions: boolean;
  24824. /**
  24825. * Gets Collider object used to compute collisions (not physics)
  24826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24827. */
  24828. readonly collider: Collider;
  24829. /**
  24830. * Move the mesh using collision engine
  24831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24832. * @param displacement defines the requested displacement vector
  24833. * @returns the current mesh
  24834. */
  24835. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24836. private _onCollisionPositionChange;
  24837. /** @hidden */
  24838. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24839. /** @hidden */
  24840. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24841. /** @hidden */
  24842. _checkCollision(collider: Collider): AbstractMesh;
  24843. /** @hidden */
  24844. _generatePointsArray(): boolean;
  24845. /**
  24846. * Checks if the passed Ray intersects with the mesh
  24847. * @param ray defines the ray to use
  24848. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24849. * @returns the picking info
  24850. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24851. */
  24852. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24853. /**
  24854. * Clones the current mesh
  24855. * @param name defines the mesh name
  24856. * @param newParent defines the new mesh parent
  24857. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24858. * @returns the new mesh
  24859. */
  24860. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24861. /**
  24862. * Disposes all the submeshes of the current meshnp
  24863. * @returns the current mesh
  24864. */
  24865. releaseSubMeshes(): AbstractMesh;
  24866. /**
  24867. * Releases resources associated with this abstract mesh.
  24868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24870. */
  24871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24872. /**
  24873. * Adds the passed mesh as a child to the current mesh
  24874. * @param mesh defines the child mesh
  24875. * @returns the current mesh
  24876. */
  24877. addChild(mesh: AbstractMesh): AbstractMesh;
  24878. /**
  24879. * Removes the passed mesh from the current mesh children list
  24880. * @param mesh defines the child mesh
  24881. * @returns the current mesh
  24882. */
  24883. removeChild(mesh: AbstractMesh): AbstractMesh;
  24884. /** @hidden */
  24885. private _initFacetData;
  24886. /**
  24887. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24888. * This method can be called within the render loop.
  24889. * 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
  24890. * @returns the current mesh
  24891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24892. */
  24893. updateFacetData(): AbstractMesh;
  24894. /**
  24895. * Returns the facetLocalNormals array.
  24896. * The normals are expressed in the mesh local spac
  24897. * @returns an array of Vector3
  24898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24899. */
  24900. getFacetLocalNormals(): Vector3[];
  24901. /**
  24902. * Returns the facetLocalPositions array.
  24903. * The facet positions are expressed in the mesh local space
  24904. * @returns an array of Vector3
  24905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24906. */
  24907. getFacetLocalPositions(): Vector3[];
  24908. /**
  24909. * Returns the facetLocalPartioning array
  24910. * @returns an array of array of numbers
  24911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24912. */
  24913. getFacetLocalPartitioning(): number[][];
  24914. /**
  24915. * Returns the i-th facet position in the world system.
  24916. * This method allocates a new Vector3 per call
  24917. * @param i defines the facet index
  24918. * @returns a new Vector3
  24919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24920. */
  24921. getFacetPosition(i: number): Vector3;
  24922. /**
  24923. * Sets the reference Vector3 with the i-th facet position in the world system
  24924. * @param i defines the facet index
  24925. * @param ref defines the target vector
  24926. * @returns the current mesh
  24927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24928. */
  24929. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24930. /**
  24931. * Returns the i-th facet normal in the world system.
  24932. * This method allocates a new Vector3 per call
  24933. * @param i defines the facet index
  24934. * @returns a new Vector3
  24935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24936. */
  24937. getFacetNormal(i: number): Vector3;
  24938. /**
  24939. * Sets the reference Vector3 with the i-th facet normal in the world system
  24940. * @param i defines the facet index
  24941. * @param ref defines the target vector
  24942. * @returns the current mesh
  24943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24944. */
  24945. getFacetNormalToRef(i: number, ref: Vector3): this;
  24946. /**
  24947. * 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)
  24948. * @param x defines x coordinate
  24949. * @param y defines y coordinate
  24950. * @param z defines z coordinate
  24951. * @returns the array of facet indexes
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24953. */
  24954. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24955. /**
  24956. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24957. * @param projected sets as the (x,y,z) world projection on the facet
  24958. * @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
  24959. * @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
  24960. * @param x defines x coordinate
  24961. * @param y defines y coordinate
  24962. * @param z defines z coordinate
  24963. * @returns the face index if found (or null instead)
  24964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24965. */
  24966. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24967. /**
  24968. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24969. * @param projected sets as the (x,y,z) local projection on the facet
  24970. * @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
  24971. * @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
  24972. * @param x defines x coordinate
  24973. * @param y defines y coordinate
  24974. * @param z defines z coordinate
  24975. * @returns the face index if found (or null instead)
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24977. */
  24978. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24979. /**
  24980. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24981. * @returns the parameters
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24983. */
  24984. getFacetDataParameters(): any;
  24985. /**
  24986. * Disables the feature FacetData and frees the related memory
  24987. * @returns the current mesh
  24988. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24989. */
  24990. disableFacetData(): AbstractMesh;
  24991. /**
  24992. * Updates the AbstractMesh indices array
  24993. * @param indices defines the data source
  24994. * @returns the current mesh
  24995. */
  24996. updateIndices(indices: IndicesArray): AbstractMesh;
  24997. /**
  24998. * Creates new normals data for the mesh
  24999. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25000. * @returns the current mesh
  25001. */
  25002. createNormals(updatable: boolean): AbstractMesh;
  25003. /**
  25004. * Align the mesh with a normal
  25005. * @param normal defines the normal to use
  25006. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25007. * @returns the current mesh
  25008. */
  25009. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25010. /** @hidden */
  25011. _checkOcclusionQuery(): boolean;
  25012. }
  25013. }
  25014. declare module BABYLON {
  25015. /**
  25016. * Class used to store data that will be store in GPU memory
  25017. */
  25018. class Buffer {
  25019. private _engine;
  25020. private _buffer;
  25021. /** @hidden */
  25022. _data: Nullable<DataArray>;
  25023. private _updatable;
  25024. private _instanced;
  25025. /**
  25026. * Gets the byte stride.
  25027. */
  25028. readonly byteStride: number;
  25029. /**
  25030. * Constructor
  25031. * @param engine the engine
  25032. * @param data the data to use for this buffer
  25033. * @param updatable whether the data is updatable
  25034. * @param stride the stride (optional)
  25035. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25036. * @param instanced whether the buffer is instanced (optional)
  25037. * @param useBytes set to true if the stride in in bytes (optional)
  25038. */
  25039. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25040. /**
  25041. * Create a new VertexBuffer based on the current buffer
  25042. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25043. * @param offset defines offset in the buffer (0 by default)
  25044. * @param size defines the size in floats of attributes (position is 3 for instance)
  25045. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25046. * @param instanced defines if the vertex buffer contains indexed data
  25047. * @param useBytes defines if the offset and stride are in bytes
  25048. * @returns the new vertex buffer
  25049. */
  25050. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25051. /**
  25052. * Gets a boolean indicating if the Buffer is updatable?
  25053. * @returns true if the buffer is updatable
  25054. */
  25055. isUpdatable(): boolean;
  25056. /**
  25057. * Gets current buffer's data
  25058. * @returns a DataArray or null
  25059. */
  25060. getData(): Nullable<DataArray>;
  25061. /**
  25062. * Gets underlying native buffer
  25063. * @returns underlying native buffer
  25064. */
  25065. getBuffer(): Nullable<WebGLBuffer>;
  25066. /**
  25067. * Gets the stride in float32 units (i.e. byte stride / 4).
  25068. * May not be an integer if the byte stride is not divisible by 4.
  25069. * DEPRECATED. Use byteStride instead.
  25070. * @returns the stride in float32 units
  25071. */
  25072. getStrideSize(): number;
  25073. /**
  25074. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25075. * @param data defines the data to store
  25076. */
  25077. create(data?: Nullable<DataArray>): void;
  25078. /** @hidden */
  25079. _rebuild(): void;
  25080. /**
  25081. * Update current buffer data
  25082. * @param data defines the data to store
  25083. */
  25084. update(data: DataArray): void;
  25085. /**
  25086. * Updates the data directly.
  25087. * @param data the new data
  25088. * @param offset the new offset
  25089. * @param vertexCount the vertex count (optional)
  25090. * @param useBytes set to true if the offset is in bytes
  25091. */
  25092. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25093. /**
  25094. * Release all resources
  25095. */
  25096. dispose(): void;
  25097. }
  25098. }
  25099. declare module BABYLON {
  25100. /**
  25101. * Class for building Constructive Solid Geometry
  25102. */
  25103. class CSG {
  25104. private polygons;
  25105. /**
  25106. * The world matrix
  25107. */
  25108. matrix: Matrix;
  25109. /**
  25110. * Stores the position
  25111. */
  25112. position: Vector3;
  25113. /**
  25114. * Stores the rotation
  25115. */
  25116. rotation: Vector3;
  25117. /**
  25118. * Stores the rotation quaternion
  25119. */
  25120. rotationQuaternion: Nullable<Quaternion>;
  25121. /**
  25122. * Stores the scaling vector
  25123. */
  25124. scaling: Vector3;
  25125. /**
  25126. * Convert the BABYLON.Mesh to BABYLON.CSG
  25127. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25128. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25129. */
  25130. static FromMesh(mesh: Mesh): CSG;
  25131. /**
  25132. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25133. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25134. */
  25135. private static FromPolygons;
  25136. /**
  25137. * Clones, or makes a deep copy, of the BABYLON.CSG
  25138. * @returns A new BABYLON.CSG
  25139. */
  25140. clone(): CSG;
  25141. /**
  25142. * Unions this CSG with another CSG
  25143. * @param csg The CSG to union against this CSG
  25144. * @returns The unioned CSG
  25145. */
  25146. union(csg: CSG): CSG;
  25147. /**
  25148. * Unions this CSG with another CSG in place
  25149. * @param csg The CSG to union against this CSG
  25150. */
  25151. unionInPlace(csg: CSG): void;
  25152. /**
  25153. * Subtracts this CSG with another CSG
  25154. * @param csg The CSG to subtract against this CSG
  25155. * @returns A new BABYLON.CSG
  25156. */
  25157. subtract(csg: CSG): CSG;
  25158. /**
  25159. * Subtracts this CSG with another CSG in place
  25160. * @param csg The CSG to subtact against this CSG
  25161. */
  25162. subtractInPlace(csg: CSG): void;
  25163. /**
  25164. * Intersect this CSG with another CSG
  25165. * @param csg The CSG to intersect against this CSG
  25166. * @returns A new BABYLON.CSG
  25167. */
  25168. intersect(csg: CSG): CSG;
  25169. /**
  25170. * Intersects this CSG with another CSG in place
  25171. * @param csg The CSG to intersect against this CSG
  25172. */
  25173. intersectInPlace(csg: CSG): void;
  25174. /**
  25175. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25176. * not modified.
  25177. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25178. */
  25179. inverse(): CSG;
  25180. /**
  25181. * Inverses the BABYLON.CSG in place
  25182. */
  25183. inverseInPlace(): void;
  25184. /**
  25185. * This is used to keep meshes transformations so they can be restored
  25186. * when we build back a Babylon Mesh
  25187. * NB : All CSG operations are performed in world coordinates
  25188. * @param csg The BABYLON.CSG to copy the transform attributes from
  25189. * @returns This BABYLON.CSG
  25190. */
  25191. copyTransformAttributes(csg: CSG): CSG;
  25192. /**
  25193. * Build Raw mesh from CSG
  25194. * Coordinates here are in world space
  25195. * @param name The name of the mesh geometry
  25196. * @param scene The BABYLON.Scene
  25197. * @param keepSubMeshes Specifies if the submeshes should be kept
  25198. * @returns A new BABYLON.Mesh
  25199. */
  25200. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25201. /**
  25202. * Build Mesh from CSG taking material and transforms into account
  25203. * @param name The name of the BABYLON.Mesh
  25204. * @param material The material of the BABYLON.Mesh
  25205. * @param scene The BABYLON.Scene
  25206. * @param keepSubMeshes Specifies if submeshes should be kept
  25207. * @returns The new BABYLON.Mesh
  25208. */
  25209. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25210. }
  25211. }
  25212. declare module BABYLON {
  25213. /**
  25214. * Class used to store geometry data (vertex buffers + index buffer)
  25215. */
  25216. class Geometry implements IGetSetVerticesData {
  25217. /**
  25218. * Gets or sets the ID of the geometry
  25219. */
  25220. id: string;
  25221. /**
  25222. * Gets or sets the unique ID of the geometry
  25223. */
  25224. uniqueId: number;
  25225. /**
  25226. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25227. */
  25228. delayLoadState: number;
  25229. /**
  25230. * Gets the file containing the data to load when running in delay load state
  25231. */
  25232. delayLoadingFile: Nullable<string>;
  25233. /**
  25234. * Callback called when the geometry is updated
  25235. */
  25236. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25237. private _scene;
  25238. private _engine;
  25239. private _meshes;
  25240. private _totalVertices;
  25241. /** @hidden */
  25242. _indices: IndicesArray;
  25243. /** @hidden */
  25244. _vertexBuffers: {
  25245. [key: string]: VertexBuffer;
  25246. };
  25247. private _isDisposed;
  25248. private _extend;
  25249. private _boundingBias;
  25250. /** @hidden */
  25251. _delayInfo: Array<string>;
  25252. private _indexBuffer;
  25253. private _indexBufferIsUpdatable;
  25254. /** @hidden */
  25255. _boundingInfo: Nullable<BoundingInfo>;
  25256. /** @hidden */
  25257. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25258. /** @hidden */
  25259. _softwareSkinningFrameId: number;
  25260. private _vertexArrayObjects;
  25261. private _updatable;
  25262. /** @hidden */
  25263. _positions: Nullable<Vector3[]>;
  25264. /**
  25265. * 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
  25266. */
  25267. /**
  25268. * 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
  25269. */
  25270. boundingBias: Vector2;
  25271. /**
  25272. * Static function used to attach a new empty geometry to a mesh
  25273. * @param mesh defines the mesh to attach the geometry to
  25274. * @returns the new Geometry
  25275. */
  25276. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25277. /**
  25278. * Creates a new geometry
  25279. * @param id defines the unique ID
  25280. * @param scene defines the hosting scene
  25281. * @param vertexData defines the VertexData used to get geometry data
  25282. * @param updatable defines if geometry must be updatable (false by default)
  25283. * @param mesh defines the mesh that will be associated with the geometry
  25284. */
  25285. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25286. /**
  25287. * Gets the current extend of the geometry
  25288. */
  25289. readonly extend: {
  25290. minimum: Vector3;
  25291. maximum: Vector3;
  25292. };
  25293. /**
  25294. * Gets the hosting scene
  25295. * @returns the hosting Scene
  25296. */
  25297. getScene(): Scene;
  25298. /**
  25299. * Gets the hosting engine
  25300. * @returns the hosting Engine
  25301. */
  25302. getEngine(): Engine;
  25303. /**
  25304. * Defines if the geometry is ready to use
  25305. * @returns true if the geometry is ready to be used
  25306. */
  25307. isReady(): boolean;
  25308. /**
  25309. * Gets a value indicating that the geometry should not be serialized
  25310. */
  25311. readonly doNotSerialize: boolean;
  25312. /** @hidden */
  25313. _rebuild(): void;
  25314. /**
  25315. * Affects all geometry data in one call
  25316. * @param vertexData defines the geometry data
  25317. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25318. */
  25319. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25320. /**
  25321. * Set specific vertex data
  25322. * @param kind defines the data kind (Position, normal, etc...)
  25323. * @param data defines the vertex data to use
  25324. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25325. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25326. */
  25327. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25328. /**
  25329. * Removes a specific vertex data
  25330. * @param kind defines the data kind (Position, normal, etc...)
  25331. */
  25332. removeVerticesData(kind: string): void;
  25333. /**
  25334. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25335. * @param buffer defines the vertex buffer to use
  25336. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25337. */
  25338. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25339. /**
  25340. * Update a specific vertex buffer
  25341. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25342. * It will do nothing if the buffer is not updatable
  25343. * @param kind defines the data kind (Position, normal, etc...)
  25344. * @param data defines the data to use
  25345. * @param offset defines the offset in the target buffer where to store the data
  25346. * @param useBytes set to true if the offset is in bytes
  25347. */
  25348. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25349. /**
  25350. * Update a specific vertex buffer
  25351. * This function will create a new buffer if the current one is not updatable
  25352. * @param kind defines the data kind (Position, normal, etc...)
  25353. * @param data defines the data to use
  25354. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25355. */
  25356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25357. private _updateBoundingInfo;
  25358. /** @hidden */
  25359. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25360. /**
  25361. * Gets total number of vertices
  25362. * @returns the total number of vertices
  25363. */
  25364. getTotalVertices(): number;
  25365. /**
  25366. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25367. * @param kind defines the data kind (Position, normal, etc...)
  25368. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25369. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25370. * @returns a float array containing vertex data
  25371. */
  25372. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25373. /**
  25374. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25375. * @param kind defines the data kind (Position, normal, etc...)
  25376. * @returns true if the vertex buffer with the specified kind is updatable
  25377. */
  25378. isVertexBufferUpdatable(kind: string): boolean;
  25379. /**
  25380. * Gets a specific vertex buffer
  25381. * @param kind defines the data kind (Position, normal, etc...)
  25382. * @returns a VertexBuffer
  25383. */
  25384. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25385. /**
  25386. * Returns all vertex buffers
  25387. * @return an object holding all vertex buffers indexed by kind
  25388. */
  25389. getVertexBuffers(): Nullable<{
  25390. [key: string]: VertexBuffer;
  25391. }>;
  25392. /**
  25393. * Gets a boolean indicating if specific vertex buffer is present
  25394. * @param kind defines the data kind (Position, normal, etc...)
  25395. * @returns true if data is present
  25396. */
  25397. isVerticesDataPresent(kind: string): boolean;
  25398. /**
  25399. * Gets a list of all attached data kinds (Position, normal, etc...)
  25400. * @returns a list of string containing all kinds
  25401. */
  25402. getVerticesDataKinds(): string[];
  25403. /**
  25404. * Update index buffer
  25405. * @param indices defines the indices to store in the index buffer
  25406. * @param offset defines the offset in the target buffer where to store the data
  25407. */
  25408. updateIndices(indices: IndicesArray, offset?: number): void;
  25409. /**
  25410. * Creates a new index buffer
  25411. * @param indices defines the indices to store in the index buffer
  25412. * @param totalVertices defines the total number of vertices (could be null)
  25413. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25414. */
  25415. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25416. /**
  25417. * Return the total number of indices
  25418. * @returns the total number of indices
  25419. */
  25420. getTotalIndices(): number;
  25421. /**
  25422. * Gets the index buffer array
  25423. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25424. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25425. * @returns the index buffer array
  25426. */
  25427. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25428. /**
  25429. * Gets the index buffer
  25430. * @return the index buffer
  25431. */
  25432. getIndexBuffer(): Nullable<WebGLBuffer>;
  25433. /** @hidden */
  25434. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25435. /**
  25436. * Release the associated resources for a specific mesh
  25437. * @param mesh defines the source mesh
  25438. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25439. */
  25440. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25441. /**
  25442. * Apply current geometry to a given mesh
  25443. * @param mesh defines the mesh to apply geometry to
  25444. */
  25445. applyToMesh(mesh: Mesh): void;
  25446. private _updateExtend;
  25447. private _applyToMesh;
  25448. private notifyUpdate;
  25449. /**
  25450. * Load the geometry if it was flagged as delay loaded
  25451. * @param scene defines the hosting scene
  25452. * @param onLoaded defines a callback called when the geometry is loaded
  25453. */
  25454. load(scene: Scene, onLoaded?: () => void): void;
  25455. private _queueLoad;
  25456. /**
  25457. * Invert the geometry to move from a right handed system to a left handed one.
  25458. */
  25459. toLeftHanded(): void;
  25460. /** @hidden */
  25461. _resetPointsArrayCache(): void;
  25462. /** @hidden */
  25463. _generatePointsArray(): boolean;
  25464. /**
  25465. * Gets a value indicating if the geometry is disposed
  25466. * @returns true if the geometry was disposed
  25467. */
  25468. isDisposed(): boolean;
  25469. private _disposeVertexArrayObjects;
  25470. /**
  25471. * Free all associated resources
  25472. */
  25473. dispose(): void;
  25474. /**
  25475. * Clone the current geometry into a new geometry
  25476. * @param id defines the unique ID of the new geometry
  25477. * @returns a new geometry object
  25478. */
  25479. copy(id: string): Geometry;
  25480. /**
  25481. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25482. * @return a JSON representation of the current geometry data (without the vertices data)
  25483. */
  25484. serialize(): any;
  25485. private toNumberArray;
  25486. /**
  25487. * Serialize all vertices data into a JSON oject
  25488. * @returns a JSON representation of the current geometry data
  25489. */
  25490. serializeVerticeData(): any;
  25491. /**
  25492. * Extracts a clone of a mesh geometry
  25493. * @param mesh defines the source mesh
  25494. * @param id defines the unique ID of the new geometry object
  25495. * @returns the new geometry object
  25496. */
  25497. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25498. /**
  25499. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25500. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25501. * Be aware Math.random() could cause collisions, but:
  25502. * "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"
  25503. * @returns a string containing a new GUID
  25504. */
  25505. static RandomId(): string;
  25506. /** @hidden */
  25507. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25508. private static _CleanMatricesWeights;
  25509. /**
  25510. * Create a new geometry from persisted data (Using .babylon file format)
  25511. * @param parsedVertexData defines the persisted data
  25512. * @param scene defines the hosting scene
  25513. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25514. * @returns the new geometry object
  25515. */
  25516. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25517. }
  25518. /**
  25519. * Abstract class used to provide common services for all typed geometries
  25520. * @hidden
  25521. */
  25522. class _PrimitiveGeometry extends Geometry {
  25523. private _canBeRegenerated;
  25524. private _beingRegenerated;
  25525. /**
  25526. * Creates a new typed geometry
  25527. * @param id defines the unique ID of the geometry
  25528. * @param scene defines the hosting scene
  25529. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25530. * @param mesh defines the hosting mesh (can be null)
  25531. */
  25532. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25533. /**
  25534. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25535. * @returns true if the geometry can be regenerated
  25536. */
  25537. canBeRegenerated(): boolean;
  25538. /**
  25539. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25540. */
  25541. regenerate(): void;
  25542. /**
  25543. * Clone the geometry
  25544. * @param id defines the unique ID of the new geometry
  25545. * @returns the new geometry
  25546. */
  25547. asNewGeometry(id: string): Geometry;
  25548. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25550. /** @hidden */
  25551. _regenerateVertexData(): VertexData;
  25552. copy(id: string): Geometry;
  25553. serialize(): any;
  25554. }
  25555. /**
  25556. * Creates a ribbon geometry
  25557. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25558. */
  25559. class RibbonGeometry extends _PrimitiveGeometry {
  25560. /**
  25561. * Defines the array of paths to use
  25562. */
  25563. pathArray: Vector3[][];
  25564. /**
  25565. * Defines if the last and first points of each path in your pathArray must be joined
  25566. */
  25567. closeArray: boolean;
  25568. /**
  25569. * Defines if the last and first points of each path in your pathArray must be joined
  25570. */
  25571. closePath: boolean;
  25572. /**
  25573. * Defines the offset between points
  25574. */
  25575. offset: number;
  25576. /**
  25577. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25578. */
  25579. side: number;
  25580. /**
  25581. * Creates a ribbon geometry
  25582. * @param id defines the unique ID of the geometry
  25583. * @param scene defines the hosting scene
  25584. * @param pathArray defines the array of paths to use
  25585. * @param closeArray defines if the last path and the first path must be joined
  25586. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25587. * @param offset defines the offset between points
  25588. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25589. * @param mesh defines the hosting mesh (can be null)
  25590. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25591. */
  25592. constructor(id: string, scene: Scene,
  25593. /**
  25594. * Defines the array of paths to use
  25595. */
  25596. pathArray: Vector3[][],
  25597. /**
  25598. * Defines if the last and first points of each path in your pathArray must be joined
  25599. */
  25600. closeArray: boolean,
  25601. /**
  25602. * Defines if the last and first points of each path in your pathArray must be joined
  25603. */
  25604. closePath: boolean,
  25605. /**
  25606. * Defines the offset between points
  25607. */
  25608. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25609. /**
  25610. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25611. */
  25612. side?: number);
  25613. /** @hidden */
  25614. _regenerateVertexData(): VertexData;
  25615. copy(id: string): Geometry;
  25616. }
  25617. /**
  25618. * Creates a box geometry
  25619. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25620. */
  25621. class BoxGeometry extends _PrimitiveGeometry {
  25622. /**
  25623. * Defines the zise of the box (width, height and depth are the same)
  25624. */
  25625. size: number;
  25626. /**
  25627. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25628. */
  25629. side: number;
  25630. /**
  25631. * Creates a box geometry
  25632. * @param id defines the unique ID of the geometry
  25633. * @param scene defines the hosting scene
  25634. * @param size defines the zise of the box (width, height and depth are the same)
  25635. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25636. * @param mesh defines the hosting mesh (can be null)
  25637. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25638. */
  25639. constructor(id: string, scene: Scene,
  25640. /**
  25641. * Defines the zise of the box (width, height and depth are the same)
  25642. */
  25643. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25644. /**
  25645. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25646. */
  25647. side?: number);
  25648. /** @hidden */
  25649. _regenerateVertexData(): VertexData;
  25650. copy(id: string): Geometry;
  25651. serialize(): any;
  25652. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25653. }
  25654. /**
  25655. * Creates a sphere geometry
  25656. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25657. */
  25658. class SphereGeometry extends _PrimitiveGeometry {
  25659. /**
  25660. * Defines the number of segments to use to create the sphere
  25661. */
  25662. segments: number;
  25663. /**
  25664. * Defines the diameter of the sphere
  25665. */
  25666. diameter: number;
  25667. /**
  25668. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25669. */
  25670. side: number;
  25671. /**
  25672. * Create a new sphere geometry
  25673. * @param id defines the unique ID of the geometry
  25674. * @param scene defines the hosting scene
  25675. * @param segments defines the number of segments to use to create the sphere
  25676. * @param diameter defines the diameter of the sphere
  25677. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25678. * @param mesh defines the hosting mesh (can be null)
  25679. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25680. */
  25681. constructor(id: string, scene: Scene,
  25682. /**
  25683. * Defines the number of segments to use to create the sphere
  25684. */
  25685. segments: number,
  25686. /**
  25687. * Defines the diameter of the sphere
  25688. */
  25689. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25690. /**
  25691. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25692. */
  25693. side?: number);
  25694. /** @hidden */
  25695. _regenerateVertexData(): VertexData;
  25696. copy(id: string): Geometry;
  25697. serialize(): any;
  25698. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25699. }
  25700. /**
  25701. * Creates a disc geometry
  25702. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25703. */
  25704. class DiscGeometry extends _PrimitiveGeometry {
  25705. /**
  25706. * Defines the radius of the disc
  25707. */
  25708. radius: number;
  25709. /**
  25710. * Defines the tesselation factor to apply to the disc
  25711. */
  25712. tessellation: 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 disc geometry
  25719. * @param id defines the unique ID of the geometry
  25720. * @param scene defines the hosting scene
  25721. * @param radius defines the radius of the disc
  25722. * @param tessellation defines the tesselation factor to apply to the disc
  25723. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25724. * @param mesh defines the hosting mesh (can be null)
  25725. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25726. */
  25727. constructor(id: string, scene: Scene,
  25728. /**
  25729. * Defines the radius of the disc
  25730. */
  25731. radius: number,
  25732. /**
  25733. * Defines the tesselation factor to apply to the disc
  25734. */
  25735. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25736. /**
  25737. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25738. */
  25739. side?: number);
  25740. /** @hidden */
  25741. _regenerateVertexData(): VertexData;
  25742. copy(id: string): Geometry;
  25743. }
  25744. /**
  25745. * Creates a new cylinder geometry
  25746. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25747. */
  25748. class CylinderGeometry extends _PrimitiveGeometry {
  25749. /**
  25750. * Defines the height of the cylinder
  25751. */
  25752. height: number;
  25753. /**
  25754. * Defines the diameter of the cylinder's top cap
  25755. */
  25756. diameterTop: number;
  25757. /**
  25758. * Defines the diameter of the cylinder's bottom cap
  25759. */
  25760. diameterBottom: number;
  25761. /**
  25762. * Defines the tessellation factor to apply to the cylinder
  25763. */
  25764. tessellation: number;
  25765. /**
  25766. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25767. */
  25768. subdivisions: number;
  25769. /**
  25770. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25771. */
  25772. side: number;
  25773. /**
  25774. * Creates a new cylinder geometry
  25775. * @param id defines the unique ID of the geometry
  25776. * @param scene defines the hosting scene
  25777. * @param height defines the height of the cylinder
  25778. * @param diameterTop defines the diameter of the cylinder's top cap
  25779. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25780. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25781. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25782. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25783. * @param mesh defines the hosting mesh (can be null)
  25784. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25785. */
  25786. constructor(id: string, scene: Scene,
  25787. /**
  25788. * Defines the height of the cylinder
  25789. */
  25790. height: number,
  25791. /**
  25792. * Defines the diameter of the cylinder's top cap
  25793. */
  25794. diameterTop: number,
  25795. /**
  25796. * Defines the diameter of the cylinder's bottom cap
  25797. */
  25798. diameterBottom: number,
  25799. /**
  25800. * Defines the tessellation factor to apply to the cylinder
  25801. */
  25802. tessellation: number,
  25803. /**
  25804. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25805. */
  25806. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25807. /**
  25808. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25809. */
  25810. side?: number);
  25811. /** @hidden */
  25812. _regenerateVertexData(): VertexData;
  25813. copy(id: string): Geometry;
  25814. serialize(): any;
  25815. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25816. }
  25817. /**
  25818. * Creates a new torus geometry
  25819. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25820. */
  25821. class TorusGeometry extends _PrimitiveGeometry {
  25822. /**
  25823. * Defines the diameter of the torus
  25824. */
  25825. diameter: number;
  25826. /**
  25827. * Defines the thickness of the torus (ie. internal diameter)
  25828. */
  25829. thickness: number;
  25830. /**
  25831. * Defines the tesselation factor to apply to the torus
  25832. */
  25833. tessellation: number;
  25834. /**
  25835. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25836. */
  25837. side: number;
  25838. /**
  25839. * Creates a new torus geometry
  25840. * @param id defines the unique ID of the geometry
  25841. * @param scene defines the hosting scene
  25842. * @param diameter defines the diameter of the torus
  25843. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25844. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25845. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25846. * @param mesh defines the hosting mesh (can be null)
  25847. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25848. */
  25849. constructor(id: string, scene: Scene,
  25850. /**
  25851. * Defines the diameter of the torus
  25852. */
  25853. diameter: number,
  25854. /**
  25855. * Defines the thickness of the torus (ie. internal diameter)
  25856. */
  25857. thickness: number,
  25858. /**
  25859. * Defines the tesselation factor to apply to the torus
  25860. */
  25861. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25862. /**
  25863. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25864. */
  25865. side?: number);
  25866. /** @hidden */
  25867. _regenerateVertexData(): VertexData;
  25868. copy(id: string): Geometry;
  25869. serialize(): any;
  25870. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25871. }
  25872. /**
  25873. * Creates a new ground geometry
  25874. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25875. */
  25876. class GroundGeometry extends _PrimitiveGeometry {
  25877. /**
  25878. * Defines the width of the ground
  25879. */
  25880. width: number;
  25881. /**
  25882. * Defines the height of the ground
  25883. */
  25884. height: number;
  25885. /**
  25886. * Defines the subdivisions to apply to the ground
  25887. */
  25888. subdivisions: number;
  25889. /**
  25890. * Creates a new ground geometry
  25891. * @param id defines the unique ID of the geometry
  25892. * @param scene defines the hosting scene
  25893. * @param width defines the width of the ground
  25894. * @param height defines the height of the ground
  25895. * @param subdivisions defines the subdivisions to apply to the ground
  25896. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25897. * @param mesh defines the hosting mesh (can be null)
  25898. */
  25899. constructor(id: string, scene: Scene,
  25900. /**
  25901. * Defines the width of the ground
  25902. */
  25903. width: number,
  25904. /**
  25905. * Defines the height of the ground
  25906. */
  25907. height: number,
  25908. /**
  25909. * Defines the subdivisions to apply to the ground
  25910. */
  25911. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25912. /** @hidden */
  25913. _regenerateVertexData(): VertexData;
  25914. copy(id: string): Geometry;
  25915. serialize(): any;
  25916. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25917. }
  25918. /**
  25919. * Creates a tiled ground geometry
  25920. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25921. */
  25922. class TiledGroundGeometry extends _PrimitiveGeometry {
  25923. /**
  25924. * Defines the minimum value on X axis
  25925. */
  25926. xmin: number;
  25927. /**
  25928. * Defines the minimum value on Z axis
  25929. */
  25930. zmin: number;
  25931. /**
  25932. * Defines the maximum value on X axis
  25933. */
  25934. xmax: number;
  25935. /**
  25936. * Defines the maximum value on Z axis
  25937. */
  25938. zmax: number;
  25939. /**
  25940. * Defines the subdivisions to apply to the ground
  25941. */
  25942. subdivisions: {
  25943. w: number;
  25944. h: number;
  25945. };
  25946. /**
  25947. * Defines the precision to use when computing the tiles
  25948. */
  25949. precision: {
  25950. w: number;
  25951. h: number;
  25952. };
  25953. /**
  25954. * Creates a tiled ground geometry
  25955. * @param id defines the unique ID of the geometry
  25956. * @param scene defines the hosting scene
  25957. * @param xmin defines the minimum value on X axis
  25958. * @param zmin defines the minimum value on Z axis
  25959. * @param xmax defines the maximum value on X axis
  25960. * @param zmax defines the maximum value on Z axis
  25961. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25962. * @param precision defines the precision to use when computing the tiles
  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. */
  25966. constructor(id: string, scene: Scene,
  25967. /**
  25968. * Defines the minimum value on X axis
  25969. */
  25970. xmin: number,
  25971. /**
  25972. * Defines the minimum value on Z axis
  25973. */
  25974. zmin: number,
  25975. /**
  25976. * Defines the maximum value on X axis
  25977. */
  25978. xmax: number,
  25979. /**
  25980. * Defines the maximum value on Z axis
  25981. */
  25982. zmax: number,
  25983. /**
  25984. * Defines the subdivisions to apply to the ground
  25985. */
  25986. subdivisions: {
  25987. w: number;
  25988. h: number;
  25989. },
  25990. /**
  25991. * Defines the precision to use when computing the tiles
  25992. */
  25993. precision: {
  25994. w: number;
  25995. h: number;
  25996. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25997. /** @hidden */
  25998. _regenerateVertexData(): VertexData;
  25999. copy(id: string): Geometry;
  26000. }
  26001. /**
  26002. * Creates a plane geometry
  26003. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26004. */
  26005. class PlaneGeometry extends _PrimitiveGeometry {
  26006. /**
  26007. * Defines the size of the plane (width === height)
  26008. */
  26009. size: number;
  26010. /**
  26011. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26012. */
  26013. side: number;
  26014. /**
  26015. * Creates a plane geometry
  26016. * @param id defines the unique ID of the geometry
  26017. * @param scene defines the hosting scene
  26018. * @param size defines the size of the plane (width === height)
  26019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26020. * @param mesh defines the hosting mesh (can be null)
  26021. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26022. */
  26023. constructor(id: string, scene: Scene,
  26024. /**
  26025. * Defines the size of the plane (width === height)
  26026. */
  26027. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26028. /**
  26029. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26030. */
  26031. side?: number);
  26032. /** @hidden */
  26033. _regenerateVertexData(): VertexData;
  26034. copy(id: string): Geometry;
  26035. serialize(): any;
  26036. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26037. }
  26038. /**
  26039. * Creates a torus knot geometry
  26040. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26041. */
  26042. class TorusKnotGeometry extends _PrimitiveGeometry {
  26043. /**
  26044. * Defines the radius of the torus knot
  26045. */
  26046. radius: number;
  26047. /**
  26048. * Defines the thickness of the torus knot tube
  26049. */
  26050. tube: number;
  26051. /**
  26052. * Defines the number of radial segments
  26053. */
  26054. radialSegments: number;
  26055. /**
  26056. * Defines the number of tubular segments
  26057. */
  26058. tubularSegments: number;
  26059. /**
  26060. * Defines the first number of windings
  26061. */
  26062. p: number;
  26063. /**
  26064. * Defines the second number of windings
  26065. */
  26066. q: number;
  26067. /**
  26068. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26069. */
  26070. side: number;
  26071. /**
  26072. * Creates a torus knot geometry
  26073. * @param id defines the unique ID of the geometry
  26074. * @param scene defines the hosting scene
  26075. * @param radius defines the radius of the torus knot
  26076. * @param tube defines the thickness of the torus knot tube
  26077. * @param radialSegments defines the number of radial segments
  26078. * @param tubularSegments defines the number of tubular segments
  26079. * @param p defines the first number of windings
  26080. * @param q defines the second number of windings
  26081. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26082. * @param mesh defines the hosting mesh (can be null)
  26083. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26084. */
  26085. constructor(id: string, scene: Scene,
  26086. /**
  26087. * Defines the radius of the torus knot
  26088. */
  26089. radius: number,
  26090. /**
  26091. * Defines the thickness of the torus knot tube
  26092. */
  26093. tube: number,
  26094. /**
  26095. * Defines the number of radial segments
  26096. */
  26097. radialSegments: number,
  26098. /**
  26099. * Defines the number of tubular segments
  26100. */
  26101. tubularSegments: number,
  26102. /**
  26103. * Defines the first number of windings
  26104. */
  26105. p: number,
  26106. /**
  26107. * Defines the second number of windings
  26108. */
  26109. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26110. /**
  26111. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26112. */
  26113. side?: number);
  26114. /** @hidden */
  26115. _regenerateVertexData(): VertexData;
  26116. copy(id: string): Geometry;
  26117. serialize(): any;
  26118. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26119. }
  26120. }
  26121. declare module BABYLON {
  26122. /**
  26123. * Mesh representing the gorund
  26124. */
  26125. class GroundMesh extends Mesh {
  26126. /** If octree should be generated */
  26127. generateOctree: boolean;
  26128. private _heightQuads;
  26129. /** @hidden */
  26130. _subdivisionsX: number;
  26131. /** @hidden */
  26132. _subdivisionsY: number;
  26133. /** @hidden */
  26134. _width: number;
  26135. /** @hidden */
  26136. _height: number;
  26137. /** @hidden */
  26138. _minX: number;
  26139. /** @hidden */
  26140. _maxX: number;
  26141. /** @hidden */
  26142. _minZ: number;
  26143. /** @hidden */
  26144. _maxZ: number;
  26145. constructor(name: string, scene: Scene);
  26146. /**
  26147. * "GroundMesh"
  26148. * @returns "GroundMesh"
  26149. */
  26150. getClassName(): string;
  26151. /**
  26152. * The minimum of x and y subdivisions
  26153. */
  26154. readonly subdivisions: number;
  26155. /**
  26156. * X subdivisions
  26157. */
  26158. readonly subdivisionsX: number;
  26159. /**
  26160. * Y subdivisions
  26161. */
  26162. readonly subdivisionsY: number;
  26163. /**
  26164. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26165. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26166. * @param chunksCount the number of subdivisions for x and y
  26167. * @param octreeBlocksSize (Default: 32)
  26168. */
  26169. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26170. /**
  26171. * Returns a height (y) value in the Worl system :
  26172. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26173. * @param x x coordinate
  26174. * @param z z coordinate
  26175. * @returns the ground y position if (x, z) are outside the ground surface.
  26176. */
  26177. getHeightAtCoordinates(x: number, z: number): number;
  26178. /**
  26179. * Returns a normalized vector (Vector3) orthogonal to the ground
  26180. * at the ground coordinates (x, z) expressed in the World system.
  26181. * @param x x coordinate
  26182. * @param z z coordinate
  26183. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26184. */
  26185. getNormalAtCoordinates(x: number, z: number): Vector3;
  26186. /**
  26187. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26188. * at the ground coordinates (x, z) expressed in the World system.
  26189. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26190. * @param x x coordinate
  26191. * @param z z coordinate
  26192. * @param ref vector to store the result
  26193. * @returns the GroundMesh.
  26194. */
  26195. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26196. /**
  26197. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26198. * if the ground has been updated.
  26199. * This can be used in the render loop.
  26200. * @returns the GroundMesh.
  26201. */
  26202. updateCoordinateHeights(): GroundMesh;
  26203. private _getFacetAt;
  26204. private _initHeightQuads;
  26205. private _computeHeightQuads;
  26206. /**
  26207. * Serializes this ground mesh
  26208. * @param serializationObject object to write serialization to
  26209. */
  26210. serialize(serializationObject: any): void;
  26211. /**
  26212. * Parses a serialized ground mesh
  26213. * @param parsedMesh the serialized mesh
  26214. * @param scene the scene to create the ground mesh in
  26215. * @returns the created ground mesh
  26216. */
  26217. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26218. }
  26219. }
  26220. declare module BABYLON {
  26221. /**
  26222. * Creates an instance based on a source mesh.
  26223. */
  26224. class InstancedMesh extends AbstractMesh {
  26225. private _sourceMesh;
  26226. private _currentLOD;
  26227. /** @hidden */
  26228. _indexInSourceMeshInstanceArray: number;
  26229. constructor(name: string, source: Mesh);
  26230. /**
  26231. * Returns the string "InstancedMesh".
  26232. */
  26233. getClassName(): string;
  26234. /**
  26235. * If the source mesh receives shadows
  26236. */
  26237. readonly receiveShadows: boolean;
  26238. /**
  26239. * The material of the source mesh
  26240. */
  26241. readonly material: Nullable<Material>;
  26242. /**
  26243. * Visibility of the source mesh
  26244. */
  26245. readonly visibility: number;
  26246. /**
  26247. * Skeleton of the source mesh
  26248. */
  26249. readonly skeleton: Nullable<Skeleton>;
  26250. /**
  26251. * Rendering ground id of the source mesh
  26252. */
  26253. renderingGroupId: number;
  26254. /**
  26255. * Returns the total number of vertices (integer).
  26256. */
  26257. getTotalVertices(): number;
  26258. /**
  26259. * Returns a positive integer : the total number of indices in this mesh geometry.
  26260. * @returns the numner of indices or zero if the mesh has no geometry.
  26261. */
  26262. getTotalIndices(): number;
  26263. /**
  26264. * The source mesh of the instance
  26265. */
  26266. readonly sourceMesh: Mesh;
  26267. /**
  26268. * Is this node ready to be used/rendered
  26269. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26270. * @return {boolean} is it ready
  26271. */
  26272. isReady(completeCheck?: boolean): boolean;
  26273. /**
  26274. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26275. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26276. * @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.
  26277. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26278. */
  26279. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26280. /**
  26281. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26282. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26283. * The `data` are either a numeric array either a Float32Array.
  26284. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26285. * 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).
  26286. * Note that a new underlying VertexBuffer object is created each call.
  26287. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26288. *
  26289. * Possible `kind` values :
  26290. * - BABYLON.VertexBuffer.PositionKind
  26291. * - BABYLON.VertexBuffer.UVKind
  26292. * - BABYLON.VertexBuffer.UV2Kind
  26293. * - BABYLON.VertexBuffer.UV3Kind
  26294. * - BABYLON.VertexBuffer.UV4Kind
  26295. * - BABYLON.VertexBuffer.UV5Kind
  26296. * - BABYLON.VertexBuffer.UV6Kind
  26297. * - BABYLON.VertexBuffer.ColorKind
  26298. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26299. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26300. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26301. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26302. *
  26303. * Returns the Mesh.
  26304. */
  26305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26306. /**
  26307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26308. * If the mesh has no geometry, it is simply returned as it is.
  26309. * The `data` are either a numeric array either a Float32Array.
  26310. * No new underlying VertexBuffer object is created.
  26311. * 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.
  26312. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26313. *
  26314. * Possible `kind` values :
  26315. * - BABYLON.VertexBuffer.PositionKind
  26316. * - BABYLON.VertexBuffer.UVKind
  26317. * - BABYLON.VertexBuffer.UV2Kind
  26318. * - BABYLON.VertexBuffer.UV3Kind
  26319. * - BABYLON.VertexBuffer.UV4Kind
  26320. * - BABYLON.VertexBuffer.UV5Kind
  26321. * - BABYLON.VertexBuffer.UV6Kind
  26322. * - BABYLON.VertexBuffer.ColorKind
  26323. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26324. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26325. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26326. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26327. *
  26328. * Returns the Mesh.
  26329. */
  26330. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26331. /**
  26332. * Sets the mesh indices.
  26333. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26334. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26335. * This method creates a new index buffer each call.
  26336. * Returns the Mesh.
  26337. */
  26338. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26339. /**
  26340. * Boolean : True if the mesh owns the requested kind of data.
  26341. */
  26342. isVerticesDataPresent(kind: string): boolean;
  26343. /**
  26344. * Returns an array of indices (IndicesArray).
  26345. */
  26346. getIndices(): Nullable<IndicesArray>;
  26347. readonly _positions: Nullable<Vector3[]>;
  26348. /**
  26349. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26350. * This means the mesh underlying bounding box and sphere are recomputed.
  26351. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26352. * @returns the current mesh
  26353. */
  26354. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26355. /** @hidden */
  26356. _preActivate(): InstancedMesh;
  26357. /** @hidden */
  26358. _activate(renderId: number): InstancedMesh;
  26359. /**
  26360. * Returns the current associated LOD AbstractMesh.
  26361. */
  26362. getLOD(camera: Camera): AbstractMesh;
  26363. /** @hidden */
  26364. _syncSubMeshes(): InstancedMesh;
  26365. /** @hidden */
  26366. _generatePointsArray(): boolean;
  26367. /**
  26368. * Creates a new InstancedMesh from the current mesh.
  26369. * - name (string) : the cloned mesh name
  26370. * - newParent (optional Node) : the optional Node to parent the clone to.
  26371. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26372. *
  26373. * Returns the clone.
  26374. */
  26375. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26376. /**
  26377. * Disposes the InstancedMesh.
  26378. * Returns nothing.
  26379. */
  26380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26381. }
  26382. }
  26383. declare module BABYLON {
  26384. /**
  26385. * Line mesh
  26386. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26387. */
  26388. class LinesMesh extends Mesh {
  26389. /**
  26390. * If vertex color should be applied to the mesh
  26391. */
  26392. useVertexColor?: boolean | undefined;
  26393. /**
  26394. * If vertex alpha should be applied to the mesh
  26395. */
  26396. useVertexAlpha?: boolean | undefined;
  26397. /**
  26398. * Color of the line (Default: White)
  26399. */
  26400. color: Color3;
  26401. /**
  26402. * Alpha of the line (Default: 1)
  26403. */
  26404. alpha: number;
  26405. /**
  26406. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26407. * This margin is expressed in world space coordinates, so its value may vary.
  26408. * Default value is 0.1
  26409. */
  26410. intersectionThreshold: number;
  26411. private _colorShader;
  26412. /**
  26413. * Creates a new LinesMesh
  26414. * @param name defines the name
  26415. * @param scene defines the hosting scene
  26416. * @param parent defines the parent mesh if any
  26417. * @param source defines the optional source LinesMesh used to clone data from
  26418. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26419. * When false, achieved by calling a clone(), also passing False.
  26420. * This will make creation of children, recursive.
  26421. * @param useVertexColor defines if this LinesMesh supports vertex color
  26422. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26423. */
  26424. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26425. /**
  26426. * If vertex color should be applied to the mesh
  26427. */
  26428. useVertexColor?: boolean | undefined,
  26429. /**
  26430. * If vertex alpha should be applied to the mesh
  26431. */
  26432. useVertexAlpha?: boolean | undefined);
  26433. /**
  26434. * Returns the string "LineMesh"
  26435. */
  26436. getClassName(): string;
  26437. /**
  26438. * @hidden
  26439. */
  26440. /**
  26441. * @hidden
  26442. */
  26443. material: Material;
  26444. /**
  26445. * @hidden
  26446. */
  26447. readonly checkCollisions: boolean;
  26448. /** @hidden */
  26449. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26450. /** @hidden */
  26451. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26452. /**
  26453. * Disposes of the line mesh
  26454. * @param doNotRecurse If children should be disposed
  26455. */
  26456. dispose(doNotRecurse?: boolean): void;
  26457. /**
  26458. * Returns a new LineMesh object cloned from the current one.
  26459. */
  26460. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26461. /**
  26462. * Creates a new InstancedLinesMesh object from the mesh model.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26464. * @param name defines the name of the new instance
  26465. * @returns a new InstancedLinesMesh
  26466. */
  26467. createInstance(name: string): InstancedLinesMesh;
  26468. }
  26469. /**
  26470. * Creates an instance based on a source LinesMesh
  26471. */
  26472. class InstancedLinesMesh extends InstancedMesh {
  26473. /**
  26474. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26475. * This margin is expressed in world space coordinates, so its value may vary.
  26476. * Initilized with the intersectionThreshold value of the source LinesMesh
  26477. */
  26478. intersectionThreshold: number;
  26479. constructor(name: string, source: LinesMesh);
  26480. /**
  26481. * Returns the string "InstancedLinesMesh".
  26482. */
  26483. getClassName(): string;
  26484. }
  26485. }
  26486. declare module BABYLON {
  26487. /**
  26488. * @hidden
  26489. **/
  26490. class _CreationDataStorage {
  26491. closePath?: boolean;
  26492. closeArray?: boolean;
  26493. idx: number[];
  26494. dashSize: number;
  26495. gapSize: number;
  26496. path3D: Path3D;
  26497. pathArray: Vector3[][];
  26498. arc: number;
  26499. radius: number;
  26500. cap: number;
  26501. tessellation: number;
  26502. }
  26503. /**
  26504. * @hidden
  26505. **/
  26506. class _InstanceDataStorage {
  26507. visibleInstances: any;
  26508. renderIdForInstances: number[];
  26509. batchCache: _InstancesBatch;
  26510. instancesBufferSize: number;
  26511. instancesBuffer: Nullable<Buffer>;
  26512. instancesData: Float32Array;
  26513. overridenInstanceCount: number;
  26514. }
  26515. /**
  26516. * @hidden
  26517. **/
  26518. class _InstancesBatch {
  26519. mustReturn: boolean;
  26520. visibleInstances: Nullable<InstancedMesh[]>[];
  26521. renderSelf: boolean[];
  26522. }
  26523. /**
  26524. * Class used to represent renderable models
  26525. */
  26526. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26527. /**
  26528. * Mesh side orientation : usually the external or front surface
  26529. */
  26530. static readonly FRONTSIDE: number;
  26531. /**
  26532. * Mesh side orientation : usually the internal or back surface
  26533. */
  26534. static readonly BACKSIDE: number;
  26535. /**
  26536. * Mesh side orientation : both internal and external or front and back surfaces
  26537. */
  26538. static readonly DOUBLESIDE: number;
  26539. /**
  26540. * Mesh side orientation : by default, `FRONTSIDE`
  26541. */
  26542. static readonly DEFAULTSIDE: number;
  26543. /**
  26544. * Mesh cap setting : no cap
  26545. */
  26546. static readonly NO_CAP: number;
  26547. /**
  26548. * Mesh cap setting : one cap at the beginning of the mesh
  26549. */
  26550. static readonly CAP_START: number;
  26551. /**
  26552. * Mesh cap setting : one cap at the end of the mesh
  26553. */
  26554. static readonly CAP_END: number;
  26555. /**
  26556. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26557. */
  26558. static readonly CAP_ALL: number;
  26559. private _onBeforeRenderObservable;
  26560. private _onAfterRenderObservable;
  26561. private _onBeforeDrawObservable;
  26562. /**
  26563. * An event triggered before rendering the mesh
  26564. */
  26565. readonly onBeforeRenderObservable: Observable<Mesh>;
  26566. /**
  26567. * An event triggered after rendering the mesh
  26568. */
  26569. readonly onAfterRenderObservable: Observable<Mesh>;
  26570. /**
  26571. * An event triggered before drawing the mesh
  26572. */
  26573. readonly onBeforeDrawObservable: Observable<Mesh>;
  26574. private _onBeforeDrawObserver;
  26575. /**
  26576. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26577. */
  26578. onBeforeDraw: () => void;
  26579. /**
  26580. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26581. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26582. */
  26583. delayLoadState: number;
  26584. /**
  26585. * Gets the list of instances created from this mesh
  26586. * it is not supposed to be modified manually.
  26587. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26589. */
  26590. instances: InstancedMesh[];
  26591. /**
  26592. * Gets the file containing delay loading data for this mesh
  26593. */
  26594. delayLoadingFile: string;
  26595. /** @hidden */
  26596. _binaryInfo: any;
  26597. private _LODLevels;
  26598. /**
  26599. * User defined function used to change how LOD level selection is done
  26600. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26601. */
  26602. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26603. private _morphTargetManager;
  26604. /**
  26605. * Gets or sets the morph target manager
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26607. */
  26608. morphTargetManager: Nullable<MorphTargetManager>;
  26609. /** @hidden */
  26610. _creationDataStorage: Nullable<_CreationDataStorage>;
  26611. /** @hidden */
  26612. _geometry: Nullable<Geometry>;
  26613. /** @hidden */
  26614. _delayInfo: Array<string>;
  26615. /** @hidden */
  26616. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26617. /** @hidden */
  26618. _instanceDataStorage: _InstanceDataStorage;
  26619. private _effectiveMaterial;
  26620. /** @hidden */
  26621. _shouldGenerateFlatShading: boolean;
  26622. private _preActivateId;
  26623. /** @hidden */
  26624. _originalBuilderSideOrientation: number;
  26625. /**
  26626. * Use this property to change the original side orientation defined at construction time
  26627. */
  26628. overrideMaterialSideOrientation: Nullable<number>;
  26629. private _areNormalsFrozen;
  26630. private _sourcePositions;
  26631. private _sourceNormals;
  26632. private _source;
  26633. private meshMap;
  26634. /**
  26635. * Gets the source mesh (the one used to clone this one from)
  26636. */
  26637. readonly source: Nullable<Mesh>;
  26638. /**
  26639. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26640. */
  26641. isUnIndexed: boolean;
  26642. /**
  26643. * @constructor
  26644. * @param name The value used by scene.getMeshByName() to do a lookup.
  26645. * @param scene The scene to add this mesh to.
  26646. * @param parent The parent of this mesh, if it has one
  26647. * @param source An optional Mesh from which geometry is shared, cloned.
  26648. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26649. * When false, achieved by calling a clone(), also passing False.
  26650. * This will make creation of children, recursive.
  26651. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26652. */
  26653. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26654. /**
  26655. * Gets the class name
  26656. * @returns the string "Mesh".
  26657. */
  26658. getClassName(): string;
  26659. /**
  26660. * Returns a description of this mesh
  26661. * @param fullDetails define if full details about this mesh must be used
  26662. * @returns a descriptive string representing this mesh
  26663. */
  26664. toString(fullDetails?: boolean): string;
  26665. /** @hidden */
  26666. _unBindEffect(): void;
  26667. /**
  26668. * Gets a boolean indicating if this mesh has LOD
  26669. */
  26670. readonly hasLODLevels: boolean;
  26671. /**
  26672. * Gets the list of MeshLODLevel associated with the current mesh
  26673. * @returns an array of MeshLODLevel
  26674. */
  26675. getLODLevels(): MeshLODLevel[];
  26676. private _sortLODLevels;
  26677. /**
  26678. * Add a mesh as LOD level triggered at the given distance.
  26679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26680. * @param distance The distance from the center of the object to show this level
  26681. * @param mesh The mesh to be added as LOD level (can be null)
  26682. * @return This mesh (for chaining)
  26683. */
  26684. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26685. /**
  26686. * Returns the LOD level mesh at the passed distance or null if not found.
  26687. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26688. * @param distance The distance from the center of the object to show this level
  26689. * @returns a Mesh or `null`
  26690. */
  26691. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26692. /**
  26693. * Remove a mesh from the LOD array
  26694. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26695. * @param mesh defines the mesh to be removed
  26696. * @return This mesh (for chaining)
  26697. */
  26698. removeLODLevel(mesh: Mesh): Mesh;
  26699. /**
  26700. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26701. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26702. * @param camera defines the camera to use to compute distance
  26703. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26704. * @return This mesh (for chaining)
  26705. */
  26706. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26707. /**
  26708. * Gets the mesh internal Geometry object
  26709. */
  26710. readonly geometry: Nullable<Geometry>;
  26711. /**
  26712. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26713. * @returns the total number of vertices
  26714. */
  26715. getTotalVertices(): number;
  26716. /**
  26717. * Returns the content of an associated vertex buffer
  26718. * @param kind defines which buffer to read from (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. * @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
  26732. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26733. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26734. */
  26735. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26736. /**
  26737. * Returns the mesh VertexBuffer object from the requested `kind`
  26738. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26739. * - BABYLON.VertexBuffer.PositionKind
  26740. * - BABYLON.VertexBuffer.UVKind
  26741. * - BABYLON.VertexBuffer.UV2Kind
  26742. * - BABYLON.VertexBuffer.UV3Kind
  26743. * - BABYLON.VertexBuffer.UV4Kind
  26744. * - BABYLON.VertexBuffer.UV5Kind
  26745. * - BABYLON.VertexBuffer.UV6Kind
  26746. * - BABYLON.VertexBuffer.ColorKind
  26747. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26748. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26749. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26750. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26751. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26752. */
  26753. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26754. /**
  26755. * Tests if a specific vertex buffer is associated with this mesh
  26756. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26757. * - BABYLON.VertexBuffer.PositionKind
  26758. * - BABYLON.VertexBuffer.UVKind
  26759. * - BABYLON.VertexBuffer.UV2Kind
  26760. * - BABYLON.VertexBuffer.UV3Kind
  26761. * - BABYLON.VertexBuffer.UV4Kind
  26762. * - BABYLON.VertexBuffer.UV5Kind
  26763. * - BABYLON.VertexBuffer.UV6Kind
  26764. * - BABYLON.VertexBuffer.ColorKind
  26765. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26766. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26767. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26768. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26769. * @returns a boolean
  26770. */
  26771. isVerticesDataPresent(kind: string): boolean;
  26772. /**
  26773. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26774. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26775. * - BABYLON.VertexBuffer.PositionKind
  26776. * - BABYLON.VertexBuffer.UVKind
  26777. * - BABYLON.VertexBuffer.UV2Kind
  26778. * - BABYLON.VertexBuffer.UV3Kind
  26779. * - BABYLON.VertexBuffer.UV4Kind
  26780. * - BABYLON.VertexBuffer.UV5Kind
  26781. * - BABYLON.VertexBuffer.UV6Kind
  26782. * - BABYLON.VertexBuffer.ColorKind
  26783. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26784. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26785. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26786. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26787. * @returns a boolean
  26788. */
  26789. isVertexBufferUpdatable(kind: string): boolean;
  26790. /**
  26791. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26792. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26793. * - BABYLON.VertexBuffer.PositionKind
  26794. * - BABYLON.VertexBuffer.UVKind
  26795. * - BABYLON.VertexBuffer.UV2Kind
  26796. * - BABYLON.VertexBuffer.UV3Kind
  26797. * - BABYLON.VertexBuffer.UV4Kind
  26798. * - BABYLON.VertexBuffer.UV5Kind
  26799. * - BABYLON.VertexBuffer.UV6Kind
  26800. * - BABYLON.VertexBuffer.ColorKind
  26801. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26802. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26803. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26804. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26805. * @returns an array of strings
  26806. */
  26807. getVerticesDataKinds(): string[];
  26808. /**
  26809. * Returns a positive integer : the total number of indices in this mesh geometry.
  26810. * @returns the numner of indices or zero if the mesh has no geometry.
  26811. */
  26812. getTotalIndices(): number;
  26813. /**
  26814. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26815. * @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.
  26816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26817. * @returns the indices array or an empty array if the mesh has no geometry
  26818. */
  26819. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26820. readonly isBlocked: boolean;
  26821. /**
  26822. * Determine if the current mesh is ready to be rendered
  26823. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26824. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26825. * @returns true if all associated assets are ready (material, textures, shaders)
  26826. */
  26827. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26828. /**
  26829. * 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.
  26830. */
  26831. readonly areNormalsFrozen: boolean;
  26832. /**
  26833. * 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.
  26834. * @returns the current mesh
  26835. */
  26836. freezeNormals(): Mesh;
  26837. /**
  26838. * 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
  26839. * @returns the current mesh
  26840. */
  26841. unfreezeNormals(): Mesh;
  26842. /**
  26843. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26844. */
  26845. overridenInstanceCount: number;
  26846. /** @hidden */
  26847. _preActivate(): Mesh;
  26848. /** @hidden */
  26849. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26850. /** @hidden */
  26851. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26852. /**
  26853. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26854. * This means the mesh underlying bounding box and sphere are recomputed.
  26855. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26856. * @returns the current mesh
  26857. */
  26858. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26859. /** @hidden */
  26860. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26861. /**
  26862. * This function will subdivide the mesh into multiple submeshes
  26863. * @param count defines the expected number of submeshes
  26864. */
  26865. subdivide(count: number): void;
  26866. /**
  26867. * Copy a FloatArray into a specific associated vertex buffer
  26868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26869. * - BABYLON.VertexBuffer.PositionKind
  26870. * - BABYLON.VertexBuffer.UVKind
  26871. * - BABYLON.VertexBuffer.UV2Kind
  26872. * - BABYLON.VertexBuffer.UV3Kind
  26873. * - BABYLON.VertexBuffer.UV4Kind
  26874. * - BABYLON.VertexBuffer.UV5Kind
  26875. * - BABYLON.VertexBuffer.UV6Kind
  26876. * - BABYLON.VertexBuffer.ColorKind
  26877. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26878. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26879. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26880. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26881. * @param data defines the data source
  26882. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26883. * @param stride defines the data stride size (can be null)
  26884. * @returns the current mesh
  26885. */
  26886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26887. /**
  26888. * Flags an associated vertex buffer as updatable
  26889. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26890. * - BABYLON.VertexBuffer.PositionKind
  26891. * - BABYLON.VertexBuffer.UVKind
  26892. * - BABYLON.VertexBuffer.UV2Kind
  26893. * - BABYLON.VertexBuffer.UV3Kind
  26894. * - BABYLON.VertexBuffer.UV4Kind
  26895. * - BABYLON.VertexBuffer.UV5Kind
  26896. * - BABYLON.VertexBuffer.UV6Kind
  26897. * - BABYLON.VertexBuffer.ColorKind
  26898. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26899. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26900. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26901. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26902. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26903. */
  26904. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26905. /**
  26906. * Sets the mesh global Vertex Buffer
  26907. * @param buffer defines the buffer to use
  26908. * @returns the current mesh
  26909. */
  26910. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26911. /**
  26912. * Update a specific associated vertex buffer
  26913. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26914. * - BABYLON.VertexBuffer.PositionKind
  26915. * - BABYLON.VertexBuffer.UVKind
  26916. * - BABYLON.VertexBuffer.UV2Kind
  26917. * - BABYLON.VertexBuffer.UV3Kind
  26918. * - BABYLON.VertexBuffer.UV4Kind
  26919. * - BABYLON.VertexBuffer.UV5Kind
  26920. * - BABYLON.VertexBuffer.UV6Kind
  26921. * - BABYLON.VertexBuffer.ColorKind
  26922. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26923. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26924. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26925. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26926. * @param data defines the data source
  26927. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26928. * @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)
  26929. * @returns the current mesh
  26930. */
  26931. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26932. /**
  26933. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26934. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26935. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26936. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26937. * @returns the current mesh
  26938. */
  26939. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26940. /**
  26941. * Creates a un-shared specific occurence of the geometry for the mesh.
  26942. * @returns the current mesh
  26943. */
  26944. makeGeometryUnique(): Mesh;
  26945. /**
  26946. * Set the index buffer of this mesh
  26947. * @param indices defines the source data
  26948. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26949. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26950. * @returns the current mesh
  26951. */
  26952. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26953. /**
  26954. * Update the current index buffer
  26955. * @param indices defines the source data
  26956. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26957. * @returns the current mesh
  26958. */
  26959. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26960. /**
  26961. * Invert the geometry to move from a right handed system to a left handed one.
  26962. * @returns the current mesh
  26963. */
  26964. toLeftHanded(): Mesh;
  26965. /** @hidden */
  26966. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26967. /** @hidden */
  26968. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26969. /**
  26970. * Registers for this mesh a javascript function called just before the rendering process
  26971. * @param func defines the function to call before rendering this mesh
  26972. * @returns the current mesh
  26973. */
  26974. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26975. /**
  26976. * Disposes a previously registered javascript function called before the rendering
  26977. * @param func defines the function to remove
  26978. * @returns the current mesh
  26979. */
  26980. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26981. /**
  26982. * Registers for this mesh a javascript function called just after the rendering is complete
  26983. * @param func defines the function to call after rendering this mesh
  26984. * @returns the current mesh
  26985. */
  26986. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26987. /**
  26988. * Disposes a previously registered javascript function called after the rendering.
  26989. * @param func defines the function to remove
  26990. * @returns the current mesh
  26991. */
  26992. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26993. /** @hidden */
  26994. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26995. /** @hidden */
  26996. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26997. /** @hidden */
  26998. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26999. /**
  27000. * 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
  27001. * @param subMesh defines the subMesh to render
  27002. * @param enableAlphaMode defines if alpha mode can be changed
  27003. * @returns the current mesh
  27004. */
  27005. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27006. private _onBeforeDraw;
  27007. /**
  27008. * Renormalize the mesh and patch it up if there are no weights
  27009. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27010. * However in the case of zero weights then we set just a single influence to 1.
  27011. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27012. */
  27013. cleanMatrixWeights(): void;
  27014. private normalizeSkinFourWeights;
  27015. private normalizeSkinWeightsAndExtra;
  27016. /**
  27017. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27018. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27019. * the user know there was an issue with importing the mesh
  27020. * @returns a validation object with skinned, valid and report string
  27021. */
  27022. validateSkinning(): {
  27023. skinned: boolean;
  27024. valid: boolean;
  27025. report: string;
  27026. };
  27027. /** @hidden */
  27028. _checkDelayState(): Mesh;
  27029. private _queueLoad;
  27030. /**
  27031. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27032. * A mesh is in the frustum if its bounding box intersects the frustum
  27033. * @param frustumPlanes defines the frustum to test
  27034. * @returns true if the mesh is in the frustum planes
  27035. */
  27036. isInFrustum(frustumPlanes: Plane[]): boolean;
  27037. /**
  27038. * Sets the mesh material by the material or multiMaterial `id` property
  27039. * @param id is a string identifying the material or the multiMaterial
  27040. * @returns the current mesh
  27041. */
  27042. setMaterialByID(id: string): Mesh;
  27043. /**
  27044. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27045. * @returns an array of IAnimatable
  27046. */
  27047. getAnimatables(): IAnimatable[];
  27048. /**
  27049. * Modifies the mesh geometry according to the passed transformation matrix.
  27050. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27051. * The mesh normals are modified using the same transformation.
  27052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27053. * @param transform defines the transform matrix to use
  27054. * @see http://doc.babylonjs.com/resources/baking_transformations
  27055. * @returns the current mesh
  27056. */
  27057. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27058. /**
  27059. * Modifies the mesh geometry according to its own current World Matrix.
  27060. * The mesh World Matrix is then reset.
  27061. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27062. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27063. * @see http://doc.babylonjs.com/resources/baking_transformations
  27064. * @returns the current mesh
  27065. */
  27066. bakeCurrentTransformIntoVertices(): Mesh;
  27067. /** @hidden */
  27068. readonly _positions: Nullable<Vector3[]>;
  27069. /** @hidden */
  27070. _resetPointsArrayCache(): Mesh;
  27071. /** @hidden */
  27072. _generatePointsArray(): boolean;
  27073. /**
  27074. * Returns a new Mesh object generated from the current mesh properties.
  27075. * This method must not get confused with createInstance()
  27076. * @param name is a string, the name given to the new mesh
  27077. * @param newParent can be any Node object (default `null`)
  27078. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27079. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27080. * @returns a new mesh
  27081. */
  27082. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27083. /**
  27084. * Releases resources associated with this mesh.
  27085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27087. */
  27088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27089. /**
  27090. * Modifies the mesh geometry according to a displacement map.
  27091. * 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.
  27092. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27093. * @param url is a string, the URL from the image file is to be downloaded.
  27094. * @param minHeight is the lower limit of the displacement.
  27095. * @param maxHeight is the upper limit of the displacement.
  27096. * @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.
  27097. * @param uvOffset is an optional vector2 used to offset UV.
  27098. * @param uvScale is an optional vector2 used to scale UV.
  27099. * @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.
  27100. * @returns the Mesh.
  27101. */
  27102. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27103. /**
  27104. * Modifies the mesh geometry according to a displacementMap buffer.
  27105. * 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.
  27106. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27107. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27108. * @param heightMapWidth is the width of the buffer image.
  27109. * @param heightMapHeight is the height of the buffer image.
  27110. * @param minHeight is the lower limit of the displacement.
  27111. * @param maxHeight is the upper limit of the displacement.
  27112. * @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.
  27113. * @param uvOffset is an optional vector2 used to offset UV.
  27114. * @param uvScale is an optional vector2 used to scale UV.
  27115. * @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.
  27116. * @returns the Mesh.
  27117. */
  27118. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27119. /**
  27120. * Modify the mesh to get a flat shading rendering.
  27121. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27122. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27123. * @returns current mesh
  27124. */
  27125. convertToFlatShadedMesh(): Mesh;
  27126. /**
  27127. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27128. * In other words, more vertices, no more indices and a single bigger VBO.
  27129. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27130. * @returns current mesh
  27131. */
  27132. convertToUnIndexedMesh(): Mesh;
  27133. /**
  27134. * Inverses facet orientations.
  27135. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27136. * @param flipNormals will also inverts the normals
  27137. * @returns current mesh
  27138. */
  27139. flipFaces(flipNormals?: boolean): Mesh;
  27140. /**
  27141. * Creates a new InstancedMesh object from the mesh model.
  27142. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27143. * @param name defines the name of the new instance
  27144. * @returns a new InstancedMesh
  27145. */
  27146. createInstance(name: string): InstancedMesh;
  27147. /**
  27148. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27149. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27150. * @returns the current mesh
  27151. */
  27152. synchronizeInstances(): Mesh;
  27153. /**
  27154. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27155. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27156. * This should be used together with the simplification to avoid disappearing triangles.
  27157. * @param successCallback an optional success callback to be called after the optimization finished.
  27158. * @returns the current mesh
  27159. */
  27160. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27161. /**
  27162. * Serialize current mesh
  27163. * @param serializationObject defines the object which will receive the serialization data
  27164. */
  27165. serialize(serializationObject: any): void;
  27166. /** @hidden */
  27167. _syncGeometryWithMorphTargetManager(): void;
  27168. /**
  27169. * Returns a new Mesh object parsed from the source provided.
  27170. * @param parsedMesh is the source
  27171. * @param scene defines the hosting scene
  27172. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27173. * @returns a new Mesh
  27174. */
  27175. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27176. /**
  27177. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27178. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27179. * @param name defines the name of the mesh to create
  27180. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27181. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27182. * @param closePath creates a seam between the first and the last points of each path of the path array
  27183. * @param offset is taken in account only if the `pathArray` is containing a single path
  27184. * @param scene defines the hosting scene
  27185. * @param updatable defines if the mesh must be flagged as updatable
  27186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27187. * @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)
  27188. * @returns a new Mesh
  27189. */
  27190. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27191. /**
  27192. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27193. * @param name defines the name of the mesh to create
  27194. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27195. * @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
  27196. * @param scene defines the hosting scene
  27197. * @param updatable defines if the mesh must be flagged as updatable
  27198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27199. * @returns a new Mesh
  27200. */
  27201. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27202. /**
  27203. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27204. * @param name defines the name of the mesh to create
  27205. * @param size sets the size (float) of each box side (default 1)
  27206. * @param scene defines the hosting scene
  27207. * @param updatable defines if the mesh must be flagged as updatable
  27208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27209. * @returns a new Mesh
  27210. */
  27211. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27212. /**
  27213. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27214. * @param name defines the name of the mesh to create
  27215. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27216. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27217. * @param scene defines the hosting scene
  27218. * @param updatable defines if the mesh must be flagged as updatable
  27219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27220. * @returns a new Mesh
  27221. */
  27222. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27223. /**
  27224. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27225. * @param name defines the name of the mesh to create
  27226. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27227. * @param diameterTop set the top cap diameter (floats, default 1)
  27228. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27229. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27230. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27231. * @param scene defines the hosting scene
  27232. * @param updatable defines if the mesh must be flagged as updatable
  27233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27234. * @returns a new Mesh
  27235. */
  27236. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27237. /**
  27238. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27239. * @param name defines the name of the mesh to create
  27240. * @param diameter sets the diameter size (float) of the torus (default 1)
  27241. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27242. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27243. * @param scene defines the hosting scene
  27244. * @param updatable defines if the mesh must be flagged as updatable
  27245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27246. * @returns a new Mesh
  27247. */
  27248. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27249. /**
  27250. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27251. * @param name defines the name of the mesh to create
  27252. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27253. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27254. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27255. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27256. * @param p the number of windings on X axis (positive integers, default 2)
  27257. * @param q the number of windings on Y axis (positive integers, default 3)
  27258. * @param scene defines the hosting scene
  27259. * @param updatable defines if the mesh must be flagged as updatable
  27260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27261. * @returns a new Mesh
  27262. */
  27263. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27264. /**
  27265. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27266. * @param name defines the name of the mesh to create
  27267. * @param points is an array successive Vector3
  27268. * @param scene defines the hosting scene
  27269. * @param updatable defines if the mesh must be flagged as updatable
  27270. * @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).
  27271. * @returns a new Mesh
  27272. */
  27273. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27274. /**
  27275. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27276. * @param name defines the name of the mesh to create
  27277. * @param points is an array successive Vector3
  27278. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27279. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27280. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27281. * @param scene defines the hosting scene
  27282. * @param updatable defines if the mesh must be flagged as updatable
  27283. * @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)
  27284. * @returns a new Mesh
  27285. */
  27286. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27287. /**
  27288. * Creates a polygon mesh.
  27289. * Please consider using the same method from the MeshBuilder class instead.
  27290. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27291. * 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.
  27292. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27293. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27294. * Remember you can only change the shape positions, not their number when updating a polygon.
  27295. */
  27296. /**
  27297. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27298. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27299. * @param name defines the name of the mesh to create
  27300. * @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
  27301. * @param scene defines the hosting scene
  27302. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27303. * @param updatable defines if the mesh must be flagged as updatable
  27304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27305. * @returns a new Mesh
  27306. */
  27307. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27308. /**
  27309. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27310. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27311. * @param name defines the name of the mesh to create
  27312. * @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
  27313. * @param depth defines the height of extrusion
  27314. * @param scene defines the hosting scene
  27315. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27316. * @param updatable defines if the mesh must be flagged as updatable
  27317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27318. * @returns a new Mesh
  27319. */
  27320. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27321. /**
  27322. * Creates an extruded shape mesh.
  27323. * 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
  27324. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27325. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27326. * @param name defines the name of the mesh to create
  27327. * @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
  27328. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27329. * @param scale is the value to scale the shape
  27330. * @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
  27331. * @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
  27332. * @param scene defines the hosting scene
  27333. * @param updatable defines if the mesh must be flagged as updatable
  27334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27335. * @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)
  27336. * @returns a new Mesh
  27337. */
  27338. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27339. /**
  27340. * Creates an custom extruded shape mesh.
  27341. * The custom extrusion is a parametric shape.
  27342. * It has no predefined shape. Its final shape will depend on the input parameters.
  27343. * Please consider using the same method from the MeshBuilder class instead
  27344. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27345. * @param name defines the name of the mesh to create
  27346. * @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
  27347. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27348. * @param scaleFunction is a custom Javascript function called on each path point
  27349. * @param rotationFunction is a custom Javascript function called on each path point
  27350. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27351. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27352. * @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
  27353. * @param scene defines the hosting scene
  27354. * @param updatable defines if the mesh must be flagged as updatable
  27355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27356. * @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)
  27357. * @returns a new Mesh
  27358. */
  27359. 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;
  27360. /**
  27361. * Creates lathe mesh.
  27362. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27363. * Please consider using the same method from the MeshBuilder class instead
  27364. * @param name defines the name of the mesh to create
  27365. * @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
  27366. * @param radius is the radius value of the lathe
  27367. * @param tessellation is the side number of the lathe.
  27368. * @param scene defines the hosting scene
  27369. * @param updatable defines if the mesh must be flagged as updatable
  27370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27371. * @returns a new Mesh
  27372. */
  27373. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27374. /**
  27375. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27376. * @param name defines the name of the mesh to create
  27377. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27378. * @param scene defines the hosting scene
  27379. * @param updatable defines if the mesh must be flagged as updatable
  27380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27381. * @returns a new Mesh
  27382. */
  27383. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27384. /**
  27385. * Creates a ground mesh.
  27386. * Please consider using the same method from the MeshBuilder class instead
  27387. * @param name defines the name of the mesh to create
  27388. * @param width set the width of the ground
  27389. * @param height set the height of the ground
  27390. * @param subdivisions sets the number of subdivisions per side
  27391. * @param scene defines the hosting scene
  27392. * @param updatable defines if the mesh must be flagged as updatable
  27393. * @returns a new Mesh
  27394. */
  27395. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27396. /**
  27397. * Creates a tiled ground mesh.
  27398. * Please consider using the same method from the MeshBuilder class instead
  27399. * @param name defines the name of the mesh to create
  27400. * @param xmin set the ground minimum X coordinate
  27401. * @param zmin set the ground minimum Y coordinate
  27402. * @param xmax set the ground maximum X coordinate
  27403. * @param zmax set the ground maximum Z coordinate
  27404. * @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
  27405. * @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
  27406. * @param scene defines the hosting scene
  27407. * @param updatable defines if the mesh must be flagged as updatable
  27408. * @returns a new Mesh
  27409. */
  27410. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27411. w: number;
  27412. h: number;
  27413. }, precision: {
  27414. w: number;
  27415. h: number;
  27416. }, scene: Scene, updatable?: boolean): Mesh;
  27417. /**
  27418. * Creates a ground mesh from a height map.
  27419. * Please consider using the same method from the MeshBuilder class instead
  27420. * @see http://doc.babylonjs.com/babylon101/height_map
  27421. * @param name defines the name of the mesh to create
  27422. * @param url sets the URL of the height map image resource
  27423. * @param width set the ground width size
  27424. * @param height set the ground height size
  27425. * @param subdivisions sets the number of subdivision per side
  27426. * @param minHeight is the minimum altitude on the ground
  27427. * @param maxHeight is the maximum altitude on the ground
  27428. * @param scene defines the hosting scene
  27429. * @param updatable defines if the mesh must be flagged as updatable
  27430. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27431. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27432. * @returns a new Mesh
  27433. */
  27434. 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;
  27435. /**
  27436. * Creates a tube mesh.
  27437. * The tube is a parametric shape.
  27438. * It has no predefined shape. Its final shape will depend on the input parameters.
  27439. * Please consider using the same method from the MeshBuilder class instead
  27440. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27441. * @param name defines the name of the mesh to create
  27442. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27443. * @param radius sets the tube radius size
  27444. * @param tessellation is the number of sides on the tubular surface
  27445. * @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
  27446. * @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
  27447. * @param scene defines the hosting scene
  27448. * @param updatable defines if the mesh must be flagged as updatable
  27449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27450. * @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)
  27451. * @returns a new Mesh
  27452. */
  27453. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27454. (i: number, distance: number): number;
  27455. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27456. /**
  27457. * Creates a polyhedron mesh.
  27458. * Please consider using the same method from the MeshBuilder class instead.
  27459. * * 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
  27460. * * The parameter `size` (positive float, default 1) sets the polygon size
  27461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27462. * * 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`
  27463. * * 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
  27464. * * 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)`)
  27465. * * 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
  27466. * * 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
  27467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27468. * * 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
  27469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27470. * @param name defines the name of the mesh to create
  27471. * @param options defines the options used to create the mesh
  27472. * @param scene defines the hosting scene
  27473. * @returns a new Mesh
  27474. */
  27475. static CreatePolyhedron(name: string, options: {
  27476. type?: number;
  27477. size?: number;
  27478. sizeX?: number;
  27479. sizeY?: number;
  27480. sizeZ?: number;
  27481. custom?: any;
  27482. faceUV?: Vector4[];
  27483. faceColors?: Color4[];
  27484. updatable?: boolean;
  27485. sideOrientation?: number;
  27486. }, scene: Scene): Mesh;
  27487. /**
  27488. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27489. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27490. * * 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`)
  27491. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27492. * * 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
  27493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27494. * * 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
  27495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27496. * @param name defines the name of the mesh
  27497. * @param options defines the options used to create the mesh
  27498. * @param scene defines the hosting scene
  27499. * @returns a new Mesh
  27500. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27501. */
  27502. static CreateIcoSphere(name: string, options: {
  27503. radius?: number;
  27504. flat?: boolean;
  27505. subdivisions?: number;
  27506. sideOrientation?: number;
  27507. updatable?: boolean;
  27508. }, scene: Scene): Mesh;
  27509. /**
  27510. * Creates a decal mesh.
  27511. * Please consider using the same method from the MeshBuilder class instead.
  27512. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27513. * @param name defines the name of the mesh
  27514. * @param sourceMesh defines the mesh receiving the decal
  27515. * @param position sets the position of the decal in world coordinates
  27516. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27517. * @param size sets the decal scaling
  27518. * @param angle sets the angle to rotate the decal
  27519. * @returns a new Mesh
  27520. */
  27521. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27522. /**
  27523. * Prepare internal position array for software CPU skinning
  27524. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27525. */
  27526. setPositionsForCPUSkinning(): Float32Array;
  27527. /**
  27528. * Prepare internal normal array for software CPU skinning
  27529. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27530. */
  27531. setNormalsForCPUSkinning(): Float32Array;
  27532. /**
  27533. * Updates the vertex buffer by applying transformation from the bones
  27534. * @param skeleton defines the skeleton to apply to current mesh
  27535. * @returns the current mesh
  27536. */
  27537. applySkeleton(skeleton: Skeleton): Mesh;
  27538. /**
  27539. * 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
  27540. * @param meshes defines the list of meshes to scan
  27541. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27542. */
  27543. static MinMax(meshes: AbstractMesh[]): {
  27544. min: Vector3;
  27545. max: Vector3;
  27546. };
  27547. /**
  27548. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27549. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27550. * @returns a vector3
  27551. */
  27552. static Center(meshesOrMinMaxVector: {
  27553. min: Vector3;
  27554. max: Vector3;
  27555. } | AbstractMesh[]): Vector3;
  27556. /**
  27557. * Merge the array of meshes into a single mesh for performance reasons.
  27558. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27559. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27560. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27561. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27562. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27563. * @returns a new mesh
  27564. */
  27565. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27566. /** @hidden */
  27567. addInstance(instance: InstancedMesh): void;
  27568. /** @hidden */
  27569. removeInstance(instance: InstancedMesh): void;
  27570. }
  27571. }
  27572. declare module BABYLON {
  27573. /**
  27574. * Define an interface for all classes that will get and set the data on vertices
  27575. */
  27576. interface IGetSetVerticesData {
  27577. /**
  27578. * Gets a boolean indicating if specific vertex data is present
  27579. * @param kind defines the vertex data kind to use
  27580. * @returns true is data kind is present
  27581. */
  27582. isVerticesDataPresent(kind: string): boolean;
  27583. /**
  27584. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27585. * @param kind defines the data kind (Position, normal, etc...)
  27586. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27587. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27588. * @returns a float array containing vertex data
  27589. */
  27590. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27591. /**
  27592. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27593. * @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.
  27594. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27595. * @returns the indices array or an empty array if the mesh has no geometry
  27596. */
  27597. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27598. /**
  27599. * Set specific vertex data
  27600. * @param kind defines the data kind (Position, normal, etc...)
  27601. * @param data defines the vertex data to use
  27602. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27603. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27604. */
  27605. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27606. /**
  27607. * Update a specific associated vertex buffer
  27608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27609. * - BABYLON.VertexBuffer.PositionKind
  27610. * - BABYLON.VertexBuffer.UVKind
  27611. * - BABYLON.VertexBuffer.UV2Kind
  27612. * - BABYLON.VertexBuffer.UV3Kind
  27613. * - BABYLON.VertexBuffer.UV4Kind
  27614. * - BABYLON.VertexBuffer.UV5Kind
  27615. * - BABYLON.VertexBuffer.UV6Kind
  27616. * - BABYLON.VertexBuffer.ColorKind
  27617. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27618. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27619. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27620. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27621. * @param data defines the data source
  27622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27623. * @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)
  27624. */
  27625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27626. /**
  27627. * Creates a new index buffer
  27628. * @param indices defines the indices to store in the index buffer
  27629. * @param totalVertices defines the total number of vertices (could be null)
  27630. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27631. */
  27632. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27633. }
  27634. /**
  27635. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27636. */
  27637. class VertexData {
  27638. /**
  27639. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27640. */
  27641. positions: Nullable<FloatArray>;
  27642. /**
  27643. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27644. */
  27645. normals: Nullable<FloatArray>;
  27646. /**
  27647. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27648. */
  27649. tangents: Nullable<FloatArray>;
  27650. /**
  27651. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27652. */
  27653. uvs: Nullable<FloatArray>;
  27654. /**
  27655. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27656. */
  27657. uvs2: Nullable<FloatArray>;
  27658. /**
  27659. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27660. */
  27661. uvs3: Nullable<FloatArray>;
  27662. /**
  27663. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27664. */
  27665. uvs4: Nullable<FloatArray>;
  27666. /**
  27667. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27668. */
  27669. uvs5: Nullable<FloatArray>;
  27670. /**
  27671. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27672. */
  27673. uvs6: Nullable<FloatArray>;
  27674. /**
  27675. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27676. */
  27677. colors: Nullable<FloatArray>;
  27678. /**
  27679. * 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).
  27680. */
  27681. matricesIndices: Nullable<FloatArray>;
  27682. /**
  27683. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27684. */
  27685. matricesWeights: Nullable<FloatArray>;
  27686. /**
  27687. * An array extending the number of possible indices
  27688. */
  27689. matricesIndicesExtra: Nullable<FloatArray>;
  27690. /**
  27691. * An array extending the number of possible weights when the number of indices is extended
  27692. */
  27693. matricesWeightsExtra: Nullable<FloatArray>;
  27694. /**
  27695. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27696. */
  27697. indices: Nullable<IndicesArray>;
  27698. /**
  27699. * Uses the passed data array to set the set the values for the specified kind of data
  27700. * @param data a linear array of floating numbers
  27701. * @param kind the type of data that is being set, eg positions, colors etc
  27702. */
  27703. set(data: FloatArray, kind: string): void;
  27704. /**
  27705. * Associates the vertexData to the passed Mesh.
  27706. * Sets it as updatable or not (default `false`)
  27707. * @param mesh the mesh the vertexData is applied to
  27708. * @param updatable when used and having the value true allows new data to update the vertexData
  27709. * @returns the VertexData
  27710. */
  27711. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27712. /**
  27713. * Associates the vertexData to the passed Geometry.
  27714. * Sets it as updatable or not (default `false`)
  27715. * @param geometry the geometry the vertexData is applied to
  27716. * @param updatable when used and having the value true allows new data to update the vertexData
  27717. * @returns VertexData
  27718. */
  27719. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27720. /**
  27721. * Updates the associated mesh
  27722. * @param mesh the mesh to be updated
  27723. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27724. * @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
  27725. * @returns VertexData
  27726. */
  27727. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27728. /**
  27729. * Updates the associated geometry
  27730. * @param geometry the geometry to be updated
  27731. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27732. * @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
  27733. * @returns VertexData.
  27734. */
  27735. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27736. private _applyTo;
  27737. private _update;
  27738. /**
  27739. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27740. * @param matrix the transforming matrix
  27741. * @returns the VertexData
  27742. */
  27743. transform(matrix: Matrix): VertexData;
  27744. /**
  27745. * Merges the passed VertexData into the current one
  27746. * @param other the VertexData to be merged into the current one
  27747. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27748. * @returns the modified VertexData
  27749. */
  27750. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27751. private _mergeElement;
  27752. private _validate;
  27753. /**
  27754. * Serializes the VertexData
  27755. * @returns a serialized object
  27756. */
  27757. serialize(): any;
  27758. /**
  27759. * Extracts the vertexData from a mesh
  27760. * @param mesh the mesh from which to extract the VertexData
  27761. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27762. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27763. * @returns the object VertexData associated to the passed mesh
  27764. */
  27765. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27766. /**
  27767. * Extracts the vertexData from the geometry
  27768. * @param geometry the geometry from which to extract the VertexData
  27769. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27770. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27771. * @returns the object VertexData associated to the passed mesh
  27772. */
  27773. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27774. private static _ExtractFrom;
  27775. /**
  27776. * Creates the VertexData for a Ribbon
  27777. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27778. * * pathArray array of paths, each of which an array of successive Vector3
  27779. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27780. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27781. * * 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
  27782. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27783. * * 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)
  27784. * * 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)
  27785. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27786. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27787. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27788. * @returns the VertexData of the ribbon
  27789. */
  27790. static CreateRibbon(options: {
  27791. pathArray: Vector3[][];
  27792. closeArray?: boolean;
  27793. closePath?: boolean;
  27794. offset?: number;
  27795. sideOrientation?: number;
  27796. frontUVs?: Vector4;
  27797. backUVs?: Vector4;
  27798. invertUV?: boolean;
  27799. uvs?: Vector2[];
  27800. colors?: Color4[];
  27801. }): VertexData;
  27802. /**
  27803. * Creates the VertexData for a box
  27804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27805. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27806. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27807. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27808. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27809. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27810. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27811. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27812. * * 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)
  27813. * * 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)
  27814. * @returns the VertexData of the box
  27815. */
  27816. static CreateBox(options: {
  27817. size?: number;
  27818. width?: number;
  27819. height?: number;
  27820. depth?: number;
  27821. faceUV?: Vector4[];
  27822. faceColors?: Color4[];
  27823. sideOrientation?: number;
  27824. frontUVs?: Vector4;
  27825. backUVs?: Vector4;
  27826. }): VertexData;
  27827. /**
  27828. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27829. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27830. * * segments sets the number of horizontal strips optional, default 32
  27831. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27832. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27833. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27834. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27835. * * 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
  27836. * * 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
  27837. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27838. * * 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)
  27839. * * 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)
  27840. * @returns the VertexData of the ellipsoid
  27841. */
  27842. static CreateSphere(options: {
  27843. segments?: number;
  27844. diameter?: number;
  27845. diameterX?: number;
  27846. diameterY?: number;
  27847. diameterZ?: number;
  27848. arc?: number;
  27849. slice?: number;
  27850. sideOrientation?: number;
  27851. frontUVs?: Vector4;
  27852. backUVs?: Vector4;
  27853. }): VertexData;
  27854. /**
  27855. * Creates the VertexData for a cylinder, cone or prism
  27856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27857. * * height sets the height (y direction) of the cylinder, optional, default 2
  27858. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27859. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27860. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27861. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27862. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27863. * * 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
  27864. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27865. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27866. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27867. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27868. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27869. * * 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)
  27870. * * 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)
  27871. * @returns the VertexData of the cylinder, cone or prism
  27872. */
  27873. static CreateCylinder(options: {
  27874. height?: number;
  27875. diameterTop?: number;
  27876. diameterBottom?: number;
  27877. diameter?: number;
  27878. tessellation?: number;
  27879. subdivisions?: number;
  27880. arc?: number;
  27881. faceColors?: Color4[];
  27882. faceUV?: Vector4[];
  27883. hasRings?: boolean;
  27884. enclose?: boolean;
  27885. sideOrientation?: number;
  27886. frontUVs?: Vector4;
  27887. backUVs?: Vector4;
  27888. }): VertexData;
  27889. /**
  27890. * Creates the VertexData for a torus
  27891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27892. * * diameter the diameter of the torus, optional default 1
  27893. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27894. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27895. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27896. * * 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)
  27897. * * 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)
  27898. * @returns the VertexData of the torus
  27899. */
  27900. static CreateTorus(options: {
  27901. diameter?: number;
  27902. thickness?: number;
  27903. tessellation?: number;
  27904. sideOrientation?: number;
  27905. frontUVs?: Vector4;
  27906. backUVs?: Vector4;
  27907. }): VertexData;
  27908. /**
  27909. * Creates the VertexData of the LineSystem
  27910. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27911. * - lines an array of lines, each line being an array of successive Vector3
  27912. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27913. * @returns the VertexData of the LineSystem
  27914. */
  27915. static CreateLineSystem(options: {
  27916. lines: Vector3[][];
  27917. colors?: Nullable<Color4[][]>;
  27918. }): VertexData;
  27919. /**
  27920. * Create the VertexData for a DashedLines
  27921. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27922. * - points an array successive Vector3
  27923. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27924. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27925. * - dashNb the intended total number of dashes, optional, default 200
  27926. * @returns the VertexData for the DashedLines
  27927. */
  27928. static CreateDashedLines(options: {
  27929. points: Vector3[];
  27930. dashSize?: number;
  27931. gapSize?: number;
  27932. dashNb?: number;
  27933. }): VertexData;
  27934. /**
  27935. * Creates the VertexData for a Ground
  27936. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27937. * - width the width (x direction) of the ground, optional, default 1
  27938. * - height the height (z direction) of the ground, optional, default 1
  27939. * - subdivisions the number of subdivisions per side, optional, default 1
  27940. * @returns the VertexData of the Ground
  27941. */
  27942. static CreateGround(options: {
  27943. width?: number;
  27944. height?: number;
  27945. subdivisions?: number;
  27946. subdivisionsX?: number;
  27947. subdivisionsY?: number;
  27948. }): VertexData;
  27949. /**
  27950. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27951. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27952. * * xmin the ground minimum X coordinate, optional, default -1
  27953. * * zmin the ground minimum Z coordinate, optional, default -1
  27954. * * xmax the ground maximum X coordinate, optional, default 1
  27955. * * zmax the ground maximum Z coordinate, optional, default 1
  27956. * * 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}
  27957. * * 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}
  27958. * @returns the VertexData of the TiledGround
  27959. */
  27960. static CreateTiledGround(options: {
  27961. xmin: number;
  27962. zmin: number;
  27963. xmax: number;
  27964. zmax: number;
  27965. subdivisions?: {
  27966. w: number;
  27967. h: number;
  27968. };
  27969. precision?: {
  27970. w: number;
  27971. h: number;
  27972. };
  27973. }): VertexData;
  27974. /**
  27975. * Creates the VertexData of the Ground designed from a heightmap
  27976. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27977. * * width the width (x direction) of the ground
  27978. * * height the height (z direction) of the ground
  27979. * * subdivisions the number of subdivisions per side
  27980. * * minHeight the minimum altitude on the ground, optional, default 0
  27981. * * maxHeight the maximum altitude on the ground, optional default 1
  27982. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27983. * * buffer the array holding the image color data
  27984. * * bufferWidth the width of image
  27985. * * bufferHeight the height of image
  27986. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27987. * @returns the VertexData of the Ground designed from a heightmap
  27988. */
  27989. static CreateGroundFromHeightMap(options: {
  27990. width: number;
  27991. height: number;
  27992. subdivisions: number;
  27993. minHeight: number;
  27994. maxHeight: number;
  27995. colorFilter: Color3;
  27996. buffer: Uint8Array;
  27997. bufferWidth: number;
  27998. bufferHeight: number;
  27999. alphaFilter: number;
  28000. }): VertexData;
  28001. /**
  28002. * Creates the VertexData for a Plane
  28003. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28004. * * size sets the width and height of the plane to the value of size, optional default 1
  28005. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28006. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28007. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28008. * * 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)
  28009. * * 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)
  28010. * @returns the VertexData of the box
  28011. */
  28012. static CreatePlane(options: {
  28013. size?: number;
  28014. width?: number;
  28015. height?: number;
  28016. sideOrientation?: number;
  28017. frontUVs?: Vector4;
  28018. backUVs?: Vector4;
  28019. }): VertexData;
  28020. /**
  28021. * Creates the VertexData of the Disc or regular Polygon
  28022. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28023. * * radius the radius of the disc, optional default 0.5
  28024. * * tessellation the number of polygon sides, optional, default 64
  28025. * * 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
  28026. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28027. * * 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)
  28028. * * 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)
  28029. * @returns the VertexData of the box
  28030. */
  28031. static CreateDisc(options: {
  28032. radius?: number;
  28033. tessellation?: number;
  28034. arc?: number;
  28035. sideOrientation?: number;
  28036. frontUVs?: Vector4;
  28037. backUVs?: Vector4;
  28038. }): VertexData;
  28039. /**
  28040. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28041. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28042. * @param polygon a mesh built from polygonTriangulation.build()
  28043. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28044. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28045. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28046. * @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)
  28047. * @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)
  28048. * @returns the VertexData of the Polygon
  28049. */
  28050. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28051. /**
  28052. * Creates the VertexData of the IcoSphere
  28053. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28054. * * radius the radius of the IcoSphere, optional default 1
  28055. * * radiusX allows stretching in the x direction, optional, default radius
  28056. * * radiusY allows stretching in the y direction, optional, default radius
  28057. * * radiusZ allows stretching in the z direction, optional, default radius
  28058. * * flat when true creates a flat shaded mesh, optional, default true
  28059. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28060. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28061. * * 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)
  28062. * * 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)
  28063. * @returns the VertexData of the IcoSphere
  28064. */
  28065. static CreateIcoSphere(options: {
  28066. radius?: number;
  28067. radiusX?: number;
  28068. radiusY?: number;
  28069. radiusZ?: number;
  28070. flat?: boolean;
  28071. subdivisions?: number;
  28072. sideOrientation?: number;
  28073. frontUVs?: Vector4;
  28074. backUVs?: Vector4;
  28075. }): VertexData;
  28076. /**
  28077. * Creates the VertexData for a Polyhedron
  28078. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28079. * * type provided types are:
  28080. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28081. * * 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)
  28082. * * size the size of the IcoSphere, optional default 1
  28083. * * sizeX allows stretching in the x direction, optional, default size
  28084. * * sizeY allows stretching in the y direction, optional, default size
  28085. * * sizeZ allows stretching in the z direction, optional, default size
  28086. * * 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
  28087. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28088. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28089. * * flat when true creates a flat shaded mesh, optional, default true
  28090. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28091. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28092. * * 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)
  28093. * * 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)
  28094. * @returns the VertexData of the Polyhedron
  28095. */
  28096. static CreatePolyhedron(options: {
  28097. type?: number;
  28098. size?: number;
  28099. sizeX?: number;
  28100. sizeY?: number;
  28101. sizeZ?: number;
  28102. custom?: any;
  28103. faceUV?: Vector4[];
  28104. faceColors?: Color4[];
  28105. flat?: boolean;
  28106. sideOrientation?: number;
  28107. frontUVs?: Vector4;
  28108. backUVs?: Vector4;
  28109. }): VertexData;
  28110. /**
  28111. * Creates the VertexData for a TorusKnot
  28112. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28113. * * radius the radius of the torus knot, optional, default 2
  28114. * * tube the thickness of the tube, optional, default 0.5
  28115. * * radialSegments the number of sides on each tube segments, optional, default 32
  28116. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28117. * * p the number of windings around the z axis, optional, default 2
  28118. * * q the number of windings around the x axis, optional, default 3
  28119. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28120. * * 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)
  28121. * * 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)
  28122. * @returns the VertexData of the Torus Knot
  28123. */
  28124. static CreateTorusKnot(options: {
  28125. radius?: number;
  28126. tube?: number;
  28127. radialSegments?: number;
  28128. tubularSegments?: number;
  28129. p?: number;
  28130. q?: number;
  28131. sideOrientation?: number;
  28132. frontUVs?: Vector4;
  28133. backUVs?: Vector4;
  28134. }): VertexData;
  28135. /**
  28136. * Compute normals for given positions and indices
  28137. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28138. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28139. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28140. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28141. * * facetNormals : optional array of facet normals (vector3)
  28142. * * facetPositions : optional array of facet positions (vector3)
  28143. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28144. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28145. * * bInfo : optional bounding info, required for facetPartitioning computation
  28146. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28147. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28148. * * useRightHandedSystem: optional boolean to for right handed system computation
  28149. * * depthSort : optional boolean to enable the facet depth sort computation
  28150. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28151. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28152. */
  28153. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28154. facetNormals?: any;
  28155. facetPositions?: any;
  28156. facetPartitioning?: any;
  28157. ratio?: number;
  28158. bInfo?: any;
  28159. bbSize?: Vector3;
  28160. subDiv?: any;
  28161. useRightHandedSystem?: boolean;
  28162. depthSort?: boolean;
  28163. distanceTo?: Vector3;
  28164. depthSortedFacets?: any;
  28165. }): void;
  28166. private static _ComputeSides;
  28167. /**
  28168. * Applies VertexData created from the imported parameters to the geometry
  28169. * @param parsedVertexData the parsed data from an imported file
  28170. * @param geometry the geometry to apply the VertexData to
  28171. */
  28172. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28173. }
  28174. }
  28175. declare module BABYLON {
  28176. /**
  28177. * Class containing static functions to help procedurally build meshes
  28178. */
  28179. class MeshBuilder {
  28180. private static updateSideOrientation;
  28181. /**
  28182. * Creates a box mesh
  28183. * * The parameter `size` sets the size (float) of each box side (default 1)
  28184. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28185. * * 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)
  28186. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28188. * * 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
  28189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28190. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28191. * @param name defines the name of the mesh
  28192. * @param options defines the options used to create the mesh
  28193. * @param scene defines the hosting scene
  28194. * @returns the box mesh
  28195. */
  28196. static CreateBox(name: string, options: {
  28197. size?: number;
  28198. width?: number;
  28199. height?: number;
  28200. depth?: number;
  28201. faceUV?: Vector4[];
  28202. faceColors?: Color4[];
  28203. sideOrientation?: number;
  28204. frontUVs?: Vector4;
  28205. backUVs?: Vector4;
  28206. updatable?: boolean;
  28207. }, scene?: Nullable<Scene>): Mesh;
  28208. /**
  28209. * Creates a sphere mesh
  28210. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28211. * * 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`)
  28212. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28213. * * 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
  28214. * * 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)
  28215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28216. * * 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
  28217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28218. * @param name defines the name of the mesh
  28219. * @param options defines the options used to create the mesh
  28220. * @param scene defines the hosting scene
  28221. * @returns the sphere mesh
  28222. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28223. */
  28224. static CreateSphere(name: string, options: {
  28225. segments?: number;
  28226. diameter?: number;
  28227. diameterX?: number;
  28228. diameterY?: number;
  28229. diameterZ?: number;
  28230. arc?: number;
  28231. slice?: number;
  28232. sideOrientation?: number;
  28233. frontUVs?: Vector4;
  28234. backUVs?: Vector4;
  28235. updatable?: boolean;
  28236. }, scene: any): Mesh;
  28237. /**
  28238. * Creates a plane polygonal mesh. By default, this is a disc
  28239. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28240. * * 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
  28241. * * 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
  28242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28243. * * 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
  28244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28245. * @param name defines the name of the mesh
  28246. * @param options defines the options used to create the mesh
  28247. * @param scene defines the hosting scene
  28248. * @returns the plane polygonal mesh
  28249. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28250. */
  28251. static CreateDisc(name: string, options: {
  28252. radius?: number;
  28253. tessellation?: number;
  28254. arc?: number;
  28255. updatable?: boolean;
  28256. sideOrientation?: number;
  28257. frontUVs?: Vector4;
  28258. backUVs?: Vector4;
  28259. }, scene?: Nullable<Scene>): Mesh;
  28260. /**
  28261. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28262. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28263. * * 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`)
  28264. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28265. * * 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
  28266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28267. * * 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
  28268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28269. * @param name defines the name of the mesh
  28270. * @param options defines the options used to create the mesh
  28271. * @param scene defines the hosting scene
  28272. * @returns the icosahedron mesh
  28273. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28274. */
  28275. static CreateIcoSphere(name: string, options: {
  28276. radius?: number;
  28277. radiusX?: number;
  28278. radiusY?: number;
  28279. radiusZ?: number;
  28280. flat?: boolean;
  28281. subdivisions?: number;
  28282. sideOrientation?: number;
  28283. frontUVs?: Vector4;
  28284. backUVs?: Vector4;
  28285. updatable?: boolean;
  28286. }, scene: Scene): Mesh;
  28287. /**
  28288. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28289. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28290. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28291. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28292. * * 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
  28293. * * 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
  28294. * * 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
  28295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28296. * * 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
  28297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28298. * * 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
  28299. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28300. * * 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
  28301. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28303. * @param name defines the name of the mesh
  28304. * @param options defines the options used to create the mesh
  28305. * @param scene defines the hosting scene
  28306. * @returns the ribbon mesh
  28307. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28309. */
  28310. static CreateRibbon(name: string, options: {
  28311. pathArray: Vector3[][];
  28312. closeArray?: boolean;
  28313. closePath?: boolean;
  28314. offset?: number;
  28315. updatable?: boolean;
  28316. sideOrientation?: number;
  28317. frontUVs?: Vector4;
  28318. backUVs?: Vector4;
  28319. instance?: Mesh;
  28320. invertUV?: boolean;
  28321. uvs?: Vector2[];
  28322. colors?: Color4[];
  28323. }, scene?: Nullable<Scene>): Mesh;
  28324. /**
  28325. * Creates a cylinder or a cone mesh
  28326. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28327. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28328. * * 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.
  28329. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28330. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28331. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28332. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28333. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28334. * * 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).
  28335. * * 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
  28336. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28337. * * 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
  28338. * * 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.
  28339. * * If `enclose` is false, a ring surface is one element.
  28340. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28341. * * 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
  28342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28343. * * 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
  28344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28345. * @param name defines the name of the mesh
  28346. * @param options defines the options used to create the mesh
  28347. * @param scene defines the hosting scene
  28348. * @returns the cylinder mesh
  28349. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28350. */
  28351. static CreateCylinder(name: string, options: {
  28352. height?: number;
  28353. diameterTop?: number;
  28354. diameterBottom?: number;
  28355. diameter?: number;
  28356. tessellation?: number;
  28357. subdivisions?: number;
  28358. arc?: number;
  28359. faceColors?: Color4[];
  28360. faceUV?: Vector4[];
  28361. updatable?: boolean;
  28362. hasRings?: boolean;
  28363. enclose?: boolean;
  28364. sideOrientation?: number;
  28365. frontUVs?: Vector4;
  28366. backUVs?: Vector4;
  28367. }, scene: any): Mesh;
  28368. /**
  28369. * Creates a torus mesh
  28370. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28371. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28372. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28374. * * 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
  28375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28376. * @param name defines the name of the mesh
  28377. * @param options defines the options used to create the mesh
  28378. * @param scene defines the hosting scene
  28379. * @returns the torus mesh
  28380. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28381. */
  28382. static CreateTorus(name: string, options: {
  28383. diameter?: number;
  28384. thickness?: number;
  28385. tessellation?: number;
  28386. updatable?: boolean;
  28387. sideOrientation?: number;
  28388. frontUVs?: Vector4;
  28389. backUVs?: Vector4;
  28390. }, scene: any): Mesh;
  28391. /**
  28392. * Creates a torus knot mesh
  28393. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28394. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28395. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28396. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28398. * * 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
  28399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28400. * @param name defines the name of the mesh
  28401. * @param options defines the options used to create the mesh
  28402. * @param scene defines the hosting scene
  28403. * @returns the torus knot mesh
  28404. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28405. */
  28406. static CreateTorusKnot(name: string, options: {
  28407. radius?: number;
  28408. tube?: number;
  28409. radialSegments?: number;
  28410. tubularSegments?: number;
  28411. p?: number;
  28412. q?: number;
  28413. updatable?: boolean;
  28414. sideOrientation?: number;
  28415. frontUVs?: Vector4;
  28416. backUVs?: Vector4;
  28417. }, scene: any): Mesh;
  28418. /**
  28419. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28420. * * 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
  28421. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28422. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28423. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28424. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28425. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28426. * * 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
  28427. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28430. * @param name defines the name of the new line system
  28431. * @param options defines the options used to create the line system
  28432. * @param scene defines the hosting scene
  28433. * @returns a new line system mesh
  28434. */
  28435. static CreateLineSystem(name: string, options: {
  28436. lines: Vector3[][];
  28437. updatable?: boolean;
  28438. instance?: Nullable<LinesMesh>;
  28439. colors?: Nullable<Color4[][]>;
  28440. useVertexAlpha?: boolean;
  28441. }, scene: Nullable<Scene>): LinesMesh;
  28442. /**
  28443. * Creates a line mesh
  28444. * 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
  28445. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28446. * * The parameter `points` is an array successive Vector3
  28447. * * 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
  28448. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28449. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28450. * * When updating an instance, remember that only point positions can change, not the number of points
  28451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28453. * @param name defines the name of the new line system
  28454. * @param options defines the options used to create the line system
  28455. * @param scene defines the hosting scene
  28456. * @returns a new line mesh
  28457. */
  28458. static CreateLines(name: string, options: {
  28459. points: Vector3[];
  28460. updatable?: boolean;
  28461. instance?: Nullable<LinesMesh>;
  28462. colors?: Color4[];
  28463. useVertexAlpha?: boolean;
  28464. }, scene?: Nullable<Scene>): LinesMesh;
  28465. /**
  28466. * Creates a dashed line mesh
  28467. * * 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
  28468. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28469. * * The parameter `points` is an array successive Vector3
  28470. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28471. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28472. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28473. * * 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
  28474. * * When updating an instance, remember that only point positions can change, not the number of points
  28475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28476. * @param name defines the name of the mesh
  28477. * @param options defines the options used to create the mesh
  28478. * @param scene defines the hosting scene
  28479. * @returns the dashed line mesh
  28480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28481. */
  28482. static CreateDashedLines(name: string, options: {
  28483. points: Vector3[];
  28484. dashSize?: number;
  28485. gapSize?: number;
  28486. dashNb?: number;
  28487. updatable?: boolean;
  28488. instance?: LinesMesh;
  28489. }, scene?: Nullable<Scene>): LinesMesh;
  28490. /**
  28491. * 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.
  28492. * * 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.
  28493. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28494. * * 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.
  28495. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28496. * * 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
  28497. * * 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
  28498. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28500. * * 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
  28501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28503. * @param name defines the name of the mesh
  28504. * @param options defines the options used to create the mesh
  28505. * @param scene defines the hosting scene
  28506. * @returns the extruded shape mesh
  28507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28509. */
  28510. static ExtrudeShape(name: string, options: {
  28511. shape: Vector3[];
  28512. path: Vector3[];
  28513. scale?: number;
  28514. rotation?: number;
  28515. cap?: number;
  28516. updatable?: boolean;
  28517. sideOrientation?: number;
  28518. frontUVs?: Vector4;
  28519. backUVs?: Vector4;
  28520. instance?: Mesh;
  28521. invertUV?: boolean;
  28522. }, scene?: Nullable<Scene>): Mesh;
  28523. /**
  28524. * Creates an custom extruded shape mesh.
  28525. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28526. * * 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.
  28527. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28528. * * 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
  28529. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28530. * * 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
  28531. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28532. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28533. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28534. * * 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
  28535. * * 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
  28536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28538. * * 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
  28539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28541. * @param name defines the name of the mesh
  28542. * @param options defines the options used to create the mesh
  28543. * @param scene defines the hosting scene
  28544. * @returns the custom extruded shape mesh
  28545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28548. */
  28549. static ExtrudeShapeCustom(name: string, options: {
  28550. shape: Vector3[];
  28551. path: Vector3[];
  28552. scaleFunction?: any;
  28553. rotationFunction?: any;
  28554. ribbonCloseArray?: boolean;
  28555. ribbonClosePath?: boolean;
  28556. cap?: number;
  28557. updatable?: boolean;
  28558. sideOrientation?: number;
  28559. frontUVs?: Vector4;
  28560. backUVs?: Vector4;
  28561. instance?: Mesh;
  28562. invertUV?: boolean;
  28563. }, scene: Scene): Mesh;
  28564. /**
  28565. * Creates lathe mesh.
  28566. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28567. * * 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
  28568. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28569. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28570. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28571. * * 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
  28572. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28573. * * 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
  28574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28575. * * 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
  28576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28578. * @param name defines the name of the mesh
  28579. * @param options defines the options used to create the mesh
  28580. * @param scene defines the hosting scene
  28581. * @returns the lathe mesh
  28582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28583. */
  28584. static CreateLathe(name: string, options: {
  28585. shape: Vector3[];
  28586. radius?: number;
  28587. tessellation?: number;
  28588. clip?: number;
  28589. arc?: number;
  28590. closed?: boolean;
  28591. updatable?: boolean;
  28592. sideOrientation?: number;
  28593. frontUVs?: Vector4;
  28594. backUVs?: Vector4;
  28595. cap?: number;
  28596. invertUV?: boolean;
  28597. }, scene: Scene): Mesh;
  28598. /**
  28599. * Creates a plane mesh
  28600. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28601. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28602. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28604. * * 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
  28605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28606. * @param name defines the name of the mesh
  28607. * @param options defines the options used to create the mesh
  28608. * @param scene defines the hosting scene
  28609. * @returns the plane mesh
  28610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28611. */
  28612. static CreatePlane(name: string, options: {
  28613. size?: number;
  28614. width?: number;
  28615. height?: number;
  28616. sideOrientation?: number;
  28617. frontUVs?: Vector4;
  28618. backUVs?: Vector4;
  28619. updatable?: boolean;
  28620. sourcePlane?: Plane;
  28621. }, scene: Scene): Mesh;
  28622. /**
  28623. * Creates a ground mesh
  28624. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28625. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28627. * @param name defines the name of the mesh
  28628. * @param options defines the options used to create the mesh
  28629. * @param scene defines the hosting scene
  28630. * @returns the ground mesh
  28631. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28632. */
  28633. static CreateGround(name: string, options: {
  28634. width?: number;
  28635. height?: number;
  28636. subdivisions?: number;
  28637. subdivisionsX?: number;
  28638. subdivisionsY?: number;
  28639. updatable?: boolean;
  28640. }, scene: any): Mesh;
  28641. /**
  28642. * Creates a tiled ground mesh
  28643. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28644. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28645. * * 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
  28646. * * 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
  28647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28648. * @param name defines the name of the mesh
  28649. * @param options defines the options used to create the mesh
  28650. * @param scene defines the hosting scene
  28651. * @returns the tiled ground mesh
  28652. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28653. */
  28654. static CreateTiledGround(name: string, options: {
  28655. xmin: number;
  28656. zmin: number;
  28657. xmax: number;
  28658. zmax: number;
  28659. subdivisions?: {
  28660. w: number;
  28661. h: number;
  28662. };
  28663. precision?: {
  28664. w: number;
  28665. h: number;
  28666. };
  28667. updatable?: boolean;
  28668. }, scene: Scene): Mesh;
  28669. /**
  28670. * Creates a ground mesh from a height map
  28671. * * The parameter `url` sets the URL of the height map image resource.
  28672. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28673. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28674. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28675. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28676. * * 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.
  28677. * * 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).
  28678. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28680. * @param name defines the name of the mesh
  28681. * @param url defines the url to the height map
  28682. * @param options defines the options used to create the mesh
  28683. * @param scene defines the hosting scene
  28684. * @returns the ground mesh
  28685. * @see https://doc.babylonjs.com/babylon101/height_map
  28686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28687. */
  28688. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28689. width?: number;
  28690. height?: number;
  28691. subdivisions?: number;
  28692. minHeight?: number;
  28693. maxHeight?: number;
  28694. colorFilter?: Color3;
  28695. alphaFilter?: number;
  28696. updatable?: boolean;
  28697. onReady?: (mesh: GroundMesh) => void;
  28698. }, scene: Scene): GroundMesh;
  28699. /**
  28700. * Creates a polygon mesh
  28701. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28702. * * 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
  28703. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28705. * * 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)
  28706. * * Remember you can only change the shape positions, not their number when updating a polygon
  28707. * @param name defines the name of the mesh
  28708. * @param options defines the options used to create the mesh
  28709. * @param scene defines the hosting scene
  28710. * @returns the polygon mesh
  28711. */
  28712. static CreatePolygon(name: string, options: {
  28713. shape: Vector3[];
  28714. holes?: Vector3[][];
  28715. depth?: number;
  28716. faceUV?: Vector4[];
  28717. faceColors?: Color4[];
  28718. updatable?: boolean;
  28719. sideOrientation?: number;
  28720. frontUVs?: Vector4;
  28721. backUVs?: Vector4;
  28722. }, scene: Scene): Mesh;
  28723. /**
  28724. * Creates an extruded polygon mesh, with depth in the Y direction.
  28725. * * 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)
  28726. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28727. * @param name defines the name of the mesh
  28728. * @param options defines the options used to create the mesh
  28729. * @param scene defines the hosting scene
  28730. * @returns the polygon mesh
  28731. */
  28732. static ExtrudePolygon(name: string, options: {
  28733. shape: Vector3[];
  28734. holes?: Vector3[][];
  28735. depth?: number;
  28736. faceUV?: Vector4[];
  28737. faceColors?: Color4[];
  28738. updatable?: boolean;
  28739. sideOrientation?: number;
  28740. frontUVs?: Vector4;
  28741. backUVs?: Vector4;
  28742. }, scene: Scene): Mesh;
  28743. /**
  28744. * Creates a tube mesh.
  28745. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28746. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28747. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28748. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28749. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28750. * * 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)
  28751. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28752. * * 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
  28753. * * 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
  28754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28755. * * 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
  28756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28758. * @param name defines the name of the mesh
  28759. * @param options defines the options used to create the mesh
  28760. * @param scene defines the hosting scene
  28761. * @returns the tube mesh
  28762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28763. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28764. */
  28765. static CreateTube(name: string, options: {
  28766. path: Vector3[];
  28767. radius?: number;
  28768. tessellation?: number;
  28769. radiusFunction?: {
  28770. (i: number, distance: number): number;
  28771. };
  28772. cap?: number;
  28773. arc?: number;
  28774. updatable?: boolean;
  28775. sideOrientation?: number;
  28776. frontUVs?: Vector4;
  28777. backUVs?: Vector4;
  28778. instance?: Mesh;
  28779. invertUV?: boolean;
  28780. }, scene: Scene): Mesh;
  28781. /**
  28782. * Creates a polyhedron mesh
  28783. * * 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
  28784. * * The parameter `size` (positive float, default 1) sets the polygon size
  28785. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28786. * * 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`
  28787. * * 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
  28788. * * 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)`)
  28789. * * 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
  28790. * * 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
  28791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28792. * * 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
  28793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28794. * @param name defines the name of the mesh
  28795. * @param options defines the options used to create the mesh
  28796. * @param scene defines the hosting scene
  28797. * @returns the polyhedron mesh
  28798. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28799. */
  28800. static CreatePolyhedron(name: string, options: {
  28801. type?: number;
  28802. size?: number;
  28803. sizeX?: number;
  28804. sizeY?: number;
  28805. sizeZ?: number;
  28806. custom?: any;
  28807. faceUV?: Vector4[];
  28808. faceColors?: Color4[];
  28809. flat?: boolean;
  28810. updatable?: boolean;
  28811. sideOrientation?: number;
  28812. frontUVs?: Vector4;
  28813. backUVs?: Vector4;
  28814. }, scene: Scene): Mesh;
  28815. /**
  28816. * Creates a decal mesh.
  28817. * 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
  28818. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28819. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28820. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28821. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28822. * @param name defines the name of the mesh
  28823. * @param sourceMesh defines the mesh where the decal must be applied
  28824. * @param options defines the options used to create the mesh
  28825. * @param scene defines the hosting scene
  28826. * @returns the decal mesh
  28827. * @see https://doc.babylonjs.com/how_to/decals
  28828. */
  28829. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28830. position?: Vector3;
  28831. normal?: Vector3;
  28832. size?: Vector3;
  28833. angle?: number;
  28834. }): Mesh;
  28835. private static _ExtrudeShapeGeneric;
  28836. }
  28837. }
  28838. declare module BABYLON {
  28839. /**
  28840. * Class used to represent a specific level of detail of a mesh
  28841. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28842. */
  28843. class MeshLODLevel {
  28844. /** Defines the distance where this level should star being displayed */
  28845. distance: number;
  28846. /** Defines the mesh to use to render this level */
  28847. mesh: Nullable<Mesh>;
  28848. /**
  28849. * Creates a new LOD level
  28850. * @param distance defines the distance where this level should star being displayed
  28851. * @param mesh defines the mesh to use to render this level
  28852. */
  28853. constructor(
  28854. /** Defines the distance where this level should star being displayed */
  28855. distance: number,
  28856. /** Defines the mesh to use to render this level */
  28857. mesh: Nullable<Mesh>);
  28858. }
  28859. }
  28860. declare module BABYLON {
  28861. /**
  28862. * A simplifier interface for future simplification implementations
  28863. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28864. */
  28865. interface ISimplifier {
  28866. /**
  28867. * Simplification of a given mesh according to the given settings.
  28868. * Since this requires computation, it is assumed that the function runs async.
  28869. * @param settings The settings of the simplification, including quality and distance
  28870. * @param successCallback A callback that will be called after the mesh was simplified.
  28871. * @param errorCallback in case of an error, this callback will be called. optional.
  28872. */
  28873. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28874. }
  28875. /**
  28876. * Expected simplification settings.
  28877. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28879. */
  28880. interface ISimplificationSettings {
  28881. /**
  28882. * Gets or sets the expected quality
  28883. */
  28884. quality: number;
  28885. /**
  28886. * Gets or sets the distance when this optimized version should be used
  28887. */
  28888. distance: number;
  28889. /**
  28890. * Gets an already optimized mesh
  28891. */
  28892. optimizeMesh?: boolean;
  28893. }
  28894. /**
  28895. * Class used to specify simplification options
  28896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28897. */
  28898. class SimplificationSettings implements ISimplificationSettings {
  28899. /** expected quality */
  28900. quality: number;
  28901. /** distance when this optimized version should be used */
  28902. distance: number;
  28903. /** already optimized mesh */
  28904. optimizeMesh?: boolean | undefined;
  28905. /**
  28906. * Creates a SimplificationSettings
  28907. * @param quality expected quality
  28908. * @param distance distance when this optimized version should be used
  28909. * @param optimizeMesh already optimized mesh
  28910. */
  28911. constructor(
  28912. /** expected quality */
  28913. quality: number,
  28914. /** distance when this optimized version should be used */
  28915. distance: number,
  28916. /** already optimized mesh */
  28917. optimizeMesh?: boolean | undefined);
  28918. }
  28919. /**
  28920. * Interface used to define a simplification task
  28921. */
  28922. interface ISimplificationTask {
  28923. /**
  28924. * Array of settings
  28925. */
  28926. settings: Array<ISimplificationSettings>;
  28927. /**
  28928. * Simplification type
  28929. */
  28930. simplificationType: SimplificationType;
  28931. /**
  28932. * Mesh to simplify
  28933. */
  28934. mesh: Mesh;
  28935. /**
  28936. * Callback called on success
  28937. */
  28938. successCallback?: () => void;
  28939. /**
  28940. * Defines if parallel processing can be used
  28941. */
  28942. parallelProcessing: boolean;
  28943. }
  28944. /**
  28945. * Queue used to order the simplification tasks
  28946. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28947. */
  28948. class SimplificationQueue {
  28949. private _simplificationArray;
  28950. /**
  28951. * Gets a boolean indicating that the process is still running
  28952. */
  28953. running: boolean;
  28954. /**
  28955. * Creates a new queue
  28956. */
  28957. constructor();
  28958. /**
  28959. * Adds a new simplification task
  28960. * @param task defines a task to add
  28961. */
  28962. addTask(task: ISimplificationTask): void;
  28963. /**
  28964. * Execute next task
  28965. */
  28966. executeNext(): void;
  28967. /**
  28968. * Execute a simplification task
  28969. * @param task defines the task to run
  28970. */
  28971. runSimplification(task: ISimplificationTask): void;
  28972. private getSimplifier;
  28973. }
  28974. /**
  28975. * The implemented types of simplification
  28976. * At the moment only Quadratic Error Decimation is implemented
  28977. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28978. */
  28979. enum SimplificationType {
  28980. /** Quadratic error decimation */
  28981. QUADRATIC = 0
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. interface Scene {
  28986. /** @hidden (Backing field) */
  28987. _simplificationQueue: SimplificationQueue;
  28988. /**
  28989. * Gets or sets the simplification queue attached to the scene
  28990. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28991. */
  28992. simplificationQueue: SimplificationQueue;
  28993. }
  28994. interface Mesh {
  28995. /**
  28996. * Simplify the mesh according to the given array of settings.
  28997. * Function will return immediately and will simplify async
  28998. * @param settings a collection of simplification settings
  28999. * @param parallelProcessing should all levels calculate parallel or one after the other
  29000. * @param simplificationType the type of simplification to run
  29001. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29002. * @returns the current mesh
  29003. */
  29004. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29005. }
  29006. /**
  29007. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29008. * created in a scene
  29009. */
  29010. class SimplicationQueueSceneComponent implements ISceneComponent {
  29011. /**
  29012. * The component name helpfull to identify the component in the list of scene components.
  29013. */
  29014. readonly name: string;
  29015. /**
  29016. * The scene the component belongs to.
  29017. */
  29018. scene: Scene;
  29019. /**
  29020. * Creates a new instance of the component for the given scene
  29021. * @param scene Defines the scene to register the component in
  29022. */
  29023. constructor(scene: Scene);
  29024. /**
  29025. * Registers the component in a given scene
  29026. */
  29027. register(): void;
  29028. /**
  29029. * Rebuilds the elements related to this component in case of
  29030. * context lost for instance.
  29031. */
  29032. rebuild(): void;
  29033. /**
  29034. * Disposes the component and the associated ressources
  29035. */
  29036. dispose(): void;
  29037. private _beforeCameraUpdate;
  29038. }
  29039. }
  29040. declare module BABYLON {
  29041. /**
  29042. * Polygon
  29043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29044. */
  29045. class Polygon {
  29046. /**
  29047. * Creates a rectangle
  29048. * @param xmin bottom X coord
  29049. * @param ymin bottom Y coord
  29050. * @param xmax top X coord
  29051. * @param ymax top Y coord
  29052. * @returns points that make the resulting rectation
  29053. */
  29054. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29055. /**
  29056. * Creates a circle
  29057. * @param radius radius of circle
  29058. * @param cx scale in x
  29059. * @param cy scale in y
  29060. * @param numberOfSides number of sides that make up the circle
  29061. * @returns points that make the resulting circle
  29062. */
  29063. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29064. /**
  29065. * Creates a polygon from input string
  29066. * @param input Input polygon data
  29067. * @returns the parsed points
  29068. */
  29069. static Parse(input: string): Vector2[];
  29070. /**
  29071. * Starts building a polygon from x and y coordinates
  29072. * @param x x coordinate
  29073. * @param y y coordinate
  29074. * @returns the started path2
  29075. */
  29076. static StartingAt(x: number, y: number): Path2;
  29077. }
  29078. /**
  29079. * Builds a polygon
  29080. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29081. */
  29082. class PolygonMeshBuilder {
  29083. private _points;
  29084. private _outlinepoints;
  29085. private _holes;
  29086. private _name;
  29087. private _scene;
  29088. private _epoints;
  29089. private _eholes;
  29090. private _addToepoint;
  29091. /**
  29092. * Creates a PolygonMeshBuilder
  29093. * @param name name of the builder
  29094. * @param contours Path of the polygon
  29095. * @param scene scene to add to
  29096. */
  29097. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29098. /**
  29099. * Adds a whole within the polygon
  29100. * @param hole Array of points defining the hole
  29101. * @returns this
  29102. */
  29103. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29104. /**
  29105. * Creates the polygon
  29106. * @param updatable If the mesh should be updatable
  29107. * @param depth The depth of the mesh created
  29108. * @returns the created mesh
  29109. */
  29110. build(updatable?: boolean, depth?: number): Mesh;
  29111. /**
  29112. * Adds a side to the polygon
  29113. * @param positions points that make the polygon
  29114. * @param normals normals of the polygon
  29115. * @param uvs uvs of the polygon
  29116. * @param indices indices of the polygon
  29117. * @param bounds bounds of the polygon
  29118. * @param points points of the polygon
  29119. * @param depth depth of the polygon
  29120. * @param flip flip of the polygon
  29121. */
  29122. private addSide;
  29123. }
  29124. }
  29125. declare module BABYLON {
  29126. /**
  29127. * Base class for submeshes
  29128. */
  29129. class BaseSubMesh {
  29130. /** @hidden */
  29131. _materialDefines: Nullable<MaterialDefines>;
  29132. /** @hidden */
  29133. _materialEffect: Nullable<Effect>;
  29134. /**
  29135. * Gets associated effect
  29136. */
  29137. readonly effect: Nullable<Effect>;
  29138. /**
  29139. * Sets associated effect (effect used to render this submesh)
  29140. * @param effect defines the effect to associate with
  29141. * @param defines defines the set of defines used to compile this effect
  29142. */
  29143. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29144. }
  29145. /**
  29146. * Defines a subdivision inside a mesh
  29147. */
  29148. class SubMesh extends BaseSubMesh implements ICullable {
  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;
  29159. /** @hidden */
  29160. _linesIndexCount: number;
  29161. private _mesh;
  29162. private _renderingMesh;
  29163. private _boundingInfo;
  29164. private _linesIndexBuffer;
  29165. /** @hidden */
  29166. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29167. /** @hidden */
  29168. _trianglePlanes: Plane[];
  29169. /** @hidden */
  29170. _lastColliderTransformMatrix: Matrix;
  29171. /** @hidden */
  29172. _renderId: number;
  29173. /** @hidden */
  29174. _alphaIndex: number;
  29175. /** @hidden */
  29176. _distanceToCamera: number;
  29177. /** @hidden */
  29178. _id: number;
  29179. private _currentMaterial;
  29180. /**
  29181. * Add a new submesh to a mesh
  29182. * @param materialIndex defines the material index to use
  29183. * @param verticesStart defines vertex index start
  29184. * @param verticesCount defines vertices count
  29185. * @param indexStart defines index start
  29186. * @param indexCount defines indices count
  29187. * @param mesh defines the parent mesh
  29188. * @param renderingMesh defines an optional rendering mesh
  29189. * @param createBoundingBox defines if bounding box should be created for this submesh
  29190. * @returns the new submesh
  29191. */
  29192. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29193. /**
  29194. * Creates a new submesh
  29195. * @param materialIndex defines the material index to use
  29196. * @param verticesStart defines vertex index start
  29197. * @param verticesCount defines vertices count
  29198. * @param indexStart defines index start
  29199. * @param indexCount defines indices count
  29200. * @param mesh defines the parent mesh
  29201. * @param renderingMesh defines an optional rendering mesh
  29202. * @param createBoundingBox defines if bounding box should be created for this submesh
  29203. */
  29204. constructor(
  29205. /** the material index to use */
  29206. materialIndex: number,
  29207. /** vertex index start */
  29208. verticesStart: number,
  29209. /** vertices count */
  29210. verticesCount: number,
  29211. /** index start */
  29212. indexStart: number,
  29213. /** indices count */
  29214. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29215. /**
  29216. * Returns true if this submesh covers the entire parent mesh
  29217. * @ignorenaming
  29218. */
  29219. readonly IsGlobal: boolean;
  29220. /**
  29221. * Returns the submesh BoudingInfo object
  29222. * @returns current bounding info (or mesh's one if the submesh is global)
  29223. */
  29224. getBoundingInfo(): BoundingInfo;
  29225. /**
  29226. * Sets the submesh BoundingInfo
  29227. * @param boundingInfo defines the new bounding info to use
  29228. * @returns the SubMesh
  29229. */
  29230. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29231. /**
  29232. * Returns the mesh of the current submesh
  29233. * @return the parent mesh
  29234. */
  29235. getMesh(): AbstractMesh;
  29236. /**
  29237. * Returns the rendering mesh of the submesh
  29238. * @returns the rendering mesh (could be different from parent mesh)
  29239. */
  29240. getRenderingMesh(): Mesh;
  29241. /**
  29242. * Returns the submesh material
  29243. * @returns null or the current material
  29244. */
  29245. getMaterial(): Nullable<Material>;
  29246. /**
  29247. * Sets a new updated BoundingInfo object to the submesh
  29248. * @returns the SubMesh
  29249. */
  29250. refreshBoundingInfo(): SubMesh;
  29251. /** @hidden */
  29252. _checkCollision(collider: Collider): boolean;
  29253. /**
  29254. * Updates the submesh BoundingInfo
  29255. * @param world defines the world matrix to use to update the bounding info
  29256. * @returns the submesh
  29257. */
  29258. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29259. /**
  29260. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29261. * @param frustumPlanes defines the frustum planes
  29262. * @returns true if the submesh is intersecting with the frustum
  29263. */
  29264. isInFrustum(frustumPlanes: Plane[]): boolean;
  29265. /**
  29266. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29267. * @param frustumPlanes defines the frustum planes
  29268. * @returns true if the submesh is inside the frustum
  29269. */
  29270. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29271. /**
  29272. * Renders the submesh
  29273. * @param enableAlphaMode defines if alpha needs to be used
  29274. * @returns the submesh
  29275. */
  29276. render(enableAlphaMode: boolean): SubMesh;
  29277. /**
  29278. * @hidden
  29279. */
  29280. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29281. /**
  29282. * Checks if the submesh intersects with a ray
  29283. * @param ray defines the ray to test
  29284. * @returns true is the passed ray intersects the submesh bounding box
  29285. */
  29286. canIntersects(ray: Ray): boolean;
  29287. /**
  29288. * Intersects current submesh with a ray
  29289. * @param ray defines the ray to test
  29290. * @param positions defines mesh's positions array
  29291. * @param indices defines mesh's indices array
  29292. * @param fastCheck defines if only bounding info should be used
  29293. * @returns intersection info or null if no intersection
  29294. */
  29295. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29296. /** @hidden */
  29297. private _intersectLines;
  29298. /** @hidden */
  29299. private _intersectTriangles;
  29300. /** @hidden */
  29301. _rebuild(): void;
  29302. /**
  29303. * Creates a new submesh from the passed mesh
  29304. * @param newMesh defines the new hosting mesh
  29305. * @param newRenderingMesh defines an optional rendering mesh
  29306. * @returns the new submesh
  29307. */
  29308. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29309. /**
  29310. * Release associated resources
  29311. */
  29312. dispose(): void;
  29313. /**
  29314. * Creates a new submesh from indices data
  29315. * @param materialIndex the index of the main mesh material
  29316. * @param startIndex the index where to start the copy in the mesh indices array
  29317. * @param indexCount the number of indices to copy then from the startIndex
  29318. * @param mesh the main mesh to create the submesh from
  29319. * @param renderingMesh the optional rendering mesh
  29320. * @returns a new submesh
  29321. */
  29322. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29323. }
  29324. }
  29325. declare module BABYLON {
  29326. /**
  29327. * 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.
  29328. * @see https://doc.babylonjs.com/how_to/transformnode
  29329. */
  29330. class TransformNode extends Node {
  29331. /**
  29332. * Object will not rotate to face the camera
  29333. */
  29334. static BILLBOARDMODE_NONE: number;
  29335. /**
  29336. * Object will rotate to face the camera but only on the x axis
  29337. */
  29338. static BILLBOARDMODE_X: number;
  29339. /**
  29340. * Object will rotate to face the camera but only on the y axis
  29341. */
  29342. static BILLBOARDMODE_Y: number;
  29343. /**
  29344. * Object will rotate to face the camera but only on the z axis
  29345. */
  29346. static BILLBOARDMODE_Z: number;
  29347. /**
  29348. * Object will rotate to face the camera
  29349. */
  29350. static BILLBOARDMODE_ALL: number;
  29351. private _forward;
  29352. private _forwardInverted;
  29353. private _up;
  29354. private _right;
  29355. private _rightInverted;
  29356. private _position;
  29357. private _rotation;
  29358. private _rotationQuaternion;
  29359. protected _scaling: Vector3;
  29360. protected _isDirty: boolean;
  29361. private _transformToBoneReferal;
  29362. /**
  29363. * Set the billboard mode. Default is 0.
  29364. *
  29365. * | Value | Type | Description |
  29366. * | --- | --- | --- |
  29367. * | 0 | BILLBOARDMODE_NONE | |
  29368. * | 1 | BILLBOARDMODE_X | |
  29369. * | 2 | BILLBOARDMODE_Y | |
  29370. * | 4 | BILLBOARDMODE_Z | |
  29371. * | 7 | BILLBOARDMODE_ALL | |
  29372. *
  29373. */
  29374. billboardMode: number;
  29375. /**
  29376. * 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
  29377. */
  29378. scalingDeterminant: number;
  29379. /**
  29380. * Sets the distance of the object to max, often used by skybox
  29381. */
  29382. infiniteDistance: boolean;
  29383. /**
  29384. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29385. * By default the system will update normals to compensate
  29386. */
  29387. ignoreNonUniformScaling: boolean;
  29388. /** @hidden */
  29389. _poseMatrix: Matrix;
  29390. /** @hidden */
  29391. _localMatrix: Matrix;
  29392. private _absolutePosition;
  29393. private _pivotMatrix;
  29394. private _pivotMatrixInverse;
  29395. protected _postMultiplyPivotMatrix: boolean;
  29396. protected _isWorldMatrixFrozen: boolean;
  29397. /** @hidden */
  29398. _indexInSceneTransformNodesArray: number;
  29399. /**
  29400. * An event triggered after the world matrix is updated
  29401. */
  29402. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29403. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29404. /**
  29405. * Gets a string identifying the name of the class
  29406. * @returns "TransformNode" string
  29407. */
  29408. getClassName(): string;
  29409. /**
  29410. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29411. */
  29412. position: Vector3;
  29413. /**
  29414. * 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)).
  29415. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29416. */
  29417. rotation: Vector3;
  29418. /**
  29419. * 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)).
  29420. */
  29421. scaling: Vector3;
  29422. /**
  29423. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29424. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29425. */
  29426. rotationQuaternion: Nullable<Quaternion>;
  29427. /**
  29428. * The forward direction of that transform in world space.
  29429. */
  29430. readonly forward: Vector3;
  29431. /**
  29432. * The up direction of that transform in world space.
  29433. */
  29434. readonly up: Vector3;
  29435. /**
  29436. * The right direction of that transform in world space.
  29437. */
  29438. readonly right: Vector3;
  29439. /**
  29440. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29441. * @param matrix the matrix to copy the pose from
  29442. * @returns this TransformNode.
  29443. */
  29444. updatePoseMatrix(matrix: Matrix): TransformNode;
  29445. /**
  29446. * Returns the mesh Pose matrix.
  29447. * @returns the pose matrix
  29448. */
  29449. getPoseMatrix(): Matrix;
  29450. /** @hidden */
  29451. _isSynchronized(): boolean;
  29452. /** @hidden */
  29453. _initCache(): void;
  29454. /**
  29455. * Flag the transform node as dirty (Forcing it to update everything)
  29456. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29457. * @returns this transform node
  29458. */
  29459. markAsDirty(property: string): TransformNode;
  29460. /**
  29461. * Returns the current mesh absolute position.
  29462. * Returns a Vector3.
  29463. */
  29464. readonly absolutePosition: Vector3;
  29465. /**
  29466. * Sets a new matrix to apply before all other transformation
  29467. * @param matrix defines the transform matrix
  29468. * @returns the current TransformNode
  29469. */
  29470. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29471. /**
  29472. * Sets a new pivot matrix to the current node
  29473. * @param matrix defines the new pivot matrix to use
  29474. * @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
  29475. * @returns the current TransformNode
  29476. */
  29477. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29478. /**
  29479. * Returns the mesh pivot matrix.
  29480. * Default : Identity.
  29481. * @returns the matrix
  29482. */
  29483. getPivotMatrix(): Matrix;
  29484. /**
  29485. * Prevents the World matrix to be computed any longer.
  29486. * @returns the TransformNode.
  29487. */
  29488. freezeWorldMatrix(): TransformNode;
  29489. /**
  29490. * Allows back the World matrix computation.
  29491. * @returns the TransformNode.
  29492. */
  29493. unfreezeWorldMatrix(): this;
  29494. /**
  29495. * True if the World matrix has been frozen.
  29496. */
  29497. readonly isWorldMatrixFrozen: boolean;
  29498. /**
  29499. * Retuns the mesh absolute position in the World.
  29500. * @returns a Vector3.
  29501. */
  29502. getAbsolutePosition(): Vector3;
  29503. /**
  29504. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29505. * @param absolutePosition the absolute position to set
  29506. * @returns the TransformNode.
  29507. */
  29508. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29509. /**
  29510. * Sets the mesh position in its local space.
  29511. * @param vector3 the position to set in localspace
  29512. * @returns the TransformNode.
  29513. */
  29514. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29515. /**
  29516. * Returns the mesh position in the local space from the current World matrix values.
  29517. * @returns a new Vector3.
  29518. */
  29519. getPositionExpressedInLocalSpace(): Vector3;
  29520. /**
  29521. * Translates the mesh along the passed Vector3 in its local space.
  29522. * @param vector3 the distance to translate in localspace
  29523. * @returns the TransformNode.
  29524. */
  29525. locallyTranslate(vector3: Vector3): TransformNode;
  29526. private static _lookAtVectorCache;
  29527. /**
  29528. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29529. * @param targetPoint the position (must be in same space as current mesh) to look at
  29530. * @param yawCor optional yaw (y-axis) correction in radians
  29531. * @param pitchCor optional pitch (x-axis) correction in radians
  29532. * @param rollCor optional roll (z-axis) correction in radians
  29533. * @param space the choosen space of the target
  29534. * @returns the TransformNode.
  29535. */
  29536. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29537. /**
  29538. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29539. * This Vector3 is expressed in the World space.
  29540. * @param localAxis axis to rotate
  29541. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29542. */
  29543. getDirection(localAxis: Vector3): Vector3;
  29544. /**
  29545. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29546. * localAxis is expressed in the mesh local space.
  29547. * result is computed in the Wordl space from the mesh World matrix.
  29548. * @param localAxis axis to rotate
  29549. * @param result the resulting transformnode
  29550. * @returns this TransformNode.
  29551. */
  29552. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29553. /**
  29554. * Sets this transform node rotation to the given local axis.
  29555. * @param localAxis the axis in local space
  29556. * @param yawCor optional yaw (y-axis) correction in radians
  29557. * @param pitchCor optional pitch (x-axis) correction in radians
  29558. * @param rollCor optional roll (z-axis) correction in radians
  29559. * @returns this TransformNode
  29560. */
  29561. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29562. /**
  29563. * Sets a new pivot point to the current node
  29564. * @param point defines the new pivot point to use
  29565. * @param space defines if the point is in world or local space (local by default)
  29566. * @returns the current TransformNode
  29567. */
  29568. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29569. /**
  29570. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29571. * @returns the pivot point
  29572. */
  29573. getPivotPoint(): Vector3;
  29574. /**
  29575. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29576. * @param result the vector3 to store the result
  29577. * @returns this TransformNode.
  29578. */
  29579. getPivotPointToRef(result: Vector3): TransformNode;
  29580. /**
  29581. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29582. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29583. */
  29584. getAbsolutePivotPoint(): Vector3;
  29585. /**
  29586. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29587. * @param result vector3 to store the result
  29588. * @returns this TransformNode.
  29589. */
  29590. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29591. /**
  29592. * Defines the passed node as the parent of the current node.
  29593. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29594. * @param node the node ot set as the parent
  29595. * @returns this TransformNode.
  29596. */
  29597. setParent(node: Nullable<Node>): TransformNode;
  29598. private _nonUniformScaling;
  29599. /**
  29600. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29601. */
  29602. readonly nonUniformScaling: boolean;
  29603. /** @hidden */
  29604. _updateNonUniformScalingState(value: boolean): boolean;
  29605. /**
  29606. * Attach the current TransformNode to another TransformNode associated with a bone
  29607. * @param bone Bone affecting the TransformNode
  29608. * @param affectedTransformNode TransformNode associated with the bone
  29609. * @returns this object
  29610. */
  29611. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29612. /**
  29613. * Detach the transform node if its associated with a bone
  29614. * @returns this object
  29615. */
  29616. detachFromBone(): TransformNode;
  29617. private static _rotationAxisCache;
  29618. /**
  29619. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29620. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29621. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29622. * The passed axis is also normalized.
  29623. * @param axis the axis to rotate around
  29624. * @param amount the amount to rotate in radians
  29625. * @param space Space to rotate in (Default: local)
  29626. * @returns the TransformNode.
  29627. */
  29628. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29629. /**
  29630. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29631. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29632. * The passed axis is also normalized. .
  29633. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29634. * @param point the point to rotate around
  29635. * @param axis the axis to rotate around
  29636. * @param amount the amount to rotate in radians
  29637. * @returns the TransformNode
  29638. */
  29639. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29640. /**
  29641. * Translates the mesh along the axis vector for the passed distance in the given space.
  29642. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29643. * @param axis the axis to translate in
  29644. * @param distance the distance to translate
  29645. * @param space Space to rotate in (Default: local)
  29646. * @returns the TransformNode.
  29647. */
  29648. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29649. /**
  29650. * Adds a rotation step to the mesh current rotation.
  29651. * x, y, z are Euler angles expressed in radians.
  29652. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29653. * This means this rotation is made in the mesh local space only.
  29654. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29655. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29656. * ```javascript
  29657. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29658. * ```
  29659. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29660. * 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.
  29661. * @param x Rotation to add
  29662. * @param y Rotation to add
  29663. * @param z Rotation to add
  29664. * @returns the TransformNode.
  29665. */
  29666. addRotation(x: number, y: number, z: number): TransformNode;
  29667. /**
  29668. * Computes the world matrix of the node
  29669. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29670. * @returns the world matrix
  29671. */
  29672. computeWorldMatrix(force?: boolean): Matrix;
  29673. protected _afterComputeWorldMatrix(): void;
  29674. /**
  29675. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29676. * @param func callback function to add
  29677. *
  29678. * @returns the TransformNode.
  29679. */
  29680. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29681. /**
  29682. * Removes a registered callback function.
  29683. * @param func callback function to remove
  29684. * @returns the TransformNode.
  29685. */
  29686. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29687. /**
  29688. * Gets the position of the current mesh in camera space
  29689. * @param camera defines the camera to use
  29690. * @returns a position
  29691. */
  29692. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29693. /**
  29694. * Returns the distance from the mesh to the active camera
  29695. * @param camera defines the camera to use
  29696. * @returns the distance
  29697. */
  29698. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29699. /**
  29700. * Clone the current transform node
  29701. * @param name Name of the new clone
  29702. * @param newParent New parent for the clone
  29703. * @param doNotCloneChildren Do not clone children hierarchy
  29704. * @returns the new transform node
  29705. */
  29706. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29707. /**
  29708. * Serializes the objects information.
  29709. * @param currentSerializationObject defines the object to serialize in
  29710. * @returns the serialized object
  29711. */
  29712. serialize(currentSerializationObject?: any): any;
  29713. /**
  29714. * Returns a new TransformNode object parsed from the source provided.
  29715. * @param parsedTransformNode is the source.
  29716. * @param scene the scne the object belongs to
  29717. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29718. * @returns a new TransformNode object parsed from the source provided.
  29719. */
  29720. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29721. /**
  29722. * Releases resources associated with this transform node.
  29723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29725. */
  29726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29727. }
  29728. }
  29729. declare module BABYLON {
  29730. /**
  29731. * Specialized buffer used to store vertex data
  29732. */
  29733. class VertexBuffer {
  29734. /** @hidden */
  29735. _buffer: Buffer;
  29736. private _kind;
  29737. private _size;
  29738. private _ownsBuffer;
  29739. private _instanced;
  29740. private _instanceDivisor;
  29741. /**
  29742. * The byte type.
  29743. */
  29744. static readonly BYTE: number;
  29745. /**
  29746. * The unsigned byte type.
  29747. */
  29748. static readonly UNSIGNED_BYTE: number;
  29749. /**
  29750. * The short type.
  29751. */
  29752. static readonly SHORT: number;
  29753. /**
  29754. * The unsigned short type.
  29755. */
  29756. static readonly UNSIGNED_SHORT: number;
  29757. /**
  29758. * The integer type.
  29759. */
  29760. static readonly INT: number;
  29761. /**
  29762. * The unsigned integer type.
  29763. */
  29764. static readonly UNSIGNED_INT: number;
  29765. /**
  29766. * The float type.
  29767. */
  29768. static readonly FLOAT: number;
  29769. /**
  29770. * Gets or sets the instance divisor when in instanced mode
  29771. */
  29772. instanceDivisor: number;
  29773. /**
  29774. * Gets the byte stride.
  29775. */
  29776. readonly byteStride: number;
  29777. /**
  29778. * Gets the byte offset.
  29779. */
  29780. readonly byteOffset: number;
  29781. /**
  29782. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29783. */
  29784. readonly normalized: boolean;
  29785. /**
  29786. * Gets the data type of each component in the array.
  29787. */
  29788. readonly type: number;
  29789. /**
  29790. * Constructor
  29791. * @param engine the engine
  29792. * @param data the data to use for this vertex buffer
  29793. * @param kind the vertex buffer kind
  29794. * @param updatable whether the data is updatable
  29795. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29796. * @param stride the stride (optional)
  29797. * @param instanced whether the buffer is instanced (optional)
  29798. * @param offset the offset of the data (optional)
  29799. * @param size the number of components (optional)
  29800. * @param type the type of the component (optional)
  29801. * @param normalized whether the data contains normalized data (optional)
  29802. * @param useBytes set to true if stride and offset are in bytes (optional)
  29803. */
  29804. 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);
  29805. /** @hidden */
  29806. _rebuild(): void;
  29807. /**
  29808. * Returns the kind of the VertexBuffer (string)
  29809. * @returns a string
  29810. */
  29811. getKind(): string;
  29812. /**
  29813. * Gets a boolean indicating if the VertexBuffer is updatable?
  29814. * @returns true if the buffer is updatable
  29815. */
  29816. isUpdatable(): boolean;
  29817. /**
  29818. * Gets current buffer's data
  29819. * @returns a DataArray or null
  29820. */
  29821. getData(): Nullable<DataArray>;
  29822. /**
  29823. * Gets underlying native buffer
  29824. * @returns underlying native buffer
  29825. */
  29826. getBuffer(): Nullable<WebGLBuffer>;
  29827. /**
  29828. * Gets the stride in float32 units (i.e. byte stride / 4).
  29829. * May not be an integer if the byte stride is not divisible by 4.
  29830. * DEPRECATED. Use byteStride instead.
  29831. * @returns the stride in float32 units
  29832. */
  29833. getStrideSize(): number;
  29834. /**
  29835. * Returns the offset as a multiple of the type byte length.
  29836. * DEPRECATED. Use byteOffset instead.
  29837. * @returns the offset in bytes
  29838. */
  29839. getOffset(): number;
  29840. /**
  29841. * Returns the number of components per vertex attribute (integer)
  29842. * @returns the size in float
  29843. */
  29844. getSize(): number;
  29845. /**
  29846. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29847. * @returns true if this buffer is instanced
  29848. */
  29849. getIsInstanced(): boolean;
  29850. /**
  29851. * Returns the instancing divisor, zero for non-instanced (integer).
  29852. * @returns a number
  29853. */
  29854. getInstanceDivisor(): number;
  29855. /**
  29856. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29857. * @param data defines the data to store
  29858. */
  29859. create(data?: DataArray): void;
  29860. /**
  29861. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29862. * This function will create a new buffer if the current one is not updatable
  29863. * @param data defines the data to store
  29864. */
  29865. update(data: DataArray): void;
  29866. /**
  29867. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29868. * Returns the directly updated WebGLBuffer.
  29869. * @param data the new data
  29870. * @param offset the new offset
  29871. * @param useBytes set to true if the offset is in bytes
  29872. */
  29873. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29874. /**
  29875. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29876. */
  29877. dispose(): void;
  29878. /**
  29879. * Enumerates each value of this vertex buffer as numbers.
  29880. * @param count the number of values to enumerate
  29881. * @param callback the callback function called for each value
  29882. */
  29883. forEach(count: number, callback: (value: number, index: number) => void): void;
  29884. /**
  29885. * Positions
  29886. */
  29887. static readonly PositionKind: string;
  29888. /**
  29889. * Normals
  29890. */
  29891. static readonly NormalKind: string;
  29892. /**
  29893. * Tangents
  29894. */
  29895. static readonly TangentKind: string;
  29896. /**
  29897. * Texture coordinates
  29898. */
  29899. static readonly UVKind: string;
  29900. /**
  29901. * Texture coordinates 2
  29902. */
  29903. static readonly UV2Kind: string;
  29904. /**
  29905. * Texture coordinates 3
  29906. */
  29907. static readonly UV3Kind: string;
  29908. /**
  29909. * Texture coordinates 4
  29910. */
  29911. static readonly UV4Kind: string;
  29912. /**
  29913. * Texture coordinates 5
  29914. */
  29915. static readonly UV5Kind: string;
  29916. /**
  29917. * Texture coordinates 6
  29918. */
  29919. static readonly UV6Kind: string;
  29920. /**
  29921. * Colors
  29922. */
  29923. static readonly ColorKind: string;
  29924. /**
  29925. * Matrix indices (for bones)
  29926. */
  29927. static readonly MatricesIndicesKind: string;
  29928. /**
  29929. * Matrix weights (for bones)
  29930. */
  29931. static readonly MatricesWeightsKind: string;
  29932. /**
  29933. * Additional matrix indices (for bones)
  29934. */
  29935. static readonly MatricesIndicesExtraKind: string;
  29936. /**
  29937. * Additional matrix weights (for bones)
  29938. */
  29939. static readonly MatricesWeightsExtraKind: string;
  29940. /**
  29941. * Deduces the stride given a kind.
  29942. * @param kind The kind string to deduce
  29943. * @returns The deduced stride
  29944. */
  29945. static DeduceStride(kind: string): number;
  29946. /**
  29947. * Gets the byte length of the given type.
  29948. * @param type the type
  29949. * @returns the number of bytes
  29950. */
  29951. static GetTypeByteLength(type: number): number;
  29952. /**
  29953. * Enumerates each value of the given parameters as numbers.
  29954. * @param data the data to enumerate
  29955. * @param byteOffset the byte offset of the data
  29956. * @param byteStride the byte stride of the data
  29957. * @param componentCount the number of components per element
  29958. * @param componentType the type of the component
  29959. * @param count the total number of components
  29960. * @param normalized whether the data is normalized
  29961. * @param callback the callback function called for each value
  29962. */
  29963. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29964. private static _GetFloatValue;
  29965. }
  29966. }
  29967. declare module BABYLON {
  29968. /**
  29969. * Defines a target to use with MorphTargetManager
  29970. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29971. */
  29972. class MorphTarget implements IAnimatable {
  29973. /** defines the name of the target */
  29974. name: string;
  29975. /**
  29976. * Gets or sets the list of animations
  29977. */
  29978. animations: Animation[];
  29979. private _scene;
  29980. private _positions;
  29981. private _normals;
  29982. private _tangents;
  29983. private _influence;
  29984. /**
  29985. * Observable raised when the influence changes
  29986. */
  29987. onInfluenceChanged: Observable<boolean>;
  29988. /** @hidden */
  29989. _onDataLayoutChanged: Observable<void>;
  29990. /**
  29991. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29992. */
  29993. influence: number;
  29994. /**
  29995. * Gets or sets the id of the morph Target
  29996. */
  29997. id: string;
  29998. private _animationPropertiesOverride;
  29999. /**
  30000. * Gets or sets the animation properties override
  30001. */
  30002. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30003. /**
  30004. * Creates a new MorphTarget
  30005. * @param name defines the name of the target
  30006. * @param influence defines the influence to use
  30007. */
  30008. constructor(
  30009. /** defines the name of the target */
  30010. name: string, influence?: number, scene?: Nullable<Scene>);
  30011. /**
  30012. * Gets a boolean defining if the target contains position data
  30013. */
  30014. readonly hasPositions: boolean;
  30015. /**
  30016. * Gets a boolean defining if the target contains normal data
  30017. */
  30018. readonly hasNormals: boolean;
  30019. /**
  30020. * Gets a boolean defining if the target contains tangent data
  30021. */
  30022. readonly hasTangents: boolean;
  30023. /**
  30024. * Affects position data to this target
  30025. * @param data defines the position data to use
  30026. */
  30027. setPositions(data: Nullable<FloatArray>): void;
  30028. /**
  30029. * Gets the position data stored in this target
  30030. * @returns a FloatArray containing the position data (or null if not present)
  30031. */
  30032. getPositions(): Nullable<FloatArray>;
  30033. /**
  30034. * Affects normal data to this target
  30035. * @param data defines the normal data to use
  30036. */
  30037. setNormals(data: Nullable<FloatArray>): void;
  30038. /**
  30039. * Gets the normal data stored in this target
  30040. * @returns a FloatArray containing the normal data (or null if not present)
  30041. */
  30042. getNormals(): Nullable<FloatArray>;
  30043. /**
  30044. * Affects tangent data to this target
  30045. * @param data defines the tangent data to use
  30046. */
  30047. setTangents(data: Nullable<FloatArray>): void;
  30048. /**
  30049. * Gets the tangent data stored in this target
  30050. * @returns a FloatArray containing the tangent data (or null if not present)
  30051. */
  30052. getTangents(): Nullable<FloatArray>;
  30053. /**
  30054. * Serializes the current target into a Serialization object
  30055. * @returns the serialized object
  30056. */
  30057. serialize(): any;
  30058. /**
  30059. * Returns the string "MorphTarget"
  30060. * @returns "MorphTarget"
  30061. */
  30062. getClassName(): string;
  30063. /**
  30064. * Creates a new target from serialized data
  30065. * @param serializationObject defines the serialized data to use
  30066. * @returns a new MorphTarget
  30067. */
  30068. static Parse(serializationObject: any): MorphTarget;
  30069. /**
  30070. * Creates a MorphTarget from mesh data
  30071. * @param mesh defines the source mesh
  30072. * @param name defines the name to use for the new target
  30073. * @param influence defines the influence to attach to the target
  30074. * @returns a new MorphTarget
  30075. */
  30076. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /**
  30081. * This class is used to deform meshes using morphing between different targets
  30082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30083. */
  30084. class MorphTargetManager {
  30085. private _targets;
  30086. private _targetInfluenceChangedObservers;
  30087. private _targetDataLayoutChangedObservers;
  30088. private _activeTargets;
  30089. private _scene;
  30090. private _influences;
  30091. private _supportsNormals;
  30092. private _supportsTangents;
  30093. private _vertexCount;
  30094. private _uniqueId;
  30095. private _tempInfluences;
  30096. /**
  30097. * Creates a new MorphTargetManager
  30098. * @param scene defines the current scene
  30099. */
  30100. constructor(scene?: Nullable<Scene>);
  30101. /**
  30102. * Gets the unique ID of this manager
  30103. */
  30104. readonly uniqueId: number;
  30105. /**
  30106. * Gets the number of vertices handled by this manager
  30107. */
  30108. readonly vertexCount: number;
  30109. /**
  30110. * Gets a boolean indicating if this manager supports morphing of normals
  30111. */
  30112. readonly supportsNormals: boolean;
  30113. /**
  30114. * Gets a boolean indicating if this manager supports morphing of tangents
  30115. */
  30116. readonly supportsTangents: boolean;
  30117. /**
  30118. * Gets the number of targets stored in this manager
  30119. */
  30120. readonly numTargets: number;
  30121. /**
  30122. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30123. */
  30124. readonly numInfluencers: number;
  30125. /**
  30126. * Gets the list of influences (one per target)
  30127. */
  30128. readonly influences: Float32Array;
  30129. /**
  30130. * Gets the active target at specified index. An active target is a target with an influence > 0
  30131. * @param index defines the index to check
  30132. * @returns the requested target
  30133. */
  30134. getActiveTarget(index: number): MorphTarget;
  30135. /**
  30136. * Gets the target at specified index
  30137. * @param index defines the index to check
  30138. * @returns the requested target
  30139. */
  30140. getTarget(index: number): MorphTarget;
  30141. /**
  30142. * Add a new target to this manager
  30143. * @param target defines the target to add
  30144. */
  30145. addTarget(target: MorphTarget): void;
  30146. /**
  30147. * Removes a target from the manager
  30148. * @param target defines the target to remove
  30149. */
  30150. removeTarget(target: MorphTarget): void;
  30151. /**
  30152. * Serializes the current manager into a Serialization object
  30153. * @returns the serialized object
  30154. */
  30155. serialize(): any;
  30156. private _syncActiveTargets;
  30157. /**
  30158. * Syncrhonize the targets with all the meshes using this morph target manager
  30159. */
  30160. synchronize(): void;
  30161. /**
  30162. * Creates a new MorphTargetManager from serialized data
  30163. * @param serializationObject defines the serialized data
  30164. * @param scene defines the hosting scene
  30165. * @returns the new MorphTargetManager
  30166. */
  30167. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30168. }
  30169. }
  30170. declare module BABYLON {
  30171. /**
  30172. * Class used to enable access to IndexedDB
  30173. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30174. */
  30175. class Database implements IOfflineProvider {
  30176. private _callbackManifestChecked;
  30177. private _currentSceneUrl;
  30178. private _db;
  30179. private _enableSceneOffline;
  30180. private _enableTexturesOffline;
  30181. private _manifestVersionFound;
  30182. private _mustUpdateRessources;
  30183. private _hasReachedQuota;
  30184. private _isSupported;
  30185. private _idbFactory;
  30186. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30187. private static IsUASupportingBlobStorage;
  30188. /**
  30189. * Gets a boolean indicating if Database storate is enabled (off by default)
  30190. */
  30191. static IDBStorageEnabled: boolean;
  30192. /**
  30193. * Gets a boolean indicating if scene must be saved in the database
  30194. */
  30195. readonly enableSceneOffline: boolean;
  30196. /**
  30197. * Gets a boolean indicating if textures must be saved in the database
  30198. */
  30199. readonly enableTexturesOffline: boolean;
  30200. /**
  30201. * Creates a new Database
  30202. * @param urlToScene defines the url to load the scene
  30203. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30204. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30205. */
  30206. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30207. private static _ParseURL;
  30208. private static _ReturnFullUrlLocation;
  30209. private _checkManifestFile;
  30210. /**
  30211. * Open the database and make it available
  30212. * @param successCallback defines the callback to call on success
  30213. * @param errorCallback defines the callback to call on error
  30214. */
  30215. open(successCallback: () => void, errorCallback: () => void): void;
  30216. /**
  30217. * Loads an image from the database
  30218. * @param url defines the url to load from
  30219. * @param image defines the target DOM image
  30220. */
  30221. loadImage(url: string, image: HTMLImageElement): void;
  30222. private _loadImageFromDBAsync;
  30223. private _saveImageIntoDBAsync;
  30224. private _checkVersionFromDB;
  30225. private _loadVersionFromDBAsync;
  30226. private _saveVersionIntoDBAsync;
  30227. /**
  30228. * Loads a file from database
  30229. * @param url defines the URL to load from
  30230. * @param sceneLoaded defines a callback to call on success
  30231. * @param progressCallBack defines a callback to call when progress changed
  30232. * @param errorCallback defines a callback to call on error
  30233. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30234. */
  30235. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30236. private _loadFileAsync;
  30237. private _saveFileAsync;
  30238. }
  30239. }
  30240. declare module BABYLON {
  30241. /**
  30242. * Class used to enable access to offline support
  30243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30244. */
  30245. interface IOfflineProvider {
  30246. /**
  30247. * Gets a boolean indicating if scene must be saved in the database
  30248. */
  30249. enableSceneOffline: boolean;
  30250. /**
  30251. * Gets a boolean indicating if textures must be saved in the database
  30252. */
  30253. enableTexturesOffline: boolean;
  30254. /**
  30255. * Open the offline support and make it available
  30256. * @param successCallback defines the callback to call on success
  30257. * @param errorCallback defines the callback to call on error
  30258. */
  30259. open(successCallback: () => void, errorCallback: () => void): void;
  30260. /**
  30261. * Loads an image from the offline support
  30262. * @param url defines the url to load from
  30263. * @param image defines the target DOM image
  30264. */
  30265. loadImage(url: string, image: HTMLImageElement): void;
  30266. /**
  30267. * Loads a file from offline support
  30268. * @param url defines the URL to load from
  30269. * @param sceneLoaded defines a callback to call on success
  30270. * @param progressCallBack defines a callback to call when progress changed
  30271. * @param errorCallback defines a callback to call on error
  30272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30273. */
  30274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30275. }
  30276. }
  30277. declare module BABYLON {
  30278. /**
  30279. * This represents the base class for particle system in Babylon.
  30280. * 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.
  30281. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30282. * @example https://doc.babylonjs.com/babylon101/particles
  30283. */
  30284. class BaseParticleSystem {
  30285. /**
  30286. * Source color is added to the destination color without alpha affecting the result
  30287. */
  30288. static BLENDMODE_ONEONE: number;
  30289. /**
  30290. * Blend current color and particle color using particle’s alpha
  30291. */
  30292. static BLENDMODE_STANDARD: number;
  30293. /**
  30294. * Add current color and particle color multiplied by particle’s alpha
  30295. */
  30296. static BLENDMODE_ADD: number;
  30297. /**
  30298. * Multiply current color with particle color
  30299. */
  30300. static BLENDMODE_MULTIPLY: number;
  30301. /**
  30302. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30303. */
  30304. static BLENDMODE_MULTIPLYADD: number;
  30305. /**
  30306. * List of animations used by the particle system.
  30307. */
  30308. animations: Animation[];
  30309. /**
  30310. * The id of the Particle system.
  30311. */
  30312. id: string;
  30313. /**
  30314. * The friendly name of the Particle system.
  30315. */
  30316. name: string;
  30317. /**
  30318. * The rendering group used by the Particle system to chose when to render.
  30319. */
  30320. renderingGroupId: number;
  30321. /**
  30322. * The emitter represents the Mesh or position we are attaching the particle system to.
  30323. */
  30324. emitter: Nullable<AbstractMesh | Vector3>;
  30325. /**
  30326. * The maximum number of particles to emit per frame
  30327. */
  30328. emitRate: number;
  30329. /**
  30330. * If you want to launch only a few particles at once, that can be done, as well.
  30331. */
  30332. manualEmitCount: number;
  30333. /**
  30334. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30335. */
  30336. updateSpeed: number;
  30337. /**
  30338. * The amount of time the particle system is running (depends of the overall update speed).
  30339. */
  30340. targetStopDuration: number;
  30341. /**
  30342. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30343. */
  30344. disposeOnStop: boolean;
  30345. /**
  30346. * Minimum power of emitting particles.
  30347. */
  30348. minEmitPower: number;
  30349. /**
  30350. * Maximum power of emitting particles.
  30351. */
  30352. maxEmitPower: number;
  30353. /**
  30354. * Minimum life time of emitting particles.
  30355. */
  30356. minLifeTime: number;
  30357. /**
  30358. * Maximum life time of emitting particles.
  30359. */
  30360. maxLifeTime: number;
  30361. /**
  30362. * Minimum Size of emitting particles.
  30363. */
  30364. minSize: number;
  30365. /**
  30366. * Maximum Size of emitting particles.
  30367. */
  30368. maxSize: number;
  30369. /**
  30370. * Minimum scale of emitting particles on X axis.
  30371. */
  30372. minScaleX: number;
  30373. /**
  30374. * Maximum scale of emitting particles on X axis.
  30375. */
  30376. maxScaleX: number;
  30377. /**
  30378. * Minimum scale of emitting particles on Y axis.
  30379. */
  30380. minScaleY: number;
  30381. /**
  30382. * Maximum scale of emitting particles on Y axis.
  30383. */
  30384. maxScaleY: number;
  30385. /**
  30386. * Gets or sets the minimal initial rotation in radians.
  30387. */
  30388. minInitialRotation: number;
  30389. /**
  30390. * Gets or sets the maximal initial rotation in radians.
  30391. */
  30392. maxInitialRotation: number;
  30393. /**
  30394. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30395. */
  30396. minAngularSpeed: number;
  30397. /**
  30398. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30399. */
  30400. maxAngularSpeed: number;
  30401. /**
  30402. * The texture used to render each particle. (this can be a spritesheet)
  30403. */
  30404. particleTexture: Nullable<Texture>;
  30405. /**
  30406. * The layer mask we are rendering the particles through.
  30407. */
  30408. layerMask: number;
  30409. /**
  30410. * This can help using your own shader to render the particle system.
  30411. * The according effect will be created
  30412. */
  30413. customShader: any;
  30414. /**
  30415. * By default particle system starts as soon as they are created. This prevents the
  30416. * automatic start to happen and let you decide when to start emitting particles.
  30417. */
  30418. preventAutoStart: boolean;
  30419. private _noiseTexture;
  30420. /**
  30421. * Gets or sets a texture used to add random noise to particle positions
  30422. */
  30423. noiseTexture: Nullable<ProceduralTexture>;
  30424. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30425. noiseStrength: Vector3;
  30426. /**
  30427. * Callback triggered when the particle animation is ending.
  30428. */
  30429. onAnimationEnd: Nullable<() => void>;
  30430. /**
  30431. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30432. */
  30433. blendMode: number;
  30434. /**
  30435. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30436. * to override the particles.
  30437. */
  30438. forceDepthWrite: boolean;
  30439. /** 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 */
  30440. preWarmCycles: number;
  30441. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30442. preWarmStepOffset: number;
  30443. /**
  30444. * 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)
  30445. */
  30446. spriteCellChangeSpeed: number;
  30447. /**
  30448. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30449. */
  30450. startSpriteCellID: number;
  30451. /**
  30452. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30453. */
  30454. endSpriteCellID: number;
  30455. /**
  30456. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30457. */
  30458. spriteCellWidth: number;
  30459. /**
  30460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30461. */
  30462. spriteCellHeight: number;
  30463. /**
  30464. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30465. */
  30466. spriteRandomStartCell: boolean;
  30467. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30468. translationPivot: Vector2;
  30469. /** @hidden */
  30470. protected _isAnimationSheetEnabled: boolean;
  30471. /**
  30472. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30473. */
  30474. beginAnimationOnStart: boolean;
  30475. /**
  30476. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30477. */
  30478. beginAnimationFrom: number;
  30479. /**
  30480. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30481. */
  30482. beginAnimationTo: number;
  30483. /**
  30484. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30485. */
  30486. beginAnimationLoop: boolean;
  30487. /**
  30488. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30489. */
  30490. isAnimationSheetEnabled: boolean;
  30491. /**
  30492. * Get hosting scene
  30493. * @returns the scene
  30494. */
  30495. getScene(): Scene;
  30496. /**
  30497. * You can use gravity if you want to give an orientation to your particles.
  30498. */
  30499. gravity: Vector3;
  30500. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30501. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30502. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30503. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30504. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30505. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30506. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30507. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30508. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30509. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30510. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30511. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30512. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30513. /**
  30514. * Defines the delay in milliseconds before starting the system (0 by default)
  30515. */
  30516. startDelay: number;
  30517. /**
  30518. * Gets the current list of drag gradients.
  30519. * You must use addDragGradient and removeDragGradient to udpate this list
  30520. * @returns the list of drag gradients
  30521. */
  30522. getDragGradients(): Nullable<Array<FactorGradient>>;
  30523. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30524. limitVelocityDamping: number;
  30525. /**
  30526. * Gets the current list of limit velocity gradients.
  30527. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30528. * @returns the list of limit velocity gradients
  30529. */
  30530. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30531. /**
  30532. * Gets the current list of color gradients.
  30533. * You must use addColorGradient and removeColorGradient to udpate this list
  30534. * @returns the list of color gradients
  30535. */
  30536. getColorGradients(): Nullable<Array<ColorGradient>>;
  30537. /**
  30538. * Gets the current list of size gradients.
  30539. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30540. * @returns the list of size gradients
  30541. */
  30542. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30543. /**
  30544. * Gets the current list of color remap gradients.
  30545. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30546. * @returns the list of color remap gradients
  30547. */
  30548. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30549. /**
  30550. * Gets the current list of alpha remap gradients.
  30551. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30552. * @returns the list of alpha remap gradients
  30553. */
  30554. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30555. /**
  30556. * Gets the current list of life time gradients.
  30557. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30558. * @returns the list of life time gradients
  30559. */
  30560. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30561. /**
  30562. * Gets the current list of angular speed gradients.
  30563. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30564. * @returns the list of angular speed gradients
  30565. */
  30566. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30567. /**
  30568. * Gets the current list of velocity gradients.
  30569. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30570. * @returns the list of velocity gradients
  30571. */
  30572. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30573. /**
  30574. * Gets the current list of start size gradients.
  30575. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30576. * @returns the list of start size gradients
  30577. */
  30578. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30579. /**
  30580. * Gets the current list of emit rate gradients.
  30581. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30582. * @returns the list of emit rate gradients
  30583. */
  30584. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30585. /**
  30586. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30588. */
  30589. direction1: Vector3;
  30590. /**
  30591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30592. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30593. */
  30594. direction2: Vector3;
  30595. /**
  30596. * 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.
  30597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30598. */
  30599. minEmitBox: Vector3;
  30600. /**
  30601. * 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.
  30602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30603. */
  30604. maxEmitBox: Vector3;
  30605. /**
  30606. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30607. */
  30608. color1: Color4;
  30609. /**
  30610. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30611. */
  30612. color2: Color4;
  30613. /**
  30614. * Color the particle will have at the end of its lifetime
  30615. */
  30616. colorDead: Color4;
  30617. /**
  30618. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30619. */
  30620. textureMask: Color4;
  30621. /**
  30622. * The particle emitter type defines the emitter used by the particle system.
  30623. * It can be for example box, sphere, or cone...
  30624. */
  30625. particleEmitterType: IParticleEmitterType;
  30626. /** @hidden */
  30627. _isSubEmitter: boolean;
  30628. /**
  30629. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30630. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30631. */
  30632. billboardMode: number;
  30633. protected _isBillboardBased: boolean;
  30634. /**
  30635. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30636. */
  30637. isBillboardBased: boolean;
  30638. /**
  30639. * The scene the particle system belongs to.
  30640. */
  30641. protected _scene: Scene;
  30642. /**
  30643. * Local cache of defines for image processing.
  30644. */
  30645. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30646. /**
  30647. * Default configuration related to image processing available in the standard Material.
  30648. */
  30649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30650. /**
  30651. * Gets the image processing configuration used either in this material.
  30652. */
  30653. /**
  30654. * Sets the Default image processing configuration used either in the this material.
  30655. *
  30656. * If sets to null, the scene one is in use.
  30657. */
  30658. imageProcessingConfiguration: ImageProcessingConfiguration;
  30659. /**
  30660. * Attaches a new image processing configuration to the Standard Material.
  30661. * @param configuration
  30662. */
  30663. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30664. /** @hidden */
  30665. protected _reset(): void;
  30666. /** @hidden */
  30667. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30668. /**
  30669. * Instantiates a particle system.
  30670. * 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.
  30671. * @param name The name of the particle system
  30672. */
  30673. constructor(name: string);
  30674. /**
  30675. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30678. * @returns the emitter
  30679. */
  30680. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30681. /**
  30682. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30683. * @param radius The radius of the hemisphere to emit from
  30684. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30685. * @returns the emitter
  30686. */
  30687. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30688. /**
  30689. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30690. * @param radius The radius of the sphere to emit from
  30691. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30692. * @returns the emitter
  30693. */
  30694. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30695. /**
  30696. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30697. * @param radius The radius of the sphere to emit from
  30698. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30699. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30700. * @returns the emitter
  30701. */
  30702. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30703. /**
  30704. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30705. * @param radius The radius of the emission cylinder
  30706. * @param height The height of the emission cylinder
  30707. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30708. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30709. * @returns the emitter
  30710. */
  30711. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30712. /**
  30713. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30714. * @param radius The radius of the cylinder to emit from
  30715. * @param height The height of the emission cylinder
  30716. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30719. * @returns the emitter
  30720. */
  30721. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30722. /**
  30723. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30724. * @param radius The radius of the cone to emit from
  30725. * @param angle The base angle of the cone
  30726. * @returns the emitter
  30727. */
  30728. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30729. /**
  30730. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30733. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30734. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30735. * @returns the emitter
  30736. */
  30737. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30738. }
  30739. }
  30740. declare module BABYLON {
  30741. /**
  30742. * This represents a GPU particle system in Babylon
  30743. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30744. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30745. */
  30746. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30747. /**
  30748. * The layer mask we are rendering the particles through.
  30749. */
  30750. layerMask: number;
  30751. private _capacity;
  30752. private _activeCount;
  30753. private _currentActiveCount;
  30754. private _accumulatedCount;
  30755. private _renderEffect;
  30756. private _updateEffect;
  30757. private _buffer0;
  30758. private _buffer1;
  30759. private _spriteBuffer;
  30760. private _updateVAO;
  30761. private _renderVAO;
  30762. private _targetIndex;
  30763. private _sourceBuffer;
  30764. private _targetBuffer;
  30765. private _engine;
  30766. private _currentRenderId;
  30767. private _started;
  30768. private _stopped;
  30769. private _timeDelta;
  30770. private _randomTexture;
  30771. private _randomTexture2;
  30772. private _attributesStrideSize;
  30773. private _updateEffectOptions;
  30774. private _randomTextureSize;
  30775. private _actualFrame;
  30776. private readonly _rawTextureWidth;
  30777. /**
  30778. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30779. */
  30780. static readonly IsSupported: boolean;
  30781. /**
  30782. * An event triggered when the system is disposed.
  30783. */
  30784. onDisposeObservable: Observable<GPUParticleSystem>;
  30785. /**
  30786. * Gets the maximum number of particles active at the same time.
  30787. * @returns The max number of active particles.
  30788. */
  30789. getCapacity(): number;
  30790. /**
  30791. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30792. * to override the particles.
  30793. */
  30794. forceDepthWrite: boolean;
  30795. /**
  30796. * Gets or set the number of active particles
  30797. */
  30798. activeParticleCount: number;
  30799. private _preWarmDone;
  30800. /**
  30801. * Is this system ready to be used/rendered
  30802. * @return true if the system is ready
  30803. */
  30804. isReady(): boolean;
  30805. /**
  30806. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30807. * @returns True if it has been started, otherwise false.
  30808. */
  30809. isStarted(): boolean;
  30810. /**
  30811. * Starts the particle system and begins to emit
  30812. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30813. */
  30814. start(delay?: number): void;
  30815. /**
  30816. * Stops the particle system.
  30817. */
  30818. stop(): void;
  30819. /**
  30820. * Remove all active particles
  30821. */
  30822. reset(): void;
  30823. /**
  30824. * Returns the string "GPUParticleSystem"
  30825. * @returns a string containing the class name
  30826. */
  30827. getClassName(): string;
  30828. private _colorGradientsTexture;
  30829. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30830. /**
  30831. * Adds a new color gradient
  30832. * @param gradient defines the gradient to use (between 0 and 1)
  30833. * @param color1 defines the color to affect to the specified gradient
  30834. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30835. * @returns the current particle system
  30836. */
  30837. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30838. /**
  30839. * Remove a specific color gradient
  30840. * @param gradient defines the gradient to remove
  30841. * @returns the current particle system
  30842. */
  30843. removeColorGradient(gradient: number): GPUParticleSystem;
  30844. private _angularSpeedGradientsTexture;
  30845. private _sizeGradientsTexture;
  30846. private _velocityGradientsTexture;
  30847. private _limitVelocityGradientsTexture;
  30848. private _dragGradientsTexture;
  30849. private _addFactorGradient;
  30850. /**
  30851. * Adds a new size gradient
  30852. * @param gradient defines the gradient to use (between 0 and 1)
  30853. * @param factor defines the size factor to affect to the specified gradient
  30854. * @returns the current particle system
  30855. */
  30856. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30857. /**
  30858. * Remove a specific size gradient
  30859. * @param gradient defines the gradient to remove
  30860. * @returns the current particle system
  30861. */
  30862. removeSizeGradient(gradient: number): GPUParticleSystem;
  30863. /**
  30864. * Adds a new angular speed gradient
  30865. * @param gradient defines the gradient to use (between 0 and 1)
  30866. * @param factor defines the angular speed to affect to the specified gradient
  30867. * @returns the current particle system
  30868. */
  30869. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30870. /**
  30871. * Remove a specific angular speed gradient
  30872. * @param gradient defines the gradient to remove
  30873. * @returns the current particle system
  30874. */
  30875. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30876. /**
  30877. * Adds a new velocity gradient
  30878. * @param gradient defines the gradient to use (between 0 and 1)
  30879. * @param factor defines the velocity to affect to the specified gradient
  30880. * @returns the current particle system
  30881. */
  30882. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30883. /**
  30884. * Remove a specific velocity gradient
  30885. * @param gradient defines the gradient to remove
  30886. * @returns the current particle system
  30887. */
  30888. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30889. /**
  30890. * Adds a new limit velocity gradient
  30891. * @param gradient defines the gradient to use (between 0 and 1)
  30892. * @param factor defines the limit velocity value to affect to the specified gradient
  30893. * @returns the current particle system
  30894. */
  30895. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30896. /**
  30897. * Remove a specific limit velocity gradient
  30898. * @param gradient defines the gradient to remove
  30899. * @returns the current particle system
  30900. */
  30901. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30902. /**
  30903. * Adds a new drag gradient
  30904. * @param gradient defines the gradient to use (between 0 and 1)
  30905. * @param factor defines the drag value to affect to the specified gradient
  30906. * @returns the current particle system
  30907. */
  30908. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30909. /**
  30910. * Remove a specific drag gradient
  30911. * @param gradient defines the gradient to remove
  30912. * @returns the current particle system
  30913. */
  30914. removeDragGradient(gradient: number): GPUParticleSystem;
  30915. /**
  30916. * Not supported by GPUParticleSystem
  30917. * @param gradient defines the gradient to use (between 0 and 1)
  30918. * @param factor defines the emit rate value to affect to the specified gradient
  30919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30920. * @returns the current particle system
  30921. */
  30922. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30923. /**
  30924. * Not supported by GPUParticleSystem
  30925. * @param gradient defines the gradient to remove
  30926. * @returns the current particle system
  30927. */
  30928. removeEmitRateGradient(gradient: number): IParticleSystem;
  30929. /**
  30930. * Not supported by GPUParticleSystem
  30931. * @param gradient defines the gradient to use (between 0 and 1)
  30932. * @param factor defines the start size value 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. addStartSizeGradient(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. removeStartSizeGradient(gradient: number): IParticleSystem;
  30943. /**
  30944. * Not supported by GPUParticleSystem
  30945. * @param gradient defines the gradient to use (between 0 and 1)
  30946. * @param min defines the color remap minimal range
  30947. * @param max defines the color remap maximal range
  30948. * @returns the current particle system
  30949. */
  30950. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30951. /**
  30952. * Not supported by GPUParticleSystem
  30953. * @param gradient defines the gradient to remove
  30954. * @returns the current particle system
  30955. */
  30956. removeColorRemapGradient(gradient: number): IParticleSystem;
  30957. /**
  30958. * Not supported by GPUParticleSystem
  30959. * @param gradient defines the gradient to use (between 0 and 1)
  30960. * @param min defines the alpha remap minimal range
  30961. * @param max defines the alpha remap maximal range
  30962. * @returns the current particle system
  30963. */
  30964. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30965. /**
  30966. * Not supported by GPUParticleSystem
  30967. * @param gradient defines the gradient to remove
  30968. * @returns the current particle system
  30969. */
  30970. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30971. /**
  30972. * Not supported by GPUParticleSystem
  30973. * @param gradient defines the gradient to use (between 0 and 1)
  30974. * @param color defines the color to affect to the specified gradient
  30975. * @returns the current particle system
  30976. */
  30977. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30978. /**
  30979. * Not supported by GPUParticleSystem
  30980. * @param gradient defines the gradient to remove
  30981. * @returns the current particle system
  30982. */
  30983. removeRampGradient(gradient: number): IParticleSystem;
  30984. /**
  30985. * Not supported by GPUParticleSystem
  30986. * @returns the list of ramp gradients
  30987. */
  30988. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30989. /**
  30990. * Not supported by GPUParticleSystem
  30991. * Gets or sets a boolean indicating that ramp gradients must be used
  30992. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30993. */
  30994. useRampGradients: boolean;
  30995. /**
  30996. * Not supported by GPUParticleSystem
  30997. * @param gradient defines the gradient to use (between 0 and 1)
  30998. * @param factor defines the life time factor to affect to the specified gradient
  30999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31000. * @returns the current particle system
  31001. */
  31002. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31003. /**
  31004. * Not supported by GPUParticleSystem
  31005. * @param gradient defines the gradient to remove
  31006. * @returns the current particle system
  31007. */
  31008. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31009. /**
  31010. * Instantiates a GPU particle system.
  31011. * 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.
  31012. * @param name The name of the particle system
  31013. * @param options The options used to create the system
  31014. * @param scene The scene the particle system belongs to
  31015. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31016. */
  31017. constructor(name: string, options: Partial<{
  31018. capacity: number;
  31019. randomTextureSize: number;
  31020. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31021. protected _reset(): void;
  31022. private _createUpdateVAO;
  31023. private _createRenderVAO;
  31024. private _initialize;
  31025. /** @hidden */
  31026. _recreateUpdateEffect(): void;
  31027. /** @hidden */
  31028. _recreateRenderEffect(): void;
  31029. /**
  31030. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31031. * @param preWarm defines if we are in the pre-warmimg phase
  31032. */
  31033. animate(preWarm?: boolean): void;
  31034. private _createFactorGradientTexture;
  31035. private _createSizeGradientTexture;
  31036. private _createAngularSpeedGradientTexture;
  31037. private _createVelocityGradientTexture;
  31038. private _createLimitVelocityGradientTexture;
  31039. private _createDragGradientTexture;
  31040. private _createColorGradientTexture;
  31041. /**
  31042. * Renders the particle system in its current state
  31043. * @param preWarm defines if the system should only update the particles but not render them
  31044. * @returns the current number of particles
  31045. */
  31046. render(preWarm?: boolean): number;
  31047. /**
  31048. * Rebuilds the particle system
  31049. */
  31050. rebuild(): void;
  31051. private _releaseBuffers;
  31052. private _releaseVAOs;
  31053. /**
  31054. * Disposes the particle system and free the associated resources
  31055. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31056. */
  31057. dispose(disposeTexture?: boolean): void;
  31058. /**
  31059. * Clones the particle system.
  31060. * @param name The name of the cloned object
  31061. * @param newEmitter The new emitter to use
  31062. * @returns the cloned particle system
  31063. */
  31064. clone(name: string, newEmitter: any): GPUParticleSystem;
  31065. /**
  31066. * Serializes the particle system to a JSON object.
  31067. * @returns the JSON object
  31068. */
  31069. serialize(): any;
  31070. /**
  31071. * Parses a JSON object to create a GPU particle system.
  31072. * @param parsedParticleSystem The JSON object to parse
  31073. * @param scene The scene to create the particle system in
  31074. * @param rootUrl The root url to use to load external dependencies like texture
  31075. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31076. * @returns the parsed GPU particle system
  31077. */
  31078. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31079. }
  31080. }
  31081. declare module BABYLON {
  31082. /**
  31083. * Interface representing a particle system in Babylon.js.
  31084. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31085. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31086. */
  31087. interface IParticleSystem {
  31088. /**
  31089. * List of animations used by the particle system.
  31090. */
  31091. animations: Animation[];
  31092. /**
  31093. * The id of the Particle system.
  31094. */
  31095. id: string;
  31096. /**
  31097. * The name of the Particle system.
  31098. */
  31099. name: string;
  31100. /**
  31101. * The emitter represents the Mesh or position we are attaching the particle system to.
  31102. */
  31103. emitter: Nullable<AbstractMesh | Vector3>;
  31104. /**
  31105. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31106. */
  31107. isBillboardBased: boolean;
  31108. /**
  31109. * The rendering group used by the Particle system to chose when to render.
  31110. */
  31111. renderingGroupId: number;
  31112. /**
  31113. * The layer mask we are rendering the particles through.
  31114. */
  31115. layerMask: number;
  31116. /**
  31117. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31118. */
  31119. updateSpeed: number;
  31120. /**
  31121. * The amount of time the particle system is running (depends of the overall update speed).
  31122. */
  31123. targetStopDuration: number;
  31124. /**
  31125. * The texture used to render each particle. (this can be a spritesheet)
  31126. */
  31127. particleTexture: Nullable<Texture>;
  31128. /**
  31129. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31130. */
  31131. blendMode: number;
  31132. /**
  31133. * Minimum life time of emitting particles.
  31134. */
  31135. minLifeTime: number;
  31136. /**
  31137. * Maximum life time of emitting particles.
  31138. */
  31139. maxLifeTime: number;
  31140. /**
  31141. * Minimum Size of emitting particles.
  31142. */
  31143. minSize: number;
  31144. /**
  31145. * Maximum Size of emitting particles.
  31146. */
  31147. maxSize: number;
  31148. /**
  31149. * Minimum scale of emitting particles on X axis.
  31150. */
  31151. minScaleX: number;
  31152. /**
  31153. * Maximum scale of emitting particles on X axis.
  31154. */
  31155. maxScaleX: number;
  31156. /**
  31157. * Minimum scale of emitting particles on Y axis.
  31158. */
  31159. minScaleY: number;
  31160. /**
  31161. * Maximum scale of emitting particles on Y axis.
  31162. */
  31163. maxScaleY: number;
  31164. /**
  31165. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31166. */
  31167. color1: Color4;
  31168. /**
  31169. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31170. */
  31171. color2: Color4;
  31172. /**
  31173. * Color the particle will have at the end of its lifetime.
  31174. */
  31175. colorDead: Color4;
  31176. /**
  31177. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31178. */
  31179. emitRate: number;
  31180. /**
  31181. * You can use gravity if you want to give an orientation to your particles.
  31182. */
  31183. gravity: Vector3;
  31184. /**
  31185. * Minimum power of emitting particles.
  31186. */
  31187. minEmitPower: number;
  31188. /**
  31189. * Maximum power of emitting particles.
  31190. */
  31191. maxEmitPower: number;
  31192. /**
  31193. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31194. */
  31195. minAngularSpeed: number;
  31196. /**
  31197. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31198. */
  31199. maxAngularSpeed: number;
  31200. /**
  31201. * Gets or sets the minimal initial rotation in radians.
  31202. */
  31203. minInitialRotation: number;
  31204. /**
  31205. * Gets or sets the maximal initial rotation in radians.
  31206. */
  31207. maxInitialRotation: number;
  31208. /**
  31209. * The particle emitter type defines the emitter used by the particle system.
  31210. * It can be for example box, sphere, or cone...
  31211. */
  31212. particleEmitterType: Nullable<IParticleEmitterType>;
  31213. /**
  31214. * Defines the delay in milliseconds before starting the system (0 by default)
  31215. */
  31216. startDelay: number;
  31217. /**
  31218. * 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
  31219. */
  31220. preWarmCycles: number;
  31221. /**
  31222. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31223. */
  31224. preWarmStepOffset: number;
  31225. /**
  31226. * 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)
  31227. */
  31228. spriteCellChangeSpeed: number;
  31229. /**
  31230. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31231. */
  31232. startSpriteCellID: number;
  31233. /**
  31234. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31235. */
  31236. endSpriteCellID: number;
  31237. /**
  31238. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31239. */
  31240. spriteCellWidth: number;
  31241. /**
  31242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31243. */
  31244. spriteCellHeight: number;
  31245. /**
  31246. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31247. */
  31248. spriteRandomStartCell: boolean;
  31249. /**
  31250. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31251. */
  31252. isAnimationSheetEnabled: boolean;
  31253. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31254. translationPivot: Vector2;
  31255. /**
  31256. * Gets or sets a texture used to add random noise to particle positions
  31257. */
  31258. noiseTexture: Nullable<BaseTexture>;
  31259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31260. noiseStrength: Vector3;
  31261. /**
  31262. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31263. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31264. */
  31265. billboardMode: number;
  31266. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31267. limitVelocityDamping: number;
  31268. /**
  31269. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31270. */
  31271. beginAnimationOnStart: boolean;
  31272. /**
  31273. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31274. */
  31275. beginAnimationFrom: number;
  31276. /**
  31277. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31278. */
  31279. beginAnimationTo: number;
  31280. /**
  31281. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31282. */
  31283. beginAnimationLoop: boolean;
  31284. /**
  31285. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31286. */
  31287. disposeOnStop: boolean;
  31288. /**
  31289. * Gets the maximum number of particles active at the same time.
  31290. * @returns The max number of active particles.
  31291. */
  31292. getCapacity(): number;
  31293. /**
  31294. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31295. * @returns True if it has been started, otherwise false.
  31296. */
  31297. isStarted(): boolean;
  31298. /**
  31299. * Animates the particle system for this frame.
  31300. */
  31301. animate(): void;
  31302. /**
  31303. * Renders the particle system in its current state.
  31304. * @returns the current number of particles
  31305. */
  31306. render(): number;
  31307. /**
  31308. * Dispose the particle system and frees its associated resources.
  31309. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31310. */
  31311. dispose(disposeTexture?: boolean): void;
  31312. /**
  31313. * Clones the particle system.
  31314. * @param name The name of the cloned object
  31315. * @param newEmitter The new emitter to use
  31316. * @returns the cloned particle system
  31317. */
  31318. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31319. /**
  31320. * Serializes the particle system to a JSON object.
  31321. * @returns the JSON object
  31322. */
  31323. serialize(): any;
  31324. /**
  31325. * Rebuild the particle system
  31326. */
  31327. rebuild(): void;
  31328. /**
  31329. * Starts the particle system and begins to emit
  31330. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31331. */
  31332. start(delay?: number): void;
  31333. /**
  31334. * Stops the particle system.
  31335. */
  31336. stop(): void;
  31337. /**
  31338. * Remove all active particles
  31339. */
  31340. reset(): void;
  31341. /**
  31342. * Is this system ready to be used/rendered
  31343. * @return true if the system is ready
  31344. */
  31345. isReady(): boolean;
  31346. /**
  31347. * Adds a new color gradient
  31348. * @param gradient defines the gradient to use (between 0 and 1)
  31349. * @param color1 defines the color to affect to the specified gradient
  31350. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31351. * @returns the current particle system
  31352. */
  31353. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31354. /**
  31355. * Remove a specific color gradient
  31356. * @param gradient defines the gradient to remove
  31357. * @returns the current particle system
  31358. */
  31359. removeColorGradient(gradient: number): IParticleSystem;
  31360. /**
  31361. * Adds a new size gradient
  31362. * @param gradient defines the gradient to use (between 0 and 1)
  31363. * @param factor defines the size factor to affect to the specified gradient
  31364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31365. * @returns the current particle system
  31366. */
  31367. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31368. /**
  31369. * Remove a specific size gradient
  31370. * @param gradient defines the gradient to remove
  31371. * @returns the current particle system
  31372. */
  31373. removeSizeGradient(gradient: number): IParticleSystem;
  31374. /**
  31375. * Gets the current list of color gradients.
  31376. * You must use addColorGradient and removeColorGradient to udpate this list
  31377. * @returns the list of color gradients
  31378. */
  31379. getColorGradients(): Nullable<Array<ColorGradient>>;
  31380. /**
  31381. * Gets the current list of size gradients.
  31382. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31383. * @returns the list of size gradients
  31384. */
  31385. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31386. /**
  31387. * Gets the current list of angular speed gradients.
  31388. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31389. * @returns the list of angular speed gradients
  31390. */
  31391. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31392. /**
  31393. * Adds a new angular speed gradient
  31394. * @param gradient defines the gradient to use (between 0 and 1)
  31395. * @param factor defines the angular speed to affect to the specified gradient
  31396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31397. * @returns the current particle system
  31398. */
  31399. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31400. /**
  31401. * Remove a specific angular speed gradient
  31402. * @param gradient defines the gradient to remove
  31403. * @returns the current particle system
  31404. */
  31405. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31406. /**
  31407. * Gets the current list of velocity gradients.
  31408. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31409. * @returns the list of velocity gradients
  31410. */
  31411. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31412. /**
  31413. * Adds a new velocity gradient
  31414. * @param gradient defines the gradient to use (between 0 and 1)
  31415. * @param factor defines the velocity to affect to the specified gradient
  31416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31417. * @returns the current particle system
  31418. */
  31419. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31420. /**
  31421. * Remove a specific velocity gradient
  31422. * @param gradient defines the gradient to remove
  31423. * @returns the current particle system
  31424. */
  31425. removeVelocityGradient(gradient: number): IParticleSystem;
  31426. /**
  31427. * Gets the current list of limit velocity gradients.
  31428. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31429. * @returns the list of limit velocity gradients
  31430. */
  31431. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31432. /**
  31433. * Adds a new limit velocity gradient
  31434. * @param gradient defines the gradient to use (between 0 and 1)
  31435. * @param factor defines the limit velocity to affect to the specified gradient
  31436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31437. * @returns the current particle system
  31438. */
  31439. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31440. /**
  31441. * Remove a specific limit velocity gradient
  31442. * @param gradient defines the gradient to remove
  31443. * @returns the current particle system
  31444. */
  31445. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31446. /**
  31447. * Adds a new drag gradient
  31448. * @param gradient defines the gradient to use (between 0 and 1)
  31449. * @param factor defines the drag to affect to the specified gradient
  31450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31451. * @returns the current particle system
  31452. */
  31453. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31454. /**
  31455. * Remove a specific drag gradient
  31456. * @param gradient defines the gradient to remove
  31457. * @returns the current particle system
  31458. */
  31459. removeDragGradient(gradient: number): IParticleSystem;
  31460. /**
  31461. * Gets the current list of drag gradients.
  31462. * You must use addDragGradient and removeDragGradient to udpate this list
  31463. * @returns the list of drag gradients
  31464. */
  31465. getDragGradients(): Nullable<Array<FactorGradient>>;
  31466. /**
  31467. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31468. * @param gradient defines the gradient to use (between 0 and 1)
  31469. * @param factor defines the emit rate to affect to the specified gradient
  31470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31471. * @returns the current particle system
  31472. */
  31473. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31474. /**
  31475. * Remove a specific emit rate gradient
  31476. * @param gradient defines the gradient to remove
  31477. * @returns the current particle system
  31478. */
  31479. removeEmitRateGradient(gradient: number): IParticleSystem;
  31480. /**
  31481. * Gets the current list of emit rate gradients.
  31482. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31483. * @returns the list of emit rate gradients
  31484. */
  31485. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31486. /**
  31487. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31488. * @param gradient defines the gradient to use (between 0 and 1)
  31489. * @param factor defines the start size to affect to the specified gradient
  31490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31491. * @returns the current particle system
  31492. */
  31493. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31494. /**
  31495. * Remove a specific start size gradient
  31496. * @param gradient defines the gradient to remove
  31497. * @returns the current particle system
  31498. */
  31499. removeStartSizeGradient(gradient: number): IParticleSystem;
  31500. /**
  31501. * Gets the current list of start size gradients.
  31502. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31503. * @returns the list of start size gradients
  31504. */
  31505. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31506. /**
  31507. * Adds a new life time gradient
  31508. * @param gradient defines the gradient to use (between 0 and 1)
  31509. * @param factor defines the life time factor to affect to the specified gradient
  31510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31511. * @returns the current particle system
  31512. */
  31513. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31514. /**
  31515. * Remove a specific life time gradient
  31516. * @param gradient defines the gradient to remove
  31517. * @returns the current particle system
  31518. */
  31519. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31520. /**
  31521. * Gets the current list of life time gradients.
  31522. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31523. * @returns the list of life time gradients
  31524. */
  31525. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31526. /**
  31527. * Gets the current list of color gradients.
  31528. * You must use addColorGradient and removeColorGradient to udpate this list
  31529. * @returns the list of color gradients
  31530. */
  31531. getColorGradients(): Nullable<Array<ColorGradient>>;
  31532. /**
  31533. * Adds a new ramp gradient used to remap particle colors
  31534. * @param gradient defines the gradient to use (between 0 and 1)
  31535. * @param color defines the color to affect to the specified gradient
  31536. * @returns the current particle system
  31537. */
  31538. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31539. /**
  31540. * Gets the current list of ramp gradients.
  31541. * You must use addRampGradient and removeRampGradient to udpate this list
  31542. * @returns the list of ramp gradients
  31543. */
  31544. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31545. /** Gets or sets a boolean indicating that ramp gradients must be used
  31546. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31547. */
  31548. useRampGradients: boolean;
  31549. /**
  31550. * Adds a new color remap gradient
  31551. * @param gradient defines the gradient to use (between 0 and 1)
  31552. * @param min defines the color remap minimal range
  31553. * @param max defines the color remap maximal range
  31554. * @returns the current particle system
  31555. */
  31556. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31557. /**
  31558. * Gets the current list of color remap gradients.
  31559. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31560. * @returns the list of color remap gradients
  31561. */
  31562. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31563. /**
  31564. * Adds a new alpha remap gradient
  31565. * @param gradient defines the gradient to use (between 0 and 1)
  31566. * @param min defines the alpha remap minimal range
  31567. * @param max defines the alpha remap maximal range
  31568. * @returns the current particle system
  31569. */
  31570. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31571. /**
  31572. * Gets the current list of alpha remap gradients.
  31573. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31574. * @returns the list of alpha remap gradients
  31575. */
  31576. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31577. /**
  31578. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31581. * @returns the emitter
  31582. */
  31583. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31584. /**
  31585. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31586. * @param radius The radius of the hemisphere to emit from
  31587. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31588. * @returns the emitter
  31589. */
  31590. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31591. /**
  31592. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31593. * @param radius The radius of the sphere to emit from
  31594. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31595. * @returns the emitter
  31596. */
  31597. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31598. /**
  31599. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31600. * @param radius The radius of the sphere to emit from
  31601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31603. * @returns the emitter
  31604. */
  31605. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31606. /**
  31607. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31608. * @param radius The radius of the emission cylinder
  31609. * @param height The height of the emission cylinder
  31610. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31611. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31612. * @returns the emitter
  31613. */
  31614. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31615. /**
  31616. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31617. * @param radius The radius of the cylinder to emit from
  31618. * @param height The height of the emission cylinder
  31619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31622. * @returns the emitter
  31623. */
  31624. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31625. /**
  31626. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31627. * @param radius The radius of the cone to emit from
  31628. * @param angle The base angle of the cone
  31629. * @returns the emitter
  31630. */
  31631. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31632. /**
  31633. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31636. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31637. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31638. * @returns the emitter
  31639. */
  31640. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31641. /**
  31642. * Get hosting scene
  31643. * @returns the scene
  31644. */
  31645. getScene(): Scene;
  31646. }
  31647. }
  31648. declare module BABYLON {
  31649. /**
  31650. * A particle represents one of the element emitted by a particle system.
  31651. * This is mainly define by its coordinates, direction, velocity and age.
  31652. */
  31653. class Particle {
  31654. /**
  31655. * The particle system the particle belongs to.
  31656. */
  31657. particleSystem: ParticleSystem;
  31658. private static _Count;
  31659. /**
  31660. * Unique ID of the particle
  31661. */
  31662. id: number;
  31663. /**
  31664. * The world position of the particle in the scene.
  31665. */
  31666. position: Vector3;
  31667. /**
  31668. * The world direction of the particle in the scene.
  31669. */
  31670. direction: Vector3;
  31671. /**
  31672. * The color of the particle.
  31673. */
  31674. color: Color4;
  31675. /**
  31676. * The color change of the particle per step.
  31677. */
  31678. colorStep: Color4;
  31679. /**
  31680. * Defines how long will the life of the particle be.
  31681. */
  31682. lifeTime: number;
  31683. /**
  31684. * The current age of the particle.
  31685. */
  31686. age: number;
  31687. /**
  31688. * The current size of the particle.
  31689. */
  31690. size: number;
  31691. /**
  31692. * The current scale of the particle.
  31693. */
  31694. scale: Vector2;
  31695. /**
  31696. * The current angle of the particle.
  31697. */
  31698. angle: number;
  31699. /**
  31700. * Defines how fast is the angle changing.
  31701. */
  31702. angularSpeed: number;
  31703. /**
  31704. * Defines the cell index used by the particle to be rendered from a sprite.
  31705. */
  31706. cellIndex: number;
  31707. /**
  31708. * The information required to support color remapping
  31709. */
  31710. remapData: Vector4;
  31711. /** @hidden */
  31712. _randomCellOffset?: number;
  31713. /** @hidden */
  31714. _initialDirection: Nullable<Vector3>;
  31715. /** @hidden */
  31716. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31717. /** @hidden */
  31718. _initialStartSpriteCellID: number;
  31719. /** @hidden */
  31720. _initialEndSpriteCellID: number;
  31721. /** @hidden */
  31722. _currentColorGradient: Nullable<ColorGradient>;
  31723. /** @hidden */
  31724. _currentColor1: Color4;
  31725. /** @hidden */
  31726. _currentColor2: Color4;
  31727. /** @hidden */
  31728. _currentSizeGradient: Nullable<FactorGradient>;
  31729. /** @hidden */
  31730. _currentSize1: number;
  31731. /** @hidden */
  31732. _currentSize2: number;
  31733. /** @hidden */
  31734. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31735. /** @hidden */
  31736. _currentAngularSpeed1: number;
  31737. /** @hidden */
  31738. _currentAngularSpeed2: number;
  31739. /** @hidden */
  31740. _currentVelocityGradient: Nullable<FactorGradient>;
  31741. /** @hidden */
  31742. _currentVelocity1: number;
  31743. /** @hidden */
  31744. _currentVelocity2: number;
  31745. /** @hidden */
  31746. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31747. /** @hidden */
  31748. _currentLimitVelocity1: number;
  31749. /** @hidden */
  31750. _currentLimitVelocity2: number;
  31751. /** @hidden */
  31752. _currentDragGradient: Nullable<FactorGradient>;
  31753. /** @hidden */
  31754. _currentDrag1: number;
  31755. /** @hidden */
  31756. _currentDrag2: number;
  31757. /** @hidden */
  31758. _randomNoiseCoordinates1: Vector3;
  31759. /** @hidden */
  31760. _randomNoiseCoordinates2: Vector3;
  31761. /**
  31762. * Creates a new instance Particle
  31763. * @param particleSystem the particle system the particle belongs to
  31764. */
  31765. constructor(
  31766. /**
  31767. * The particle system the particle belongs to.
  31768. */
  31769. particleSystem: ParticleSystem);
  31770. private updateCellInfoFromSystem;
  31771. /**
  31772. * Defines how the sprite cell index is updated for the particle
  31773. */
  31774. updateCellIndex(): void;
  31775. /** @hidden */
  31776. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31777. /** @hidden */
  31778. _inheritParticleInfoToSubEmitters(): void;
  31779. /** @hidden */
  31780. _reset(): void;
  31781. /**
  31782. * Copy the properties of particle to another one.
  31783. * @param other the particle to copy the information to.
  31784. */
  31785. copyTo(other: Particle): void;
  31786. }
  31787. }
  31788. declare module BABYLON {
  31789. /**
  31790. * This class is made for on one-liner static method to help creating particle system set.
  31791. */
  31792. class ParticleHelper {
  31793. /**
  31794. * Gets or sets base Assets URL
  31795. */
  31796. static BaseAssetsUrl: string;
  31797. /**
  31798. * Create a default particle system that you can tweak
  31799. * @param emitter defines the emitter to use
  31800. * @param capacity defines the system capacity (default is 500 particles)
  31801. * @param scene defines the hosting scene
  31802. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31803. * @returns the new Particle system
  31804. */
  31805. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31806. /**
  31807. * This is the main static method (one-liner) of this helper to create different particle systems
  31808. * @param type This string represents the type to the particle system to create
  31809. * @param scene The scene where the particle system should live
  31810. * @param gpu If the system will use gpu
  31811. * @returns the ParticleSystemSet created
  31812. */
  31813. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31814. /**
  31815. * Static function used to export a particle system to a ParticleSystemSet variable.
  31816. * Please note that the emitter shape is not exported
  31817. * @param systems defines the particle systems to export
  31818. * @returns the created particle system set
  31819. */
  31820. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31821. }
  31822. }
  31823. declare module BABYLON {
  31824. /**
  31825. * This represents a particle system in Babylon.
  31826. * 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.
  31827. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31828. * @example https://doc.babylonjs.com/babylon101/particles
  31829. */
  31830. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31831. /**
  31832. * Billboard mode will only apply to Y axis
  31833. */
  31834. static readonly BILLBOARDMODE_Y: number;
  31835. /**
  31836. * Billboard mode will apply to all axes
  31837. */
  31838. static readonly BILLBOARDMODE_ALL: number;
  31839. /**
  31840. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31841. */
  31842. static readonly BILLBOARDMODE_STRETCHED: number;
  31843. /**
  31844. * This function can be defined to provide custom update for active particles.
  31845. * This function will be called instead of regular update (age, position, color, etc.).
  31846. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31847. */
  31848. updateFunction: (particles: Particle[]) => void;
  31849. private _emitterWorldMatrix;
  31850. /**
  31851. * This function can be defined to specify initial direction for every new particle.
  31852. * It by default use the emitterType defined function
  31853. */
  31854. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31855. /**
  31856. * This function can be defined to specify initial position for every new particle.
  31857. * It by default use the emitterType defined function
  31858. */
  31859. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31860. /**
  31861. * @hidden
  31862. */
  31863. _inheritedVelocityOffset: Vector3;
  31864. /**
  31865. * An event triggered when the system is disposed
  31866. */
  31867. onDisposeObservable: Observable<ParticleSystem>;
  31868. private _onDisposeObserver;
  31869. /**
  31870. * Sets a callback that will be triggered when the system is disposed
  31871. */
  31872. onDispose: () => void;
  31873. private _particles;
  31874. private _epsilon;
  31875. private _capacity;
  31876. private _stockParticles;
  31877. private _newPartsExcess;
  31878. private _vertexData;
  31879. private _vertexBuffer;
  31880. private _vertexBuffers;
  31881. private _spriteBuffer;
  31882. private _indexBuffer;
  31883. private _effect;
  31884. private _customEffect;
  31885. private _cachedDefines;
  31886. private _scaledColorStep;
  31887. private _colorDiff;
  31888. private _scaledDirection;
  31889. private _scaledGravity;
  31890. private _currentRenderId;
  31891. private _alive;
  31892. private _useInstancing;
  31893. private _started;
  31894. private _stopped;
  31895. private _actualFrame;
  31896. private _scaledUpdateSpeed;
  31897. private _vertexBufferSize;
  31898. /** @hidden */
  31899. _currentEmitRateGradient: Nullable<FactorGradient>;
  31900. /** @hidden */
  31901. _currentEmitRate1: number;
  31902. /** @hidden */
  31903. _currentEmitRate2: number;
  31904. /** @hidden */
  31905. _currentStartSizeGradient: Nullable<FactorGradient>;
  31906. /** @hidden */
  31907. _currentStartSize1: number;
  31908. /** @hidden */
  31909. _currentStartSize2: number;
  31910. private readonly _rawTextureWidth;
  31911. private _rampGradientsTexture;
  31912. private _useRampGradients;
  31913. /** Gets or sets a boolean indicating that ramp gradients must be used
  31914. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31915. */
  31916. useRampGradients: boolean;
  31917. /**
  31918. * 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.
  31919. * 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: [])
  31920. */
  31921. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31922. private _subEmitters;
  31923. /**
  31924. * @hidden
  31925. * If the particle systems emitter should be disposed when the particle system is disposed
  31926. */
  31927. _disposeEmitterOnDispose: boolean;
  31928. /**
  31929. * The current active Sub-systems, this property is used by the root particle system only.
  31930. */
  31931. activeSubSystems: Array<ParticleSystem>;
  31932. private _rootParticleSystem;
  31933. /**
  31934. * Gets the current list of active particles
  31935. */
  31936. readonly particles: Particle[];
  31937. /**
  31938. * Returns the string "ParticleSystem"
  31939. * @returns a string containing the class name
  31940. */
  31941. getClassName(): string;
  31942. /**
  31943. * Instantiates a particle system.
  31944. * 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.
  31945. * @param name The name of the particle system
  31946. * @param capacity The max number of particles alive at the same time
  31947. * @param scene The scene the particle system belongs to
  31948. * @param customEffect a custom effect used to change the way particles are rendered by default
  31949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31950. * @param epsilon Offset used to render the particles
  31951. */
  31952. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31953. private _addFactorGradient;
  31954. private _removeFactorGradient;
  31955. /**
  31956. * Adds a new life time gradient
  31957. * @param gradient defines the gradient to use (between 0 and 1)
  31958. * @param factor defines the life time factor to affect to the specified gradient
  31959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31960. * @returns the current particle system
  31961. */
  31962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31963. /**
  31964. * Remove a specific life time gradient
  31965. * @param gradient defines the gradient to remove
  31966. * @returns the current particle system
  31967. */
  31968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31969. /**
  31970. * Adds a new size gradient
  31971. * @param gradient defines the gradient to use (between 0 and 1)
  31972. * @param factor defines the size factor to affect to the specified gradient
  31973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31974. * @returns the current particle system
  31975. */
  31976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31977. /**
  31978. * Remove a specific size gradient
  31979. * @param gradient defines the gradient to remove
  31980. * @returns the current particle system
  31981. */
  31982. removeSizeGradient(gradient: number): IParticleSystem;
  31983. /**
  31984. * Adds a new color remap gradient
  31985. * @param gradient defines the gradient to use (between 0 and 1)
  31986. * @param min defines the color remap minimal range
  31987. * @param max defines the color remap maximal range
  31988. * @returns the current particle system
  31989. */
  31990. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31991. /**
  31992. * Remove a specific color remap gradient
  31993. * @param gradient defines the gradient to remove
  31994. * @returns the current particle system
  31995. */
  31996. removeColorRemapGradient(gradient: number): IParticleSystem;
  31997. /**
  31998. * Adds a new alpha remap gradient
  31999. * @param gradient defines the gradient to use (between 0 and 1)
  32000. * @param min defines the alpha remap minimal range
  32001. * @param max defines the alpha remap maximal range
  32002. * @returns the current particle system
  32003. */
  32004. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32005. /**
  32006. * Remove a specific alpha remap gradient
  32007. * @param gradient defines the gradient to remove
  32008. * @returns the current particle system
  32009. */
  32010. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32011. /**
  32012. * Adds a new angular speed gradient
  32013. * @param gradient defines the gradient to use (between 0 and 1)
  32014. * @param factor defines the angular speed to affect to the specified gradient
  32015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32016. * @returns the current particle system
  32017. */
  32018. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32019. /**
  32020. * Remove a specific angular speed gradient
  32021. * @param gradient defines the gradient to remove
  32022. * @returns the current particle system
  32023. */
  32024. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32025. /**
  32026. * Adds a new velocity gradient
  32027. * @param gradient defines the gradient to use (between 0 and 1)
  32028. * @param factor defines the velocity to affect to the specified gradient
  32029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32030. * @returns the current particle system
  32031. */
  32032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32033. /**
  32034. * Remove a specific velocity gradient
  32035. * @param gradient defines the gradient to remove
  32036. * @returns the current particle system
  32037. */
  32038. removeVelocityGradient(gradient: number): IParticleSystem;
  32039. /**
  32040. * Adds a new limit velocity gradient
  32041. * @param gradient defines the gradient to use (between 0 and 1)
  32042. * @param factor defines the limit velocity value to affect to the specified gradient
  32043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32044. * @returns the current particle system
  32045. */
  32046. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32047. /**
  32048. * Remove a specific limit velocity gradient
  32049. * @param gradient defines the gradient to remove
  32050. * @returns the current particle system
  32051. */
  32052. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32053. /**
  32054. * Adds a new drag gradient
  32055. * @param gradient defines the gradient to use (between 0 and 1)
  32056. * @param factor defines the drag value to affect to the specified gradient
  32057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32058. * @returns the current particle system
  32059. */
  32060. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32061. /**
  32062. * Remove a specific drag gradient
  32063. * @param gradient defines the gradient to remove
  32064. * @returns the current particle system
  32065. */
  32066. removeDragGradient(gradient: number): IParticleSystem;
  32067. /**
  32068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32069. * @param gradient defines the gradient to use (between 0 and 1)
  32070. * @param factor defines the emit rate value to affect to the specified gradient
  32071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32072. * @returns the current particle system
  32073. */
  32074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32075. /**
  32076. * Remove a specific emit rate gradient
  32077. * @param gradient defines the gradient to remove
  32078. * @returns the current particle system
  32079. */
  32080. removeEmitRateGradient(gradient: number): IParticleSystem;
  32081. /**
  32082. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32083. * @param gradient defines the gradient to use (between 0 and 1)
  32084. * @param factor defines the start size value to affect to the specified gradient
  32085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32086. * @returns the current particle system
  32087. */
  32088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32089. /**
  32090. * Remove a specific start size gradient
  32091. * @param gradient defines the gradient to remove
  32092. * @returns the current particle system
  32093. */
  32094. removeStartSizeGradient(gradient: number): IParticleSystem;
  32095. private _createRampGradientTexture;
  32096. /**
  32097. * Gets the current list of ramp gradients.
  32098. * You must use addRampGradient and removeRampGradient to udpate this list
  32099. * @returns the list of ramp gradients
  32100. */
  32101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32102. /**
  32103. * Adds a new ramp gradient used to remap particle colors
  32104. * @param gradient defines the gradient to use (between 0 and 1)
  32105. * @param color defines the color to affect to the specified gradient
  32106. * @returns the current particle system
  32107. */
  32108. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32109. /**
  32110. * Remove a specific ramp gradient
  32111. * @param gradient defines the gradient to remove
  32112. * @returns the current particle system
  32113. */
  32114. removeRampGradient(gradient: number): ParticleSystem;
  32115. /**
  32116. * Adds a new color gradient
  32117. * @param gradient defines the gradient to use (between 0 and 1)
  32118. * @param color1 defines the color to affect to the specified gradient
  32119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32120. * @returns this particle system
  32121. */
  32122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32123. /**
  32124. * Remove a specific color gradient
  32125. * @param gradient defines the gradient to remove
  32126. * @returns this particle system
  32127. */
  32128. removeColorGradient(gradient: number): IParticleSystem;
  32129. private _fetchR;
  32130. protected _reset(): void;
  32131. private _resetEffect;
  32132. private _createVertexBuffers;
  32133. private _createIndexBuffer;
  32134. /**
  32135. * Gets the maximum number of particles active at the same time.
  32136. * @returns The max number of active particles.
  32137. */
  32138. getCapacity(): number;
  32139. /**
  32140. * Gets whether there are still active particles in the system.
  32141. * @returns True if it is alive, otherwise false.
  32142. */
  32143. isAlive(): boolean;
  32144. /**
  32145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32146. * @returns True if it has been started, otherwise false.
  32147. */
  32148. isStarted(): boolean;
  32149. private _prepareSubEmitterInternalArray;
  32150. /**
  32151. * Starts the particle system and begins to emit
  32152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32153. */
  32154. start(delay?: number): void;
  32155. /**
  32156. * Stops the particle system.
  32157. * @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.
  32158. */
  32159. stop(stopSubEmitters?: boolean): void;
  32160. /**
  32161. * Remove all active particles
  32162. */
  32163. reset(): void;
  32164. /**
  32165. * @hidden (for internal use only)
  32166. */
  32167. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32168. /**
  32169. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32170. * Its lifetime will start back at 0.
  32171. */
  32172. recycleParticle: (particle: Particle) => void;
  32173. private _stopSubEmitters;
  32174. private _createParticle;
  32175. private _removeFromRoot;
  32176. private _emitFromParticle;
  32177. private _update;
  32178. /** @hidden */
  32179. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32180. /** @hidden */
  32181. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32182. /** @hidden */
  32183. private _getEffect;
  32184. /**
  32185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32186. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32187. */
  32188. animate(preWarmOnly?: boolean): void;
  32189. private _appendParticleVertices;
  32190. /**
  32191. * Rebuilds the particle system.
  32192. */
  32193. rebuild(): void;
  32194. /**
  32195. * Is this system ready to be used/rendered
  32196. * @return true if the system is ready
  32197. */
  32198. isReady(): boolean;
  32199. private _render;
  32200. /**
  32201. * Renders the particle system in its current state.
  32202. * @returns the current number of particles
  32203. */
  32204. render(): number;
  32205. /**
  32206. * Disposes the particle system and free the associated resources
  32207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32208. */
  32209. dispose(disposeTexture?: boolean): void;
  32210. /**
  32211. * Clones the particle system.
  32212. * @param name The name of the cloned object
  32213. * @param newEmitter The new emitter to use
  32214. * @returns the cloned particle system
  32215. */
  32216. clone(name: string, newEmitter: any): ParticleSystem;
  32217. /**
  32218. * Serializes the particle system to a JSON object.
  32219. * @returns the JSON object
  32220. */
  32221. serialize(): any;
  32222. /** @hidden */
  32223. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32224. /** @hidden */
  32225. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32226. /**
  32227. * Parses a JSON object to create a particle system.
  32228. * @param parsedParticleSystem The JSON object to parse
  32229. * @param scene The scene to create the particle system in
  32230. * @param rootUrl The root url to use to load external dependencies like texture
  32231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32232. * @returns the Parsed particle system
  32233. */
  32234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32235. }
  32236. }
  32237. declare module BABYLON {
  32238. interface Engine {
  32239. /**
  32240. * Create an effect to use with particle systems.
  32241. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32242. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32243. * @param uniformsNames defines a list of attribute names
  32244. * @param samplers defines an array of string used to represent textures
  32245. * @param defines defines the string containing the defines to use to compile the shaders
  32246. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32247. * @param onCompiled defines a function to call when the effect creation is successful
  32248. * @param onError defines a function to call when the effect creation has failed
  32249. * @returns the new Effect
  32250. */
  32251. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32252. }
  32253. interface Mesh {
  32254. /**
  32255. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32256. * @returns an array of IParticleSystem
  32257. */
  32258. getEmittedParticleSystems(): IParticleSystem[];
  32259. /**
  32260. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32261. * @returns an array of IParticleSystem
  32262. */
  32263. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32264. }
  32265. }
  32266. declare module BABYLON {
  32267. /**
  32268. * Represents a set of particle systems working together to create a specific effect
  32269. */
  32270. class ParticleSystemSet implements IDisposable {
  32271. private _emitterCreationOptions;
  32272. private _emitterNode;
  32273. /**
  32274. * Gets the particle system list
  32275. */
  32276. systems: IParticleSystem[];
  32277. /**
  32278. * Gets the emitter node used with this set
  32279. */
  32280. readonly emitterNode: Nullable<TransformNode>;
  32281. /**
  32282. * Creates a new emitter mesh as a sphere
  32283. * @param options defines the options used to create the sphere
  32284. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32285. * @param scene defines the hosting scene
  32286. */
  32287. setEmitterAsSphere(options: {
  32288. diameter: number;
  32289. segments: number;
  32290. color: Color3;
  32291. }, renderingGroupId: number, scene: Scene): void;
  32292. /**
  32293. * Starts all particle systems of the set
  32294. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32295. */
  32296. start(emitter?: AbstractMesh): void;
  32297. /**
  32298. * Release all associated resources
  32299. */
  32300. dispose(): void;
  32301. /**
  32302. * Serialize the set into a JSON compatible object
  32303. * @returns a JSON compatible representation of the set
  32304. */
  32305. serialize(): any;
  32306. /**
  32307. * Parse a new ParticleSystemSet from a serialized source
  32308. * @param data defines a JSON compatible representation of the set
  32309. * @param scene defines the hosting scene
  32310. * @param gpu defines if we want GPU particles or CPU particles
  32311. * @returns a new ParticleSystemSet
  32312. */
  32313. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32314. }
  32315. }
  32316. declare module BABYLON {
  32317. /**
  32318. * Represents one particle of a solid particle system.
  32319. */
  32320. class SolidParticle {
  32321. /**
  32322. * particle global index
  32323. */
  32324. idx: number;
  32325. /**
  32326. * The color of the particle
  32327. */
  32328. color: Nullable<Color4>;
  32329. /**
  32330. * The world space position of the particle.
  32331. */
  32332. position: Vector3;
  32333. /**
  32334. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32335. */
  32336. rotation: Vector3;
  32337. /**
  32338. * The world space rotation quaternion of the particle.
  32339. */
  32340. rotationQuaternion: Nullable<Quaternion>;
  32341. /**
  32342. * The scaling of the particle.
  32343. */
  32344. scaling: Vector3;
  32345. /**
  32346. * The uvs of the particle.
  32347. */
  32348. uvs: Vector4;
  32349. /**
  32350. * The current speed of the particle.
  32351. */
  32352. velocity: Vector3;
  32353. /**
  32354. * The pivot point in the particle local space.
  32355. */
  32356. pivot: Vector3;
  32357. /**
  32358. * Must the particle be translated from its pivot point in its local space ?
  32359. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32360. * Default : false
  32361. */
  32362. translateFromPivot: boolean;
  32363. /**
  32364. * Is the particle active or not ?
  32365. */
  32366. alive: boolean;
  32367. /**
  32368. * Is the particle visible or not ?
  32369. */
  32370. isVisible: boolean;
  32371. /**
  32372. * Index of this particle in the global "positions" array (Internal use)
  32373. * @hidden
  32374. */
  32375. _pos: number;
  32376. /**
  32377. * @hidden Index of this particle in the global "indices" array (Internal use)
  32378. */
  32379. _ind: number;
  32380. /**
  32381. * @hidden ModelShape of this particle (Internal use)
  32382. */
  32383. _model: ModelShape;
  32384. /**
  32385. * ModelShape id of this particle
  32386. */
  32387. shapeId: number;
  32388. /**
  32389. * Index of the particle in its shape id (Internal use)
  32390. */
  32391. idxInShape: number;
  32392. /**
  32393. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32394. */
  32395. _modelBoundingInfo: BoundingInfo;
  32396. /**
  32397. * @hidden Particle BoundingInfo object (Internal use)
  32398. */
  32399. _boundingInfo: BoundingInfo;
  32400. /**
  32401. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32402. */
  32403. _sps: SolidParticleSystem;
  32404. /**
  32405. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32406. */
  32407. _stillInvisible: boolean;
  32408. /**
  32409. * @hidden Last computed particle rotation matrix
  32410. */
  32411. _rotationMatrix: number[];
  32412. /**
  32413. * Parent particle Id, if any.
  32414. * Default null.
  32415. */
  32416. parentId: Nullable<number>;
  32417. /**
  32418. * @hidden Internal global position in the SPS.
  32419. */
  32420. _globalPosition: Vector3;
  32421. /**
  32422. * Creates a Solid Particle object.
  32423. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32424. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32425. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32426. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32427. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32428. * @param shapeId (integer) is the model shape identifier in the SPS.
  32429. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32430. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32431. */
  32432. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32433. /**
  32434. * Legacy support, changed scale to scaling
  32435. */
  32436. /**
  32437. * Legacy support, changed scale to scaling
  32438. */
  32439. scale: Vector3;
  32440. /**
  32441. * Legacy support, changed quaternion to rotationQuaternion
  32442. */
  32443. /**
  32444. * Legacy support, changed quaternion to rotationQuaternion
  32445. */
  32446. quaternion: Nullable<Quaternion>;
  32447. /**
  32448. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32449. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32450. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32451. * @returns true if it intersects
  32452. */
  32453. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32454. /**
  32455. * get the rotation matrix of the particle
  32456. * @hidden
  32457. */
  32458. getRotationMatrix(m: Matrix): void;
  32459. }
  32460. /**
  32461. * Represents the shape of the model used by one particle of a solid particle system.
  32462. * SPS internal tool, don't use it manually.
  32463. */
  32464. class ModelShape {
  32465. /**
  32466. * The shape id
  32467. * @hidden
  32468. */
  32469. shapeID: number;
  32470. /**
  32471. * flat array of model positions (internal use)
  32472. * @hidden
  32473. */
  32474. _shape: Vector3[];
  32475. /**
  32476. * flat array of model UVs (internal use)
  32477. * @hidden
  32478. */
  32479. _shapeUV: number[];
  32480. /**
  32481. * length of the shape in the model indices array (internal use)
  32482. * @hidden
  32483. */
  32484. _indicesLength: number;
  32485. /**
  32486. * Custom position function (internal use)
  32487. * @hidden
  32488. */
  32489. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32490. /**
  32491. * Custom vertex function (internal use)
  32492. * @hidden
  32493. */
  32494. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32495. /**
  32496. * 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.
  32497. * SPS internal tool, don't use it manually.
  32498. * @hidden
  32499. */
  32500. 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>);
  32501. }
  32502. /**
  32503. * Represents a Depth Sorted Particle in the solid particle system.
  32504. */
  32505. class DepthSortedParticle {
  32506. /**
  32507. * Index of the particle in the "indices" array
  32508. */
  32509. ind: number;
  32510. /**
  32511. * Length of the particle shape in the "indices" array
  32512. */
  32513. indicesLength: number;
  32514. /**
  32515. * Squared distance from the particle to the camera
  32516. */
  32517. sqDistance: number;
  32518. }
  32519. }
  32520. declare module BABYLON {
  32521. /**
  32522. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32523. *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.
  32524. * The SPS is also a particle system. It provides some methods to manage the particles.
  32525. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32526. *
  32527. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32528. */
  32529. class SolidParticleSystem implements IDisposable {
  32530. /**
  32531. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32532. * Example : var p = SPS.particles[i];
  32533. */
  32534. particles: SolidParticle[];
  32535. /**
  32536. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32537. */
  32538. nbParticles: number;
  32539. /**
  32540. * If the particles must ever face the camera (default false). Useful for planar particles.
  32541. */
  32542. billboard: boolean;
  32543. /**
  32544. * Recompute normals when adding a shape
  32545. */
  32546. recomputeNormals: boolean;
  32547. /**
  32548. * This a counter ofr your own usage. It's not set by any SPS functions.
  32549. */
  32550. counter: number;
  32551. /**
  32552. * The SPS name. This name is also given to the underlying mesh.
  32553. */
  32554. name: string;
  32555. /**
  32556. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32557. */
  32558. mesh: Mesh;
  32559. /**
  32560. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32561. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32562. */
  32563. vars: any;
  32564. /**
  32565. * This array is populated when the SPS is set as 'pickable'.
  32566. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32567. * Each element of this array is an object `{idx: int, faceId: int}`.
  32568. * `idx` is the picked particle index in the `SPS.particles` array
  32569. * `faceId` is the picked face index counted within this particle.
  32570. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32571. */
  32572. pickedParticles: {
  32573. idx: number;
  32574. faceId: number;
  32575. }[];
  32576. /**
  32577. * This array is populated when `enableDepthSort` is set to true.
  32578. * Each element of this array is an instance of the class DepthSortedParticle.
  32579. */
  32580. depthSortedParticles: DepthSortedParticle[];
  32581. /**
  32582. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32583. * @hidden
  32584. */
  32585. _bSphereOnly: boolean;
  32586. /**
  32587. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32588. * @hidden
  32589. */
  32590. _bSphereRadiusFactor: number;
  32591. private _scene;
  32592. private _positions;
  32593. private _indices;
  32594. private _normals;
  32595. private _colors;
  32596. private _uvs;
  32597. private _indices32;
  32598. private _positions32;
  32599. private _normals32;
  32600. private _fixedNormal32;
  32601. private _colors32;
  32602. private _uvs32;
  32603. private _index;
  32604. private _updatable;
  32605. private _pickable;
  32606. private _isVisibilityBoxLocked;
  32607. private _alwaysVisible;
  32608. private _depthSort;
  32609. private _shapeCounter;
  32610. private _copy;
  32611. private _color;
  32612. private _computeParticleColor;
  32613. private _computeParticleTexture;
  32614. private _computeParticleRotation;
  32615. private _computeParticleVertex;
  32616. private _computeBoundingBox;
  32617. private _depthSortParticles;
  32618. private _camera;
  32619. private _mustUnrotateFixedNormals;
  32620. private _particlesIntersect;
  32621. private _needs32Bits;
  32622. /**
  32623. * Creates a SPS (Solid Particle System) object.
  32624. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32625. * @param scene (Scene) is the scene in which the SPS is added.
  32626. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32627. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32628. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32629. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32630. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32631. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32632. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32633. */
  32634. constructor(name: string, scene: Scene, options?: {
  32635. updatable?: boolean;
  32636. isPickable?: boolean;
  32637. enableDepthSort?: boolean;
  32638. particleIntersection?: boolean;
  32639. boundingSphereOnly?: boolean;
  32640. bSphereRadiusFactor?: number;
  32641. });
  32642. /**
  32643. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32644. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32645. * @returns the created mesh
  32646. */
  32647. buildMesh(): Mesh;
  32648. /**
  32649. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32650. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32651. * Thus the particles generated from `digest()` have their property `position` set yet.
  32652. * @param mesh ( Mesh ) is the mesh to be digested
  32653. * @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
  32654. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32655. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32656. * @returns the current SPS
  32657. */
  32658. digest(mesh: Mesh, options?: {
  32659. facetNb?: number;
  32660. number?: number;
  32661. delta?: number;
  32662. }): SolidParticleSystem;
  32663. private _unrotateFixedNormals;
  32664. private _resetCopy;
  32665. private _meshBuilder;
  32666. private _posToShape;
  32667. private _uvsToShapeUV;
  32668. private _addParticle;
  32669. /**
  32670. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32671. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32672. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32673. * @param nb (positive integer) the number of particles to be created from this model
  32674. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32675. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32676. * @returns the number of shapes in the system
  32677. */
  32678. addShape(mesh: Mesh, nb: number, options?: {
  32679. positionFunction?: any;
  32680. vertexFunction?: any;
  32681. }): number;
  32682. private _rebuildParticle;
  32683. /**
  32684. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32685. * @returns the SPS.
  32686. */
  32687. rebuildMesh(): SolidParticleSystem;
  32688. /**
  32689. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32690. * This method calls `updateParticle()` for each particle of the SPS.
  32691. * For an animated SPS, it is usually called within the render loop.
  32692. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32693. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32694. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32695. * @returns the SPS.
  32696. */
  32697. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32698. /**
  32699. * Disposes the SPS.
  32700. */
  32701. dispose(): void;
  32702. /**
  32703. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32704. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32705. * @returns the SPS.
  32706. */
  32707. refreshVisibleSize(): SolidParticleSystem;
  32708. /**
  32709. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32710. * @param size the size (float) of the visibility box
  32711. * note : this doesn't lock the SPS mesh bounding box.
  32712. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32713. */
  32714. setVisibilityBox(size: number): void;
  32715. /**
  32716. * Gets whether the SPS as always visible or not
  32717. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32718. */
  32719. /**
  32720. * Sets the SPS as always visible or not
  32721. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32722. */
  32723. isAlwaysVisible: boolean;
  32724. /**
  32725. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32726. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32727. */
  32728. /**
  32729. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32730. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32731. */
  32732. isVisibilityBoxLocked: boolean;
  32733. /**
  32734. * Tells to `setParticles()` to compute the particle rotations or not.
  32735. * Default value : true. The SPS is faster when it's set to false.
  32736. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32737. */
  32738. /**
  32739. * Gets if `setParticles()` computes the particle rotations or not.
  32740. * Default value : true. The SPS is faster when it's set to false.
  32741. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32742. */
  32743. computeParticleRotation: boolean;
  32744. /**
  32745. * Tells to `setParticles()` to compute the particle colors or not.
  32746. * Default value : true. The SPS is faster when it's set to false.
  32747. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32748. */
  32749. /**
  32750. * Gets if `setParticles()` computes the particle colors or not.
  32751. * Default value : true. The SPS is faster when it's set to false.
  32752. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32753. */
  32754. computeParticleColor: boolean;
  32755. /**
  32756. * Gets if `setParticles()` computes the particle textures or not.
  32757. * Default value : true. The SPS is faster when it's set to false.
  32758. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32759. */
  32760. computeParticleTexture: boolean;
  32761. /**
  32762. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32763. * Default value : false. The SPS is faster when it's set to false.
  32764. * Note : the particle custom vertex positions aren't stored values.
  32765. */
  32766. /**
  32767. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32768. * Default value : false. The SPS is faster when it's set to false.
  32769. * Note : the particle custom vertex positions aren't stored values.
  32770. */
  32771. computeParticleVertex: boolean;
  32772. /**
  32773. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32774. */
  32775. /**
  32776. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32777. */
  32778. computeBoundingBox: boolean;
  32779. /**
  32780. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32781. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32782. * Default : `true`
  32783. */
  32784. /**
  32785. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32786. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32787. * Default : `true`
  32788. */
  32789. depthSortParticles: boolean;
  32790. /**
  32791. * This function does nothing. It may be overwritten to set all the particle first values.
  32792. * The SPS doesn't call this function, you may have to call it by your own.
  32793. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32794. */
  32795. initParticles(): void;
  32796. /**
  32797. * This function does nothing. It may be overwritten to recycle a particle.
  32798. * The SPS doesn't call this function, you may have to call it by your own.
  32799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32800. * @param particle The particle to recycle
  32801. * @returns the recycled particle
  32802. */
  32803. recycleParticle(particle: SolidParticle): SolidParticle;
  32804. /**
  32805. * Updates a particle : this function should be overwritten by the user.
  32806. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32808. * @example : just set a particle position or velocity and recycle conditions
  32809. * @param particle The particle to update
  32810. * @returns the updated particle
  32811. */
  32812. updateParticle(particle: SolidParticle): SolidParticle;
  32813. /**
  32814. * Updates a vertex of a particle : it can be overwritten by the user.
  32815. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32816. * @param particle the current particle
  32817. * @param vertex the current index of the current particle
  32818. * @param pt the index of the current vertex in the particle shape
  32819. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32820. * @example : just set a vertex particle position
  32821. * @returns the updated vertex
  32822. */
  32823. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32824. /**
  32825. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32826. * This does nothing and may be overwritten by the user.
  32827. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32828. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32829. * @param update the boolean update value actually passed to setParticles()
  32830. */
  32831. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32832. /**
  32833. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32834. * This will be passed three parameters.
  32835. * This does nothing and may be overwritten by the user.
  32836. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32837. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32838. * @param update the boolean update value actually passed to setParticles()
  32839. */
  32840. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32841. }
  32842. }
  32843. declare module BABYLON {
  32844. /**
  32845. * Type of sub emitter
  32846. */
  32847. enum SubEmitterType {
  32848. /**
  32849. * Attached to the particle over it's lifetime
  32850. */
  32851. ATTACHED = 0,
  32852. /**
  32853. * Created when the particle dies
  32854. */
  32855. END = 1
  32856. }
  32857. /**
  32858. * Sub emitter class used to emit particles from an existing particle
  32859. */
  32860. class SubEmitter {
  32861. /**
  32862. * the particle system to be used by the sub emitter
  32863. */
  32864. particleSystem: ParticleSystem;
  32865. /**
  32866. * Type of the submitter (Default: END)
  32867. */
  32868. type: SubEmitterType;
  32869. /**
  32870. * 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)
  32871. * Note: This only is supported when using an emitter of type Mesh
  32872. */
  32873. inheritDirection: boolean;
  32874. /**
  32875. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32876. */
  32877. inheritedVelocityAmount: number;
  32878. /**
  32879. * Creates a sub emitter
  32880. * @param particleSystem the particle system to be used by the sub emitter
  32881. */
  32882. constructor(
  32883. /**
  32884. * the particle system to be used by the sub emitter
  32885. */
  32886. particleSystem: ParticleSystem);
  32887. /**
  32888. * Clones the sub emitter
  32889. * @returns the cloned sub emitter
  32890. */
  32891. clone(): SubEmitter;
  32892. /**
  32893. * Serialize current object to a JSON object
  32894. * @returns the serialized object
  32895. */
  32896. serialize(): any;
  32897. /**
  32898. * Creates a new SubEmitter from a serialized JSON version
  32899. * @param serializationObject defines the JSON object to read from
  32900. * @param scene defines the hosting scene
  32901. * @param rootUrl defines the rootUrl for data loading
  32902. * @returns a new SubEmitter
  32903. */
  32904. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32905. /** Release associated resources */
  32906. dispose(): void;
  32907. }
  32908. }
  32909. declare module BABYLON {
  32910. /**
  32911. * Interface used to describe a physics joint
  32912. */
  32913. interface PhysicsImpostorJoint {
  32914. /** Defines the main impostor to which the joint is linked */
  32915. mainImpostor: PhysicsImpostor;
  32916. /** Defines the impostor that is connected to the main impostor using this joint */
  32917. connectedImpostor: PhysicsImpostor;
  32918. /** Defines the joint itself */
  32919. joint: PhysicsJoint;
  32920. }
  32921. /** @hidden */
  32922. interface IPhysicsEnginePlugin {
  32923. world: any;
  32924. name: string;
  32925. setGravity(gravity: Vector3): void;
  32926. setTimeStep(timeStep: number): void;
  32927. getTimeStep(): number;
  32928. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32929. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32930. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32931. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32932. removePhysicsBody(impostor: PhysicsImpostor): void;
  32933. generateJoint(joint: PhysicsImpostorJoint): void;
  32934. removeJoint(joint: PhysicsImpostorJoint): void;
  32935. isSupported(): boolean;
  32936. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32937. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32938. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32939. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32940. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32941. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32942. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32943. getBodyMass(impostor: PhysicsImpostor): number;
  32944. getBodyFriction(impostor: PhysicsImpostor): number;
  32945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32946. getBodyRestitution(impostor: PhysicsImpostor): number;
  32947. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32948. sleepBody(impostor: PhysicsImpostor): void;
  32949. wakeUpBody(impostor: PhysicsImpostor): void;
  32950. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32951. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32953. getRadius(impostor: PhysicsImpostor): number;
  32954. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32955. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32956. dispose(): void;
  32957. }
  32958. /**
  32959. * Interface used to define a physics engine
  32960. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32961. */
  32962. interface IPhysicsEngine {
  32963. /**
  32964. * Gets the gravity vector used by the simulation
  32965. */
  32966. gravity: Vector3;
  32967. /**
  32968. * Sets the gravity vector used by the simulation
  32969. * @param gravity defines the gravity vector to use
  32970. */
  32971. setGravity(gravity: Vector3): void;
  32972. /**
  32973. * Set the time step of the physics engine.
  32974. * Default is 1/60.
  32975. * To slow it down, enter 1/600 for example.
  32976. * To speed it up, 1/30
  32977. * @param newTimeStep the new timestep to apply to this world.
  32978. */
  32979. setTimeStep(newTimeStep: number): void;
  32980. /**
  32981. * Get the time step of the physics engine.
  32982. * @returns the current time step
  32983. */
  32984. getTimeStep(): number;
  32985. /**
  32986. * Release all resources
  32987. */
  32988. dispose(): void;
  32989. /**
  32990. * Gets the name of the current physics plugin
  32991. * @returns the name of the plugin
  32992. */
  32993. getPhysicsPluginName(): string;
  32994. /**
  32995. * Adding a new impostor for the impostor tracking.
  32996. * This will be done by the impostor itself.
  32997. * @param impostor the impostor to add
  32998. */
  32999. addImpostor(impostor: PhysicsImpostor): void;
  33000. /**
  33001. * Remove an impostor from the engine.
  33002. * This impostor and its mesh will not longer be updated by the physics engine.
  33003. * @param impostor the impostor to remove
  33004. */
  33005. removeImpostor(impostor: PhysicsImpostor): void;
  33006. /**
  33007. * Add a joint to the physics engine
  33008. * @param mainImpostor defines the main impostor to which the joint is added.
  33009. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33010. * @param joint defines the joint that will connect both impostors.
  33011. */
  33012. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33013. /**
  33014. * Removes a joint from the simulation
  33015. * @param mainImpostor defines the impostor used with the joint
  33016. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33017. * @param joint defines the joint to remove
  33018. */
  33019. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33020. /**
  33021. * Gets the current plugin used to run the simulation
  33022. * @returns current plugin
  33023. */
  33024. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33025. /**
  33026. * Gets the list of physic impostors
  33027. * @returns an array of PhysicsImpostor
  33028. */
  33029. getImpostors(): Array<PhysicsImpostor>;
  33030. /**
  33031. * Gets the impostor for a physics enabled object
  33032. * @param object defines the object impersonated by the impostor
  33033. * @returns the PhysicsImpostor or null if not found
  33034. */
  33035. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33036. /**
  33037. * Gets the impostor for a physics body object
  33038. * @param body defines physics body used by the impostor
  33039. * @returns the PhysicsImpostor or null if not found
  33040. */
  33041. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33042. /**
  33043. * Called by the scene. No need to call it.
  33044. * @param delta defines the timespam between frames
  33045. */
  33046. _step(delta: number): void;
  33047. }
  33048. }
  33049. declare module BABYLON {
  33050. /**
  33051. * Class used to control physics engine
  33052. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33053. */
  33054. class PhysicsEngine implements IPhysicsEngine {
  33055. private _physicsPlugin;
  33056. /**
  33057. * Global value used to control the smallest number supported by the simulation
  33058. */
  33059. static Epsilon: number;
  33060. private _impostors;
  33061. private _joints;
  33062. /**
  33063. * Gets the gravity vector used by the simulation
  33064. */
  33065. gravity: Vector3;
  33066. /**
  33067. * Creates a new Physics Engine
  33068. * @param gravity defines the gravity vector used by the simulation
  33069. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33070. */
  33071. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33072. /**
  33073. * Sets the gravity vector used by the simulation
  33074. * @param gravity defines the gravity vector to use
  33075. */
  33076. setGravity(gravity: Vector3): void;
  33077. /**
  33078. * Set the time step of the physics engine.
  33079. * Default is 1/60.
  33080. * To slow it down, enter 1/600 for example.
  33081. * To speed it up, 1/30
  33082. * @param newTimeStep defines the new timestep to apply to this world.
  33083. */
  33084. setTimeStep(newTimeStep?: number): void;
  33085. /**
  33086. * Get the time step of the physics engine.
  33087. * @returns the current time step
  33088. */
  33089. getTimeStep(): number;
  33090. /**
  33091. * Release all resources
  33092. */
  33093. dispose(): void;
  33094. /**
  33095. * Gets the name of the current physics plugin
  33096. * @returns the name of the plugin
  33097. */
  33098. getPhysicsPluginName(): string;
  33099. /**
  33100. * Adding a new impostor for the impostor tracking.
  33101. * This will be done by the impostor itself.
  33102. * @param impostor the impostor to add
  33103. */
  33104. addImpostor(impostor: PhysicsImpostor): void;
  33105. /**
  33106. * Remove an impostor from the engine.
  33107. * This impostor and its mesh will not longer be updated by the physics engine.
  33108. * @param impostor the impostor to remove
  33109. */
  33110. removeImpostor(impostor: PhysicsImpostor): void;
  33111. /**
  33112. * Add a joint to the physics engine
  33113. * @param mainImpostor defines the main impostor to which the joint is added.
  33114. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33115. * @param joint defines the joint that will connect both impostors.
  33116. */
  33117. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33118. /**
  33119. * Removes a joint from the simulation
  33120. * @param mainImpostor defines the impostor used with the joint
  33121. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33122. * @param joint defines the joint to remove
  33123. */
  33124. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33125. /**
  33126. * Called by the scene. No need to call it.
  33127. * @param delta defines the timespam between frames
  33128. */
  33129. _step(delta: number): void;
  33130. /**
  33131. * Gets the current plugin used to run the simulation
  33132. * @returns current plugin
  33133. */
  33134. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33135. /**
  33136. * Gets the list of physic impostors
  33137. * @returns an array of PhysicsImpostor
  33138. */
  33139. getImpostors(): Array<PhysicsImpostor>;
  33140. /**
  33141. * Gets the impostor for a physics enabled object
  33142. * @param object defines the object impersonated by the impostor
  33143. * @returns the PhysicsImpostor or null if not found
  33144. */
  33145. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33146. /**
  33147. * Gets the impostor for a physics body object
  33148. * @param body defines physics body used by the impostor
  33149. * @returns the PhysicsImpostor or null if not found
  33150. */
  33151. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33152. }
  33153. }
  33154. declare module BABYLON {
  33155. interface Scene {
  33156. /** @hidden (Backing field) */
  33157. _physicsEngine: Nullable<IPhysicsEngine>;
  33158. /**
  33159. * Gets the current physics engine
  33160. * @returns a IPhysicsEngine or null if none attached
  33161. */
  33162. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33163. /**
  33164. * Enables physics to the current scene
  33165. * @param gravity defines the scene's gravity for the physics engine
  33166. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33167. * @return a boolean indicating if the physics engine was initialized
  33168. */
  33169. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33170. /**
  33171. * Disables and disposes the physics engine associated with the scene
  33172. */
  33173. disablePhysicsEngine(): void;
  33174. /**
  33175. * Gets a boolean indicating if there is an active physics engine
  33176. * @returns a boolean indicating if there is an active physics engine
  33177. */
  33178. isPhysicsEnabled(): boolean;
  33179. /**
  33180. * Deletes a physics compound impostor
  33181. * @param compound defines the compound to delete
  33182. */
  33183. deleteCompoundImpostor(compound: any): void;
  33184. /**
  33185. * An event triggered when physic simulation is about to be run
  33186. */
  33187. onBeforePhysicsObservable: Observable<Scene>;
  33188. /**
  33189. * An event triggered when physic simulation has been done
  33190. */
  33191. onAfterPhysicsObservable: Observable<Scene>;
  33192. }
  33193. interface AbstractMesh {
  33194. /** @hidden */
  33195. _physicsImpostor: Nullable<PhysicsImpostor>;
  33196. /**
  33197. * Gets or sets impostor used for physic simulation
  33198. * @see http://doc.babylonjs.com/features/physics_engine
  33199. */
  33200. physicsImpostor: Nullable<PhysicsImpostor>;
  33201. /**
  33202. * Gets the current physics impostor
  33203. * @see http://doc.babylonjs.com/features/physics_engine
  33204. * @returns a physics impostor or null
  33205. */
  33206. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33207. /** Apply a physic impulse to the mesh
  33208. * @param force defines the force to apply
  33209. * @param contactPoint defines where to apply the force
  33210. * @returns the current mesh
  33211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33212. */
  33213. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33214. /**
  33215. * Creates a physic joint between two meshes
  33216. * @param otherMesh defines the other mesh to use
  33217. * @param pivot1 defines the pivot to use on this mesh
  33218. * @param pivot2 defines the pivot to use on the other mesh
  33219. * @param options defines additional options (can be plugin dependent)
  33220. * @returns the current mesh
  33221. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33222. */
  33223. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33224. /** @hidden */
  33225. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33226. }
  33227. /**
  33228. * Defines the physics engine scene component responsible to manage a physics engine
  33229. */
  33230. class PhysicsEngineSceneComponent implements ISceneComponent {
  33231. /**
  33232. * The component name helpful to identify the component in the list of scene components.
  33233. */
  33234. readonly name: string;
  33235. /**
  33236. * The scene the component belongs to.
  33237. */
  33238. scene: Scene;
  33239. /**
  33240. * Creates a new instance of the component for the given scene
  33241. * @param scene Defines the scene to register the component in
  33242. */
  33243. constructor(scene: Scene);
  33244. /**
  33245. * Registers the component in a given scene
  33246. */
  33247. register(): void;
  33248. /**
  33249. * Rebuilds the elements related to this component in case of
  33250. * context lost for instance.
  33251. */
  33252. rebuild(): void;
  33253. /**
  33254. * Disposes the component and the associated ressources
  33255. */
  33256. dispose(): void;
  33257. }
  33258. }
  33259. declare module BABYLON {
  33260. /**
  33261. * A helper for physics simulations
  33262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33263. */
  33264. class PhysicsHelper {
  33265. private _scene;
  33266. private _physicsEngine;
  33267. /**
  33268. * Initializes the Physics helper
  33269. * @param scene Babylon.js scene
  33270. */
  33271. constructor(scene: Scene);
  33272. /**
  33273. * Applies a radial explosion impulse
  33274. * @param origin the origin of the explosion
  33275. * @param radius the explosion radius
  33276. * @param strength the explosion strength
  33277. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33278. * @returns A physics radial explosion event, or null
  33279. */
  33280. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33281. /**
  33282. * Applies a radial explosion force
  33283. * @param origin the origin of the explosion
  33284. * @param radius the explosion radius
  33285. * @param strength the explosion strength
  33286. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33287. * @returns A physics radial explosion event, or null
  33288. */
  33289. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33290. /**
  33291. * Creates a gravitational field
  33292. * @param origin the origin of the explosion
  33293. * @param radius the explosion radius
  33294. * @param strength the explosion strength
  33295. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33296. * @returns A physics gravitational field event, or null
  33297. */
  33298. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33299. /**
  33300. * Creates a physics updraft event
  33301. * @param origin the origin of the updraft
  33302. * @param radius the radius of the updraft
  33303. * @param strength the strength of the updraft
  33304. * @param height the height of the updraft
  33305. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33306. * @returns A physics updraft event, or null
  33307. */
  33308. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33309. /**
  33310. * Creates a physics vortex event
  33311. * @param origin the of the vortex
  33312. * @param radius the radius of the vortex
  33313. * @param strength the strength of the vortex
  33314. * @param height the height of the vortex
  33315. * @returns a Physics vortex event, or null
  33316. * A physics vortex event or null
  33317. */
  33318. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33319. }
  33320. /**
  33321. * Represents a physics radial explosion event
  33322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33323. */
  33324. class PhysicsRadialExplosionEvent {
  33325. private _scene;
  33326. private _sphere;
  33327. private _sphereOptions;
  33328. private _rays;
  33329. private _dataFetched;
  33330. /**
  33331. * Initializes a radial explosioin event
  33332. * @param scene BabylonJS scene
  33333. */
  33334. constructor(scene: Scene);
  33335. /**
  33336. * Returns the data related to the radial explosion event (sphere & rays).
  33337. * @returns The radial explosion event data
  33338. */
  33339. getData(): PhysicsRadialExplosionEventData;
  33340. /**
  33341. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33342. * @param impostor A physics imposter
  33343. * @param origin the origin of the explosion
  33344. * @param radius the explosion radius
  33345. * @param strength the explosion strength
  33346. * @param falloff possible options: Constant & Linear
  33347. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33348. */
  33349. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33350. /**
  33351. * Disposes the sphere.
  33352. * @param force Specifies if the sphere should be disposed by force
  33353. */
  33354. dispose(force?: boolean): void;
  33355. /*** Helpers ***/
  33356. private _prepareSphere;
  33357. private _intersectsWithSphere;
  33358. }
  33359. /**
  33360. * Represents a gravitational field event
  33361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33362. */
  33363. class PhysicsGravitationalFieldEvent {
  33364. private _physicsHelper;
  33365. private _scene;
  33366. private _origin;
  33367. private _radius;
  33368. private _strength;
  33369. private _falloff;
  33370. private _tickCallback;
  33371. private _sphere;
  33372. private _dataFetched;
  33373. /**
  33374. * Initializes the physics gravitational field event
  33375. * @param physicsHelper A physics helper
  33376. * @param scene BabylonJS scene
  33377. * @param origin The origin position of the gravitational field event
  33378. * @param radius The radius of the gravitational field event
  33379. * @param strength The strength of the gravitational field event
  33380. * @param falloff The falloff for the gravitational field event
  33381. */
  33382. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33383. /**
  33384. * Returns the data related to the gravitational field event (sphere).
  33385. * @returns A gravitational field event
  33386. */
  33387. getData(): PhysicsGravitationalFieldEventData;
  33388. /**
  33389. * Enables the gravitational field.
  33390. */
  33391. enable(): void;
  33392. /**
  33393. * Disables the gravitational field.
  33394. */
  33395. disable(): void;
  33396. /**
  33397. * Disposes the sphere.
  33398. * @param force The force to dispose from the gravitational field event
  33399. */
  33400. dispose(force?: boolean): void;
  33401. private _tick;
  33402. }
  33403. /**
  33404. * Represents a physics updraft event
  33405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33406. */
  33407. class PhysicsUpdraftEvent {
  33408. private _scene;
  33409. private _origin;
  33410. private _radius;
  33411. private _strength;
  33412. private _height;
  33413. private _updraftMode;
  33414. private _physicsEngine;
  33415. private _originTop;
  33416. private _originDirection;
  33417. private _tickCallback;
  33418. private _cylinder;
  33419. private _cylinderPosition;
  33420. private _dataFetched;
  33421. /**
  33422. * Initializes the physics updraft event
  33423. * @param _scene BabylonJS scene
  33424. * @param _origin The origin position of the updraft
  33425. * @param _radius The radius of the updraft
  33426. * @param _strength The strength of the updraft
  33427. * @param _height The height of the updraft
  33428. * @param _updraftMode The mode of the updraft
  33429. */
  33430. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33431. /**
  33432. * Returns the data related to the updraft event (cylinder).
  33433. * @returns A physics updraft event
  33434. */
  33435. getData(): PhysicsUpdraftEventData;
  33436. /**
  33437. * Enables the updraft.
  33438. */
  33439. enable(): void;
  33440. /**
  33441. * Disables the cortex.
  33442. */
  33443. disable(): void;
  33444. /**
  33445. * Disposes the sphere.
  33446. * @param force Specifies if the updraft should be disposed by force
  33447. */
  33448. dispose(force?: boolean): void;
  33449. private getImpostorForceAndContactPoint;
  33450. private _tick;
  33451. /*** Helpers ***/
  33452. private _prepareCylinder;
  33453. private _intersectsWithCylinder;
  33454. }
  33455. /**
  33456. * Represents a physics vortex event
  33457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33458. */
  33459. class PhysicsVortexEvent {
  33460. private _scene;
  33461. private _origin;
  33462. private _radius;
  33463. private _strength;
  33464. private _height;
  33465. private _physicsEngine;
  33466. private _originTop;
  33467. private _centripetalForceThreshold;
  33468. private _updraftMultiplier;
  33469. private _tickCallback;
  33470. private _cylinder;
  33471. private _cylinderPosition;
  33472. private _dataFetched;
  33473. /**
  33474. * Initializes the physics vortex event
  33475. * @param _scene The BabylonJS scene
  33476. * @param _origin The origin position of the vortex
  33477. * @param _radius The radius of the vortex
  33478. * @param _strength The strength of the vortex
  33479. * @param _height The height of the vortex
  33480. */
  33481. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33482. /**
  33483. * Returns the data related to the vortex event (cylinder).
  33484. * @returns The physics vortex event data
  33485. */
  33486. getData(): PhysicsVortexEventData;
  33487. /**
  33488. * Enables the vortex.
  33489. */
  33490. enable(): void;
  33491. /**
  33492. * Disables the cortex.
  33493. */
  33494. disable(): void;
  33495. /**
  33496. * Disposes the sphere.
  33497. * @param force
  33498. */
  33499. dispose(force?: boolean): void;
  33500. private getImpostorForceAndContactPoint;
  33501. private _tick;
  33502. /*** Helpers ***/
  33503. private _prepareCylinder;
  33504. private _intersectsWithCylinder;
  33505. }
  33506. /**
  33507. * The strenght of the force in correspondence to the distance of the affected object
  33508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33509. */
  33510. enum PhysicsRadialImpulseFalloff {
  33511. /** Defines that impulse is constant in strength across it's whole radius */
  33512. Constant = 0,
  33513. /** DEfines that impulse gets weaker if it's further from the origin */
  33514. Linear = 1
  33515. }
  33516. /**
  33517. * The strength of the force in correspondence to the distance of the affected object
  33518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33519. */
  33520. enum PhysicsUpdraftMode {
  33521. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33522. Center = 0,
  33523. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33524. Perpendicular = 1
  33525. }
  33526. /**
  33527. * Interface for a physics force and contact point
  33528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33529. */
  33530. interface PhysicsForceAndContactPoint {
  33531. /**
  33532. * The force applied at the contact point
  33533. */
  33534. force: Vector3;
  33535. /**
  33536. * The contact point
  33537. */
  33538. contactPoint: Vector3;
  33539. }
  33540. /**
  33541. * Interface for radial explosion event data
  33542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33543. */
  33544. interface PhysicsRadialExplosionEventData {
  33545. /**
  33546. * A sphere used for the radial explosion event
  33547. */
  33548. sphere: Mesh;
  33549. /**
  33550. * An array of rays for the radial explosion event
  33551. */
  33552. rays: Array<Ray>;
  33553. }
  33554. /**
  33555. * Interface for gravitational field event data
  33556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33557. */
  33558. interface PhysicsGravitationalFieldEventData {
  33559. /**
  33560. * A sphere mesh used for the gravitational field event
  33561. */
  33562. sphere: Mesh;
  33563. }
  33564. /**
  33565. * Interface for updraft event data
  33566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33567. */
  33568. interface PhysicsUpdraftEventData {
  33569. /**
  33570. * A cylinder used for the updraft event
  33571. */
  33572. cylinder: Mesh;
  33573. }
  33574. /**
  33575. * Interface for vortex event data
  33576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33577. */
  33578. interface PhysicsVortexEventData {
  33579. /**
  33580. * A cylinder used for the vortex event
  33581. */
  33582. cylinder: Mesh;
  33583. }
  33584. }
  33585. declare module BABYLON {
  33586. /**
  33587. * The interface for the physics imposter parameters
  33588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33589. */
  33590. interface PhysicsImpostorParameters {
  33591. /**
  33592. * The mass of the physics imposter
  33593. */
  33594. mass: number;
  33595. /**
  33596. * The friction of the physics imposter
  33597. */
  33598. friction?: number;
  33599. /**
  33600. * The coefficient of restitution of the physics imposter
  33601. */
  33602. restitution?: number;
  33603. /**
  33604. * The native options of the physics imposter
  33605. */
  33606. nativeOptions?: any;
  33607. /**
  33608. * Specifies if the parent should be ignored
  33609. */
  33610. ignoreParent?: boolean;
  33611. /**
  33612. * Specifies if bi-directional transformations should be disabled
  33613. */
  33614. disableBidirectionalTransformation?: boolean;
  33615. }
  33616. /**
  33617. * Interface for a physics-enabled object
  33618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33619. */
  33620. interface IPhysicsEnabledObject {
  33621. /**
  33622. * The position of the physics-enabled object
  33623. */
  33624. position: Vector3;
  33625. /**
  33626. * The rotation of the physics-enabled object
  33627. */
  33628. rotationQuaternion: Nullable<Quaternion>;
  33629. /**
  33630. * The scale of the physics-enabled object
  33631. */
  33632. scaling: Vector3;
  33633. /**
  33634. * The rotation of the physics-enabled object
  33635. */
  33636. rotation?: Vector3;
  33637. /**
  33638. * The parent of the physics-enabled object
  33639. */
  33640. parent?: any;
  33641. /**
  33642. * The bounding info of the physics-enabled object
  33643. * @returns The bounding info of the physics-enabled object
  33644. */
  33645. getBoundingInfo(): BoundingInfo;
  33646. /**
  33647. * Computes the world matrix
  33648. * @param force Specifies if the world matrix should be computed by force
  33649. * @returns A world matrix
  33650. */
  33651. computeWorldMatrix(force: boolean): Matrix;
  33652. /**
  33653. * Gets the world matrix
  33654. * @returns A world matrix
  33655. */
  33656. getWorldMatrix?(): Matrix;
  33657. /**
  33658. * Gets the child meshes
  33659. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33660. * @returns An array of abstract meshes
  33661. */
  33662. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33663. /**
  33664. * Gets the vertex data
  33665. * @param kind The type of vertex data
  33666. * @returns A nullable array of numbers, or a float32 array
  33667. */
  33668. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33669. /**
  33670. * Gets the indices from the mesh
  33671. * @returns A nullable array of index arrays
  33672. */
  33673. getIndices?(): Nullable<IndicesArray>;
  33674. /**
  33675. * Gets the scene from the mesh
  33676. * @returns the indices array or null
  33677. */
  33678. getScene?(): Scene;
  33679. /**
  33680. * Gets the absolute position from the mesh
  33681. * @returns the absolute position
  33682. */
  33683. getAbsolutePosition(): Vector3;
  33684. /**
  33685. * Gets the absolute pivot point from the mesh
  33686. * @returns the absolute pivot point
  33687. */
  33688. getAbsolutePivotPoint(): Vector3;
  33689. /**
  33690. * Rotates the mesh
  33691. * @param axis The axis of rotation
  33692. * @param amount The amount of rotation
  33693. * @param space The space of the rotation
  33694. * @returns The rotation transform node
  33695. */
  33696. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33697. /**
  33698. * Translates the mesh
  33699. * @param axis The axis of translation
  33700. * @param distance The distance of translation
  33701. * @param space The space of the translation
  33702. * @returns The transform node
  33703. */
  33704. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33705. /**
  33706. * Sets the absolute position of the mesh
  33707. * @param absolutePosition The absolute position of the mesh
  33708. * @returns The transform node
  33709. */
  33710. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33711. /**
  33712. * Gets the class name of the mesh
  33713. * @returns The class name
  33714. */
  33715. getClassName(): string;
  33716. }
  33717. /**
  33718. * Represents a physics imposter
  33719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33720. */
  33721. class PhysicsImpostor {
  33722. /**
  33723. * The physics-enabled object used as the physics imposter
  33724. */
  33725. object: IPhysicsEnabledObject;
  33726. /**
  33727. * The type of the physics imposter
  33728. */
  33729. type: number;
  33730. private _options;
  33731. private _scene?;
  33732. /**
  33733. * The default object size of the imposter
  33734. */
  33735. static DEFAULT_OBJECT_SIZE: Vector3;
  33736. /**
  33737. * The identity quaternion of the imposter
  33738. */
  33739. static IDENTITY_QUATERNION: Quaternion;
  33740. private _physicsEngine;
  33741. private _physicsBody;
  33742. private _bodyUpdateRequired;
  33743. private _onBeforePhysicsStepCallbacks;
  33744. private _onAfterPhysicsStepCallbacks;
  33745. private _onPhysicsCollideCallbacks;
  33746. private _deltaPosition;
  33747. private _deltaRotation;
  33748. private _deltaRotationConjugated;
  33749. private _parent;
  33750. private _isDisposed;
  33751. private static _tmpVecs;
  33752. private static _tmpQuat;
  33753. /**
  33754. * Specifies if the physics imposter is disposed
  33755. */
  33756. readonly isDisposed: boolean;
  33757. /**
  33758. * Gets the mass of the physics imposter
  33759. */
  33760. mass: number;
  33761. /**
  33762. * Gets the coefficient of friction
  33763. */
  33764. /**
  33765. * Sets the coefficient of friction
  33766. */
  33767. friction: number;
  33768. /**
  33769. * Gets the coefficient of restitution
  33770. */
  33771. /**
  33772. * Sets the coefficient of restitution
  33773. */
  33774. restitution: number;
  33775. /**
  33776. * The unique id of the physics imposter
  33777. * set by the physics engine when adding this impostor to the array
  33778. */
  33779. uniqueId: number;
  33780. private _joints;
  33781. /**
  33782. * Initializes the physics imposter
  33783. * @param object The physics-enabled object used as the physics imposter
  33784. * @param type The type of the physics imposter
  33785. * @param _options The options for the physics imposter
  33786. * @param _scene The Babylon scene
  33787. */
  33788. constructor(
  33789. /**
  33790. * The physics-enabled object used as the physics imposter
  33791. */
  33792. object: IPhysicsEnabledObject,
  33793. /**
  33794. * The type of the physics imposter
  33795. */
  33796. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33797. /**
  33798. * This function will completly initialize this impostor.
  33799. * It will create a new body - but only if this mesh has no parent.
  33800. * If it has, this impostor will not be used other than to define the impostor
  33801. * of the child mesh.
  33802. * @hidden
  33803. */
  33804. _init(): void;
  33805. private _getPhysicsParent;
  33806. /**
  33807. * Should a new body be generated.
  33808. * @returns boolean specifying if body initialization is required
  33809. */
  33810. isBodyInitRequired(): boolean;
  33811. /**
  33812. * Sets the updated scaling
  33813. * @param updated Specifies if the scaling is updated
  33814. */
  33815. setScalingUpdated(updated: boolean): void;
  33816. /**
  33817. * Force a regeneration of this or the parent's impostor's body.
  33818. * Use under cautious - This will remove all joints already implemented.
  33819. */
  33820. forceUpdate(): void;
  33821. /**
  33822. * Gets the body that holds this impostor. Either its own, or its parent.
  33823. */
  33824. /**
  33825. * Set the physics body. Used mainly by the physics engine/plugin
  33826. */
  33827. physicsBody: any;
  33828. /**
  33829. * Get the parent of the physics imposter
  33830. * @returns Physics imposter or null
  33831. */
  33832. /**
  33833. * Sets the parent of the physics imposter
  33834. */
  33835. parent: Nullable<PhysicsImpostor>;
  33836. /**
  33837. * Resets the update flags
  33838. */
  33839. resetUpdateFlags(): void;
  33840. /**
  33841. * Gets the object extend size
  33842. * @returns the object extend size
  33843. */
  33844. getObjectExtendSize(): Vector3;
  33845. /**
  33846. * Gets the object center
  33847. * @returns The object center
  33848. */
  33849. getObjectCenter(): Vector3;
  33850. /**
  33851. * Get a specific parametes from the options parameter
  33852. * @param paramName The object parameter name
  33853. * @returns The object parameter
  33854. */
  33855. getParam(paramName: string): any;
  33856. /**
  33857. * Sets a specific parameter in the options given to the physics plugin
  33858. * @param paramName The parameter name
  33859. * @param value The value of the parameter
  33860. */
  33861. setParam(paramName: string, value: number): void;
  33862. /**
  33863. * Specifically change the body's mass option. Won't recreate the physics body object
  33864. * @param mass The mass of the physics imposter
  33865. */
  33866. setMass(mass: number): void;
  33867. /**
  33868. * Gets the linear velocity
  33869. * @returns linear velocity or null
  33870. */
  33871. getLinearVelocity(): Nullable<Vector3>;
  33872. /**
  33873. * Sets the linear velocity
  33874. * @param velocity linear velocity or null
  33875. */
  33876. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33877. /**
  33878. * Gets the angular velocity
  33879. * @returns angular velocity or null
  33880. */
  33881. getAngularVelocity(): Nullable<Vector3>;
  33882. /**
  33883. * Sets the angular velocity
  33884. * @param velocity The velocity or null
  33885. */
  33886. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33887. /**
  33888. * Execute a function with the physics plugin native code
  33889. * Provide a function the will have two variables - the world object and the physics body object
  33890. * @param func The function to execute with the physics plugin native code
  33891. */
  33892. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33893. /**
  33894. * Register a function that will be executed before the physics world is stepping forward
  33895. * @param func The function to execute before the physics world is stepped forward
  33896. */
  33897. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33898. /**
  33899. * Unregister a function that will be executed before the physics world is stepping forward
  33900. * @param func The function to execute before the physics world is stepped forward
  33901. */
  33902. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33903. /**
  33904. * Register a function that will be executed after the physics step
  33905. * @param func The function to execute after physics step
  33906. */
  33907. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33908. /**
  33909. * Unregisters a function that will be executed after the physics step
  33910. * @param func The function to execute after physics step
  33911. */
  33912. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33913. /**
  33914. * register a function that will be executed when this impostor collides against a different body
  33915. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33916. * @param func Callback that is executed on collision
  33917. */
  33918. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33919. /**
  33920. * Unregisters the physics imposter on contact
  33921. * @param collideAgainst The physics object to collide against
  33922. * @param func Callback to execute on collision
  33923. */
  33924. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33925. private _tmpQuat;
  33926. private _tmpQuat2;
  33927. /**
  33928. * Get the parent rotation
  33929. * @returns The parent rotation
  33930. */
  33931. getParentsRotation(): Quaternion;
  33932. /**
  33933. * this function is executed by the physics engine.
  33934. */
  33935. beforeStep: () => void;
  33936. /**
  33937. * this function is executed by the physics engine
  33938. */
  33939. afterStep: () => void;
  33940. /**
  33941. * Legacy collision detection event support
  33942. */
  33943. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33944. /**
  33945. * event and body object due to cannon's event-based architecture.
  33946. */
  33947. onCollide: (e: {
  33948. body: any;
  33949. }) => void;
  33950. /**
  33951. * Apply a force
  33952. * @param force The force to apply
  33953. * @param contactPoint The contact point for the force
  33954. * @returns The physics imposter
  33955. */
  33956. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33957. /**
  33958. * Apply an impulse
  33959. * @param force The impulse force
  33960. * @param contactPoint The contact point for the impulse force
  33961. * @returns The physics imposter
  33962. */
  33963. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33964. /**
  33965. * A help function to create a joint
  33966. * @param otherImpostor A physics imposter used to create a joint
  33967. * @param jointType The type of joint
  33968. * @param jointData The data for the joint
  33969. * @returns The physics imposter
  33970. */
  33971. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33972. /**
  33973. * Add a joint to this impostor with a different impostor
  33974. * @param otherImpostor A physics imposter used to add a joint
  33975. * @param joint The joint to add
  33976. * @returns The physics imposter
  33977. */
  33978. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33979. /**
  33980. * Will keep this body still, in a sleep mode.
  33981. * @returns the physics imposter
  33982. */
  33983. sleep(): PhysicsImpostor;
  33984. /**
  33985. * Wake the body up.
  33986. * @returns The physics imposter
  33987. */
  33988. wakeUp(): PhysicsImpostor;
  33989. /**
  33990. * Clones the physics imposter
  33991. * @param newObject The physics imposter clones to this physics-enabled object
  33992. * @returns A nullable physics imposter
  33993. */
  33994. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33995. /**
  33996. * Disposes the physics imposter
  33997. */
  33998. dispose(): void;
  33999. /**
  34000. * Sets the delta position
  34001. * @param position The delta position amount
  34002. */
  34003. setDeltaPosition(position: Vector3): void;
  34004. /**
  34005. * Sets the delta rotation
  34006. * @param rotation The delta rotation amount
  34007. */
  34008. setDeltaRotation(rotation: Quaternion): void;
  34009. /**
  34010. * Gets the box size of the physics imposter and stores the result in the input parameter
  34011. * @param result Stores the box size
  34012. * @returns The physics imposter
  34013. */
  34014. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34015. /**
  34016. * Gets the radius of the physics imposter
  34017. * @returns Radius of the physics imposter
  34018. */
  34019. getRadius(): number;
  34020. /**
  34021. * Sync a bone with this impostor
  34022. * @param bone The bone to sync to the impostor.
  34023. * @param boneMesh The mesh that the bone is influencing.
  34024. * @param jointPivot The pivot of the joint / bone in local space.
  34025. * @param distToJoint Optional distance from the impostor to the joint.
  34026. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34027. */
  34028. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34029. /**
  34030. * Sync impostor to a bone
  34031. * @param bone The bone that the impostor will be synced to.
  34032. * @param boneMesh The mesh that the bone is influencing.
  34033. * @param jointPivot The pivot of the joint / bone in local space.
  34034. * @param distToJoint Optional distance from the impostor to the joint.
  34035. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34036. * @param boneAxis Optional vector3 axis the bone is aligned with
  34037. */
  34038. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34039. /**
  34040. * No-Imposter type
  34041. */
  34042. static NoImpostor: number;
  34043. /**
  34044. * Sphere-Imposter type
  34045. */
  34046. static SphereImpostor: number;
  34047. /**
  34048. * Box-Imposter type
  34049. */
  34050. static BoxImpostor: number;
  34051. /**
  34052. * Plane-Imposter type
  34053. */
  34054. static PlaneImpostor: number;
  34055. /**
  34056. * Mesh-imposter type
  34057. */
  34058. static MeshImpostor: number;
  34059. /**
  34060. * Cylinder-Imposter type
  34061. */
  34062. static CylinderImpostor: number;
  34063. /**
  34064. * Particle-Imposter type
  34065. */
  34066. static ParticleImpostor: number;
  34067. /**
  34068. * Heightmap-Imposter type
  34069. */
  34070. static HeightmapImpostor: number;
  34071. }
  34072. }
  34073. declare module BABYLON {
  34074. /**
  34075. * Interface for Physics-Joint data
  34076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34077. */
  34078. interface PhysicsJointData {
  34079. /**
  34080. * The main pivot of the joint
  34081. */
  34082. mainPivot?: Vector3;
  34083. /**
  34084. * The connected pivot of the joint
  34085. */
  34086. connectedPivot?: Vector3;
  34087. /**
  34088. * The main axis of the joint
  34089. */
  34090. mainAxis?: Vector3;
  34091. /**
  34092. * The connected axis of the joint
  34093. */
  34094. connectedAxis?: Vector3;
  34095. /**
  34096. * The collision of the joint
  34097. */
  34098. collision?: boolean;
  34099. /**
  34100. * Native Oimo/Cannon/Energy data
  34101. */
  34102. nativeParams?: any;
  34103. }
  34104. /**
  34105. * This is a holder class for the physics joint created by the physics plugin
  34106. * It holds a set of functions to control the underlying joint
  34107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34108. */
  34109. class PhysicsJoint {
  34110. /**
  34111. * The type of the physics joint
  34112. */
  34113. type: number;
  34114. /**
  34115. * The data for the physics joint
  34116. */
  34117. jointData: PhysicsJointData;
  34118. private _physicsJoint;
  34119. protected _physicsPlugin: IPhysicsEnginePlugin;
  34120. /**
  34121. * Initializes the physics joint
  34122. * @param type The type of the physics joint
  34123. * @param jointData The data for the physics joint
  34124. */
  34125. constructor(
  34126. /**
  34127. * The type of the physics joint
  34128. */
  34129. type: number,
  34130. /**
  34131. * The data for the physics joint
  34132. */
  34133. jointData: PhysicsJointData);
  34134. /**
  34135. * Gets the physics joint
  34136. */
  34137. /**
  34138. * Sets the physics joint
  34139. */
  34140. physicsJoint: any;
  34141. /**
  34142. * Sets the physics plugin
  34143. */
  34144. physicsPlugin: IPhysicsEnginePlugin;
  34145. /**
  34146. * Execute a function that is physics-plugin specific.
  34147. * @param {Function} func the function that will be executed.
  34148. * It accepts two parameters: the physics world and the physics joint
  34149. */
  34150. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34151. /**
  34152. * Distance-Joint type
  34153. */
  34154. static DistanceJoint: number;
  34155. /**
  34156. * Hinge-Joint type
  34157. */
  34158. static HingeJoint: number;
  34159. /**
  34160. * Ball-and-Socket joint type
  34161. */
  34162. static BallAndSocketJoint: number;
  34163. /**
  34164. * Wheel-Joint type
  34165. */
  34166. static WheelJoint: number;
  34167. /**
  34168. * Slider-Joint type
  34169. */
  34170. static SliderJoint: number;
  34171. /**
  34172. * Prismatic-Joint type
  34173. */
  34174. static PrismaticJoint: number;
  34175. /**
  34176. * Universal-Joint type
  34177. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34178. */
  34179. static UniversalJoint: number;
  34180. /**
  34181. * Hinge-Joint 2 type
  34182. */
  34183. static Hinge2Joint: number;
  34184. /**
  34185. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34186. */
  34187. static PointToPointJoint: number;
  34188. /**
  34189. * Spring-Joint type
  34190. */
  34191. static SpringJoint: number;
  34192. /**
  34193. * Lock-Joint type
  34194. */
  34195. static LockJoint: number;
  34196. }
  34197. /**
  34198. * A class representing a physics distance joint
  34199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34200. */
  34201. class DistanceJoint extends PhysicsJoint {
  34202. /**
  34203. *
  34204. * @param jointData The data for the Distance-Joint
  34205. */
  34206. constructor(jointData: DistanceJointData);
  34207. /**
  34208. * Update the predefined distance.
  34209. * @param maxDistance The maximum preferred distance
  34210. * @param minDistance The minimum preferred distance
  34211. */
  34212. updateDistance(maxDistance: number, minDistance?: number): void;
  34213. }
  34214. /**
  34215. * Represents a Motor-Enabled Joint
  34216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34217. */
  34218. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34219. /**
  34220. * Initializes the Motor-Enabled Joint
  34221. * @param type The type of the joint
  34222. * @param jointData The physica joint data for the joint
  34223. */
  34224. constructor(type: number, jointData: PhysicsJointData);
  34225. /**
  34226. * Set the motor values.
  34227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34228. * @param force the force to apply
  34229. * @param maxForce max force for this motor.
  34230. */
  34231. setMotor(force?: number, maxForce?: number): void;
  34232. /**
  34233. * Set the motor's limits.
  34234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34235. * @param upperLimit The upper limit of the motor
  34236. * @param lowerLimit The lower limit of the motor
  34237. */
  34238. setLimit(upperLimit: number, lowerLimit?: number): void;
  34239. }
  34240. /**
  34241. * This class represents a single physics Hinge-Joint
  34242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34243. */
  34244. class HingeJoint extends MotorEnabledJoint {
  34245. /**
  34246. * Initializes the Hinge-Joint
  34247. * @param jointData The joint data for the Hinge-Joint
  34248. */
  34249. constructor(jointData: PhysicsJointData);
  34250. /**
  34251. * Set the motor values.
  34252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34253. * @param {number} force the force to apply
  34254. * @param {number} maxForce max force for this motor.
  34255. */
  34256. setMotor(force?: number, maxForce?: number): void;
  34257. /**
  34258. * Set the motor's limits.
  34259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34260. * @param upperLimit The upper limit of the motor
  34261. * @param lowerLimit The lower limit of the motor
  34262. */
  34263. setLimit(upperLimit: number, lowerLimit?: number): void;
  34264. }
  34265. /**
  34266. * This class represents a dual hinge physics joint (same as wheel joint)
  34267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34268. */
  34269. class Hinge2Joint extends MotorEnabledJoint {
  34270. /**
  34271. * Initializes the Hinge2-Joint
  34272. * @param jointData The joint data for the Hinge2-Joint
  34273. */
  34274. constructor(jointData: PhysicsJointData);
  34275. /**
  34276. * Set the motor values.
  34277. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34278. * @param {number} force the force to apply
  34279. * @param {number} maxForce max force for this motor.
  34280. * @param {motorIndex} the motor's index, 0 or 1.
  34281. */
  34282. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34283. /**
  34284. * Set the motor limits.
  34285. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34286. * @param {number} upperLimit the upper limit
  34287. * @param {number} lowerLimit lower limit
  34288. * @param {motorIndex} the motor's index, 0 or 1.
  34289. */
  34290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34291. }
  34292. /**
  34293. * Interface for a motor enabled joint
  34294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34295. */
  34296. interface IMotorEnabledJoint {
  34297. /**
  34298. * Physics joint
  34299. */
  34300. physicsJoint: any;
  34301. /**
  34302. * Sets the motor of the motor-enabled joint
  34303. * @param force The force of the motor
  34304. * @param maxForce The maximum force of the motor
  34305. * @param motorIndex The index of the motor
  34306. */
  34307. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34308. /**
  34309. * Sets the limit of the motor
  34310. * @param upperLimit The upper limit of the motor
  34311. * @param lowerLimit The lower limit of the motor
  34312. * @param motorIndex The index of the motor
  34313. */
  34314. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34315. }
  34316. /**
  34317. * Joint data for a Distance-Joint
  34318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34319. */
  34320. interface DistanceJointData extends PhysicsJointData {
  34321. /**
  34322. * Max distance the 2 joint objects can be apart
  34323. */
  34324. maxDistance: number;
  34325. }
  34326. /**
  34327. * Joint data from a spring joint
  34328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34329. */
  34330. interface SpringJointData extends PhysicsJointData {
  34331. /**
  34332. * Length of the spring
  34333. */
  34334. length: number;
  34335. /**
  34336. * Stiffness of the spring
  34337. */
  34338. stiffness: number;
  34339. /**
  34340. * Damping of the spring
  34341. */
  34342. damping: number;
  34343. /** this callback will be called when applying the force to the impostors. */
  34344. forceApplicationCallback: () => void;
  34345. }
  34346. }
  34347. declare module BABYLON {
  34348. interface AbstractScene {
  34349. /**
  34350. * The list of reflection probes added to the scene
  34351. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34352. */
  34353. reflectionProbes: Array<ReflectionProbe>;
  34354. /**
  34355. * Removes the given reflection probe from this scene.
  34356. * @param toRemove The reflection probe to remove
  34357. * @returns The index of the removed reflection probe
  34358. */
  34359. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34360. /**
  34361. * Adds the given reflection probe to this scene.
  34362. * @param newReflectionProbe The reflection probe to add
  34363. */
  34364. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34365. }
  34366. /**
  34367. * Class used to generate realtime reflection / refraction cube textures
  34368. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34369. */
  34370. class ReflectionProbe {
  34371. /** defines the name of the probe */
  34372. name: string;
  34373. private _scene;
  34374. private _renderTargetTexture;
  34375. private _projectionMatrix;
  34376. private _viewMatrix;
  34377. private _target;
  34378. private _add;
  34379. private _attachedMesh;
  34380. private _invertYAxis;
  34381. /** Gets or sets probe position (center of the cube map) */
  34382. position: Vector3;
  34383. /**
  34384. * Creates a new reflection probe
  34385. * @param name defines the name of the probe
  34386. * @param size defines the texture resolution (for each face)
  34387. * @param scene defines the hosting scene
  34388. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34389. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34390. */
  34391. constructor(
  34392. /** defines the name of the probe */
  34393. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34394. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34395. samples: number;
  34396. /** Gets or sets the refresh rate to use (on every frame by default) */
  34397. refreshRate: number;
  34398. /**
  34399. * Gets the hosting scene
  34400. * @returns a Scene
  34401. */
  34402. getScene(): Scene;
  34403. /** Gets the internal CubeTexture used to render to */
  34404. readonly cubeTexture: RenderTargetTexture;
  34405. /** Gets the list of meshes to render */
  34406. readonly renderList: Nullable<AbstractMesh[]>;
  34407. /**
  34408. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34409. * @param mesh defines the mesh to attach to
  34410. */
  34411. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34412. /**
  34413. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34414. * @param renderingGroupId The rendering group id corresponding to its index
  34415. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34416. */
  34417. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34418. /**
  34419. * Clean all associated resources
  34420. */
  34421. dispose(): void;
  34422. /**
  34423. * Converts the reflection probe information to a readable string for debug purpose.
  34424. * @param fullDetails Supports for multiple levels of logging within scene loading
  34425. * @returns the human readable reflection probe info
  34426. */
  34427. toString(fullDetails?: boolean): string;
  34428. /**
  34429. * Get the class name of the relfection probe.
  34430. * @returns "ReflectionProbe"
  34431. */
  34432. getClassName(): string;
  34433. /**
  34434. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34435. * @returns The JSON representation of the texture
  34436. */
  34437. serialize(): any;
  34438. /**
  34439. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34440. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34441. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34442. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34443. * @returns The parsed reflection probe if successful
  34444. */
  34445. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34446. }
  34447. }
  34448. declare module BABYLON {
  34449. /**
  34450. * Postprocess used to generate anaglyphic rendering
  34451. */
  34452. class AnaglyphPostProcess extends PostProcess {
  34453. private _passedProcess;
  34454. /**
  34455. * Creates a new AnaglyphPostProcess
  34456. * @param name defines postprocess name
  34457. * @param options defines creation options or target ratio scale
  34458. * @param rigCameras defines cameras using this postprocess
  34459. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34460. * @param engine defines hosting engine
  34461. * @param reusable defines if the postprocess will be reused multiple times per frame
  34462. */
  34463. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34464. }
  34465. }
  34466. declare module BABYLON {
  34467. /**
  34468. * Post process used to render in black and white
  34469. */
  34470. class BlackAndWhitePostProcess extends PostProcess {
  34471. /**
  34472. * Linear about to convert he result to black and white (default: 1)
  34473. */
  34474. degree: number;
  34475. /**
  34476. * Creates a black and white post process
  34477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34478. * @param name The name of the effect.
  34479. * @param options The required width/height ratio to downsize to before computing the render pass.
  34480. * @param camera The camera to apply the render pass to.
  34481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34482. * @param engine The engine which the post process will be applied. (default: current engine)
  34483. * @param reusable If the post process can be reused on the same frame. (default: false)
  34484. */
  34485. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34486. }
  34487. }
  34488. declare module BABYLON {
  34489. /**
  34490. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34491. */
  34492. class BloomEffect extends PostProcessRenderEffect {
  34493. private bloomScale;
  34494. /**
  34495. * @hidden Internal
  34496. */
  34497. _effects: Array<PostProcess>;
  34498. /**
  34499. * @hidden Internal
  34500. */
  34501. _downscale: ExtractHighlightsPostProcess;
  34502. private _blurX;
  34503. private _blurY;
  34504. private _merge;
  34505. /**
  34506. * The luminance threshold to find bright areas of the image to bloom.
  34507. */
  34508. threshold: number;
  34509. /**
  34510. * The strength of the bloom.
  34511. */
  34512. weight: number;
  34513. /**
  34514. * Specifies the size of the bloom blur kernel, relative to the final output size
  34515. */
  34516. kernel: number;
  34517. /**
  34518. * Creates a new instance of @see BloomEffect
  34519. * @param scene The scene the effect belongs to.
  34520. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34521. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34522. * @param bloomWeight The the strength of bloom.
  34523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34524. * @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)
  34525. */
  34526. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34527. /**
  34528. * Disposes each of the internal effects for a given camera.
  34529. * @param camera The camera to dispose the effect on.
  34530. */
  34531. disposeEffects(camera: Camera): void;
  34532. /**
  34533. * @hidden Internal
  34534. */
  34535. _updateEffects(): void;
  34536. /**
  34537. * Internal
  34538. * @returns if all the contained post processes are ready.
  34539. * @hidden
  34540. */
  34541. _isReady(): boolean;
  34542. }
  34543. }
  34544. declare module BABYLON {
  34545. /**
  34546. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34547. */
  34548. class BloomMergePostProcess extends PostProcess {
  34549. /** Weight of the bloom to be added to the original input. */
  34550. weight: number;
  34551. /**
  34552. * Creates a new instance of @see BloomMergePostProcess
  34553. * @param name The name of the effect.
  34554. * @param originalFromInput Post process which's input will be used for the merge.
  34555. * @param blurred Blurred highlights post process which's output will be used.
  34556. * @param weight Weight of the bloom to be added to the original input.
  34557. * @param options The required width/height ratio to downsize to before computing the render pass.
  34558. * @param camera The camera to apply the render pass to.
  34559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34560. * @param engine The engine which the post process will be applied. (default: current engine)
  34561. * @param reusable If the post process can be reused on the same frame. (default: false)
  34562. * @param textureType Type of textures used when performing the post process. (default: 0)
  34563. * @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)
  34564. */
  34565. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34566. /** Weight of the bloom to be added to the original input. */
  34567. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34568. }
  34569. }
  34570. declare module BABYLON {
  34571. /**
  34572. * The Blur Post Process which blurs an image based on a kernel and direction.
  34573. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34574. */
  34575. class BlurPostProcess extends PostProcess {
  34576. /** The direction in which to blur the image. */
  34577. direction: Vector2;
  34578. private blockCompilation;
  34579. protected _kernel: number;
  34580. protected _idealKernel: number;
  34581. protected _packedFloat: boolean;
  34582. private _staticDefines;
  34583. /**
  34584. * Sets the length in pixels of the blur sample region
  34585. */
  34586. /**
  34587. * Gets the length in pixels of the blur sample region
  34588. */
  34589. kernel: number;
  34590. /**
  34591. * Sets wether or not the blur needs to unpack/repack floats
  34592. */
  34593. /**
  34594. * Gets wether or not the blur is unpacking/repacking floats
  34595. */
  34596. packedFloat: boolean;
  34597. /**
  34598. * Creates a new instance BlurPostProcess
  34599. * @param name The name of the effect.
  34600. * @param direction The direction in which to blur the image.
  34601. * @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.
  34602. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34603. * @param camera The camera to apply the render pass to.
  34604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34605. * @param engine The engine which the post process will be applied. (default: current engine)
  34606. * @param reusable If the post process can be reused on the same frame. (default: false)
  34607. * @param textureType Type of textures used when performing the post process. (default: 0)
  34608. * @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)
  34609. */
  34610. constructor(name: string,
  34611. /** The direction in which to blur the image. */
  34612. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34613. /**
  34614. * Updates the effect with the current post process compile time values and recompiles the shader.
  34615. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34616. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34617. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34618. * @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
  34619. * @param onCompiled Called when the shader has been compiled.
  34620. * @param onError Called if there is an error when compiling a shader.
  34621. */
  34622. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34623. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34624. /**
  34625. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34626. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34627. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34628. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34629. * The gaps between physical kernels are compensated for in the weighting of the samples
  34630. * @param idealKernel Ideal blur kernel.
  34631. * @return Nearest best kernel.
  34632. */
  34633. protected _nearestBestKernel(idealKernel: number): number;
  34634. /**
  34635. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34636. * @param x The point on the Gaussian distribution to sample.
  34637. * @return the value of the Gaussian function at x.
  34638. */
  34639. protected _gaussianWeight(x: number): number;
  34640. /**
  34641. * Generates a string that can be used as a floating point number in GLSL.
  34642. * @param x Value to print.
  34643. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34644. * @return GLSL float string.
  34645. */
  34646. protected _glslFloat(x: number, decimalFigures?: number): string;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. /**
  34651. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34652. */
  34653. class ChromaticAberrationPostProcess extends PostProcess {
  34654. /**
  34655. * The amount of seperation of rgb channels (default: 30)
  34656. */
  34657. aberrationAmount: number;
  34658. /**
  34659. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34660. */
  34661. radialIntensity: number;
  34662. /**
  34663. * 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))
  34664. */
  34665. direction: Vector2;
  34666. /**
  34667. * 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))
  34668. */
  34669. centerPosition: Vector2;
  34670. /**
  34671. * Creates a new instance ChromaticAberrationPostProcess
  34672. * @param name The name of the effect.
  34673. * @param screenWidth The width of the screen to apply the effect on.
  34674. * @param screenHeight The height of the screen to apply the effect on.
  34675. * @param options The required width/height ratio to downsize to before computing the render pass.
  34676. * @param camera The camera to apply the render pass to.
  34677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34678. * @param engine The engine which the post process will be applied. (default: current engine)
  34679. * @param reusable If the post process can be reused on the same frame. (default: false)
  34680. * @param textureType Type of textures used when performing the post process. (default: 0)
  34681. * @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)
  34682. */
  34683. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34684. }
  34685. }
  34686. declare module BABYLON {
  34687. /**
  34688. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34689. */
  34690. class CircleOfConfusionPostProcess extends PostProcess {
  34691. /**
  34692. * 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.
  34693. */
  34694. lensSize: number;
  34695. /**
  34696. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34697. */
  34698. fStop: number;
  34699. /**
  34700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34701. */
  34702. focusDistance: number;
  34703. /**
  34704. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34705. */
  34706. focalLength: number;
  34707. private _depthTexture;
  34708. /**
  34709. * Creates a new instance CircleOfConfusionPostProcess
  34710. * @param name The name of the effect.
  34711. * @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.
  34712. * @param options The required width/height ratio to downsize to before computing the render pass.
  34713. * @param camera The camera to apply the render pass to.
  34714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34715. * @param engine The engine which the post process will be applied. (default: current engine)
  34716. * @param reusable If the post process can be reused on the same frame. (default: false)
  34717. * @param textureType Type of textures used when performing the post process. (default: 0)
  34718. * @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)
  34719. */
  34720. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34721. /**
  34722. * 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.
  34723. */
  34724. depthTexture: RenderTargetTexture;
  34725. }
  34726. }
  34727. declare module BABYLON {
  34728. /**
  34729. *
  34730. * This post-process allows the modification of rendered colors by using
  34731. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34732. *
  34733. * The object needs to be provided an url to a texture containing the color
  34734. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34735. * Use an image editing software to tweak the LUT to match your needs.
  34736. *
  34737. * For an example of a color LUT, see here:
  34738. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34739. * For explanations on color grading, see here:
  34740. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34741. *
  34742. */
  34743. class ColorCorrectionPostProcess extends PostProcess {
  34744. private _colorTableTexture;
  34745. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34751. * input texture to perform effects such as edge detection or sharpening
  34752. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34753. */
  34754. class ConvolutionPostProcess extends PostProcess {
  34755. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34756. kernel: number[];
  34757. /**
  34758. * Creates a new instance ConvolutionPostProcess
  34759. * @param name The name of the effect.
  34760. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34761. * @param options The required width/height ratio to downsize to before computing the render pass.
  34762. * @param camera The camera to apply the render pass to.
  34763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34764. * @param engine The engine which the post process will be applied. (default: current engine)
  34765. * @param reusable If the post process can be reused on the same frame. (default: false)
  34766. * @param textureType Type of textures used when performing the post process. (default: 0)
  34767. */
  34768. constructor(name: string,
  34769. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34770. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34771. /**
  34772. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34773. */
  34774. static EdgeDetect0Kernel: number[];
  34775. /**
  34776. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34777. */
  34778. static EdgeDetect1Kernel: number[];
  34779. /**
  34780. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34781. */
  34782. static EdgeDetect2Kernel: number[];
  34783. /**
  34784. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34785. */
  34786. static SharpenKernel: number[];
  34787. /**
  34788. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34789. */
  34790. static EmbossKernel: number[];
  34791. /**
  34792. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34793. */
  34794. static GaussianKernel: number[];
  34795. }
  34796. }
  34797. declare module BABYLON {
  34798. /**
  34799. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34800. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34801. * based on samples that have a large difference in distance than the center pixel.
  34802. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34803. */
  34804. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34805. direction: Vector2;
  34806. /**
  34807. * Creates a new instance CircleOfConfusionPostProcess
  34808. * @param name The name of the effect.
  34809. * @param scene The scene the effect belongs to.
  34810. * @param direction The direction the blur should be applied.
  34811. * @param kernel The size of the kernel used to blur.
  34812. * @param options The required width/height ratio to downsize to before computing the render pass.
  34813. * @param camera The camera to apply the render pass to.
  34814. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34815. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34817. * @param engine The engine which the post process will be applied. (default: current engine)
  34818. * @param reusable If the post process can be reused on the same frame. (default: false)
  34819. * @param textureType Type of textures used when performing the post process. (default: 0)
  34820. * @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)
  34821. */
  34822. 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);
  34823. }
  34824. }
  34825. declare module BABYLON {
  34826. /**
  34827. * Specifies the level of max blur that should be applied when using the depth of field effect
  34828. */
  34829. enum DepthOfFieldEffectBlurLevel {
  34830. /**
  34831. * Subtle blur
  34832. */
  34833. Low = 0,
  34834. /**
  34835. * Medium blur
  34836. */
  34837. Medium = 1,
  34838. /**
  34839. * Large blur
  34840. */
  34841. High = 2
  34842. }
  34843. /**
  34844. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34845. */
  34846. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34847. private _circleOfConfusion;
  34848. /**
  34849. * @hidden Internal, blurs from high to low
  34850. */
  34851. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34852. private _depthOfFieldBlurY;
  34853. private _dofMerge;
  34854. /**
  34855. * @hidden Internal post processes in depth of field effect
  34856. */
  34857. _effects: Array<PostProcess>;
  34858. /**
  34859. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34860. */
  34861. focalLength: number;
  34862. /**
  34863. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34864. */
  34865. fStop: number;
  34866. /**
  34867. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34868. */
  34869. focusDistance: number;
  34870. /**
  34871. * 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.
  34872. */
  34873. lensSize: number;
  34874. /**
  34875. * Creates a new instance DepthOfFieldEffect
  34876. * @param scene The scene the effect belongs to.
  34877. * @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.
  34878. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34879. * @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)
  34880. */
  34881. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34882. /**
  34883. * 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.
  34884. */
  34885. depthTexture: RenderTargetTexture;
  34886. /**
  34887. * Disposes each of the internal effects for a given camera.
  34888. * @param camera The camera to dispose the effect on.
  34889. */
  34890. disposeEffects(camera: Camera): void;
  34891. /**
  34892. * @hidden Internal
  34893. */
  34894. _updateEffects(): void;
  34895. /**
  34896. * Internal
  34897. * @returns if all the contained post processes are ready.
  34898. * @hidden
  34899. */
  34900. _isReady(): boolean;
  34901. }
  34902. }
  34903. declare module BABYLON {
  34904. /**
  34905. * Options to be set when merging outputs from the default pipeline.
  34906. */
  34907. class DepthOfFieldMergePostProcessOptions {
  34908. /**
  34909. * The original image to merge on top of
  34910. */
  34911. originalFromInput: PostProcess;
  34912. /**
  34913. * Parameters to perform the merge of the depth of field effect
  34914. */
  34915. depthOfField?: {
  34916. circleOfConfusion: PostProcess;
  34917. blurSteps: Array<PostProcess>;
  34918. };
  34919. /**
  34920. * Parameters to perform the merge of bloom effect
  34921. */
  34922. bloom?: {
  34923. blurred: PostProcess;
  34924. weight: number;
  34925. };
  34926. }
  34927. /**
  34928. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34929. */
  34930. class DepthOfFieldMergePostProcess extends PostProcess {
  34931. private blurSteps;
  34932. /**
  34933. * Creates a new instance of DepthOfFieldMergePostProcess
  34934. * @param name The name of the effect.
  34935. * @param originalFromInput Post process which's input will be used for the merge.
  34936. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34937. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34938. * @param options The required width/height ratio to downsize to before computing the render pass.
  34939. * @param camera The camera to apply the render pass to.
  34940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34941. * @param engine The engine which the post process will be applied. (default: current engine)
  34942. * @param reusable If the post process can be reused on the same frame. (default: false)
  34943. * @param textureType Type of textures used when performing the post process. (default: 0)
  34944. * @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)
  34945. */
  34946. 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);
  34947. /**
  34948. * Updates the effect with the current post process compile time values and recompiles the shader.
  34949. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34950. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34951. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34952. * @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
  34953. * @param onCompiled Called when the shader has been compiled.
  34954. * @param onError Called if there is an error when compiling a shader.
  34955. */
  34956. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34957. }
  34958. }
  34959. declare module BABYLON {
  34960. /**
  34961. * DisplayPassPostProcess which produces an output the same as it's input
  34962. */
  34963. class DisplayPassPostProcess extends PostProcess {
  34964. /**
  34965. * Creates the DisplayPassPostProcess
  34966. * @param name The name of the effect.
  34967. * @param options The required width/height ratio to downsize to before computing the render pass.
  34968. * @param camera The camera to apply the render pass to.
  34969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34970. * @param engine The engine which the post process will be applied. (default: current engine)
  34971. * @param reusable If the post process can be reused on the same frame. (default: false)
  34972. */
  34973. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34974. }
  34975. }
  34976. declare module BABYLON {
  34977. /**
  34978. * 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.
  34979. */
  34980. class ExtractHighlightsPostProcess extends PostProcess {
  34981. /**
  34982. * The luminance threshold, pixels below this value will be set to black.
  34983. */
  34984. threshold: number;
  34985. /** @hidden */
  34986. _exposure: number;
  34987. /**
  34988. * Post process which has the input texture to be used when performing highlight extraction
  34989. * @hidden
  34990. */
  34991. _inputPostProcess: Nullable<PostProcess>;
  34992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34993. }
  34994. }
  34995. declare module BABYLON {
  34996. /**
  34997. * Applies a kernel filter to the image
  34998. */
  34999. class FilterPostProcess extends PostProcess {
  35000. /** The matrix to be applied to the image */
  35001. kernelMatrix: Matrix;
  35002. /**
  35003. *
  35004. * @param name The name of the effect.
  35005. * @param kernelMatrix The matrix to be applied to the image
  35006. * @param options The required width/height ratio to downsize to before computing the render pass.
  35007. * @param camera The camera to apply the render pass to.
  35008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35009. * @param engine The engine which the post process will be applied. (default: current engine)
  35010. * @param reusable If the post process can be reused on the same frame. (default: false)
  35011. */
  35012. constructor(name: string,
  35013. /** The matrix to be applied to the image */
  35014. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35015. }
  35016. }
  35017. declare module BABYLON {
  35018. /**
  35019. * Fxaa post process
  35020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35021. */
  35022. class FxaaPostProcess extends PostProcess {
  35023. /** @hidden */
  35024. texelWidth: number;
  35025. /** @hidden */
  35026. texelHeight: number;
  35027. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35028. private _getDefines;
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /**
  35033. * The GrainPostProcess adds noise to the image at mid luminance levels
  35034. */
  35035. class GrainPostProcess extends PostProcess {
  35036. /**
  35037. * The intensity of the grain added (default: 30)
  35038. */
  35039. intensity: number;
  35040. /**
  35041. * If the grain should be randomized on every frame
  35042. */
  35043. animated: boolean;
  35044. /**
  35045. * Creates a new instance of @see GrainPostProcess
  35046. * @param name The name of the effect.
  35047. * @param options The required width/height ratio to downsize to before computing the render pass.
  35048. * @param camera The camera to apply the render pass to.
  35049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35050. * @param engine The engine which the post process will be applied. (default: current engine)
  35051. * @param reusable If the post process can be reused on the same frame. (default: false)
  35052. * @param textureType Type of textures used when performing the post process. (default: 0)
  35053. * @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)
  35054. */
  35055. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35056. }
  35057. }
  35058. declare module BABYLON {
  35059. /**
  35060. * Extracts highlights from the image
  35061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35062. */
  35063. class HighlightsPostProcess extends PostProcess {
  35064. /**
  35065. * Extracts highlights from the image
  35066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35067. * @param name The name of the effect.
  35068. * @param options The required width/height ratio to downsize to before computing the render pass.
  35069. * @param camera The camera to apply the render pass to.
  35070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35071. * @param engine The engine which the post process will be applied. (default: current engine)
  35072. * @param reusable If the post process can be reused on the same frame. (default: false)
  35073. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35074. */
  35075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35076. }
  35077. }
  35078. declare module BABYLON {
  35079. /**
  35080. * ImageProcessingPostProcess
  35081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35082. */
  35083. class ImageProcessingPostProcess extends PostProcess {
  35084. /**
  35085. * Default configuration related to image processing available in the PBR Material.
  35086. */
  35087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35088. /**
  35089. * Gets the image processing configuration used either in this material.
  35090. */
  35091. /**
  35092. * Sets the Default image processing configuration used either in the this material.
  35093. *
  35094. * If sets to null, the scene one is in use.
  35095. */
  35096. imageProcessingConfiguration: ImageProcessingConfiguration;
  35097. /**
  35098. * Keep track of the image processing observer to allow dispose and replace.
  35099. */
  35100. private _imageProcessingObserver;
  35101. /**
  35102. * Attaches a new image processing configuration to the PBR Material.
  35103. * @param configuration
  35104. */
  35105. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35106. /**
  35107. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35108. */
  35109. /**
  35110. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35111. */
  35112. colorCurves: Nullable<ColorCurves>;
  35113. /**
  35114. * Gets wether the color curves effect is enabled.
  35115. */
  35116. /**
  35117. * Sets wether the color curves effect is enabled.
  35118. */
  35119. colorCurvesEnabled: boolean;
  35120. /**
  35121. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35122. */
  35123. /**
  35124. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35125. */
  35126. colorGradingTexture: Nullable<BaseTexture>;
  35127. /**
  35128. * Gets wether the color grading effect is enabled.
  35129. */
  35130. /**
  35131. * Gets wether the color grading effect is enabled.
  35132. */
  35133. colorGradingEnabled: boolean;
  35134. /**
  35135. * Gets exposure used in the effect.
  35136. */
  35137. /**
  35138. * Sets exposure used in the effect.
  35139. */
  35140. exposure: number;
  35141. /**
  35142. * Gets wether tonemapping is enabled or not.
  35143. */
  35144. /**
  35145. * Sets wether tonemapping is enabled or not
  35146. */
  35147. toneMappingEnabled: boolean;
  35148. /**
  35149. * Gets contrast used in the effect.
  35150. */
  35151. /**
  35152. * Sets contrast used in the effect.
  35153. */
  35154. contrast: number;
  35155. /**
  35156. * Gets Vignette stretch size.
  35157. */
  35158. /**
  35159. * Sets Vignette stretch size.
  35160. */
  35161. vignetteStretch: number;
  35162. /**
  35163. * Gets Vignette centre X Offset.
  35164. */
  35165. /**
  35166. * Sets Vignette centre X Offset.
  35167. */
  35168. vignetteCentreX: number;
  35169. /**
  35170. * Gets Vignette centre Y Offset.
  35171. */
  35172. /**
  35173. * Sets Vignette centre Y Offset.
  35174. */
  35175. vignetteCentreY: number;
  35176. /**
  35177. * Gets Vignette weight or intensity of the vignette effect.
  35178. */
  35179. /**
  35180. * Sets Vignette weight or intensity of the vignette effect.
  35181. */
  35182. vignetteWeight: number;
  35183. /**
  35184. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35185. * if vignetteEnabled is set to true.
  35186. */
  35187. /**
  35188. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35189. * if vignetteEnabled is set to true.
  35190. */
  35191. vignetteColor: Color4;
  35192. /**
  35193. * Gets Camera field of view used by the Vignette effect.
  35194. */
  35195. /**
  35196. * Sets Camera field of view used by the Vignette effect.
  35197. */
  35198. vignetteCameraFov: number;
  35199. /**
  35200. * Gets the vignette blend mode allowing different kind of effect.
  35201. */
  35202. /**
  35203. * Sets the vignette blend mode allowing different kind of effect.
  35204. */
  35205. vignetteBlendMode: number;
  35206. /**
  35207. * Gets wether the vignette effect is enabled.
  35208. */
  35209. /**
  35210. * Sets wether the vignette effect is enabled.
  35211. */
  35212. vignetteEnabled: boolean;
  35213. private _fromLinearSpace;
  35214. /**
  35215. * Gets wether the input of the processing is in Gamma or Linear Space.
  35216. */
  35217. /**
  35218. * Sets wether the input of the processing is in Gamma or Linear Space.
  35219. */
  35220. fromLinearSpace: boolean;
  35221. /**
  35222. * Defines cache preventing GC.
  35223. */
  35224. private _defines;
  35225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35226. /**
  35227. * "ImageProcessingPostProcess"
  35228. * @returns "ImageProcessingPostProcess"
  35229. */
  35230. getClassName(): string;
  35231. protected _updateParameters(): void;
  35232. dispose(camera?: Camera): void;
  35233. }
  35234. }
  35235. declare module BABYLON {
  35236. /**
  35237. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35238. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35239. * As an example, all you have to do is to create the post-process:
  35240. * var mb = new BABYLON.MotionBlurPostProcess(
  35241. * 'mb', // The name of the effect.
  35242. * scene, // The scene containing the objects to blur according to their velocity.
  35243. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35244. * camera // The camera to apply the render pass to.
  35245. * );
  35246. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35247. */
  35248. class MotionBlurPostProcess extends PostProcess {
  35249. /**
  35250. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35251. */
  35252. motionStrength: number;
  35253. /**
  35254. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35255. */
  35256. /**
  35257. * Sets the number of iterations to be used for motion blur quality
  35258. */
  35259. motionBlurSamples: number;
  35260. private _motionBlurSamples;
  35261. private _geometryBufferRenderer;
  35262. /**
  35263. * Creates a new instance MotionBlurPostProcess
  35264. * @param name The name of the effect.
  35265. * @param scene The scene containing the objects to blur according to their velocity.
  35266. * @param options The required width/height ratio to downsize to before computing the render pass.
  35267. * @param camera The camera to apply the render pass to.
  35268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35269. * @param engine The engine which the post process will be applied. (default: current engine)
  35270. * @param reusable If the post process can be reused on the same frame. (default: false)
  35271. * @param textureType Type of textures used when performing the post process. (default: 0)
  35272. * @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)
  35273. */
  35274. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35275. /**
  35276. * Disposes the post process.
  35277. * @param camera The camera to dispose the post process on.
  35278. */
  35279. dispose(camera?: Camera): void;
  35280. }
  35281. }
  35282. declare module BABYLON {
  35283. /**
  35284. * PassPostProcess which produces an output the same as it's input
  35285. */
  35286. class PassPostProcess extends PostProcess {
  35287. /**
  35288. * Creates the PassPostProcess
  35289. * @param name The name of the effect.
  35290. * @param options The required width/height ratio to downsize to before computing the render pass.
  35291. * @param camera The camera to apply the render pass to.
  35292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35293. * @param engine The engine which the post process will be applied. (default: current engine)
  35294. * @param reusable If the post process can be reused on the same frame. (default: false)
  35295. * @param textureType The type of texture to be used when performing the post processing.
  35296. * @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)
  35297. */
  35298. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35299. }
  35300. /**
  35301. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35302. */
  35303. class PassCubePostProcess extends PostProcess {
  35304. private _face;
  35305. /**
  35306. * Gets or sets the cube face to display.
  35307. * * 0 is +X
  35308. * * 1 is -X
  35309. * * 2 is +Y
  35310. * * 3 is -Y
  35311. * * 4 is +Z
  35312. * * 5 is -Z
  35313. */
  35314. face: number;
  35315. /**
  35316. * Creates the PassCubePostProcess
  35317. * @param name The name of the effect.
  35318. * @param options The required width/height ratio to downsize to before computing the render pass.
  35319. * @param camera The camera to apply the render pass to.
  35320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35321. * @param engine The engine which the post process will be applied. (default: current engine)
  35322. * @param reusable If the post process can be reused on the same frame. (default: false)
  35323. * @param textureType The type of texture to be used when performing the post processing.
  35324. * @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)
  35325. */
  35326. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35327. }
  35328. }
  35329. declare module BABYLON {
  35330. /**
  35331. * Size options for a post process
  35332. */
  35333. type PostProcessOptions = {
  35334. width: number;
  35335. height: number;
  35336. };
  35337. /**
  35338. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35339. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35340. */
  35341. class PostProcess {
  35342. /** Name of the PostProcess. */
  35343. name: string;
  35344. /**
  35345. * Width of the texture to apply the post process on
  35346. */
  35347. width: number;
  35348. /**
  35349. * Height of the texture to apply the post process on
  35350. */
  35351. height: number;
  35352. /**
  35353. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35354. * @hidden
  35355. */
  35356. _outputTexture: Nullable<InternalTexture>;
  35357. /**
  35358. * Sampling mode used by the shader
  35359. * See https://doc.babylonjs.com/classes/3.1/texture
  35360. */
  35361. renderTargetSamplingMode: number;
  35362. /**
  35363. * Clear color to use when screen clearing
  35364. */
  35365. clearColor: Color4;
  35366. /**
  35367. * If the buffer needs to be cleared before applying the post process. (default: true)
  35368. * Should be set to false if shader will overwrite all previous pixels.
  35369. */
  35370. autoClear: boolean;
  35371. /**
  35372. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35373. */
  35374. alphaMode: number;
  35375. /**
  35376. * Sets the setAlphaBlendConstants of the babylon engine
  35377. */
  35378. alphaConstants: Color4;
  35379. /**
  35380. * Animations to be used for the post processing
  35381. */
  35382. animations: Animation[];
  35383. /**
  35384. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35385. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35386. */
  35387. enablePixelPerfectMode: boolean;
  35388. /**
  35389. * Force the postprocess to be applied without taking in account viewport
  35390. */
  35391. forceFullscreenViewport: boolean;
  35392. /**
  35393. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35394. *
  35395. * | Value | Type | Description |
  35396. * | ----- | ----------------------------------- | ----------- |
  35397. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35398. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35399. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35400. *
  35401. */
  35402. scaleMode: number;
  35403. /**
  35404. * Force textures to be a power of two (default: false)
  35405. */
  35406. alwaysForcePOT: boolean;
  35407. private _samples;
  35408. /**
  35409. * Number of sample textures (default: 1)
  35410. */
  35411. samples: number;
  35412. /**
  35413. * Modify the scale of the post process to be the same as the viewport (default: false)
  35414. */
  35415. adaptScaleToCurrentViewport: boolean;
  35416. private _camera;
  35417. private _scene;
  35418. private _engine;
  35419. private _options;
  35420. private _reusable;
  35421. private _textureType;
  35422. /**
  35423. * Smart array of input and output textures for the post process.
  35424. * @hidden
  35425. */
  35426. _textures: SmartArray<InternalTexture>;
  35427. /**
  35428. * The index in _textures that corresponds to the output texture.
  35429. * @hidden
  35430. */
  35431. _currentRenderTextureInd: number;
  35432. private _effect;
  35433. private _samplers;
  35434. private _fragmentUrl;
  35435. private _vertexUrl;
  35436. private _parameters;
  35437. private _scaleRatio;
  35438. protected _indexParameters: any;
  35439. private _shareOutputWithPostProcess;
  35440. private _texelSize;
  35441. private _forcedOutputTexture;
  35442. /**
  35443. * An event triggered when the postprocess is activated.
  35444. */
  35445. onActivateObservable: Observable<Camera>;
  35446. private _onActivateObserver;
  35447. /**
  35448. * A function that is added to the onActivateObservable
  35449. */
  35450. onActivate: Nullable<(camera: Camera) => void>;
  35451. /**
  35452. * An event triggered when the postprocess changes its size.
  35453. */
  35454. onSizeChangedObservable: Observable<PostProcess>;
  35455. private _onSizeChangedObserver;
  35456. /**
  35457. * A function that is added to the onSizeChangedObservable
  35458. */
  35459. onSizeChanged: (postProcess: PostProcess) => void;
  35460. /**
  35461. * An event triggered when the postprocess applies its effect.
  35462. */
  35463. onApplyObservable: Observable<Effect>;
  35464. private _onApplyObserver;
  35465. /**
  35466. * A function that is added to the onApplyObservable
  35467. */
  35468. onApply: (effect: Effect) => void;
  35469. /**
  35470. * An event triggered before rendering the postprocess
  35471. */
  35472. onBeforeRenderObservable: Observable<Effect>;
  35473. private _onBeforeRenderObserver;
  35474. /**
  35475. * A function that is added to the onBeforeRenderObservable
  35476. */
  35477. onBeforeRender: (effect: Effect) => void;
  35478. /**
  35479. * An event triggered after rendering the postprocess
  35480. */
  35481. onAfterRenderObservable: Observable<Effect>;
  35482. private _onAfterRenderObserver;
  35483. /**
  35484. * A function that is added to the onAfterRenderObservable
  35485. */
  35486. onAfterRender: (efect: Effect) => void;
  35487. /**
  35488. * 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
  35489. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35490. */
  35491. inputTexture: InternalTexture;
  35492. /**
  35493. * Gets the camera which post process is applied to.
  35494. * @returns The camera the post process is applied to.
  35495. */
  35496. getCamera(): Camera;
  35497. /**
  35498. * Gets the texel size of the postprocess.
  35499. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35500. */
  35501. readonly texelSize: Vector2;
  35502. /**
  35503. * Creates a new instance PostProcess
  35504. * @param name The name of the PostProcess.
  35505. * @param fragmentUrl The url of the fragment shader to be used.
  35506. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35507. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35508. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35509. * @param camera The camera to apply the render pass to.
  35510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35511. * @param engine The engine which the post process will be applied. (default: current engine)
  35512. * @param reusable If the post process can be reused on the same frame. (default: false)
  35513. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35514. * @param textureType Type of textures used when performing the post process. (default: 0)
  35515. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35516. * @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
  35517. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35518. */
  35519. constructor(
  35520. /** Name of the PostProcess. */
  35521. 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);
  35522. /**
  35523. * Gets the engine which this post process belongs to.
  35524. * @returns The engine the post process was enabled with.
  35525. */
  35526. getEngine(): Engine;
  35527. /**
  35528. * The effect that is created when initializing the post process.
  35529. * @returns The created effect corrisponding the the postprocess.
  35530. */
  35531. getEffect(): Effect;
  35532. /**
  35533. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35534. * @param postProcess The post process to share the output with.
  35535. * @returns This post process.
  35536. */
  35537. shareOutputWith(postProcess: PostProcess): PostProcess;
  35538. /**
  35539. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35540. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35541. */
  35542. useOwnOutput(): void;
  35543. /**
  35544. * Updates the effect with the current post process compile time values and recompiles the shader.
  35545. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35546. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35547. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35548. * @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
  35549. * @param onCompiled Called when the shader has been compiled.
  35550. * @param onError Called if there is an error when compiling a shader.
  35551. */
  35552. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35553. /**
  35554. * The post process is reusable if it can be used multiple times within one frame.
  35555. * @returns If the post process is reusable
  35556. */
  35557. isReusable(): boolean;
  35558. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35559. markTextureDirty(): void;
  35560. /**
  35561. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35562. * 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.
  35563. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35564. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35565. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35566. * @returns The target texture that was bound to be written to.
  35567. */
  35568. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35569. /**
  35570. * If the post process is supported.
  35571. */
  35572. readonly isSupported: boolean;
  35573. /**
  35574. * The aspect ratio of the output texture.
  35575. */
  35576. readonly aspectRatio: number;
  35577. /**
  35578. * Get a value indicating if the post-process is ready to be used
  35579. * @returns true if the post-process is ready (shader is compiled)
  35580. */
  35581. isReady(): boolean;
  35582. /**
  35583. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35584. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35585. */
  35586. apply(): Nullable<Effect>;
  35587. private _disposeTextures;
  35588. /**
  35589. * Disposes the post process.
  35590. * @param camera The camera to dispose the post process on.
  35591. */
  35592. dispose(camera?: Camera): void;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. /**
  35597. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35598. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35599. */
  35600. class PostProcessManager {
  35601. private _scene;
  35602. private _indexBuffer;
  35603. private _vertexBuffers;
  35604. /**
  35605. * Creates a new instance PostProcess
  35606. * @param scene The scene that the post process is associated with.
  35607. */
  35608. constructor(scene: Scene);
  35609. private _prepareBuffers;
  35610. private _buildIndexBuffer;
  35611. /**
  35612. * Rebuilds the vertex buffers of the manager.
  35613. * @hidden
  35614. */
  35615. _rebuild(): void;
  35616. /**
  35617. * Prepares a frame to be run through a post process.
  35618. * @param sourceTexture The input texture to the post procesess. (default: null)
  35619. * @param postProcesses An array of post processes to be run. (default: null)
  35620. * @returns True if the post processes were able to be run.
  35621. * @hidden
  35622. */
  35623. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35624. /**
  35625. * Manually render a set of post processes to a texture.
  35626. * @param postProcesses An array of post processes to be run.
  35627. * @param targetTexture The target texture to render to.
  35628. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35629. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35630. * @param lodLevel defines which lod of the texture to render to
  35631. */
  35632. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35633. /**
  35634. * Finalize the result of the output of the postprocesses.
  35635. * @param doNotPresent If true the result will not be displayed to the screen.
  35636. * @param targetTexture The target texture to render to.
  35637. * @param faceIndex The index of the face to bind the target texture to.
  35638. * @param postProcesses The array of post processes to render.
  35639. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35640. * @hidden
  35641. */
  35642. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35643. /**
  35644. * Disposes of the post process manager.
  35645. */
  35646. dispose(): void;
  35647. }
  35648. }
  35649. declare module BABYLON {
  35650. /**
  35651. * Post process which applies a refractin texture
  35652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35653. */
  35654. class RefractionPostProcess extends PostProcess {
  35655. /** the base color of the refraction (used to taint the rendering) */
  35656. color: Color3;
  35657. /** simulated refraction depth */
  35658. depth: number;
  35659. /** the coefficient of the base color (0 to remove base color tainting) */
  35660. colorLevel: number;
  35661. private _refTexture;
  35662. private _ownRefractionTexture;
  35663. /**
  35664. * Gets or sets the refraction texture
  35665. * Please note that you are responsible for disposing the texture if you set it manually
  35666. */
  35667. refractionTexture: Texture;
  35668. /**
  35669. * Initializes the RefractionPostProcess
  35670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35671. * @param name The name of the effect.
  35672. * @param refractionTextureUrl Url of the refraction texture to use
  35673. * @param color the base color of the refraction (used to taint the rendering)
  35674. * @param depth simulated refraction depth
  35675. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35676. * @param camera The camera to apply the render pass to.
  35677. * @param options The required width/height ratio to downsize to before computing the render pass.
  35678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35679. * @param engine The engine which the post process will be applied. (default: current engine)
  35680. * @param reusable If the post process can be reused on the same frame. (default: false)
  35681. */
  35682. constructor(name: string, refractionTextureUrl: string,
  35683. /** the base color of the refraction (used to taint the rendering) */
  35684. color: Color3,
  35685. /** simulated refraction depth */
  35686. depth: number,
  35687. /** the coefficient of the base color (0 to remove base color tainting) */
  35688. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35689. /**
  35690. * Disposes of the post process
  35691. * @param camera Camera to dispose post process on
  35692. */
  35693. dispose(camera: Camera): void;
  35694. }
  35695. }
  35696. declare module BABYLON {
  35697. /**
  35698. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35699. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35700. */
  35701. class SharpenPostProcess extends PostProcess {
  35702. /**
  35703. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35704. */
  35705. colorAmount: number;
  35706. /**
  35707. * How much sharpness should be applied (default: 0.3)
  35708. */
  35709. edgeAmount: number;
  35710. /**
  35711. * Creates a new instance ConvolutionPostProcess
  35712. * @param name The name of the effect.
  35713. * @param options The required width/height ratio to downsize to before computing the render pass.
  35714. * @param camera The camera to apply the render pass to.
  35715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35716. * @param engine The engine which the post process will be applied. (default: current engine)
  35717. * @param reusable If the post process can be reused on the same frame. (default: false)
  35718. * @param textureType Type of textures used when performing the post process. (default: 0)
  35719. * @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)
  35720. */
  35721. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35722. }
  35723. }
  35724. declare module BABYLON {
  35725. /**
  35726. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35727. */
  35728. class StereoscopicInterlacePostProcess extends PostProcess {
  35729. private _stepSize;
  35730. private _passedProcess;
  35731. /**
  35732. * Initializes a StereoscopicInterlacePostProcess
  35733. * @param name The name of the effect.
  35734. * @param rigCameras The rig cameras to be appled to the post process
  35735. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35737. * @param engine The engine which the post process will be applied. (default: current engine)
  35738. * @param reusable If the post process can be reused on the same frame. (default: false)
  35739. */
  35740. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35741. }
  35742. }
  35743. declare module BABYLON {
  35744. /** Defines operator used for tonemapping */
  35745. enum TonemappingOperator {
  35746. /** Hable */
  35747. Hable = 0,
  35748. /** Reinhard */
  35749. Reinhard = 1,
  35750. /** HejiDawson */
  35751. HejiDawson = 2,
  35752. /** Photographic */
  35753. Photographic = 3
  35754. }
  35755. /**
  35756. * Defines a post process to apply tone mapping
  35757. */
  35758. class TonemapPostProcess extends PostProcess {
  35759. private _operator;
  35760. /** Defines the required exposure adjustement */
  35761. exposureAdjustment: number;
  35762. /**
  35763. * Creates a new TonemapPostProcess
  35764. * @param name defines the name of the postprocess
  35765. * @param _operator defines the operator to use
  35766. * @param exposureAdjustment defines the required exposure adjustement
  35767. * @param camera defines the camera to use (can be null)
  35768. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35769. * @param engine defines the hosting engine (can be ignore if camera is set)
  35770. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35771. */
  35772. constructor(name: string, _operator: TonemappingOperator,
  35773. /** Defines the required exposure adjustement */
  35774. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35775. }
  35776. }
  35777. declare module BABYLON {
  35778. /**
  35779. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35780. */
  35781. class VolumetricLightScatteringPostProcess extends PostProcess {
  35782. private _volumetricLightScatteringPass;
  35783. private _volumetricLightScatteringRTT;
  35784. private _viewPort;
  35785. private _screenCoordinates;
  35786. private _cachedDefines;
  35787. /**
  35788. * If not undefined, the mesh position is computed from the attached node position
  35789. */
  35790. attachedNode: {
  35791. position: Vector3;
  35792. };
  35793. /**
  35794. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35795. */
  35796. customMeshPosition: Vector3;
  35797. /**
  35798. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35799. */
  35800. useCustomMeshPosition: boolean;
  35801. /**
  35802. * If the post-process should inverse the light scattering direction
  35803. */
  35804. invert: boolean;
  35805. /**
  35806. * The internal mesh used by the post-process
  35807. */
  35808. mesh: Mesh;
  35809. /**
  35810. * @hidden
  35811. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35812. */
  35813. useDiffuseColor: boolean;
  35814. /**
  35815. * Array containing the excluded meshes not rendered in the internal pass
  35816. */
  35817. excludedMeshes: AbstractMesh[];
  35818. /**
  35819. * Controls the overall intensity of the post-process
  35820. */
  35821. exposure: number;
  35822. /**
  35823. * Dissipates each sample's contribution in range [0, 1]
  35824. */
  35825. decay: number;
  35826. /**
  35827. * Controls the overall intensity of each sample
  35828. */
  35829. weight: number;
  35830. /**
  35831. * Controls the density of each sample
  35832. */
  35833. density: number;
  35834. /**
  35835. * @constructor
  35836. * @param name The post-process name
  35837. * @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)
  35838. * @param camera The camera that the post-process will be attached to
  35839. * @param mesh The mesh used to create the light scattering
  35840. * @param samples The post-process quality, default 100
  35841. * @param samplingModeThe post-process filtering mode
  35842. * @param engine The babylon engine
  35843. * @param reusable If the post-process is reusable
  35844. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35845. */
  35846. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35847. /**
  35848. * Returns the string "VolumetricLightScatteringPostProcess"
  35849. * @returns "VolumetricLightScatteringPostProcess"
  35850. */
  35851. getClassName(): string;
  35852. private _isReady;
  35853. /**
  35854. * Sets the new light position for light scattering effect
  35855. * @param position The new custom light position
  35856. */
  35857. setCustomMeshPosition(position: Vector3): void;
  35858. /**
  35859. * Returns the light position for light scattering effect
  35860. * @return Vector3 The custom light position
  35861. */
  35862. getCustomMeshPosition(): Vector3;
  35863. /**
  35864. * Disposes the internal assets and detaches the post-process from the camera
  35865. */
  35866. dispose(camera: Camera): void;
  35867. /**
  35868. * Returns the render target texture used by the post-process
  35869. * @return the render target texture used by the post-process
  35870. */
  35871. getPass(): RenderTargetTexture;
  35872. private _meshExcluded;
  35873. private _createPass;
  35874. private _updateMeshScreenCoordinates;
  35875. /**
  35876. * Creates a default mesh for the Volumeric Light Scattering post-process
  35877. * @param name The mesh name
  35878. * @param scene The scene where to create the mesh
  35879. * @return the default mesh
  35880. */
  35881. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35882. }
  35883. }
  35884. declare module BABYLON {
  35885. /**
  35886. * VRDistortionCorrectionPostProcess used for mobile VR
  35887. */
  35888. class VRDistortionCorrectionPostProcess extends PostProcess {
  35889. private _isRightEye;
  35890. private _distortionFactors;
  35891. private _postProcessScaleFactor;
  35892. private _lensCenterOffset;
  35893. private _scaleIn;
  35894. private _scaleFactor;
  35895. private _lensCenter;
  35896. /**
  35897. * Initializes the VRDistortionCorrectionPostProcess
  35898. * @param name The name of the effect.
  35899. * @param camera The camera to apply the render pass to.
  35900. * @param isRightEye If this is for the right eye distortion
  35901. * @param vrMetrics All the required metrics for the VR camera
  35902. */
  35903. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35904. }
  35905. }
  35906. declare module BABYLON {
  35907. interface Scene {
  35908. /** @hidden (Backing field) */
  35909. _boundingBoxRenderer: BoundingBoxRenderer;
  35910. /** @hidden (Backing field) */
  35911. _forceShowBoundingBoxes: boolean;
  35912. /**
  35913. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35914. */
  35915. forceShowBoundingBoxes: boolean;
  35916. /**
  35917. * Gets the bounding box renderer associated with the scene
  35918. * @returns a BoundingBoxRenderer
  35919. */
  35920. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35921. }
  35922. interface AbstractMesh {
  35923. /** @hidden (Backing field) */
  35924. _showBoundingBox: boolean;
  35925. /**
  35926. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35927. */
  35928. showBoundingBox: boolean;
  35929. }
  35930. /**
  35931. * Component responsible of rendering the bounding box of the meshes in a scene.
  35932. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35933. */
  35934. class BoundingBoxRenderer implements ISceneComponent {
  35935. /**
  35936. * The component name helpfull to identify the component in the list of scene components.
  35937. */
  35938. readonly name: string;
  35939. /**
  35940. * The scene the component belongs to.
  35941. */
  35942. scene: Scene;
  35943. /**
  35944. * Color of the bounding box lines placed in front of an object
  35945. */
  35946. frontColor: Color3;
  35947. /**
  35948. * Color of the bounding box lines placed behind an object
  35949. */
  35950. backColor: Color3;
  35951. /**
  35952. * Defines if the renderer should show the back lines or not
  35953. */
  35954. showBackLines: boolean;
  35955. /**
  35956. * @hidden
  35957. */
  35958. renderList: SmartArray<BoundingBox>;
  35959. private _colorShader;
  35960. private _vertexBuffers;
  35961. private _indexBuffer;
  35962. /**
  35963. * Instantiates a new bounding box renderer in a scene.
  35964. * @param scene the scene the renderer renders in
  35965. */
  35966. constructor(scene: Scene);
  35967. /**
  35968. * Registers the component in a given scene
  35969. */
  35970. register(): void;
  35971. private _evaluateSubMesh;
  35972. private _activeMesh;
  35973. private _prepareRessources;
  35974. private _createIndexBuffer;
  35975. /**
  35976. * Rebuilds the elements related to this component in case of
  35977. * context lost for instance.
  35978. */
  35979. rebuild(): void;
  35980. /**
  35981. * @hidden
  35982. */
  35983. reset(): void;
  35984. /**
  35985. * Render the bounding boxes of a specific rendering group
  35986. * @param renderingGroupId defines the rendering group to render
  35987. */
  35988. render(renderingGroupId: number): void;
  35989. /**
  35990. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35991. * @param mesh Define the mesh to render the occlusion bounding box for
  35992. */
  35993. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35994. /**
  35995. * Dispose and release the resources attached to this renderer.
  35996. */
  35997. dispose(): void;
  35998. }
  35999. }
  36000. declare module BABYLON {
  36001. /**
  36002. * This represents a depth renderer in Babylon.
  36003. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36004. */
  36005. class DepthRenderer {
  36006. private _scene;
  36007. private _depthMap;
  36008. private _effect;
  36009. private _cachedDefines;
  36010. private _camera;
  36011. /**
  36012. * Specifiess that the depth renderer will only be used within
  36013. * the camera it is created for.
  36014. * This can help forcing its rendering during the camera processing.
  36015. */
  36016. useOnlyInActiveCamera: boolean;
  36017. /**
  36018. * Instantiates a depth renderer
  36019. * @param scene The scene the renderer belongs to
  36020. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36021. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36022. */
  36023. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36024. /**
  36025. * Creates the depth rendering effect and checks if the effect is ready.
  36026. * @param subMesh The submesh to be used to render the depth map of
  36027. * @param useInstances If multiple world instances should be used
  36028. * @returns if the depth renderer is ready to render the depth map
  36029. */
  36030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36031. /**
  36032. * Gets the texture which the depth map will be written to.
  36033. * @returns The depth map texture
  36034. */
  36035. getDepthMap(): RenderTargetTexture;
  36036. /**
  36037. * Disposes of the depth renderer.
  36038. */
  36039. dispose(): void;
  36040. }
  36041. }
  36042. declare module BABYLON {
  36043. interface Scene {
  36044. /** @hidden (Backing field) */
  36045. _depthRenderer: {
  36046. [id: string]: DepthRenderer;
  36047. };
  36048. /**
  36049. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36050. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36051. * @returns the created depth renderer
  36052. */
  36053. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36054. /**
  36055. * Disables a depth renderer for a given camera
  36056. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36057. */
  36058. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36059. }
  36060. /**
  36061. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36062. * in several rendering techniques.
  36063. */
  36064. class DepthRendererSceneComponent implements ISceneComponent {
  36065. /**
  36066. * The component name helpfull to identify the component in the list of scene components.
  36067. */
  36068. readonly name: string;
  36069. /**
  36070. * The scene the component belongs to.
  36071. */
  36072. scene: Scene;
  36073. /**
  36074. * Creates a new instance of the component for the given scene
  36075. * @param scene Defines the scene to register the component in
  36076. */
  36077. constructor(scene: Scene);
  36078. /**
  36079. * Registers the component in a given scene
  36080. */
  36081. register(): void;
  36082. /**
  36083. * Rebuilds the elements related to this component in case of
  36084. * context lost for instance.
  36085. */
  36086. rebuild(): void;
  36087. /**
  36088. * Disposes the component and the associated ressources
  36089. */
  36090. dispose(): void;
  36091. private _gatherRenderTargets;
  36092. private _gatherActiveCameraRenderTargets;
  36093. }
  36094. }
  36095. declare module BABYLON {
  36096. interface AbstractMesh {
  36097. /**
  36098. * Disables the mesh edge rendering mode
  36099. * @returns the currentAbstractMesh
  36100. */
  36101. disableEdgesRendering(): AbstractMesh;
  36102. /**
  36103. * Enables the edge rendering mode on the mesh.
  36104. * This mode makes the mesh edges visible
  36105. * @param epsilon defines the maximal distance between two angles to detect a face
  36106. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36107. * @returns the currentAbstractMesh
  36108. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36109. */
  36110. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36111. /**
  36112. * Gets the edgesRenderer associated with the mesh
  36113. */
  36114. edgesRenderer: Nullable<EdgesRenderer>;
  36115. }
  36116. interface LinesMesh {
  36117. /**
  36118. * Enables the edge rendering mode on the mesh.
  36119. * This mode makes the mesh edges visible
  36120. * @param epsilon defines the maximal distance between two angles to detect a face
  36121. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36122. * @returns the currentAbstractMesh
  36123. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36124. */
  36125. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36126. }
  36127. interface InstancedLinesMesh {
  36128. /**
  36129. * Enables the edge rendering mode on the mesh.
  36130. * This mode makes the mesh edges visible
  36131. * @param epsilon defines the maximal distance between two angles to detect a face
  36132. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36133. * @returns the current InstancedLinesMesh
  36134. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36135. */
  36136. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36137. }
  36138. /**
  36139. * Defines the minimum contract an Edges renderer should follow.
  36140. */
  36141. interface IEdgesRenderer extends IDisposable {
  36142. /**
  36143. * Gets or sets a boolean indicating if the edgesRenderer is active
  36144. */
  36145. isEnabled: boolean;
  36146. /**
  36147. * Renders the edges of the attached mesh,
  36148. */
  36149. render(): void;
  36150. /**
  36151. * Checks wether or not the edges renderer is ready to render.
  36152. * @return true if ready, otherwise false.
  36153. */
  36154. isReady(): boolean;
  36155. }
  36156. /**
  36157. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36158. */
  36159. class EdgesRenderer implements IEdgesRenderer {
  36160. /**
  36161. * Define the size of the edges with an orthographic camera
  36162. */
  36163. edgesWidthScalerForOrthographic: number;
  36164. /**
  36165. * Define the size of the edges with a perspective camera
  36166. */
  36167. edgesWidthScalerForPerspective: number;
  36168. protected _source: AbstractMesh;
  36169. protected _linesPositions: number[];
  36170. protected _linesNormals: number[];
  36171. protected _linesIndices: number[];
  36172. protected _epsilon: number;
  36173. protected _indicesCount: number;
  36174. protected _lineShader: ShaderMaterial;
  36175. protected _ib: WebGLBuffer;
  36176. protected _buffers: {
  36177. [key: string]: Nullable<VertexBuffer>;
  36178. };
  36179. protected _checkVerticesInsteadOfIndices: boolean;
  36180. private _meshRebuildObserver;
  36181. private _meshDisposeObserver;
  36182. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36183. isEnabled: boolean;
  36184. /**
  36185. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36186. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36187. * @param source Mesh used to create edges
  36188. * @param epsilon sum of angles in adjacency to check for edge
  36189. * @param checkVerticesInsteadOfIndices
  36190. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36191. */
  36192. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36193. protected _prepareRessources(): void;
  36194. /** @hidden */
  36195. _rebuild(): void;
  36196. /**
  36197. * Releases the required resources for the edges renderer
  36198. */
  36199. dispose(): void;
  36200. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36201. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36202. /**
  36203. * Checks if the pair of p0 and p1 is en edge
  36204. * @param faceIndex
  36205. * @param edge
  36206. * @param faceNormals
  36207. * @param p0
  36208. * @param p1
  36209. * @private
  36210. */
  36211. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36212. /**
  36213. * push line into the position, normal and index buffer
  36214. * @protected
  36215. */
  36216. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36217. /**
  36218. * Generates lines edges from adjacencjes
  36219. * @private
  36220. */
  36221. _generateEdgesLines(): void;
  36222. /**
  36223. * Checks wether or not the edges renderer is ready to render.
  36224. * @return true if ready, otherwise false.
  36225. */
  36226. isReady(): boolean;
  36227. /**
  36228. * Renders the edges of the attached mesh,
  36229. */
  36230. render(): void;
  36231. }
  36232. }
  36233. declare module BABYLON {
  36234. /**
  36235. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36236. */
  36237. class GeometryBufferRenderer {
  36238. /**
  36239. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36240. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36241. */
  36242. static readonly POSITION_TEXTURE_TYPE: number;
  36243. /**
  36244. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36245. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36246. */
  36247. static readonly VELOCITY_TEXTURE_TYPE: number;
  36248. /**
  36249. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36250. * in order to compute objects velocities when enableVelocity is set to "true"
  36251. * @hidden
  36252. */
  36253. _previousTransformationMatrices: {
  36254. [index: number]: Matrix;
  36255. };
  36256. private _scene;
  36257. private _multiRenderTarget;
  36258. private _ratio;
  36259. private _enablePosition;
  36260. private _enableVelocity;
  36261. private _positionIndex;
  36262. private _velocityIndex;
  36263. protected _effect: Effect;
  36264. protected _cachedDefines: string;
  36265. /**
  36266. * Set the render list (meshes to be rendered) used in the G buffer.
  36267. */
  36268. renderList: Mesh[];
  36269. /**
  36270. * Gets wether or not G buffer are supported by the running hardware.
  36271. * This requires draw buffer supports
  36272. */
  36273. readonly isSupported: boolean;
  36274. /**
  36275. * Returns the index of the given texture type in the G-Buffer textures array
  36276. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36277. * @returns the index of the given texture type in the G-Buffer textures array
  36278. */
  36279. getTextureIndex(textureType: number): number;
  36280. /**
  36281. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36282. */
  36283. /**
  36284. * Sets whether or not objects positions are enabled for the G buffer.
  36285. */
  36286. enablePosition: boolean;
  36287. /**
  36288. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36289. */
  36290. /**
  36291. * Sets wether or not objects velocities are enabled for the G buffer.
  36292. */
  36293. enableVelocity: boolean;
  36294. /**
  36295. * Gets the scene associated with the buffer.
  36296. */
  36297. readonly scene: Scene;
  36298. /**
  36299. * Gets the ratio used by the buffer during its creation.
  36300. * How big is the buffer related to the main canvas.
  36301. */
  36302. readonly ratio: number;
  36303. /**
  36304. * Creates a new G Buffer for the scene
  36305. * @param scene The scene the buffer belongs to
  36306. * @param ratio How big is the buffer related to the main canvas.
  36307. */
  36308. constructor(scene: Scene, ratio?: number);
  36309. /**
  36310. * Checks wether everything is ready to render a submesh to the G buffer.
  36311. * @param subMesh the submesh to check readiness for
  36312. * @param useInstances is the mesh drawn using instance or not
  36313. * @returns true if ready otherwise false
  36314. */
  36315. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36316. /**
  36317. * Gets the current underlying G Buffer.
  36318. * @returns the buffer
  36319. */
  36320. getGBuffer(): MultiRenderTarget;
  36321. /**
  36322. * Gets the number of samples used to render the buffer (anti aliasing).
  36323. */
  36324. /**
  36325. * Sets the number of samples used to render the buffer (anti aliasing).
  36326. */
  36327. samples: number;
  36328. /**
  36329. * Disposes the renderer and frees up associated resources.
  36330. */
  36331. dispose(): void;
  36332. protected _createRenderTargets(): void;
  36333. }
  36334. }
  36335. declare module BABYLON {
  36336. interface Scene {
  36337. /** @hidden (Backing field) */
  36338. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36339. /**
  36340. * Gets or Sets the current geometry buffer associated to the scene.
  36341. */
  36342. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36343. /**
  36344. * Enables a GeometryBufferRender and associates it with the scene
  36345. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36346. * @returns the GeometryBufferRenderer
  36347. */
  36348. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36349. /**
  36350. * Disables the GeometryBufferRender associated with the scene
  36351. */
  36352. disableGeometryBufferRenderer(): void;
  36353. }
  36354. /**
  36355. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36356. * in several rendering techniques.
  36357. */
  36358. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36359. /**
  36360. * The component name helpful to identify the component in the list of scene components.
  36361. */
  36362. readonly name: string;
  36363. /**
  36364. * The scene the component belongs to.
  36365. */
  36366. scene: Scene;
  36367. /**
  36368. * Creates a new instance of the component for the given scene
  36369. * @param scene Defines the scene to register the component in
  36370. */
  36371. constructor(scene: Scene);
  36372. /**
  36373. * Registers the component in a given scene
  36374. */
  36375. register(): void;
  36376. /**
  36377. * Rebuilds the elements related to this component in case of
  36378. * context lost for instance.
  36379. */
  36380. rebuild(): void;
  36381. /**
  36382. * Disposes the component and the associated ressources
  36383. */
  36384. dispose(): void;
  36385. private _gatherRenderTargets;
  36386. }
  36387. }
  36388. declare module BABYLON {
  36389. /**
  36390. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36391. */
  36392. class LineEdgesRenderer extends EdgesRenderer {
  36393. /**
  36394. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36395. * @param source LineMesh used to generate edges
  36396. * @param epsilon not important (specified angle for edge detection)
  36397. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36398. */
  36399. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36400. /**
  36401. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36402. */
  36403. _generateEdgesLines(): void;
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. interface Scene {
  36408. /** @hidden */
  36409. _outlineRenderer: OutlineRenderer;
  36410. /**
  36411. * Gets the outline renderer associated with the scene
  36412. * @returns a OutlineRenderer
  36413. */
  36414. getOutlineRenderer(): OutlineRenderer;
  36415. }
  36416. interface AbstractMesh {
  36417. /** @hidden (Backing field) */
  36418. _renderOutline: boolean;
  36419. /**
  36420. * Gets or sets a boolean indicating if the outline must be rendered as well
  36421. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36422. */
  36423. renderOutline: boolean;
  36424. /** @hidden (Backing field) */
  36425. _renderOverlay: boolean;
  36426. /**
  36427. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36428. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36429. */
  36430. renderOverlay: boolean;
  36431. }
  36432. /**
  36433. * This class is responsible to draw bothe outline/overlay of meshes.
  36434. * It should not be used directly but through the available method on mesh.
  36435. */
  36436. class OutlineRenderer implements ISceneComponent {
  36437. /**
  36438. * The name of the component. Each component must have a unique name.
  36439. */
  36440. name: string;
  36441. /**
  36442. * The scene the component belongs to.
  36443. */
  36444. scene: Scene;
  36445. /**
  36446. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36447. */
  36448. zOffset: number;
  36449. private _engine;
  36450. private _effect;
  36451. private _cachedDefines;
  36452. private _savedDepthWrite;
  36453. /**
  36454. * Instantiates a new outline renderer. (There could be only one per scene).
  36455. * @param scene Defines the scene it belongs to
  36456. */
  36457. constructor(scene: Scene);
  36458. /**
  36459. * Register the component to one instance of a scene.
  36460. */
  36461. register(): void;
  36462. /**
  36463. * Rebuilds the elements related to this component in case of
  36464. * context lost for instance.
  36465. */
  36466. rebuild(): void;
  36467. /**
  36468. * Disposes the component and the associated ressources.
  36469. */
  36470. dispose(): void;
  36471. /**
  36472. * Renders the outline in the canvas.
  36473. * @param subMesh Defines the sumesh to render
  36474. * @param batch Defines the batch of meshes in case of instances
  36475. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36476. */
  36477. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36478. /**
  36479. * Returns whether or not the outline renderer is ready for a given submesh.
  36480. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36481. * @param subMesh Defines the submesh to check readyness for
  36482. * @param useInstances Defines wheter wee are trying to render instances or not
  36483. * @returns true if ready otherwise false
  36484. */
  36485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36486. private _beforeRenderingMesh;
  36487. private _afterRenderingMesh;
  36488. }
  36489. }
  36490. declare module BABYLON {
  36491. /**
  36492. * This represents the object necessary to create a rendering group.
  36493. * This is exclusively used and created by the rendering manager.
  36494. * To modify the behavior, you use the available helpers in your scene or meshes.
  36495. * @hidden
  36496. */
  36497. class RenderingGroup {
  36498. index: number;
  36499. private _scene;
  36500. private _opaqueSubMeshes;
  36501. private _transparentSubMeshes;
  36502. private _alphaTestSubMeshes;
  36503. private _depthOnlySubMeshes;
  36504. private _particleSystems;
  36505. private _spriteManagers;
  36506. private _opaqueSortCompareFn;
  36507. private _alphaTestSortCompareFn;
  36508. private _transparentSortCompareFn;
  36509. private _renderOpaque;
  36510. private _renderAlphaTest;
  36511. private _renderTransparent;
  36512. private _edgesRenderers;
  36513. onBeforeTransparentRendering: () => void;
  36514. /**
  36515. * Set the opaque sort comparison function.
  36516. * If null the sub meshes will be render in the order they were created
  36517. */
  36518. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36519. /**
  36520. * Set the alpha test sort comparison function.
  36521. * If null the sub meshes will be render in the order they were created
  36522. */
  36523. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36524. /**
  36525. * Set the transparent sort comparison function.
  36526. * If null the sub meshes will be render in the order they were created
  36527. */
  36528. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36529. /**
  36530. * Creates a new rendering group.
  36531. * @param index The rendering group index
  36532. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36533. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36534. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36535. */
  36536. 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>);
  36537. /**
  36538. * Render all the sub meshes contained in the group.
  36539. * @param customRenderFunction Used to override the default render behaviour of the group.
  36540. * @returns true if rendered some submeshes.
  36541. */
  36542. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36543. /**
  36544. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36545. * @param subMeshes The submeshes to render
  36546. */
  36547. private renderOpaqueSorted;
  36548. /**
  36549. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36550. * @param subMeshes The submeshes to render
  36551. */
  36552. private renderAlphaTestSorted;
  36553. /**
  36554. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36555. * @param subMeshes The submeshes to render
  36556. */
  36557. private renderTransparentSorted;
  36558. /**
  36559. * Renders the submeshes in a specified order.
  36560. * @param subMeshes The submeshes to sort before render
  36561. * @param sortCompareFn The comparison function use to sort
  36562. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36563. * @param transparent Specifies to activate blending if true
  36564. */
  36565. private static renderSorted;
  36566. /**
  36567. * Renders the submeshes in the order they were dispatched (no sort applied).
  36568. * @param subMeshes The submeshes to render
  36569. */
  36570. private static renderUnsorted;
  36571. /**
  36572. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36573. * are rendered back to front if in the same alpha index.
  36574. *
  36575. * @param a The first submesh
  36576. * @param b The second submesh
  36577. * @returns The result of the comparison
  36578. */
  36579. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36580. /**
  36581. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36582. * are rendered back to front.
  36583. *
  36584. * @param a The first submesh
  36585. * @param b The second submesh
  36586. * @returns The result of the comparison
  36587. */
  36588. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36589. /**
  36590. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36591. * are rendered front to back (prevent overdraw).
  36592. *
  36593. * @param a The first submesh
  36594. * @param b The second submesh
  36595. * @returns The result of the comparison
  36596. */
  36597. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36598. /**
  36599. * Resets the different lists of submeshes to prepare a new frame.
  36600. */
  36601. prepare(): void;
  36602. dispose(): void;
  36603. /**
  36604. * Inserts the submesh in its correct queue depending on its material.
  36605. * @param subMesh The submesh to dispatch
  36606. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36607. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36608. */
  36609. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36610. dispatchSprites(spriteManager: ISpriteManager): void;
  36611. dispatchParticles(particleSystem: IParticleSystem): void;
  36612. private _renderParticles;
  36613. private _renderSprites;
  36614. }
  36615. }
  36616. declare module BABYLON {
  36617. /**
  36618. * Interface describing the different options available in the rendering manager
  36619. * regarding Auto Clear between groups.
  36620. */
  36621. interface IRenderingManagerAutoClearSetup {
  36622. /**
  36623. * Defines whether or not autoclear is enable.
  36624. */
  36625. autoClear: boolean;
  36626. /**
  36627. * Defines whether or not to autoclear the depth buffer.
  36628. */
  36629. depth: boolean;
  36630. /**
  36631. * Defines whether or not to autoclear the stencil buffer.
  36632. */
  36633. stencil: boolean;
  36634. }
  36635. /**
  36636. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36637. * It is enable to manage the different groups as well as the different necessary sort functions.
  36638. * This should not be used directly aside of the few static configurations
  36639. */
  36640. class RenderingManager {
  36641. /**
  36642. * The max id used for rendering groups (not included)
  36643. */
  36644. static MAX_RENDERINGGROUPS: number;
  36645. /**
  36646. * The min id used for rendering groups (included)
  36647. */
  36648. static MIN_RENDERINGGROUPS: number;
  36649. /**
  36650. * Used to globally prevent autoclearing scenes.
  36651. */
  36652. static AUTOCLEAR: boolean;
  36653. /**
  36654. * @hidden
  36655. */
  36656. _useSceneAutoClearSetup: boolean;
  36657. private _scene;
  36658. private _renderingGroups;
  36659. private _depthStencilBufferAlreadyCleaned;
  36660. private _autoClearDepthStencil;
  36661. private _customOpaqueSortCompareFn;
  36662. private _customAlphaTestSortCompareFn;
  36663. private _customTransparentSortCompareFn;
  36664. private _renderingGroupInfo;
  36665. /**
  36666. * Instantiates a new rendering group for a particular scene
  36667. * @param scene Defines the scene the groups belongs to
  36668. */
  36669. constructor(scene: Scene);
  36670. private _clearDepthStencilBuffer;
  36671. /**
  36672. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36673. * @hidden
  36674. */
  36675. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36676. /**
  36677. * Resets the different information of the group to prepare a new frame
  36678. * @hidden
  36679. */
  36680. reset(): void;
  36681. /**
  36682. * Dispose and release the group and its associated resources.
  36683. * @hidden
  36684. */
  36685. dispose(): void;
  36686. /**
  36687. * Clear the info related to rendering groups preventing retention points during dispose.
  36688. */
  36689. freeRenderingGroups(): void;
  36690. private _prepareRenderingGroup;
  36691. /**
  36692. * Add a sprite manager to the rendering manager in order to render it this frame.
  36693. * @param spriteManager Define the sprite manager to render
  36694. */
  36695. dispatchSprites(spriteManager: ISpriteManager): void;
  36696. /**
  36697. * Add a particle system to the rendering manager in order to render it this frame.
  36698. * @param particleSystem Define the particle system to render
  36699. */
  36700. dispatchParticles(particleSystem: IParticleSystem): void;
  36701. /**
  36702. * Add a submesh to the manager in order to render it this frame
  36703. * @param subMesh The submesh to dispatch
  36704. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36705. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36706. */
  36707. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36708. /**
  36709. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36710. * This allowed control for front to back rendering or reversly depending of the special needs.
  36711. *
  36712. * @param renderingGroupId The rendering group id corresponding to its index
  36713. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36714. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36715. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36716. */
  36717. 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;
  36718. /**
  36719. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36720. *
  36721. * @param renderingGroupId The rendering group id corresponding to its index
  36722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36723. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36724. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36725. */
  36726. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36727. /**
  36728. * Gets the current auto clear configuration for one rendering group of the rendering
  36729. * manager.
  36730. * @param index the rendering group index to get the information for
  36731. * @returns The auto clear setup for the requested rendering group
  36732. */
  36733. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * Renders a layer on top of an existing scene
  36739. */
  36740. class UtilityLayerRenderer implements IDisposable {
  36741. /** the original scene that will be rendered on top of */
  36742. originalScene: Scene;
  36743. private _pointerCaptures;
  36744. private _lastPointerEvents;
  36745. private static _DefaultUtilityLayer;
  36746. private static _DefaultKeepDepthUtilityLayer;
  36747. /**
  36748. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36749. */
  36750. pickUtilitySceneFirst: boolean;
  36751. /**
  36752. * 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)
  36753. */
  36754. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36755. /**
  36756. * 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)
  36757. */
  36758. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36759. /**
  36760. * The scene that is rendered on top of the original scene
  36761. */
  36762. utilityLayerScene: Scene;
  36763. /**
  36764. * If the utility layer should automatically be rendered on top of existing scene
  36765. */
  36766. shouldRender: boolean;
  36767. /**
  36768. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36769. */
  36770. onlyCheckPointerDownEvents: boolean;
  36771. /**
  36772. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36773. */
  36774. processAllEvents: boolean;
  36775. /**
  36776. * Observable raised when the pointer move from the utility layer scene to the main scene
  36777. */
  36778. onPointerOutObservable: Observable<number>;
  36779. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36780. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36781. private _afterRenderObserver;
  36782. private _sceneDisposeObserver;
  36783. private _originalPointerObserver;
  36784. /**
  36785. * Instantiates a UtilityLayerRenderer
  36786. * @param originalScene the original scene that will be rendered on top of
  36787. * @param handleEvents boolean indicating if the utility layer should handle events
  36788. */
  36789. constructor(
  36790. /** the original scene that will be rendered on top of */
  36791. originalScene: Scene, handleEvents?: boolean);
  36792. private _notifyObservers;
  36793. /**
  36794. * Renders the utility layers scene on top of the original scene
  36795. */
  36796. render(): void;
  36797. /**
  36798. * Disposes of the renderer
  36799. */
  36800. dispose(): void;
  36801. private _updateCamera;
  36802. }
  36803. }
  36804. declare module BABYLON {
  36805. /**
  36806. * Class used to represent a sprite
  36807. * @see http://doc.babylonjs.com/babylon101/sprites
  36808. */
  36809. class Sprite {
  36810. /** defines the name */
  36811. name: string;
  36812. /** Gets or sets the current world position */
  36813. position: Vector3;
  36814. /** Gets or sets the main color */
  36815. color: Color4;
  36816. /** Gets or sets the width */
  36817. width: number;
  36818. /** Gets or sets the height */
  36819. height: number;
  36820. /** Gets or sets rotation angle */
  36821. angle: number;
  36822. /** Gets or sets the cell index in the sprite sheet */
  36823. cellIndex: number;
  36824. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36825. invertU: number;
  36826. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36827. invertV: number;
  36828. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36829. disposeWhenFinishedAnimating: boolean;
  36830. /** Gets the list of attached animations */
  36831. animations: Animation[];
  36832. /** Gets or sets a boolean indicating if the sprite can be picked */
  36833. isPickable: boolean;
  36834. /**
  36835. * Gets or sets the associated action manager
  36836. */
  36837. actionManager: Nullable<ActionManager>;
  36838. private _animationStarted;
  36839. private _loopAnimation;
  36840. private _fromIndex;
  36841. private _toIndex;
  36842. private _delay;
  36843. private _direction;
  36844. private _manager;
  36845. private _time;
  36846. private _onAnimationEnd;
  36847. /**
  36848. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36849. */
  36850. isVisible: boolean;
  36851. /**
  36852. * Gets or sets the sprite size
  36853. */
  36854. size: number;
  36855. /**
  36856. * Creates a new Sprite
  36857. * @param name defines the name
  36858. * @param manager defines the manager
  36859. */
  36860. constructor(
  36861. /** defines the name */
  36862. name: string, manager: ISpriteManager);
  36863. /**
  36864. * Starts an animation
  36865. * @param from defines the initial key
  36866. * @param to defines the end key
  36867. * @param loop defines if the animation must loop
  36868. * @param delay defines the start delay (in ms)
  36869. * @param onAnimationEnd defines a callback to call when animation ends
  36870. */
  36871. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36872. /** Stops current animation (if any) */
  36873. stopAnimation(): void;
  36874. /** @hidden */
  36875. _animate(deltaTime: number): void;
  36876. /** Release associated resources */
  36877. dispose(): void;
  36878. }
  36879. }
  36880. declare module BABYLON {
  36881. /**
  36882. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36883. */
  36884. interface ISpriteManager extends IDisposable {
  36885. /**
  36886. * Restricts the camera to viewing objects with the same layerMask.
  36887. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36888. */
  36889. layerMask: number;
  36890. /**
  36891. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36892. */
  36893. isPickable: boolean;
  36894. /**
  36895. * Specifies the rendering group id for this mesh (0 by default)
  36896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36897. */
  36898. renderingGroupId: number;
  36899. /**
  36900. * Defines the list of sprites managed by the manager.
  36901. */
  36902. sprites: Array<Sprite>;
  36903. /**
  36904. * Tests the intersection of a sprite with a specific ray.
  36905. * @param ray The ray we are sending to test the collision
  36906. * @param camera The camera space we are sending rays in
  36907. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36908. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36909. * @returns picking info or null.
  36910. */
  36911. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36912. /**
  36913. * Renders the list of sprites on screen.
  36914. */
  36915. render(): void;
  36916. }
  36917. /**
  36918. * Class used to manage multiple sprites on the same spritesheet
  36919. * @see http://doc.babylonjs.com/babylon101/sprites
  36920. */
  36921. class SpriteManager implements ISpriteManager {
  36922. /** defines the manager's name */
  36923. name: string;
  36924. /** Gets the list of sprites */
  36925. sprites: Sprite[];
  36926. /** Gets or sets the rendering group id (0 by default) */
  36927. renderingGroupId: number;
  36928. /** Gets or sets camera layer mask */
  36929. layerMask: number;
  36930. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36931. fogEnabled: boolean;
  36932. /** Gets or sets a boolean indicating if the sprites are pickable */
  36933. isPickable: boolean;
  36934. /** Defines the default width of a cell in the spritesheet */
  36935. cellWidth: number;
  36936. /** Defines the default height of a cell in the spritesheet */
  36937. cellHeight: number;
  36938. /**
  36939. * An event triggered when the manager is disposed.
  36940. */
  36941. onDisposeObservable: Observable<SpriteManager>;
  36942. private _onDisposeObserver;
  36943. /**
  36944. * Callback called when the manager is disposed
  36945. */
  36946. onDispose: () => void;
  36947. private _capacity;
  36948. private _spriteTexture;
  36949. private _epsilon;
  36950. private _scene;
  36951. private _vertexData;
  36952. private _buffer;
  36953. private _vertexBuffers;
  36954. private _indexBuffer;
  36955. private _effectBase;
  36956. private _effectFog;
  36957. /**
  36958. * Gets or sets the spritesheet texture
  36959. */
  36960. texture: Texture;
  36961. /**
  36962. * Creates a new sprite manager
  36963. * @param name defines the manager's name
  36964. * @param imgUrl defines the sprite sheet url
  36965. * @param capacity defines the maximum allowed number of sprites
  36966. * @param cellSize defines the size of a sprite cell
  36967. * @param scene defines the hosting scene
  36968. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36969. * @param samplingMode defines the smapling mode to use with spritesheet
  36970. */
  36971. constructor(
  36972. /** defines the manager's name */
  36973. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36974. private _appendSpriteVertex;
  36975. /**
  36976. * Intersects the sprites with a ray
  36977. * @param ray defines the ray to intersect with
  36978. * @param camera defines the current active camera
  36979. * @param predicate defines a predicate used to select candidate sprites
  36980. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36981. * @returns null if no hit or a PickingInfo
  36982. */
  36983. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36984. /**
  36985. * Render all child sprites
  36986. */
  36987. render(): void;
  36988. /**
  36989. * Release associated resources
  36990. */
  36991. dispose(): void;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. interface Scene {
  36996. /** @hidden */
  36997. _pointerOverSprite: Nullable<Sprite>;
  36998. /** @hidden */
  36999. _pickedDownSprite: Nullable<Sprite>;
  37000. /** @hidden */
  37001. _tempSpritePickingRay: Nullable<Ray>;
  37002. /**
  37003. * All of the sprite managers added to this scene
  37004. * @see http://doc.babylonjs.com/babylon101/sprites
  37005. */
  37006. spriteManagers: Array<ISpriteManager>;
  37007. /**
  37008. * An event triggered when sprites rendering is about to start
  37009. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37010. */
  37011. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37012. /**
  37013. * An event triggered when sprites rendering is done
  37014. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37015. */
  37016. onAfterSpritesRenderingObservable: Observable<Scene>;
  37017. /** @hidden */
  37018. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37019. /** Launch a ray to try to pick a sprite in the scene
  37020. * @param x position on screen
  37021. * @param y position on screen
  37022. * @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
  37023. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37024. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37025. * @returns a PickingInfo
  37026. */
  37027. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37028. /** Use the given ray to pick a sprite in the scene
  37029. * @param ray The ray (in world space) to use to pick meshes
  37030. * @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
  37031. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37032. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37033. * @returns a PickingInfo
  37034. */
  37035. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37036. /**
  37037. * Force the sprite under the pointer
  37038. * @param sprite defines the sprite to use
  37039. */
  37040. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37041. /**
  37042. * Gets the sprite under the pointer
  37043. * @returns a Sprite or null if no sprite is under the pointer
  37044. */
  37045. getPointerOverSprite(): Nullable<Sprite>;
  37046. }
  37047. /**
  37048. * Defines the sprite scene component responsible to manage sprites
  37049. * in a given scene.
  37050. */
  37051. class SpriteSceneComponent implements ISceneComponent {
  37052. /**
  37053. * The component name helpfull to identify the component in the list of scene components.
  37054. */
  37055. readonly name: string;
  37056. /**
  37057. * The scene the component belongs to.
  37058. */
  37059. scene: Scene;
  37060. /** @hidden */
  37061. private _spritePredicate;
  37062. /**
  37063. * Creates a new instance of the component for the given scene
  37064. * @param scene Defines the scene to register the component in
  37065. */
  37066. constructor(scene: Scene);
  37067. /**
  37068. * Registers the component in a given scene
  37069. */
  37070. register(): void;
  37071. /**
  37072. * Rebuilds the elements related to this component in case of
  37073. * context lost for instance.
  37074. */
  37075. rebuild(): void;
  37076. /**
  37077. * Disposes the component and the associated ressources.
  37078. */
  37079. dispose(): void;
  37080. private _pickSpriteButKeepRay;
  37081. private _pointerMove;
  37082. private _pointerDown;
  37083. private _pointerUp;
  37084. }
  37085. }
  37086. declare module BABYLON {
  37087. /**
  37088. * @hidden
  37089. **/
  37090. class _AlphaState {
  37091. private _isAlphaBlendDirty;
  37092. private _isBlendFunctionParametersDirty;
  37093. private _isBlendEquationParametersDirty;
  37094. private _isBlendConstantsDirty;
  37095. private _alphaBlend;
  37096. private _blendFunctionParameters;
  37097. private _blendEquationParameters;
  37098. private _blendConstants;
  37099. /**
  37100. * Initializes the state.
  37101. */
  37102. constructor();
  37103. readonly isDirty: boolean;
  37104. alphaBlend: boolean;
  37105. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37106. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37107. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37108. reset(): void;
  37109. apply(gl: WebGLRenderingContext): void;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. /**
  37114. * @hidden
  37115. **/
  37116. class _DepthCullingState {
  37117. private _isDepthTestDirty;
  37118. private _isDepthMaskDirty;
  37119. private _isDepthFuncDirty;
  37120. private _isCullFaceDirty;
  37121. private _isCullDirty;
  37122. private _isZOffsetDirty;
  37123. private _isFrontFaceDirty;
  37124. private _depthTest;
  37125. private _depthMask;
  37126. private _depthFunc;
  37127. private _cull;
  37128. private _cullFace;
  37129. private _zOffset;
  37130. private _frontFace;
  37131. /**
  37132. * Initializes the state.
  37133. */
  37134. constructor();
  37135. readonly isDirty: boolean;
  37136. zOffset: number;
  37137. cullFace: Nullable<number>;
  37138. cull: Nullable<boolean>;
  37139. depthFunc: Nullable<number>;
  37140. depthMask: boolean;
  37141. depthTest: boolean;
  37142. frontFace: Nullable<number>;
  37143. reset(): void;
  37144. apply(gl: WebGLRenderingContext): void;
  37145. }
  37146. }
  37147. declare module BABYLON {
  37148. /**
  37149. * @hidden
  37150. **/
  37151. class _StencilState {
  37152. private _isStencilTestDirty;
  37153. private _isStencilMaskDirty;
  37154. private _isStencilFuncDirty;
  37155. private _isStencilOpDirty;
  37156. private _stencilTest;
  37157. private _stencilMask;
  37158. private _stencilFunc;
  37159. private _stencilFuncRef;
  37160. private _stencilFuncMask;
  37161. private _stencilOpStencilFail;
  37162. private _stencilOpDepthFail;
  37163. private _stencilOpStencilDepthPass;
  37164. readonly isDirty: boolean;
  37165. stencilFunc: number;
  37166. stencilFuncRef: number;
  37167. stencilFuncMask: number;
  37168. stencilOpStencilFail: number;
  37169. stencilOpDepthFail: number;
  37170. stencilOpStencilDepthPass: number;
  37171. stencilMask: number;
  37172. stencilTest: boolean;
  37173. constructor();
  37174. reset(): void;
  37175. apply(gl: WebGLRenderingContext): void;
  37176. }
  37177. }
  37178. declare module BABYLON {
  37179. /**
  37180. * Class used to evalaute queries containing `and` and `or` operators
  37181. */
  37182. class AndOrNotEvaluator {
  37183. /**
  37184. * Evaluate a query
  37185. * @param query defines the query to evaluate
  37186. * @param evaluateCallback defines the callback used to filter result
  37187. * @returns true if the query matches
  37188. */
  37189. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37190. private static _HandleParenthesisContent;
  37191. private static _SimplifyNegation;
  37192. }
  37193. }
  37194. declare module BABYLON {
  37195. /**
  37196. * Defines the list of states available for a task inside a AssetsManager
  37197. */
  37198. enum AssetTaskState {
  37199. /**
  37200. * Initialization
  37201. */
  37202. INIT = 0,
  37203. /**
  37204. * Running
  37205. */
  37206. RUNNING = 1,
  37207. /**
  37208. * Done
  37209. */
  37210. DONE = 2,
  37211. /**
  37212. * Error
  37213. */
  37214. ERROR = 3
  37215. }
  37216. /**
  37217. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37218. */
  37219. abstract class AbstractAssetTask {
  37220. /**
  37221. * Task name
  37222. */ name: string;
  37223. /**
  37224. * Callback called when the task is successful
  37225. */
  37226. onSuccess: (task: any) => void;
  37227. /**
  37228. * Callback called when the task is not successful
  37229. */
  37230. onError: (task: any, message?: string, exception?: any) => void;
  37231. /**
  37232. * Creates a new AssetsManager
  37233. * @param name defines the name of the task
  37234. */
  37235. constructor(
  37236. /**
  37237. * Task name
  37238. */ name: string);
  37239. private _isCompleted;
  37240. private _taskState;
  37241. private _errorObject;
  37242. /**
  37243. * Get if the task is completed
  37244. */
  37245. readonly isCompleted: boolean;
  37246. /**
  37247. * Gets the current state of the task
  37248. */
  37249. readonly taskState: AssetTaskState;
  37250. /**
  37251. * Gets the current error object (if task is in error)
  37252. */
  37253. readonly errorObject: {
  37254. message?: string;
  37255. exception?: any;
  37256. };
  37257. /**
  37258. * Internal only
  37259. * @hidden
  37260. */
  37261. _setErrorObject(message?: string, exception?: any): void;
  37262. /**
  37263. * Execute the current task
  37264. * @param scene defines the scene where you want your assets to be loaded
  37265. * @param onSuccess is a callback called when the task is successfully executed
  37266. * @param onError is a callback called if an error occurs
  37267. */
  37268. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37269. /**
  37270. * Execute the current task
  37271. * @param scene defines the scene where you want your assets to be loaded
  37272. * @param onSuccess is a callback called when the task is successfully executed
  37273. * @param onError is a callback called if an error occurs
  37274. */
  37275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37276. /**
  37277. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37278. * This can be used with failed tasks that have the reason for failure fixed.
  37279. */
  37280. reset(): void;
  37281. private onErrorCallback;
  37282. private onDoneCallback;
  37283. }
  37284. /**
  37285. * Define the interface used by progress events raised during assets loading
  37286. */
  37287. interface IAssetsProgressEvent {
  37288. /**
  37289. * Defines the number of remaining tasks to process
  37290. */
  37291. remainingCount: number;
  37292. /**
  37293. * Defines the total number of tasks
  37294. */
  37295. totalCount: number;
  37296. /**
  37297. * Defines the task that was just processed
  37298. */
  37299. task: AbstractAssetTask;
  37300. }
  37301. /**
  37302. * Class used to share progress information about assets loading
  37303. */
  37304. class AssetsProgressEvent implements IAssetsProgressEvent {
  37305. /**
  37306. * Defines the number of remaining tasks to process
  37307. */
  37308. remainingCount: number;
  37309. /**
  37310. * Defines the total number of tasks
  37311. */
  37312. totalCount: number;
  37313. /**
  37314. * Defines the task that was just processed
  37315. */
  37316. task: AbstractAssetTask;
  37317. /**
  37318. * Creates a AssetsProgressEvent
  37319. * @param remainingCount defines the number of remaining tasks to process
  37320. * @param totalCount defines the total number of tasks
  37321. * @param task defines the task that was just processed
  37322. */
  37323. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37324. }
  37325. /**
  37326. * Define a task used by AssetsManager to load meshes
  37327. */
  37328. class MeshAssetTask extends AbstractAssetTask {
  37329. /**
  37330. * Defines the name of the task
  37331. */
  37332. name: string;
  37333. /**
  37334. * Defines the list of mesh's names you want to load
  37335. */
  37336. meshesNames: any;
  37337. /**
  37338. * Defines the root url to use as a base to load your meshes and associated resources
  37339. */
  37340. rootUrl: string;
  37341. /**
  37342. * Defines the filename of the scene to load from
  37343. */
  37344. sceneFilename: string;
  37345. /**
  37346. * Gets the list of loaded meshes
  37347. */
  37348. loadedMeshes: Array<AbstractMesh>;
  37349. /**
  37350. * Gets the list of loaded particle systems
  37351. */
  37352. loadedParticleSystems: Array<IParticleSystem>;
  37353. /**
  37354. * Gets the list of loaded skeletons
  37355. */
  37356. loadedSkeletons: Array<Skeleton>;
  37357. /**
  37358. * Callback called when the task is successful
  37359. */
  37360. onSuccess: (task: MeshAssetTask) => void;
  37361. /**
  37362. * Callback called when the task is successful
  37363. */
  37364. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37365. /**
  37366. * Creates a new MeshAssetTask
  37367. * @param name defines the name of the task
  37368. * @param meshesNames defines the list of mesh's names you want to load
  37369. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37370. * @param sceneFilename defines the filename of the scene to load from
  37371. */
  37372. constructor(
  37373. /**
  37374. * Defines the name of the task
  37375. */
  37376. name: string,
  37377. /**
  37378. * Defines the list of mesh's names you want to load
  37379. */
  37380. meshesNames: any,
  37381. /**
  37382. * Defines the root url to use as a base to load your meshes and associated resources
  37383. */
  37384. rootUrl: string,
  37385. /**
  37386. * Defines the filename of the scene to load from
  37387. */
  37388. sceneFilename: string);
  37389. /**
  37390. * Execute the current task
  37391. * @param scene defines the scene where you want your assets to be loaded
  37392. * @param onSuccess is a callback called when the task is successfully executed
  37393. * @param onError is a callback called if an error occurs
  37394. */
  37395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37396. }
  37397. /**
  37398. * Define a task used by AssetsManager to load text content
  37399. */
  37400. class TextFileAssetTask extends AbstractAssetTask {
  37401. /**
  37402. * Defines the name of the task
  37403. */
  37404. name: string;
  37405. /**
  37406. * Defines the location of the file to load
  37407. */
  37408. url: string;
  37409. /**
  37410. * Gets the loaded text string
  37411. */
  37412. text: string;
  37413. /**
  37414. * Callback called when the task is successful
  37415. */
  37416. onSuccess: (task: TextFileAssetTask) => void;
  37417. /**
  37418. * Callback called when the task is successful
  37419. */
  37420. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37421. /**
  37422. * Creates a new TextFileAssetTask object
  37423. * @param name defines the name of the task
  37424. * @param url defines the location of the file to load
  37425. */
  37426. constructor(
  37427. /**
  37428. * Defines the name of the task
  37429. */
  37430. name: string,
  37431. /**
  37432. * Defines the location of the file to load
  37433. */
  37434. url: string);
  37435. /**
  37436. * Execute the current task
  37437. * @param scene defines the scene where you want your assets to be loaded
  37438. * @param onSuccess is a callback called when the task is successfully executed
  37439. * @param onError is a callback called if an error occurs
  37440. */
  37441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37442. }
  37443. /**
  37444. * Define a task used by AssetsManager to load binary data
  37445. */
  37446. class BinaryFileAssetTask extends AbstractAssetTask {
  37447. /**
  37448. * Defines the name of the task
  37449. */
  37450. name: string;
  37451. /**
  37452. * Defines the location of the file to load
  37453. */
  37454. url: string;
  37455. /**
  37456. * Gets the lodaded data (as an array buffer)
  37457. */
  37458. data: ArrayBuffer;
  37459. /**
  37460. * Callback called when the task is successful
  37461. */
  37462. onSuccess: (task: BinaryFileAssetTask) => void;
  37463. /**
  37464. * Callback called when the task is successful
  37465. */
  37466. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37467. /**
  37468. * Creates a new BinaryFileAssetTask object
  37469. * @param name defines the name of the new task
  37470. * @param url defines the location of the file to load
  37471. */
  37472. constructor(
  37473. /**
  37474. * Defines the name of the task
  37475. */
  37476. name: string,
  37477. /**
  37478. * Defines the location of the file to load
  37479. */
  37480. url: string);
  37481. /**
  37482. * Execute the current task
  37483. * @param scene defines the scene where you want your assets to be loaded
  37484. * @param onSuccess is a callback called when the task is successfully executed
  37485. * @param onError is a callback called if an error occurs
  37486. */
  37487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37488. }
  37489. /**
  37490. * Define a task used by AssetsManager to load images
  37491. */
  37492. class ImageAssetTask extends AbstractAssetTask {
  37493. /**
  37494. * Defines the name of the task
  37495. */
  37496. name: string;
  37497. /**
  37498. * Defines the location of the image to load
  37499. */
  37500. url: string;
  37501. /**
  37502. * Gets the loaded images
  37503. */
  37504. image: HTMLImageElement;
  37505. /**
  37506. * Callback called when the task is successful
  37507. */
  37508. onSuccess: (task: ImageAssetTask) => void;
  37509. /**
  37510. * Callback called when the task is successful
  37511. */
  37512. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37513. /**
  37514. * Creates a new ImageAssetTask
  37515. * @param name defines the name of the task
  37516. * @param url defines the location of the image to load
  37517. */
  37518. constructor(
  37519. /**
  37520. * Defines the name of the task
  37521. */
  37522. name: string,
  37523. /**
  37524. * Defines the location of the image to load
  37525. */
  37526. url: string);
  37527. /**
  37528. * Execute the current task
  37529. * @param scene defines the scene where you want your assets to be loaded
  37530. * @param onSuccess is a callback called when the task is successfully executed
  37531. * @param onError is a callback called if an error occurs
  37532. */
  37533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37534. }
  37535. /**
  37536. * Defines the interface used by texture loading tasks
  37537. */
  37538. interface ITextureAssetTask<TEX extends BaseTexture> {
  37539. /**
  37540. * Gets the loaded texture
  37541. */
  37542. texture: TEX;
  37543. }
  37544. /**
  37545. * Define a task used by AssetsManager to load 2D textures
  37546. */
  37547. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37548. /**
  37549. * Defines the name of the task
  37550. */
  37551. name: string;
  37552. /**
  37553. * Defines the location of the file to load
  37554. */
  37555. url: string;
  37556. /**
  37557. * Defines if mipmap should not be generated (default is false)
  37558. */
  37559. noMipmap?: boolean | undefined;
  37560. /**
  37561. * Defines if texture must be inverted on Y axis (default is false)
  37562. */
  37563. invertY?: boolean | undefined;
  37564. /**
  37565. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37566. */
  37567. samplingMode: number;
  37568. /**
  37569. * Gets the loaded texture
  37570. */
  37571. texture: Texture;
  37572. /**
  37573. * Callback called when the task is successful
  37574. */
  37575. onSuccess: (task: TextureAssetTask) => void;
  37576. /**
  37577. * Callback called when the task is successful
  37578. */
  37579. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37580. /**
  37581. * Creates a new TextureAssetTask object
  37582. * @param name defines the name of the task
  37583. * @param url defines the location of the file to load
  37584. * @param noMipmap defines if mipmap should not be generated (default is false)
  37585. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37586. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37587. */
  37588. constructor(
  37589. /**
  37590. * Defines the name of the task
  37591. */
  37592. name: string,
  37593. /**
  37594. * Defines the location of the file to load
  37595. */
  37596. url: string,
  37597. /**
  37598. * Defines if mipmap should not be generated (default is false)
  37599. */
  37600. noMipmap?: boolean | undefined,
  37601. /**
  37602. * Defines if texture must be inverted on Y axis (default is false)
  37603. */
  37604. invertY?: boolean | undefined,
  37605. /**
  37606. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37607. */
  37608. samplingMode?: number);
  37609. /**
  37610. * Execute the current task
  37611. * @param scene defines the scene where you want your assets to be loaded
  37612. * @param onSuccess is a callback called when the task is successfully executed
  37613. * @param onError is a callback called if an error occurs
  37614. */
  37615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37616. }
  37617. /**
  37618. * Define a task used by AssetsManager to load cube textures
  37619. */
  37620. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37621. /**
  37622. * Defines the name of the task
  37623. */
  37624. name: string;
  37625. /**
  37626. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37627. */
  37628. url: string;
  37629. /**
  37630. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37631. */
  37632. extensions?: string[] | undefined;
  37633. /**
  37634. * Defines if mipmaps should not be generated (default is false)
  37635. */
  37636. noMipmap?: boolean | undefined;
  37637. /**
  37638. * Defines the explicit list of files (undefined by default)
  37639. */
  37640. files?: string[] | undefined;
  37641. /**
  37642. * Gets the loaded texture
  37643. */
  37644. texture: CubeTexture;
  37645. /**
  37646. * Callback called when the task is successful
  37647. */
  37648. onSuccess: (task: CubeTextureAssetTask) => void;
  37649. /**
  37650. * Callback called when the task is successful
  37651. */
  37652. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37653. /**
  37654. * Creates a new CubeTextureAssetTask
  37655. * @param name defines the name of the task
  37656. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37657. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37658. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37659. * @param files defines the explicit list of files (undefined by default)
  37660. */
  37661. constructor(
  37662. /**
  37663. * Defines the name of the task
  37664. */
  37665. name: string,
  37666. /**
  37667. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37668. */
  37669. url: string,
  37670. /**
  37671. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37672. */
  37673. extensions?: string[] | undefined,
  37674. /**
  37675. * Defines if mipmaps should not be generated (default is false)
  37676. */
  37677. noMipmap?: boolean | undefined,
  37678. /**
  37679. * Defines the explicit list of files (undefined by default)
  37680. */
  37681. files?: string[] | undefined);
  37682. /**
  37683. * Execute the current task
  37684. * @param scene defines the scene where you want your assets to be loaded
  37685. * @param onSuccess is a callback called when the task is successfully executed
  37686. * @param onError is a callback called if an error occurs
  37687. */
  37688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37689. }
  37690. /**
  37691. * Define a task used by AssetsManager to load HDR cube textures
  37692. */
  37693. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37694. /**
  37695. * Defines the name of the task
  37696. */
  37697. name: string;
  37698. /**
  37699. * Defines the location of the file to load
  37700. */
  37701. url: string;
  37702. /**
  37703. * Defines the desired size (the more it increases the longer the generation will be)
  37704. */
  37705. size: number;
  37706. /**
  37707. * Defines if mipmaps should not be generated (default is false)
  37708. */
  37709. noMipmap: boolean;
  37710. /**
  37711. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37712. */
  37713. generateHarmonics: boolean;
  37714. /**
  37715. * 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)
  37716. */
  37717. gammaSpace: boolean;
  37718. /**
  37719. * Internal Use Only
  37720. */
  37721. reserved: boolean;
  37722. /**
  37723. * Gets the loaded texture
  37724. */
  37725. texture: HDRCubeTexture;
  37726. /**
  37727. * Callback called when the task is successful
  37728. */
  37729. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37730. /**
  37731. * Callback called when the task is successful
  37732. */
  37733. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37734. /**
  37735. * Creates a new HDRCubeTextureAssetTask object
  37736. * @param name defines the name of the task
  37737. * @param url defines the location of the file to load
  37738. * @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.
  37739. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37740. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37741. * @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)
  37742. * @param reserved Internal use only
  37743. */
  37744. constructor(
  37745. /**
  37746. * Defines the name of the task
  37747. */
  37748. name: string,
  37749. /**
  37750. * Defines the location of the file to load
  37751. */
  37752. url: string,
  37753. /**
  37754. * Defines the desired size (the more it increases the longer the generation will be)
  37755. */
  37756. size: number,
  37757. /**
  37758. * Defines if mipmaps should not be generated (default is false)
  37759. */
  37760. noMipmap?: boolean,
  37761. /**
  37762. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37763. */
  37764. generateHarmonics?: boolean,
  37765. /**
  37766. * 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)
  37767. */
  37768. gammaSpace?: boolean,
  37769. /**
  37770. * Internal Use Only
  37771. */
  37772. reserved?: boolean);
  37773. /**
  37774. * Execute the current task
  37775. * @param scene defines the scene where you want your assets to be loaded
  37776. * @param onSuccess is a callback called when the task is successfully executed
  37777. * @param onError is a callback called if an error occurs
  37778. */
  37779. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37780. }
  37781. /**
  37782. * This class can be used to easily import assets into a scene
  37783. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37784. */
  37785. class AssetsManager {
  37786. private _scene;
  37787. private _isLoading;
  37788. protected _tasks: AbstractAssetTask[];
  37789. protected _waitingTasksCount: number;
  37790. protected _totalTasksCount: number;
  37791. /**
  37792. * Callback called when all tasks are processed
  37793. */
  37794. onFinish: (tasks: AbstractAssetTask[]) => void;
  37795. /**
  37796. * Callback called when a task is successful
  37797. */
  37798. onTaskSuccess: (task: AbstractAssetTask) => void;
  37799. /**
  37800. * Callback called when a task had an error
  37801. */
  37802. onTaskError: (task: AbstractAssetTask) => void;
  37803. /**
  37804. * Callback called when a task is done (whatever the result is)
  37805. */
  37806. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37807. /**
  37808. * Observable called when all tasks are processed
  37809. */
  37810. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37811. /**
  37812. * Observable called when a task had an error
  37813. */
  37814. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37815. /**
  37816. * Observable called when a task is successful
  37817. */
  37818. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37819. /**
  37820. * Observable called when a task is done (whatever the result is)
  37821. */
  37822. onProgressObservable: Observable<IAssetsProgressEvent>;
  37823. /**
  37824. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37825. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37826. */
  37827. useDefaultLoadingScreen: boolean;
  37828. /**
  37829. * Creates a new AssetsManager
  37830. * @param scene defines the scene to work on
  37831. */
  37832. constructor(scene: Scene);
  37833. /**
  37834. * Add a MeshAssetTask to the list of active tasks
  37835. * @param taskName defines the name of the new task
  37836. * @param meshesNames defines the name of meshes to load
  37837. * @param rootUrl defines the root url to use to locate files
  37838. * @param sceneFilename defines the filename of the scene file
  37839. * @returns a new MeshAssetTask object
  37840. */
  37841. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37842. /**
  37843. * Add a TextFileAssetTask to the list of active tasks
  37844. * @param taskName defines the name of the new task
  37845. * @param url defines the url of the file to load
  37846. * @returns a new TextFileAssetTask object
  37847. */
  37848. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37849. /**
  37850. * Add a BinaryFileAssetTask to the list of active tasks
  37851. * @param taskName defines the name of the new task
  37852. * @param url defines the url of the file to load
  37853. * @returns a new BinaryFileAssetTask object
  37854. */
  37855. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37856. /**
  37857. * Add a ImageAssetTask to the list of active tasks
  37858. * @param taskName defines the name of the new task
  37859. * @param url defines the url of the file to load
  37860. * @returns a new ImageAssetTask object
  37861. */
  37862. addImageTask(taskName: string, url: string): ImageAssetTask;
  37863. /**
  37864. * Add a TextureAssetTask to the list of active tasks
  37865. * @param taskName defines the name of the new task
  37866. * @param url defines the url of the file to load
  37867. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37868. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37869. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37870. * @returns a new TextureAssetTask object
  37871. */
  37872. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37873. /**
  37874. * Add a CubeTextureAssetTask to the list of active tasks
  37875. * @param taskName defines the name of the new task
  37876. * @param url defines the url of the file to load
  37877. * @param extensions defines the extension to use to load the cube map (can be null)
  37878. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37879. * @param files defines the list of files to load (can be null)
  37880. * @returns a new CubeTextureAssetTask object
  37881. */
  37882. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37883. /**
  37884. *
  37885. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37886. * @param taskName defines the name of the new task
  37887. * @param url defines the url of the file to load
  37888. * @param size defines the size you want for the cubemap (can be null)
  37889. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37890. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37891. * @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)
  37892. * @param reserved Internal use only
  37893. * @returns a new HDRCubeTextureAssetTask object
  37894. */
  37895. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37896. /**
  37897. * Remove a task from the assets manager.
  37898. * @param task the task to remove
  37899. */
  37900. removeTask(task: AbstractAssetTask): void;
  37901. private _decreaseWaitingTasksCount;
  37902. private _runTask;
  37903. /**
  37904. * Reset the AssetsManager and remove all tasks
  37905. * @return the current instance of the AssetsManager
  37906. */
  37907. reset(): AssetsManager;
  37908. /**
  37909. * Start the loading process
  37910. * @return the current instance of the AssetsManager
  37911. */
  37912. load(): AssetsManager;
  37913. }
  37914. }
  37915. declare module BABYLON {
  37916. /**
  37917. * Direct draw surface info
  37918. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37919. */
  37920. interface DDSInfo {
  37921. /**
  37922. * Width of the texture
  37923. */
  37924. width: number;
  37925. /**
  37926. * Width of the texture
  37927. */
  37928. height: number;
  37929. /**
  37930. * Number of Mipmaps for the texture
  37931. * @see https://en.wikipedia.org/wiki/Mipmap
  37932. */
  37933. mipmapCount: number;
  37934. /**
  37935. * If the textures format is a known fourCC format
  37936. * @see https://www.fourcc.org/
  37937. */
  37938. isFourCC: boolean;
  37939. /**
  37940. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37941. */
  37942. isRGB: boolean;
  37943. /**
  37944. * If the texture is a lumincance format
  37945. */
  37946. isLuminance: boolean;
  37947. /**
  37948. * If this is a cube texture
  37949. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37950. */
  37951. isCube: boolean;
  37952. /**
  37953. * If the texture is a compressed format eg. FOURCC_DXT1
  37954. */
  37955. isCompressed: boolean;
  37956. /**
  37957. * The dxgiFormat of the texture
  37958. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37959. */
  37960. dxgiFormat: number;
  37961. /**
  37962. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37963. */
  37964. textureType: number;
  37965. /**
  37966. * Sphericle polynomial created for the dds texture
  37967. */
  37968. sphericalPolynomial?: SphericalPolynomial;
  37969. }
  37970. /**
  37971. * Class used to provide DDS decompression tools
  37972. */
  37973. class DDSTools {
  37974. /**
  37975. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37976. */
  37977. static StoreLODInAlphaChannel: boolean;
  37978. /**
  37979. * Gets DDS information from an array buffer
  37980. * @param arrayBuffer defines the array buffer to read data from
  37981. * @returns the DDS information
  37982. */
  37983. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37984. private static _FloatView;
  37985. private static _Int32View;
  37986. private static _ToHalfFloat;
  37987. private static _FromHalfFloat;
  37988. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37989. private static _GetHalfFloatRGBAArrayBuffer;
  37990. private static _GetFloatRGBAArrayBuffer;
  37991. private static _GetFloatAsUIntRGBAArrayBuffer;
  37992. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37993. private static _GetRGBAArrayBuffer;
  37994. private static _ExtractLongWordOrder;
  37995. private static _GetRGBArrayBuffer;
  37996. private static _GetLuminanceArrayBuffer;
  37997. /**
  37998. * Uploads DDS Levels to a Babylon Texture
  37999. * @hidden
  38000. */
  38001. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38006. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38007. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38008. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38009. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38010. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38011. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38012. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38013. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38014. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38015. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38016. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38017. /**
  38018. * Decorator used to define property that can be serialized as reference to a camera
  38019. * @param sourceName defines the name of the property to decorate
  38020. */
  38021. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38022. /**
  38023. * Class used to help serialization objects
  38024. */
  38025. class SerializationHelper {
  38026. /**
  38027. * Static function used to serialized a specific entity
  38028. * @param entity defines the entity to serialize
  38029. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38030. * @returns a JSON compatible object representing the serialization of the entity
  38031. */
  38032. static Serialize<T>(entity: T, serializationObject?: any): any;
  38033. /**
  38034. * Creates a new entity from a serialization data object
  38035. * @param creationFunction defines a function used to instanciated the new entity
  38036. * @param source defines the source serialization data
  38037. * @param scene defines the hosting scene
  38038. * @param rootUrl defines the root url for resources
  38039. * @returns a new entity
  38040. */
  38041. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38042. /**
  38043. * Clones an object
  38044. * @param creationFunction defines the function used to instanciate the new object
  38045. * @param source defines the source object
  38046. * @returns the cloned object
  38047. */
  38048. static Clone<T>(creationFunction: () => T, source: T): T;
  38049. /**
  38050. * Instanciates a new object based on a source one (some data will be shared between both object)
  38051. * @param creationFunction defines the function used to instanciate the new object
  38052. * @param source defines the source object
  38053. * @returns the new object
  38054. */
  38055. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. /**
  38060. * Wrapper class for promise with external resolve and reject.
  38061. */
  38062. class Deferred<T> {
  38063. /**
  38064. * The promise associated with this deferred object.
  38065. */
  38066. readonly promise: Promise<T>;
  38067. private _resolve;
  38068. private _reject;
  38069. /**
  38070. * The resolve method of the promise associated with this deferred object.
  38071. */
  38072. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38073. /**
  38074. * The reject method of the promise associated with this deferred object.
  38075. */
  38076. readonly reject: (reason?: any) => void;
  38077. /**
  38078. * Constructor for this deferred object.
  38079. */
  38080. constructor();
  38081. }
  38082. }
  38083. declare module BABYLON {
  38084. /**
  38085. * Raw texture data and descriptor sufficient for WebGL texture upload
  38086. */
  38087. interface EnvironmentTextureInfo {
  38088. /**
  38089. * Version of the environment map
  38090. */
  38091. version: number;
  38092. /**
  38093. * Width of image
  38094. */
  38095. width: number;
  38096. /**
  38097. * Irradiance information stored in the file.
  38098. */
  38099. irradiance: any;
  38100. /**
  38101. * Specular information stored in the file.
  38102. */
  38103. specular: any;
  38104. }
  38105. /**
  38106. * Sets of helpers addressing the serialization and deserialization of environment texture
  38107. * stored in a BabylonJS env file.
  38108. * Those files are usually stored as .env files.
  38109. */
  38110. class EnvironmentTextureTools {
  38111. /**
  38112. * Magic number identifying the env file.
  38113. */
  38114. private static _MagicBytes;
  38115. /**
  38116. * Gets the environment info from an env file.
  38117. * @param data The array buffer containing the .env bytes.
  38118. * @returns the environment file info (the json header) if successfully parsed.
  38119. */
  38120. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38121. /**
  38122. * Creates an environment texture from a loaded cube texture.
  38123. * @param texture defines the cube texture to convert in env file
  38124. * @return a promise containing the environment data if succesfull.
  38125. */
  38126. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38127. /**
  38128. * Creates a JSON representation of the spherical data.
  38129. * @param texture defines the texture containing the polynomials
  38130. * @return the JSON representation of the spherical info
  38131. */
  38132. private static _CreateEnvTextureIrradiance;
  38133. /**
  38134. * Uploads the texture info contained in the env file to the GPU.
  38135. * @param texture defines the internal texture to upload to
  38136. * @param arrayBuffer defines the buffer cotaining the data to load
  38137. * @param info defines the texture info retrieved through the GetEnvInfo method
  38138. * @returns a promise
  38139. */
  38140. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38141. /**
  38142. * Uploads the levels of image data to the GPU.
  38143. * @param texture defines the internal texture to upload to
  38144. * @param imageData defines the array buffer views of image data [mipmap][face]
  38145. * @returns a promise
  38146. */
  38147. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38148. /**
  38149. * Uploads spherical polynomials information to the texture.
  38150. * @param texture defines the texture we are trying to upload the information to
  38151. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38152. */
  38153. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38154. }
  38155. }
  38156. declare module BABYLON {
  38157. /**
  38158. * Class used to help managing file picking and drag'n'drop
  38159. */
  38160. class FilesInput {
  38161. /**
  38162. * List of files ready to be loaded
  38163. */
  38164. static FilesToLoad: {
  38165. [key: string]: File;
  38166. };
  38167. /**
  38168. * Callback called when a file is processed
  38169. */
  38170. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38171. private _engine;
  38172. private _currentScene;
  38173. private _sceneLoadedCallback;
  38174. private _progressCallback;
  38175. private _additionalRenderLoopLogicCallback;
  38176. private _textureLoadingCallback;
  38177. private _startingProcessingFilesCallback;
  38178. private _onReloadCallback;
  38179. private _errorCallback;
  38180. private _elementToMonitor;
  38181. private _sceneFileToLoad;
  38182. private _filesToLoad;
  38183. /**
  38184. * Creates a new FilesInput
  38185. * @param engine defines the rendering engine
  38186. * @param scene defines the hosting scene
  38187. * @param sceneLoadedCallback callback called when scene is loaded
  38188. * @param progressCallback callback called to track progress
  38189. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38190. * @param textureLoadingCallback callback called when a texture is loading
  38191. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38192. * @param onReloadCallback callback called when a reload is requested
  38193. * @param errorCallback callback call if an error occurs
  38194. */
  38195. 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);
  38196. private _dragEnterHandler;
  38197. private _dragOverHandler;
  38198. private _dropHandler;
  38199. /**
  38200. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38201. * @param elementToMonitor defines the DOM element to track
  38202. */
  38203. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38204. /**
  38205. * Release all associated resources
  38206. */
  38207. dispose(): void;
  38208. private renderFunction;
  38209. private drag;
  38210. private drop;
  38211. private _traverseFolder;
  38212. private _processFiles;
  38213. /**
  38214. * Load files from a drop event
  38215. * @param event defines the drop event to use as source
  38216. */
  38217. loadFiles(event: any): void;
  38218. private _processReload;
  38219. /**
  38220. * Reload the current scene from the loaded files
  38221. */
  38222. reload(): void;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. /**
  38227. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38228. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38229. */
  38230. class KhronosTextureContainer {
  38231. /** contents of the KTX container file */
  38232. arrayBuffer: any;
  38233. private static HEADER_LEN;
  38234. private static COMPRESSED_2D;
  38235. private static COMPRESSED_3D;
  38236. private static TEX_2D;
  38237. private static TEX_3D;
  38238. /**
  38239. * Gets the openGL type
  38240. */
  38241. glType: number;
  38242. /**
  38243. * Gets the openGL type size
  38244. */
  38245. glTypeSize: number;
  38246. /**
  38247. * Gets the openGL format
  38248. */
  38249. glFormat: number;
  38250. /**
  38251. * Gets the openGL internal format
  38252. */
  38253. glInternalFormat: number;
  38254. /**
  38255. * Gets the base internal format
  38256. */
  38257. glBaseInternalFormat: number;
  38258. /**
  38259. * Gets image width in pixel
  38260. */
  38261. pixelWidth: number;
  38262. /**
  38263. * Gets image height in pixel
  38264. */
  38265. pixelHeight: number;
  38266. /**
  38267. * Gets image depth in pixels
  38268. */
  38269. pixelDepth: number;
  38270. /**
  38271. * Gets the number of array elements
  38272. */
  38273. numberOfArrayElements: number;
  38274. /**
  38275. * Gets the number of faces
  38276. */
  38277. numberOfFaces: number;
  38278. /**
  38279. * Gets the number of mipmap levels
  38280. */
  38281. numberOfMipmapLevels: number;
  38282. /**
  38283. * Gets the bytes of key value data
  38284. */
  38285. bytesOfKeyValueData: number;
  38286. /**
  38287. * Gets the load type
  38288. */
  38289. loadType: number;
  38290. /**
  38291. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38292. */
  38293. isInvalid: boolean;
  38294. /**
  38295. * Creates a new KhronosTextureContainer
  38296. * @param arrayBuffer contents of the KTX container file
  38297. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38298. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38299. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38300. */
  38301. constructor(
  38302. /** contents of the KTX container file */
  38303. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38304. /**
  38305. * Revert the endianness of a value.
  38306. * Not as fast hardware based, but will probably never need to use
  38307. * @param val defines the value to convert
  38308. * @returns the new value
  38309. */
  38310. switchEndianness(val: number): number;
  38311. /**
  38312. * Uploads KTX content to a Babylon Texture.
  38313. * It is assumed that the texture has already been created & is currently bound
  38314. * @hidden
  38315. */
  38316. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38317. private _upload2DCompressedLevels;
  38318. }
  38319. }
  38320. declare module BABYLON {
  38321. /**
  38322. * A class serves as a medium between the observable and its observers
  38323. */
  38324. class EventState {
  38325. /**
  38326. * Create a new EventState
  38327. * @param mask defines the mask associated with this state
  38328. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38329. * @param target defines the original target of the state
  38330. * @param currentTarget defines the current target of the state
  38331. */
  38332. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38333. /**
  38334. * Initialize the current event state
  38335. * @param mask defines the mask associated with this state
  38336. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38337. * @param target defines the original target of the state
  38338. * @param currentTarget defines the current target of the state
  38339. * @returns the current event state
  38340. */
  38341. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38342. /**
  38343. * An Observer can set this property to true to prevent subsequent observers of being notified
  38344. */
  38345. skipNextObservers: boolean;
  38346. /**
  38347. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38348. */
  38349. mask: number;
  38350. /**
  38351. * The object that originally notified the event
  38352. */
  38353. target?: any;
  38354. /**
  38355. * The current object in the bubbling phase
  38356. */
  38357. currentTarget?: any;
  38358. /**
  38359. * This will be populated with the return value of the last function that was executed.
  38360. * If it is the first function in the callback chain it will be the event data.
  38361. */
  38362. lastReturnValue?: any;
  38363. }
  38364. /**
  38365. * Represent an Observer registered to a given Observable object.
  38366. */
  38367. class Observer<T> {
  38368. /**
  38369. * Defines the callback to call when the observer is notified
  38370. */
  38371. callback: (eventData: T, eventState: EventState) => void;
  38372. /**
  38373. * Defines the mask of the observer (used to filter notifications)
  38374. */
  38375. mask: number;
  38376. /**
  38377. * Defines the current scope used to restore the JS context
  38378. */
  38379. scope: any;
  38380. /** @hidden */
  38381. _willBeUnregistered: boolean;
  38382. /**
  38383. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38384. */
  38385. unregisterOnNextCall: boolean;
  38386. /**
  38387. * Creates a new observer
  38388. * @param callback defines the callback to call when the observer is notified
  38389. * @param mask defines the mask of the observer (used to filter notifications)
  38390. * @param scope defines the current scope used to restore the JS context
  38391. */
  38392. constructor(
  38393. /**
  38394. * Defines the callback to call when the observer is notified
  38395. */
  38396. callback: (eventData: T, eventState: EventState) => void,
  38397. /**
  38398. * Defines the mask of the observer (used to filter notifications)
  38399. */
  38400. mask: number,
  38401. /**
  38402. * Defines the current scope used to restore the JS context
  38403. */
  38404. scope?: any);
  38405. }
  38406. /**
  38407. * Represent a list of observers registered to multiple Observables object.
  38408. */
  38409. class MultiObserver<T> {
  38410. private _observers;
  38411. private _observables;
  38412. /**
  38413. * Release associated resources
  38414. */
  38415. dispose(): void;
  38416. /**
  38417. * Raise a callback when one of the observable will notify
  38418. * @param observables defines a list of observables to watch
  38419. * @param callback defines the callback to call on notification
  38420. * @param mask defines the mask used to filter notifications
  38421. * @param scope defines the current scope used to restore the JS context
  38422. * @returns the new MultiObserver
  38423. */
  38424. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38425. }
  38426. /**
  38427. * The Observable class is a simple implementation of the Observable pattern.
  38428. *
  38429. * 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.
  38430. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38431. * 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).
  38432. * 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.
  38433. */
  38434. class Observable<T> {
  38435. private _observers;
  38436. private _eventState;
  38437. private _onObserverAdded;
  38438. /**
  38439. * Creates a new observable
  38440. * @param onObserverAdded defines a callback to call when a new observer is added
  38441. */
  38442. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38443. /**
  38444. * Create a new Observer with the specified callback
  38445. * @param callback the callback that will be executed for that Observer
  38446. * @param mask the mask used to filter observers
  38447. * @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.
  38448. * @param scope optional scope for the callback to be called from
  38449. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38450. * @returns the new observer created for the callback
  38451. */
  38452. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38453. /**
  38454. * Create a new Observer with the specified callback and unregisters after the next notification
  38455. * @param callback the callback that will be executed for that Observer
  38456. * @returns the new observer created for the callback
  38457. */
  38458. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38459. /**
  38460. * Remove an Observer from the Observable object
  38461. * @param observer the instance of the Observer to remove
  38462. * @returns false if it doesn't belong to this Observable
  38463. */
  38464. remove(observer: Nullable<Observer<T>>): boolean;
  38465. /**
  38466. * Remove a callback from the Observable object
  38467. * @param callback the callback to remove
  38468. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38469. * @returns false if it doesn't belong to this Observable
  38470. */
  38471. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38472. private _deferUnregister;
  38473. private _remove;
  38474. /**
  38475. * Notify all Observers by calling their respective callback with the given data
  38476. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38477. * @param eventData defines the data to send to all observers
  38478. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38479. * @param target defines the original target of the state
  38480. * @param currentTarget defines the current target of the state
  38481. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38482. */
  38483. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38484. /**
  38485. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38486. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38487. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38488. * and it is crucial that all callbacks will be executed.
  38489. * The order of the callbacks is kept, callbacks are not executed parallel.
  38490. *
  38491. * @param eventData The data to be sent to each callback
  38492. * @param mask is used to filter observers defaults to -1
  38493. * @param target defines the callback target (see EventState)
  38494. * @param currentTarget defines he current object in the bubbling phase
  38495. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38496. */
  38497. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38498. /**
  38499. * Notify a specific observer
  38500. * @param observer defines the observer to notify
  38501. * @param eventData defines the data to be sent to each callback
  38502. * @param mask is used to filter observers defaults to -1
  38503. */
  38504. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38505. /**
  38506. * Gets a boolean indicating if the observable has at least one observer
  38507. * @returns true is the Observable has at least one Observer registered
  38508. */
  38509. hasObservers(): boolean;
  38510. /**
  38511. * Clear the list of observers
  38512. */
  38513. clear(): void;
  38514. /**
  38515. * Clone the current observable
  38516. * @returns a new observable
  38517. */
  38518. clone(): Observable<T>;
  38519. /**
  38520. * Does this observable handles observer registered with a given mask
  38521. * @param mask defines the mask to be tested
  38522. * @return whether or not one observer registered with the given mask is handeled
  38523. **/
  38524. hasSpecificMask(mask?: number): boolean;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38530. */
  38531. class PerformanceMonitor {
  38532. private _enabled;
  38533. private _rollingFrameTime;
  38534. private _lastFrameTimeMs;
  38535. /**
  38536. * constructor
  38537. * @param frameSampleSize The number of samples required to saturate the sliding window
  38538. */
  38539. constructor(frameSampleSize?: number);
  38540. /**
  38541. * Samples current frame
  38542. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38543. */
  38544. sampleFrame(timeMs?: number): void;
  38545. /**
  38546. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38547. */
  38548. readonly averageFrameTime: number;
  38549. /**
  38550. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38551. */
  38552. readonly averageFrameTimeVariance: number;
  38553. /**
  38554. * Returns the frame time of the most recent frame
  38555. */
  38556. readonly instantaneousFrameTime: number;
  38557. /**
  38558. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38559. */
  38560. readonly averageFPS: number;
  38561. /**
  38562. * Returns the average framerate in frames per second using the most recent frame time
  38563. */
  38564. readonly instantaneousFPS: number;
  38565. /**
  38566. * Returns true if enough samples have been taken to completely fill the sliding window
  38567. */
  38568. readonly isSaturated: boolean;
  38569. /**
  38570. * Enables contributions to the sliding window sample set
  38571. */
  38572. enable(): void;
  38573. /**
  38574. * Disables contributions to the sliding window sample set
  38575. * Samples will not be interpolated over the disabled period
  38576. */
  38577. disable(): void;
  38578. /**
  38579. * Returns true if sampling is enabled
  38580. */
  38581. readonly isEnabled: boolean;
  38582. /**
  38583. * Resets performance monitor
  38584. */
  38585. reset(): void;
  38586. }
  38587. /**
  38588. * RollingAverage
  38589. *
  38590. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38591. */
  38592. class RollingAverage {
  38593. /**
  38594. * Current average
  38595. */
  38596. average: number;
  38597. /**
  38598. * Current variance
  38599. */
  38600. variance: number;
  38601. protected _samples: Array<number>;
  38602. protected _sampleCount: number;
  38603. protected _pos: number;
  38604. protected _m2: number;
  38605. /**
  38606. * constructor
  38607. * @param length The number of samples required to saturate the sliding window
  38608. */
  38609. constructor(length: number);
  38610. /**
  38611. * Adds a sample to the sample set
  38612. * @param v The sample value
  38613. */
  38614. add(v: number): void;
  38615. /**
  38616. * Returns previously added values or null if outside of history or outside the sliding window domain
  38617. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38618. * @return Value previously recorded with add() or null if outside of range
  38619. */
  38620. history(i: number): number;
  38621. /**
  38622. * Returns true if enough samples have been taken to completely fill the sliding window
  38623. * @return true if sample-set saturated
  38624. */
  38625. isSaturated(): boolean;
  38626. /**
  38627. * Resets the rolling average (equivalent to 0 samples taken so far)
  38628. */
  38629. reset(): void;
  38630. /**
  38631. * Wraps a value around the sample range boundaries
  38632. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38633. * @return Wrapped position in sample range
  38634. */
  38635. protected _wrapPosition(i: number): number;
  38636. }
  38637. }
  38638. declare module BABYLON {
  38639. /**
  38640. * Helper class that provides a small promise polyfill
  38641. */
  38642. class PromisePolyfill {
  38643. /**
  38644. * Static function used to check if the polyfill is required
  38645. * If this is the case then the function will inject the polyfill to window.Promise
  38646. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38647. */
  38648. static Apply(force?: boolean): void;
  38649. }
  38650. }
  38651. declare module BABYLON {
  38652. /**
  38653. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38655. */
  38656. class SceneOptimization {
  38657. /**
  38658. * Defines the priority of this optimization (0 by default which means first in the list)
  38659. */
  38660. priority: number;
  38661. /**
  38662. * Gets a string describing the action executed by the current optimization
  38663. * @returns description string
  38664. */
  38665. getDescription(): string;
  38666. /**
  38667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38668. * @param scene defines the current scene where to apply this optimization
  38669. * @param optimizer defines the current optimizer
  38670. * @returns true if everything that can be done was applied
  38671. */
  38672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38673. /**
  38674. * Creates the SceneOptimization object
  38675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38676. * @param desc defines the description associated with the optimization
  38677. */
  38678. constructor(
  38679. /**
  38680. * Defines the priority of this optimization (0 by default which means first in the list)
  38681. */
  38682. priority?: number);
  38683. }
  38684. /**
  38685. * Defines an optimization used to reduce the size of render target textures
  38686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38687. */
  38688. class TextureOptimization extends SceneOptimization {
  38689. /**
  38690. * Defines the priority of this optimization (0 by default which means first in the list)
  38691. */
  38692. priority: number;
  38693. /**
  38694. * 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
  38695. */
  38696. maximumSize: number;
  38697. /**
  38698. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38699. */
  38700. step: number;
  38701. /**
  38702. * Gets a string describing the action executed by the current optimization
  38703. * @returns description string
  38704. */
  38705. getDescription(): string;
  38706. /**
  38707. * Creates the TextureOptimization object
  38708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38709. * @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
  38710. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38711. */
  38712. constructor(
  38713. /**
  38714. * Defines the priority of this optimization (0 by default which means first in the list)
  38715. */
  38716. priority?: number,
  38717. /**
  38718. * 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
  38719. */
  38720. maximumSize?: number,
  38721. /**
  38722. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38723. */
  38724. step?: number);
  38725. /**
  38726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38727. * @param scene defines the current scene where to apply this optimization
  38728. * @param optimizer defines the current optimizer
  38729. * @returns true if everything that can be done was applied
  38730. */
  38731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38732. }
  38733. /**
  38734. * Defines an optimization used to increase or decrease the rendering resolution
  38735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38736. */
  38737. class HardwareScalingOptimization extends SceneOptimization {
  38738. /**
  38739. * Defines the priority of this optimization (0 by default which means first in the list)
  38740. */
  38741. priority: number;
  38742. /**
  38743. * Defines the maximum scale to use (2 by default)
  38744. */
  38745. maximumScale: number;
  38746. /**
  38747. * Defines the step to use between two passes (0.5 by default)
  38748. */
  38749. step: number;
  38750. private _currentScale;
  38751. private _directionOffset;
  38752. /**
  38753. * Gets a string describing the action executed by the current optimization
  38754. * @return description string
  38755. */
  38756. getDescription(): string;
  38757. /**
  38758. * Creates the HardwareScalingOptimization object
  38759. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38760. * @param maximumScale defines the maximum scale to use (2 by default)
  38761. * @param step defines the step to use between two passes (0.5 by default)
  38762. */
  38763. constructor(
  38764. /**
  38765. * Defines the priority of this optimization (0 by default which means first in the list)
  38766. */
  38767. priority?: number,
  38768. /**
  38769. * Defines the maximum scale to use (2 by default)
  38770. */
  38771. maximumScale?: number,
  38772. /**
  38773. * Defines the step to use between two passes (0.5 by default)
  38774. */
  38775. step?: number);
  38776. /**
  38777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38778. * @param scene defines the current scene where to apply this optimization
  38779. * @param optimizer defines the current optimizer
  38780. * @returns true if everything that can be done was applied
  38781. */
  38782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38783. }
  38784. /**
  38785. * Defines an optimization used to remove shadows
  38786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38787. */
  38788. class ShadowsOptimization extends SceneOptimization {
  38789. /**
  38790. * Gets a string describing the action executed by the current optimization
  38791. * @return description string
  38792. */
  38793. getDescription(): string;
  38794. /**
  38795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38796. * @param scene defines the current scene where to apply this optimization
  38797. * @param optimizer defines the current optimizer
  38798. * @returns true if everything that can be done was applied
  38799. */
  38800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38801. }
  38802. /**
  38803. * Defines an optimization used to turn post-processes off
  38804. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38805. */
  38806. class PostProcessesOptimization extends SceneOptimization {
  38807. /**
  38808. * Gets a string describing the action executed by the current optimization
  38809. * @return description string
  38810. */
  38811. getDescription(): string;
  38812. /**
  38813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38814. * @param scene defines the current scene where to apply this optimization
  38815. * @param optimizer defines the current optimizer
  38816. * @returns true if everything that can be done was applied
  38817. */
  38818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38819. }
  38820. /**
  38821. * Defines an optimization used to turn lens flares off
  38822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38823. */
  38824. class LensFlaresOptimization extends SceneOptimization {
  38825. /**
  38826. * Gets a string describing the action executed by the current optimization
  38827. * @return description string
  38828. */
  38829. getDescription(): string;
  38830. /**
  38831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38832. * @param scene defines the current scene where to apply this optimization
  38833. * @param optimizer defines the current optimizer
  38834. * @returns true if everything that can be done was applied
  38835. */
  38836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38837. }
  38838. /**
  38839. * Defines an optimization based on user defined callback.
  38840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38841. */
  38842. class CustomOptimization extends SceneOptimization {
  38843. /**
  38844. * Callback called to apply the custom optimization.
  38845. */
  38846. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38847. /**
  38848. * Callback called to get custom description
  38849. */
  38850. onGetDescription: () => string;
  38851. /**
  38852. * Gets a string describing the action executed by the current optimization
  38853. * @returns description string
  38854. */
  38855. getDescription(): string;
  38856. /**
  38857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38858. * @param scene defines the current scene where to apply this optimization
  38859. * @param optimizer defines the current optimizer
  38860. * @returns true if everything that can be done was applied
  38861. */
  38862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38863. }
  38864. /**
  38865. * Defines an optimization used to turn particles off
  38866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38867. */
  38868. class ParticlesOptimization extends SceneOptimization {
  38869. /**
  38870. * Gets a string describing the action executed by the current optimization
  38871. * @return description string
  38872. */
  38873. getDescription(): string;
  38874. /**
  38875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38876. * @param scene defines the current scene where to apply this optimization
  38877. * @param optimizer defines the current optimizer
  38878. * @returns true if everything that can be done was applied
  38879. */
  38880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38881. }
  38882. /**
  38883. * Defines an optimization used to turn render targets off
  38884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38885. */
  38886. class RenderTargetsOptimization extends SceneOptimization {
  38887. /**
  38888. * Gets a string describing the action executed by the current optimization
  38889. * @return description string
  38890. */
  38891. getDescription(): string;
  38892. /**
  38893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38894. * @param scene defines the current scene where to apply this optimization
  38895. * @param optimizer defines the current optimizer
  38896. * @returns true if everything that can be done was applied
  38897. */
  38898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38899. }
  38900. /**
  38901. * Defines an optimization used to merge meshes with compatible materials
  38902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38903. */
  38904. class MergeMeshesOptimization extends SceneOptimization {
  38905. private static _UpdateSelectionTree;
  38906. /**
  38907. * Gets or sets a boolean which defines if optimization octree has to be updated
  38908. */
  38909. /**
  38910. * Gets or sets a boolean which defines if optimization octree has to be updated
  38911. */
  38912. static UpdateSelectionTree: boolean;
  38913. /**
  38914. * Gets a string describing the action executed by the current optimization
  38915. * @return description string
  38916. */
  38917. getDescription(): string;
  38918. private _canBeMerged;
  38919. /**
  38920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38921. * @param scene defines the current scene where to apply this optimization
  38922. * @param optimizer defines the current optimizer
  38923. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38924. * @returns true if everything that can be done was applied
  38925. */
  38926. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38927. }
  38928. /**
  38929. * Defines a list of options used by SceneOptimizer
  38930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38931. */
  38932. class SceneOptimizerOptions {
  38933. /**
  38934. * Defines the target frame rate to reach (60 by default)
  38935. */
  38936. targetFrameRate: number;
  38937. /**
  38938. * Defines the interval between two checkes (2000ms by default)
  38939. */
  38940. trackerDuration: number;
  38941. /**
  38942. * Gets the list of optimizations to apply
  38943. */
  38944. optimizations: SceneOptimization[];
  38945. /**
  38946. * Creates a new list of options used by SceneOptimizer
  38947. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38948. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38949. */
  38950. constructor(
  38951. /**
  38952. * Defines the target frame rate to reach (60 by default)
  38953. */
  38954. targetFrameRate?: number,
  38955. /**
  38956. * Defines the interval between two checkes (2000ms by default)
  38957. */
  38958. trackerDuration?: number);
  38959. /**
  38960. * Add a new optimization
  38961. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38962. * @returns the current SceneOptimizerOptions
  38963. */
  38964. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38965. /**
  38966. * Add a new custom optimization
  38967. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38968. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38969. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38970. * @returns the current SceneOptimizerOptions
  38971. */
  38972. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38973. /**
  38974. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38975. * @param targetFrameRate defines the target frame rate (60 by default)
  38976. * @returns a SceneOptimizerOptions object
  38977. */
  38978. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38979. /**
  38980. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38981. * @param targetFrameRate defines the target frame rate (60 by default)
  38982. * @returns a SceneOptimizerOptions object
  38983. */
  38984. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38985. /**
  38986. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38987. * @param targetFrameRate defines the target frame rate (60 by default)
  38988. * @returns a SceneOptimizerOptions object
  38989. */
  38990. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38991. }
  38992. /**
  38993. * Class used to run optimizations in order to reach a target frame rate
  38994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38995. */
  38996. class SceneOptimizer implements IDisposable {
  38997. private _isRunning;
  38998. private _options;
  38999. private _scene;
  39000. private _currentPriorityLevel;
  39001. private _targetFrameRate;
  39002. private _trackerDuration;
  39003. private _currentFrameRate;
  39004. private _sceneDisposeObserver;
  39005. private _improvementMode;
  39006. /**
  39007. * Defines an observable called when the optimizer reaches the target frame rate
  39008. */
  39009. onSuccessObservable: Observable<SceneOptimizer>;
  39010. /**
  39011. * Defines an observable called when the optimizer enables an optimization
  39012. */
  39013. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39014. /**
  39015. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39016. */
  39017. onFailureObservable: Observable<SceneOptimizer>;
  39018. /**
  39019. * Gets a boolean indicating if the optimizer is in improvement mode
  39020. */
  39021. readonly isInImprovementMode: boolean;
  39022. /**
  39023. * Gets the current priority level (0 at start)
  39024. */
  39025. readonly currentPriorityLevel: number;
  39026. /**
  39027. * Gets the current frame rate checked by the SceneOptimizer
  39028. */
  39029. readonly currentFrameRate: number;
  39030. /**
  39031. * Gets or sets the current target frame rate (60 by default)
  39032. */
  39033. /**
  39034. * Gets or sets the current target frame rate (60 by default)
  39035. */
  39036. targetFrameRate: number;
  39037. /**
  39038. * Gets or sets the current interval between two checks (every 2000ms by default)
  39039. */
  39040. /**
  39041. * Gets or sets the current interval between two checks (every 2000ms by default)
  39042. */
  39043. trackerDuration: number;
  39044. /**
  39045. * Gets the list of active optimizations
  39046. */
  39047. readonly optimizations: SceneOptimization[];
  39048. /**
  39049. * Creates a new SceneOptimizer
  39050. * @param scene defines the scene to work on
  39051. * @param options defines the options to use with the SceneOptimizer
  39052. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39053. * @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)
  39054. */
  39055. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39056. /**
  39057. * Stops the current optimizer
  39058. */
  39059. stop(): void;
  39060. /**
  39061. * Reset the optimizer to initial step (current priority level = 0)
  39062. */
  39063. reset(): void;
  39064. /**
  39065. * Start the optimizer. By default it will try to reach a specific framerate
  39066. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39067. */
  39068. start(): void;
  39069. private _checkCurrentState;
  39070. /**
  39071. * Release all resources
  39072. */
  39073. dispose(): void;
  39074. /**
  39075. * Helper function to create a SceneOptimizer with one single line of code
  39076. * @param scene defines the scene to work on
  39077. * @param options defines the options to use with the SceneOptimizer
  39078. * @param onSuccess defines a callback to call on success
  39079. * @param onFailure defines a callback to call on failure
  39080. * @returns the new SceneOptimizer object
  39081. */
  39082. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39083. }
  39084. }
  39085. declare module BABYLON {
  39086. /**
  39087. * Class used to serialize a scene into a string
  39088. */
  39089. class SceneSerializer {
  39090. /**
  39091. * Clear cache used by a previous serialization
  39092. */
  39093. static ClearCache(): void;
  39094. /**
  39095. * Serialize a scene into a JSON compatible object
  39096. * @param scene defines the scene to serialize
  39097. * @returns a JSON compatible object
  39098. */
  39099. static Serialize(scene: Scene): any;
  39100. /**
  39101. * Serialize a mesh into a JSON compatible object
  39102. * @param toSerialize defines the mesh to serialize
  39103. * @param withParents defines if parents must be serialized as well
  39104. * @param withChildren defines if children must be serialized as well
  39105. * @returns a JSON compatible object
  39106. */
  39107. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39108. }
  39109. }
  39110. declare module BABYLON {
  39111. /**
  39112. * Defines an array and its length.
  39113. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39114. */
  39115. interface ISmartArrayLike<T> {
  39116. /**
  39117. * The data of the array.
  39118. */
  39119. data: Array<T>;
  39120. /**
  39121. * The active length of the array.
  39122. */
  39123. length: number;
  39124. }
  39125. /**
  39126. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39127. */
  39128. class SmartArray<T> implements ISmartArrayLike<T> {
  39129. /**
  39130. * The full set of data from the array.
  39131. */
  39132. data: Array<T>;
  39133. /**
  39134. * The active length of the array.
  39135. */
  39136. length: number;
  39137. protected _id: number;
  39138. /**
  39139. * Instantiates a Smart Array.
  39140. * @param capacity defines the default capacity of the array.
  39141. */
  39142. constructor(capacity: number);
  39143. /**
  39144. * Pushes a value at the end of the active data.
  39145. * @param value defines the object to push in the array.
  39146. */
  39147. push(value: T): void;
  39148. /**
  39149. * Iterates over the active data and apply the lambda to them.
  39150. * @param func defines the action to apply on each value.
  39151. */
  39152. forEach(func: (content: T) => void): void;
  39153. /**
  39154. * Sorts the full sets of data.
  39155. * @param compareFn defines the comparison function to apply.
  39156. */
  39157. sort(compareFn: (a: T, b: T) => number): void;
  39158. /**
  39159. * Resets the active data to an empty array.
  39160. */
  39161. reset(): void;
  39162. /**
  39163. * Releases all the data from the array as well as the array.
  39164. */
  39165. dispose(): void;
  39166. /**
  39167. * Concats the active data with a given array.
  39168. * @param array defines the data to concatenate with.
  39169. */
  39170. concat(array: any): void;
  39171. /**
  39172. * Returns the position of a value in the active data.
  39173. * @param value defines the value to find the index for
  39174. * @returns the index if found in the active data otherwise -1
  39175. */
  39176. indexOf(value: T): number;
  39177. /**
  39178. * Returns whether an element is part of the active data.
  39179. * @param value defines the value to look for
  39180. * @returns true if found in the active data otherwise false
  39181. */
  39182. contains(value: T): boolean;
  39183. private static _GlobalId;
  39184. }
  39185. /**
  39186. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39187. * The data in this array can only be present once
  39188. */
  39189. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39190. private _duplicateId;
  39191. /**
  39192. * Pushes a value at the end of the active data.
  39193. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39194. * @param value defines the object to push in the array.
  39195. */
  39196. push(value: T): void;
  39197. /**
  39198. * Pushes a value at the end of the active data.
  39199. * If the data is already present, it won t be added again
  39200. * @param value defines the object to push in the array.
  39201. * @returns true if added false if it was already present
  39202. */
  39203. pushNoDuplicate(value: T): boolean;
  39204. /**
  39205. * Resets the active data to an empty array.
  39206. */
  39207. reset(): void;
  39208. /**
  39209. * Concats the active data with a given array.
  39210. * This ensures no dupplicate will be present in the result.
  39211. * @param array defines the data to concatenate with.
  39212. */
  39213. concatWithNoDuplicate(array: any): void;
  39214. }
  39215. }
  39216. declare module BABYLON {
  39217. /**
  39218. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39219. * The underlying implementation relies on an associative array to ensure the best performances.
  39220. * The value can be anything including 'null' but except 'undefined'
  39221. */
  39222. class StringDictionary<T> {
  39223. /**
  39224. * This will clear this dictionary and copy the content from the 'source' one.
  39225. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39226. * @param source the dictionary to take the content from and copy to this dictionary
  39227. */
  39228. copyFrom(source: StringDictionary<T>): void;
  39229. /**
  39230. * Get a value based from its key
  39231. * @param key the given key to get the matching value from
  39232. * @return the value if found, otherwise undefined is returned
  39233. */
  39234. get(key: string): T | undefined;
  39235. /**
  39236. * Get a value from its key or add it if it doesn't exist.
  39237. * This method will ensure you that a given key/data will be present in the dictionary.
  39238. * @param key the given key to get the matching value from
  39239. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39240. * The factory will only be invoked if there's no data for the given key.
  39241. * @return the value corresponding to the key.
  39242. */
  39243. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39244. /**
  39245. * Get a value from its key if present in the dictionary otherwise add it
  39246. * @param key the key to get the value from
  39247. * @param val if there's no such key/value pair in the dictionary add it with this value
  39248. * @return the value corresponding to the key
  39249. */
  39250. getOrAdd(key: string, val: T): T;
  39251. /**
  39252. * Check if there's a given key in the dictionary
  39253. * @param key the key to check for
  39254. * @return true if the key is present, false otherwise
  39255. */
  39256. contains(key: string): boolean;
  39257. /**
  39258. * Add a new key and its corresponding value
  39259. * @param key the key to add
  39260. * @param value the value corresponding to the key
  39261. * @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
  39262. */
  39263. add(key: string, value: T): boolean;
  39264. /**
  39265. * Update a specific value associated to a key
  39266. * @param key defines the key to use
  39267. * @param value defines the value to store
  39268. * @returns true if the value was updated (or false if the key was not found)
  39269. */
  39270. set(key: string, value: T): boolean;
  39271. /**
  39272. * Get the element of the given key and remove it from the dictionary
  39273. * @param key defines the key to search
  39274. * @returns the value associated with the key or null if not found
  39275. */
  39276. getAndRemove(key: string): Nullable<T>;
  39277. /**
  39278. * Remove a key/value from the dictionary.
  39279. * @param key the key to remove
  39280. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39281. */
  39282. remove(key: string): boolean;
  39283. /**
  39284. * Clear the whole content of the dictionary
  39285. */
  39286. clear(): void;
  39287. /**
  39288. * Gets the current count
  39289. */
  39290. readonly count: number;
  39291. /**
  39292. * Execute a callback on each key/val of the dictionary.
  39293. * Note that you can remove any element in this dictionary in the callback implementation
  39294. * @param callback the callback to execute on a given key/value pair
  39295. */
  39296. forEach(callback: (key: string, val: T) => void): void;
  39297. /**
  39298. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39299. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39300. * Note that you can remove any element in this dictionary in the callback implementation
  39301. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39302. * @returns the first item
  39303. */
  39304. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39305. private _count;
  39306. private _data;
  39307. }
  39308. }
  39309. declare module BABYLON {
  39310. /**
  39311. * Class used to store custom tags
  39312. */
  39313. class Tags {
  39314. /**
  39315. * Adds support for tags on the given object
  39316. * @param obj defines the object to use
  39317. */
  39318. static EnableFor(obj: any): void;
  39319. /**
  39320. * Removes tags support
  39321. * @param obj defines the object to use
  39322. */
  39323. static DisableFor(obj: any): void;
  39324. /**
  39325. * Gets a boolean indicating if the given object has tags
  39326. * @param obj defines the object to use
  39327. * @returns a boolean
  39328. */
  39329. static HasTags(obj: any): boolean;
  39330. /**
  39331. * Gets the tags available on a given object
  39332. * @param obj defines the object to use
  39333. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39334. * @returns the tags
  39335. */
  39336. static GetTags(obj: any, asString?: boolean): any;
  39337. /**
  39338. * Adds tags to an object
  39339. * @param obj defines the object to use
  39340. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39341. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39342. */
  39343. static AddTagsTo(obj: any, tagsString: string): void;
  39344. /**
  39345. * @hidden
  39346. */
  39347. static _AddTagTo(obj: any, tag: string): void;
  39348. /**
  39349. * Removes specific tags from a specific object
  39350. * @param obj defines the object to use
  39351. * @param tagsString defines the tags to remove
  39352. */
  39353. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39354. /**
  39355. * @hidden
  39356. */
  39357. static _RemoveTagFrom(obj: any, tag: string): void;
  39358. /**
  39359. * Defines if tags hosted on an object match a given query
  39360. * @param obj defines the object to use
  39361. * @param tagsQuery defines the tag query
  39362. * @returns a boolean
  39363. */
  39364. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39365. }
  39366. }
  39367. declare module BABYLON {
  39368. /**
  39369. * Class used to host texture specific utilities
  39370. */
  39371. class TextureTools {
  39372. /**
  39373. * Uses the GPU to create a copy texture rescaled at a given size
  39374. * @param texture Texture to copy from
  39375. * @param width defines the desired width
  39376. * @param height defines the desired height
  39377. * @param useBilinearMode defines if bilinear mode has to be used
  39378. * @return the generated texture
  39379. */
  39380. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39381. /**
  39382. * Gets an environment BRDF texture for a given scene
  39383. * @param scene defines the hosting scene
  39384. * @returns the environment BRDF texture
  39385. */
  39386. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39387. private static _environmentBRDFBase64Texture;
  39388. }
  39389. }
  39390. declare module BABYLON {
  39391. /**
  39392. * Based on jsTGALoader - Javascript loader for TGA file
  39393. * By Vincent Thibault
  39394. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39395. */
  39396. class TGATools {
  39397. private static _TYPE_INDEXED;
  39398. private static _TYPE_RGB;
  39399. private static _TYPE_GREY;
  39400. private static _TYPE_RLE_INDEXED;
  39401. private static _TYPE_RLE_RGB;
  39402. private static _TYPE_RLE_GREY;
  39403. private static _ORIGIN_MASK;
  39404. private static _ORIGIN_SHIFT;
  39405. private static _ORIGIN_BL;
  39406. private static _ORIGIN_BR;
  39407. private static _ORIGIN_UL;
  39408. private static _ORIGIN_UR;
  39409. /**
  39410. * Gets the header of a TGA file
  39411. * @param data defines the TGA data
  39412. * @returns the header
  39413. */
  39414. static GetTGAHeader(data: Uint8Array): any;
  39415. /**
  39416. * Uploads TGA content to a Babylon Texture
  39417. * @hidden
  39418. */
  39419. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39420. /** @hidden */
  39421. 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;
  39422. /** @hidden */
  39423. 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;
  39424. /** @hidden */
  39425. 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;
  39426. /** @hidden */
  39427. 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;
  39428. /** @hidden */
  39429. 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;
  39430. /** @hidden */
  39431. 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;
  39432. }
  39433. }
  39434. declare module BABYLON {
  39435. /**
  39436. * Interface for any object that can request an animation frame
  39437. */
  39438. interface ICustomAnimationFrameRequester {
  39439. /**
  39440. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39441. */
  39442. renderFunction?: Function;
  39443. /**
  39444. * Called to request the next frame to render to
  39445. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39446. */
  39447. requestAnimationFrame: Function;
  39448. /**
  39449. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39450. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39451. */
  39452. requestID?: number;
  39453. }
  39454. /**
  39455. * Interface containing an array of animations
  39456. */
  39457. interface IAnimatable {
  39458. /**
  39459. * Array of animations
  39460. */
  39461. animations: Array<Animation>;
  39462. }
  39463. /** Interface used by value gradients (color, factor, ...) */
  39464. interface IValueGradient {
  39465. /**
  39466. * Gets or sets the gradient value (between 0 and 1)
  39467. */
  39468. gradient: number;
  39469. }
  39470. /** Class used to store color4 gradient */
  39471. class ColorGradient implements IValueGradient {
  39472. /**
  39473. * Gets or sets the gradient value (between 0 and 1)
  39474. */
  39475. gradient: number;
  39476. /**
  39477. * Gets or sets first associated color
  39478. */
  39479. color1: Color4;
  39480. /**
  39481. * Gets or sets second associated color
  39482. */
  39483. color2?: Color4;
  39484. /**
  39485. * Will get a color picked randomly between color1 and color2.
  39486. * If color2 is undefined then color1 will be used
  39487. * @param result defines the target Color4 to store the result in
  39488. */
  39489. getColorToRef(result: Color4): void;
  39490. }
  39491. /** Class used to store color 3 gradient */
  39492. class Color3Gradient implements IValueGradient {
  39493. /**
  39494. * Gets or sets the gradient value (between 0 and 1)
  39495. */
  39496. gradient: number;
  39497. /**
  39498. * Gets or sets the associated color
  39499. */
  39500. color: Color3;
  39501. }
  39502. /** Class used to store factor gradient */
  39503. class FactorGradient implements IValueGradient {
  39504. /**
  39505. * Gets or sets the gradient value (between 0 and 1)
  39506. */
  39507. gradient: number;
  39508. /**
  39509. * Gets or sets first associated factor
  39510. */
  39511. factor1: number;
  39512. /**
  39513. * Gets or sets second associated factor
  39514. */
  39515. factor2?: number;
  39516. /**
  39517. * Will get a number picked randomly between factor1 and factor2.
  39518. * If factor2 is undefined then factor1 will be used
  39519. * @returns the picked number
  39520. */
  39521. getFactor(): number;
  39522. }
  39523. /**
  39524. * @ignore
  39525. * Application error to support additional information when loading a file
  39526. */
  39527. class LoadFileError extends Error {
  39528. /** defines the optional XHR request */
  39529. request?: XMLHttpRequest | undefined;
  39530. private static _setPrototypeOf;
  39531. /**
  39532. * Creates a new LoadFileError
  39533. * @param message defines the message of the error
  39534. * @param request defines the optional XHR request
  39535. */
  39536. constructor(message: string,
  39537. /** defines the optional XHR request */
  39538. request?: XMLHttpRequest | undefined);
  39539. }
  39540. /**
  39541. * Class used to define a retry strategy when error happens while loading assets
  39542. */
  39543. class RetryStrategy {
  39544. /**
  39545. * Function used to defines an exponential back off strategy
  39546. * @param maxRetries defines the maximum number of retries (3 by default)
  39547. * @param baseInterval defines the interval between retries
  39548. * @returns the strategy function to use
  39549. */
  39550. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39551. }
  39552. /**
  39553. * File request interface
  39554. */
  39555. interface IFileRequest {
  39556. /**
  39557. * Raised when the request is complete (success or error).
  39558. */
  39559. onCompleteObservable: Observable<IFileRequest>;
  39560. /**
  39561. * Aborts the request for a file.
  39562. */
  39563. abort: () => void;
  39564. }
  39565. /**
  39566. * Class containing a set of static utilities functions
  39567. */
  39568. class Tools {
  39569. /**
  39570. * Gets or sets the base URL to use to load assets
  39571. */
  39572. static BaseUrl: string;
  39573. /**
  39574. * Enable/Disable Custom HTTP Request Headers globally.
  39575. * default = false
  39576. * @see CustomRequestHeaders
  39577. */
  39578. static UseCustomRequestHeaders: boolean;
  39579. /**
  39580. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39581. * i.e. when loading files, where the server/service expects an Authorization header.
  39582. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39583. */
  39584. static CustomRequestHeaders: {
  39585. [key: string]: string;
  39586. };
  39587. /**
  39588. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39589. */
  39590. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39591. /**
  39592. * Default behaviour for cors in the application.
  39593. * It can be a string if the expected behavior is identical in the entire app.
  39594. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39595. */
  39596. static CorsBehavior: string | ((url: string | string[]) => string);
  39597. /**
  39598. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39599. * @ignorenaming
  39600. */
  39601. static UseFallbackTexture: boolean;
  39602. /**
  39603. * Use this object to register external classes like custom textures or material
  39604. * to allow the laoders to instantiate them
  39605. */
  39606. static RegisteredExternalClasses: {
  39607. [key: string]: Object;
  39608. };
  39609. /**
  39610. * Texture content used if a texture cannot loaded
  39611. * @ignorenaming
  39612. */
  39613. static fallbackTexture: string;
  39614. /**
  39615. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39616. * @param u defines the coordinate on X axis
  39617. * @param v defines the coordinate on Y axis
  39618. * @param width defines the width of the source data
  39619. * @param height defines the height of the source data
  39620. * @param pixels defines the source byte array
  39621. * @param color defines the output color
  39622. */
  39623. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39624. /**
  39625. * Interpolates between a and b via alpha
  39626. * @param a The lower value (returned when alpha = 0)
  39627. * @param b The upper value (returned when alpha = 1)
  39628. * @param alpha The interpolation-factor
  39629. * @return The mixed value
  39630. */
  39631. static Mix(a: number, b: number, alpha: number): number;
  39632. /**
  39633. * Tries to instantiate a new object from a given class name
  39634. * @param className defines the class name to instantiate
  39635. * @returns the new object or null if the system was not able to do the instantiation
  39636. */
  39637. static Instantiate(className: string): any;
  39638. /**
  39639. * Provides a slice function that will work even on IE
  39640. * @param data defines the array to slice
  39641. * @param start defines the start of the data (optional)
  39642. * @param end defines the end of the data (optional)
  39643. * @returns the new sliced array
  39644. */
  39645. static Slice<T>(data: T, start?: number, end?: number): T;
  39646. /**
  39647. * Polyfill for setImmediate
  39648. * @param action defines the action to execute after the current execution block
  39649. */
  39650. static SetImmediate(action: () => void): void;
  39651. /**
  39652. * Function indicating if a number is an exponent of 2
  39653. * @param value defines the value to test
  39654. * @returns true if the value is an exponent of 2
  39655. */
  39656. static IsExponentOfTwo(value: number): boolean;
  39657. private static _tmpFloatArray;
  39658. /**
  39659. * Returns the nearest 32-bit single precision float representation of a Number
  39660. * @param value A Number. If the parameter is of a different type, it will get converted
  39661. * to a number or to NaN if it cannot be converted
  39662. * @returns number
  39663. */
  39664. static FloatRound(value: number): number;
  39665. /**
  39666. * Find the next highest power of two.
  39667. * @param x Number to start search from.
  39668. * @return Next highest power of two.
  39669. */
  39670. static CeilingPOT(x: number): number;
  39671. /**
  39672. * Find the next lowest power of two.
  39673. * @param x Number to start search from.
  39674. * @return Next lowest power of two.
  39675. */
  39676. static FloorPOT(x: number): number;
  39677. /**
  39678. * Find the nearest power of two.
  39679. * @param x Number to start search from.
  39680. * @return Next nearest power of two.
  39681. */
  39682. static NearestPOT(x: number): number;
  39683. /**
  39684. * Get the closest exponent of two
  39685. * @param value defines the value to approximate
  39686. * @param max defines the maximum value to return
  39687. * @param mode defines how to define the closest value
  39688. * @returns closest exponent of two of the given value
  39689. */
  39690. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39691. /**
  39692. * Extracts the filename from a path
  39693. * @param path defines the path to use
  39694. * @returns the filename
  39695. */
  39696. static GetFilename(path: string): string;
  39697. /**
  39698. * Extracts the "folder" part of a path (everything before the filename).
  39699. * @param uri The URI to extract the info from
  39700. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39701. * @returns The "folder" part of the path
  39702. */
  39703. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39704. /**
  39705. * Extracts text content from a DOM element hierarchy
  39706. * @param element defines the root element
  39707. * @returns a string
  39708. */
  39709. static GetDOMTextContent(element: HTMLElement): string;
  39710. /**
  39711. * Convert an angle in radians to degrees
  39712. * @param angle defines the angle to convert
  39713. * @returns the angle in degrees
  39714. */
  39715. static ToDegrees(angle: number): number;
  39716. /**
  39717. * Convert an angle in degrees to radians
  39718. * @param angle defines the angle to convert
  39719. * @returns the angle in radians
  39720. */
  39721. static ToRadians(angle: number): number;
  39722. /**
  39723. * Encode a buffer to a base64 string
  39724. * @param buffer defines the buffer to encode
  39725. * @returns the encoded string
  39726. */
  39727. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39728. /**
  39729. * Extracts minimum and maximum values from a list of indexed positions
  39730. * @param positions defines the positions to use
  39731. * @param indices defines the indices to the positions
  39732. * @param indexStart defines the start index
  39733. * @param indexCount defines the end index
  39734. * @param bias defines bias value to add to the result
  39735. * @return minimum and maximum values
  39736. */
  39737. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39738. minimum: Vector3;
  39739. maximum: Vector3;
  39740. };
  39741. /**
  39742. * Extracts minimum and maximum values from a list of positions
  39743. * @param positions defines the positions to use
  39744. * @param start defines the start index in the positions array
  39745. * @param count defines the number of positions to handle
  39746. * @param bias defines bias value to add to the result
  39747. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39748. * @return minimum and maximum values
  39749. */
  39750. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39751. minimum: Vector3;
  39752. maximum: Vector3;
  39753. };
  39754. /**
  39755. * Returns an array if obj is not an array
  39756. * @param obj defines the object to evaluate as an array
  39757. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39758. * @returns either obj directly if obj is an array or a new array containing obj
  39759. */
  39760. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39761. /**
  39762. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39763. * @param size the number of element to construct and put in the array
  39764. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39765. * @returns a new array filled with new objects
  39766. */
  39767. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39768. /**
  39769. * Gets the pointer prefix to use
  39770. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39771. */
  39772. static GetPointerPrefix(): string;
  39773. /**
  39774. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39775. * @param func - the function to be called
  39776. * @param requester - the object that will request the next frame. Falls back to window.
  39777. * @returns frame number
  39778. */
  39779. static QueueNewFrame(func: () => void, requester?: any): number;
  39780. /**
  39781. * Ask the browser to promote the current element to fullscreen rendering mode
  39782. * @param element defines the DOM element to promote
  39783. */
  39784. static RequestFullscreen(element: HTMLElement): void;
  39785. /**
  39786. * Asks the browser to exit fullscreen mode
  39787. */
  39788. static ExitFullscreen(): void;
  39789. /**
  39790. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39791. * @param url define the url we are trying
  39792. * @param element define the dom element where to configure the cors policy
  39793. */
  39794. static SetCorsBehavior(url: string | string[], element: {
  39795. crossOrigin: string | null;
  39796. }): void;
  39797. /**
  39798. * Removes unwanted characters from an url
  39799. * @param url defines the url to clean
  39800. * @returns the cleaned url
  39801. */
  39802. static CleanUrl(url: string): string;
  39803. /**
  39804. * Gets or sets a function used to pre-process url before using them to load assets
  39805. */
  39806. static PreprocessUrl: (url: string) => string;
  39807. /**
  39808. * Loads an image as an HTMLImageElement.
  39809. * @param input url string, ArrayBuffer, or Blob to load
  39810. * @param onLoad callback called when the image successfully loads
  39811. * @param onError callback called when the image fails to load
  39812. * @param offlineProvider offline provider for caching
  39813. * @returns the HTMLImageElement of the loaded image
  39814. */
  39815. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39816. /**
  39817. * Loads a file
  39818. * @param url url string, ArrayBuffer, or Blob to load
  39819. * @param onSuccess callback called when the file successfully loads
  39820. * @param onProgress callback called while file is loading (if the server supports this mode)
  39821. * @param offlineProvider defines the offline provider for caching
  39822. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39823. * @param onError callback called when the file fails to load
  39824. * @returns a file request object
  39825. */
  39826. 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;
  39827. /**
  39828. * Load a script (identified by an url). When the url returns, the
  39829. * content of this file is added into a new script element, attached to the DOM (body element)
  39830. * @param scriptUrl defines the url of the script to laod
  39831. * @param onSuccess defines the callback called when the script is loaded
  39832. * @param onError defines the callback to call if an error occurs
  39833. */
  39834. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39835. /**
  39836. * Loads a file from a blob
  39837. * @param fileToLoad defines the blob to use
  39838. * @param callback defines the callback to call when data is loaded
  39839. * @param progressCallback defines the callback to call during loading process
  39840. * @returns a file request object
  39841. */
  39842. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39843. /**
  39844. * Loads a file
  39845. * @param fileToLoad defines the file to load
  39846. * @param callback defines the callback to call when data is loaded
  39847. * @param progressCallBack defines the callback to call during loading process
  39848. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39849. * @returns a file request object
  39850. */
  39851. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39852. /**
  39853. * Creates a data url from a given string content
  39854. * @param content defines the content to convert
  39855. * @returns the new data url link
  39856. */
  39857. static FileAsURL(content: string): string;
  39858. /**
  39859. * Format the given number to a specific decimal format
  39860. * @param value defines the number to format
  39861. * @param decimals defines the number of decimals to use
  39862. * @returns the formatted string
  39863. */
  39864. static Format(value: number, decimals?: number): string;
  39865. /**
  39866. * Checks if a given vector is inside a specific range
  39867. * @param v defines the vector to test
  39868. * @param min defines the minimum range
  39869. * @param max defines the maximum range
  39870. */
  39871. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39872. /**
  39873. * Tries to copy an object by duplicating every property
  39874. * @param source defines the source object
  39875. * @param destination defines the target object
  39876. * @param doNotCopyList defines a list of properties to avoid
  39877. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39878. */
  39879. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39880. /**
  39881. * Gets a boolean indicating if the given object has no own property
  39882. * @param obj defines the object to test
  39883. * @returns true if object has no own property
  39884. */
  39885. static IsEmpty(obj: any): boolean;
  39886. /**
  39887. * Function used to register events at window level
  39888. * @param events defines the events to register
  39889. */
  39890. static RegisterTopRootEvents(events: {
  39891. name: string;
  39892. handler: Nullable<(e: FocusEvent) => any>;
  39893. }[]): void;
  39894. /**
  39895. * Function used to unregister events from window level
  39896. * @param events defines the events to unregister
  39897. */
  39898. static UnregisterTopRootEvents(events: {
  39899. name: string;
  39900. handler: Nullable<(e: FocusEvent) => any>;
  39901. }[]): void;
  39902. /**
  39903. * Dumps the current bound framebuffer
  39904. * @param width defines the rendering width
  39905. * @param height defines the rendering height
  39906. * @param engine defines the hosting engine
  39907. * @param successCallback defines the callback triggered once the data are available
  39908. * @param mimeType defines the mime type of the result
  39909. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39910. */
  39911. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39912. /**
  39913. * Converts the canvas data to blob.
  39914. * This acts as a polyfill for browsers not supporting the to blob function.
  39915. * @param canvas Defines the canvas to extract the data from
  39916. * @param successCallback Defines the callback triggered once the data are available
  39917. * @param mimeType Defines the mime type of the result
  39918. */
  39919. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39920. /**
  39921. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39922. * @param successCallback defines the callback triggered once the data are available
  39923. * @param mimeType defines the mime type of the result
  39924. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39925. */
  39926. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39927. /**
  39928. * Downloads a blob in the browser
  39929. * @param blob defines the blob to download
  39930. * @param fileName defines the name of the downloaded file
  39931. */
  39932. static Download(blob: Blob, fileName: string): void;
  39933. /**
  39934. * Captures a screenshot of the current rendering
  39935. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39936. * @param engine defines the rendering engine
  39937. * @param camera defines the source camera
  39938. * @param size This parameter can be set to a single number or to an object with the
  39939. * following (optional) properties: precision, width, height. If a single number is passed,
  39940. * it will be used for both width and height. If an object is passed, the screenshot size
  39941. * will be derived from the parameters. The precision property is a multiplier allowing
  39942. * rendering at a higher or lower resolution
  39943. * @param successCallback defines the callback receives a single parameter which contains the
  39944. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39945. * src parameter of an <img> to display it
  39946. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39947. * Check your browser for supported MIME types
  39948. */
  39949. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39950. /**
  39951. * Generates an image screenshot from the specified camera.
  39952. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39953. * @param engine The engine to use for rendering
  39954. * @param camera The camera to use for rendering
  39955. * @param size This parameter can be set to a single number or to an object with the
  39956. * following (optional) properties: precision, width, height. If a single number is passed,
  39957. * it will be used for both width and height. If an object is passed, the screenshot size
  39958. * will be derived from the parameters. The precision property is a multiplier allowing
  39959. * rendering at a higher or lower resolution
  39960. * @param successCallback The callback receives a single parameter which contains the
  39961. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39962. * src parameter of an <img> to display it
  39963. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39964. * Check your browser for supported MIME types
  39965. * @param samples Texture samples (default: 1)
  39966. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39967. * @param fileName A name for for the downloaded file.
  39968. */
  39969. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39970. /**
  39971. * Validates if xhr data is correct
  39972. * @param xhr defines the request to validate
  39973. * @param dataType defines the expected data type
  39974. * @returns true if data is correct
  39975. */
  39976. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39977. /**
  39978. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39979. * Be aware Math.random() could cause collisions, but:
  39980. * "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"
  39981. * @returns a pseudo random id
  39982. */
  39983. static RandomId(): string;
  39984. /**
  39985. * Test if the given uri is a base64 string
  39986. * @param uri The uri to test
  39987. * @return True if the uri is a base64 string or false otherwise
  39988. */
  39989. static IsBase64(uri: string): boolean;
  39990. /**
  39991. * Decode the given base64 uri.
  39992. * @param uri The uri to decode
  39993. * @return The decoded base64 data.
  39994. */
  39995. static DecodeBase64(uri: string): ArrayBuffer;
  39996. /**
  39997. * No log
  39998. */
  39999. static readonly NoneLogLevel: number;
  40000. /**
  40001. * Only message logs
  40002. */
  40003. static readonly MessageLogLevel: number;
  40004. /**
  40005. * Only warning logs
  40006. */
  40007. static readonly WarningLogLevel: number;
  40008. /**
  40009. * Only error logs
  40010. */
  40011. static readonly ErrorLogLevel: number;
  40012. /**
  40013. * All logs
  40014. */
  40015. static readonly AllLogLevel: number;
  40016. private static _LogCache;
  40017. /**
  40018. * Gets a value indicating the number of loading errors
  40019. * @ignorenaming
  40020. */
  40021. static errorsCount: number;
  40022. /**
  40023. * Callback called when a new log is added
  40024. */
  40025. static OnNewCacheEntry: (entry: string) => void;
  40026. private static _AddLogEntry;
  40027. private static _FormatMessage;
  40028. private static _LogDisabled;
  40029. private static _LogEnabled;
  40030. private static _WarnDisabled;
  40031. private static _WarnEnabled;
  40032. private static _ErrorDisabled;
  40033. private static _ErrorEnabled;
  40034. /**
  40035. * Log a message to the console
  40036. */
  40037. static Log: (message: string) => void;
  40038. /**
  40039. * Write a warning message to the console
  40040. */
  40041. static Warn: (message: string) => void;
  40042. /**
  40043. * Write an error message to the console
  40044. */
  40045. static Error: (message: string) => void;
  40046. /**
  40047. * Gets current log cache (list of logs)
  40048. */
  40049. static readonly LogCache: string;
  40050. /**
  40051. * Clears the log cache
  40052. */
  40053. static ClearLogCache(): void;
  40054. /**
  40055. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40056. */
  40057. static LogLevels: number;
  40058. /**
  40059. * Checks if the loaded document was accessed via `file:`-Protocol.
  40060. * @returns boolean
  40061. */
  40062. static IsFileURL(): boolean;
  40063. /**
  40064. * Checks if the window object exists
  40065. * @returns true if the window object exists
  40066. */
  40067. static IsWindowObjectExist(): boolean;
  40068. /**
  40069. * No performance log
  40070. */
  40071. static readonly PerformanceNoneLogLevel: number;
  40072. /**
  40073. * Use user marks to log performance
  40074. */
  40075. static readonly PerformanceUserMarkLogLevel: number;
  40076. /**
  40077. * Log performance to the console
  40078. */
  40079. static readonly PerformanceConsoleLogLevel: number;
  40080. private static _performance;
  40081. /**
  40082. * Sets the current performance log level
  40083. */
  40084. static PerformanceLogLevel: number;
  40085. private static _StartPerformanceCounterDisabled;
  40086. private static _EndPerformanceCounterDisabled;
  40087. private static _StartUserMark;
  40088. private static _EndUserMark;
  40089. private static _StartPerformanceConsole;
  40090. private static _EndPerformanceConsole;
  40091. /**
  40092. * Injects the @see CustomRequestHeaders into the given request
  40093. * @param request the request that should be used for injection
  40094. */
  40095. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40096. /**
  40097. * Starts a performance counter
  40098. */
  40099. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40100. /**
  40101. * Ends a specific performance coutner
  40102. */
  40103. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40104. /**
  40105. * Gets either window.performance.now() if supported or Date.now() else
  40106. */
  40107. static readonly Now: number;
  40108. /**
  40109. * This method will return the name of the class used to create the instance of the given object.
  40110. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40111. * @param object the object to get the class name from
  40112. * @param isType defines if the object is actually a type
  40113. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40114. */
  40115. static GetClassName(object: any, isType?: boolean): string;
  40116. /**
  40117. * Gets the first element of an array satisfying a given predicate
  40118. * @param array defines the array to browse
  40119. * @param predicate defines the predicate to use
  40120. * @returns null if not found or the element
  40121. */
  40122. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40123. /**
  40124. * This method will return the name of the full name of the class, including its owning module (if any).
  40125. * 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).
  40126. * @param object the object to get the class name from
  40127. * @param isType defines if the object is actually a type
  40128. * @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.
  40129. * @ignorenaming
  40130. */
  40131. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40132. /**
  40133. * Returns a promise that resolves after the given amount of time.
  40134. * @param delay Number of milliseconds to delay
  40135. * @returns Promise that resolves after the given amount of time
  40136. */
  40137. static DelayAsync(delay: number): Promise<void>;
  40138. /**
  40139. * Gets the current gradient from an array of IValueGradient
  40140. * @param ratio defines the current ratio to get
  40141. * @param gradients defines the array of IValueGradient
  40142. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40143. */
  40144. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40145. }
  40146. /**
  40147. * This class is used to track a performance counter which is number based.
  40148. * The user has access to many properties which give statistics of different nature.
  40149. *
  40150. * The implementer can track two kinds of Performance Counter: time and count.
  40151. * 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.
  40152. * 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.
  40153. */
  40154. class PerfCounter {
  40155. /**
  40156. * Gets or sets a global boolean to turn on and off all the counters
  40157. */
  40158. static Enabled: boolean;
  40159. /**
  40160. * Returns the smallest value ever
  40161. */
  40162. readonly min: number;
  40163. /**
  40164. * Returns the biggest value ever
  40165. */
  40166. readonly max: number;
  40167. /**
  40168. * Returns the average value since the performance counter is running
  40169. */
  40170. readonly average: number;
  40171. /**
  40172. * Returns the average value of the last second the counter was monitored
  40173. */
  40174. readonly lastSecAverage: number;
  40175. /**
  40176. * Returns the current value
  40177. */
  40178. readonly current: number;
  40179. /**
  40180. * Gets the accumulated total
  40181. */
  40182. readonly total: number;
  40183. /**
  40184. * Gets the total value count
  40185. */
  40186. readonly count: number;
  40187. /**
  40188. * Creates a new counter
  40189. */
  40190. constructor();
  40191. /**
  40192. * Call this method to start monitoring a new frame.
  40193. * 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.
  40194. */
  40195. fetchNewFrame(): void;
  40196. /**
  40197. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40198. * @param newCount the count value to add to the monitored count
  40199. * @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.
  40200. */
  40201. addCount(newCount: number, fetchResult: boolean): void;
  40202. /**
  40203. * Start monitoring this performance counter
  40204. */
  40205. beginMonitoring(): void;
  40206. /**
  40207. * Compute the time lapsed since the previous beginMonitoring() call.
  40208. * @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
  40209. */
  40210. endMonitoring(newFrame?: boolean): void;
  40211. private _fetchResult;
  40212. private _startMonitoringTime;
  40213. private _min;
  40214. private _max;
  40215. private _average;
  40216. private _current;
  40217. private _totalValueCount;
  40218. private _totalAccumulated;
  40219. private _lastSecAverage;
  40220. private _lastSecAccumulated;
  40221. private _lastSecTime;
  40222. private _lastSecValueCount;
  40223. }
  40224. /**
  40225. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40226. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40227. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40228. * @param name The name of the class, case should be preserved
  40229. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40230. */
  40231. function className(name: string, module?: string): (target: Object) => void;
  40232. /**
  40233. * An implementation of a loop for asynchronous functions.
  40234. */
  40235. class AsyncLoop {
  40236. /**
  40237. * Defines the number of iterations for the loop
  40238. */
  40239. iterations: number;
  40240. /**
  40241. * Defines the current index of the loop.
  40242. */
  40243. index: number;
  40244. private _done;
  40245. private _fn;
  40246. private _successCallback;
  40247. /**
  40248. * Constructor.
  40249. * @param iterations the number of iterations.
  40250. * @param func the function to run each iteration
  40251. * @param successCallback the callback that will be called upon succesful execution
  40252. * @param offset starting offset.
  40253. */
  40254. constructor(
  40255. /**
  40256. * Defines the number of iterations for the loop
  40257. */
  40258. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40259. /**
  40260. * Execute the next iteration. Must be called after the last iteration was finished.
  40261. */
  40262. executeNext(): void;
  40263. /**
  40264. * Break the loop and run the success callback.
  40265. */
  40266. breakLoop(): void;
  40267. /**
  40268. * Create and run an async loop.
  40269. * @param iterations the number of iterations.
  40270. * @param fn the function to run each iteration
  40271. * @param successCallback the callback that will be called upon succesful execution
  40272. * @param offset starting offset.
  40273. * @returns the created async loop object
  40274. */
  40275. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40276. /**
  40277. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40278. * @param iterations total number of iterations
  40279. * @param syncedIterations number of synchronous iterations in each async iteration.
  40280. * @param fn the function to call each iteration.
  40281. * @param callback a success call back that will be called when iterating stops.
  40282. * @param breakFunction a break condition (optional)
  40283. * @param timeout timeout settings for the setTimeout function. default - 0.
  40284. * @returns the created async loop object
  40285. */
  40286. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40287. }
  40288. }
  40289. interface HTMLCanvasElement {
  40290. /** Track wether a record is in progress */
  40291. isRecording: boolean;
  40292. /** Capture Stream method defined by some browsers */
  40293. captureStream(fps?: number): MediaStream;
  40294. }
  40295. interface MediaRecorder {
  40296. /** Starts recording */
  40297. start(timeSlice: number): void;
  40298. /** Stops recording */
  40299. stop(): void;
  40300. /** Event raised when an error arised. */
  40301. onerror: (event: ErrorEvent) => void;
  40302. /** Event raised when the recording stops. */
  40303. onstop: (event: Event) => void;
  40304. /** Event raised when a new chunk of data is available and should be tracked. */
  40305. ondataavailable: (event: Event) => void;
  40306. }
  40307. interface MediaRecorderOptions {
  40308. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40309. mimeType?: string;
  40310. /** The chosen bitrate for the audio component of the media. */
  40311. audioBitsPerSecond?: number;
  40312. /** The chosen bitrate for the video component of the media. */
  40313. videoBitsPerSecond?: number;
  40314. /** 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. */
  40315. bitsPerSecond?: number;
  40316. }
  40317. interface MediaRecorderConstructor {
  40318. /**
  40319. * A reference to the prototype.
  40320. */
  40321. readonly prototype: MediaRecorder;
  40322. /**
  40323. * Creates a new MediaRecorder.
  40324. * @param stream Defines the stream to record.
  40325. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40326. */
  40327. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40328. }
  40329. /**
  40330. * MediaRecoreder object available in some browsers.
  40331. */
  40332. declare var MediaRecorder: MediaRecorderConstructor;
  40333. declare module BABYLON {
  40334. /**
  40335. * This represents the different options avilable for the video capture.
  40336. */
  40337. interface VideoRecorderOptions {
  40338. /** Defines the mime type of the video */
  40339. mimeType: string;
  40340. /** Defines the video the video should be recorded at */
  40341. fps: number;
  40342. /** Defines the chunk size for the recording data */
  40343. recordChunckSize: number;
  40344. }
  40345. /**
  40346. * This can helps recording videos from BabylonJS.
  40347. * This is based on the available WebRTC functionalities of the browser.
  40348. *
  40349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40350. */
  40351. class VideoRecorder {
  40352. private static readonly _defaultOptions;
  40353. /**
  40354. * Returns wehther or not the VideoRecorder is available in your browser.
  40355. * @param engine Defines the Babylon Engine to check the support for
  40356. * @returns true if supported otherwise false
  40357. */
  40358. static IsSupported(engine: Engine): boolean;
  40359. private readonly _options;
  40360. private _canvas;
  40361. private _mediaRecorder;
  40362. private _recordedChunks;
  40363. private _fileName;
  40364. private _resolve;
  40365. private _reject;
  40366. /**
  40367. * True wether a recording is already in progress.
  40368. */
  40369. readonly isRecording: boolean;
  40370. /**
  40371. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40372. * a video file.
  40373. * @param engine Defines the BabylonJS Engine you wish to record
  40374. * @param options Defines options that can be used to customized the capture
  40375. */
  40376. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40377. /**
  40378. * Stops the current recording before the default capture timeout passed in the startRecording
  40379. * functions.
  40380. */
  40381. stopRecording(): void;
  40382. /**
  40383. * Starts recording the canvas for a max duration specified in parameters.
  40384. * @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.
  40385. * @param maxDuration Defines the maximum recording time in seconds.
  40386. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40387. * @return a promise callback at the end of the recording with the video data in Blob.
  40388. */
  40389. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40390. /**
  40391. * Releases internal resources used during the recording.
  40392. */
  40393. dispose(): void;
  40394. private _handleDataAvailable;
  40395. private _handleError;
  40396. private _handleStop;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * Defines the potential axis of a Joystick
  40402. */
  40403. enum JoystickAxis {
  40404. /** X axis */
  40405. X = 0,
  40406. /** Y axis */
  40407. Y = 1,
  40408. /** Z axis */
  40409. Z = 2
  40410. }
  40411. /**
  40412. * Class used to define virtual joystick (used in touch mode)
  40413. */
  40414. class VirtualJoystick {
  40415. /**
  40416. * Gets or sets a boolean indicating that left and right values must be inverted
  40417. */
  40418. reverseLeftRight: boolean;
  40419. /**
  40420. * Gets or sets a boolean indicating that up and down values must be inverted
  40421. */
  40422. reverseUpDown: boolean;
  40423. /**
  40424. * Gets the offset value for the position (ie. the change of the position value)
  40425. */
  40426. deltaPosition: Vector3;
  40427. /**
  40428. * Gets a boolean indicating if the virtual joystick was pressed
  40429. */
  40430. pressed: boolean;
  40431. /**
  40432. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40433. */
  40434. static Canvas: Nullable<HTMLCanvasElement>;
  40435. private static _globalJoystickIndex;
  40436. private static vjCanvasContext;
  40437. private static vjCanvasWidth;
  40438. private static vjCanvasHeight;
  40439. private static halfWidth;
  40440. private _action;
  40441. private _axisTargetedByLeftAndRight;
  40442. private _axisTargetedByUpAndDown;
  40443. private _joystickSensibility;
  40444. private _inversedSensibility;
  40445. private _joystickPointerID;
  40446. private _joystickColor;
  40447. private _joystickPointerPos;
  40448. private _joystickPreviousPointerPos;
  40449. private _joystickPointerStartPos;
  40450. private _deltaJoystickVector;
  40451. private _leftJoystick;
  40452. private _touches;
  40453. private _onPointerDownHandlerRef;
  40454. private _onPointerMoveHandlerRef;
  40455. private _onPointerUpHandlerRef;
  40456. private _onResize;
  40457. /**
  40458. * Creates a new virtual joystick
  40459. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40460. */
  40461. constructor(leftJoystick?: boolean);
  40462. /**
  40463. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40464. * @param newJoystickSensibility defines the new sensibility
  40465. */
  40466. setJoystickSensibility(newJoystickSensibility: number): void;
  40467. private _onPointerDown;
  40468. private _onPointerMove;
  40469. private _onPointerUp;
  40470. /**
  40471. * Change the color of the virtual joystick
  40472. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40473. */
  40474. setJoystickColor(newColor: string): void;
  40475. /**
  40476. * Defines a callback to call when the joystick is touched
  40477. * @param action defines the callback
  40478. */
  40479. setActionOnTouch(action: () => any): void;
  40480. /**
  40481. * Defines which axis you'd like to control for left & right
  40482. * @param axis defines the axis to use
  40483. */
  40484. setAxisForLeftRight(axis: JoystickAxis): void;
  40485. /**
  40486. * Defines which axis you'd like to control for up & down
  40487. * @param axis defines the axis to use
  40488. */
  40489. setAxisForUpDown(axis: JoystickAxis): void;
  40490. private _drawVirtualJoystick;
  40491. /**
  40492. * Release internal HTML canvas
  40493. */
  40494. releaseCanvas(): void;
  40495. }
  40496. }
  40497. declare module BABYLON {
  40498. /**
  40499. * Helper class to push actions to a pool of workers.
  40500. */
  40501. class WorkerPool implements IDisposable {
  40502. private _workerInfos;
  40503. private _pendingActions;
  40504. /**
  40505. * Constructor
  40506. * @param workers Array of workers to use for actions
  40507. */
  40508. constructor(workers: Array<Worker>);
  40509. /**
  40510. * Terminates all workers and clears any pending actions.
  40511. */
  40512. dispose(): void;
  40513. /**
  40514. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40515. * pended until a worker has completed its action.
  40516. * @param action The action to perform. Call onComplete when the action is complete.
  40517. */
  40518. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40519. private _execute;
  40520. }
  40521. }
  40522. declare module BABYLON {
  40523. /**
  40524. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40526. */
  40527. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40528. /**
  40529. * Gets the name of the behavior.
  40530. */
  40531. readonly name: string;
  40532. private _zoomStopsAnimation;
  40533. private _idleRotationSpeed;
  40534. private _idleRotationWaitTime;
  40535. private _idleRotationSpinupTime;
  40536. /**
  40537. * Sets the flag that indicates if user zooming should stop animation.
  40538. */
  40539. /**
  40540. * Gets the flag that indicates if user zooming should stop animation.
  40541. */
  40542. zoomStopsAnimation: boolean;
  40543. /**
  40544. * Sets the default speed at which the camera rotates around the model.
  40545. */
  40546. /**
  40547. * Gets the default speed at which the camera rotates around the model.
  40548. */
  40549. idleRotationSpeed: number;
  40550. /**
  40551. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40552. */
  40553. /**
  40554. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40555. */
  40556. idleRotationWaitTime: number;
  40557. /**
  40558. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40559. */
  40560. /**
  40561. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40562. */
  40563. idleRotationSpinupTime: number;
  40564. /**
  40565. * Gets a value indicating if the camera is currently rotating because of this behavior
  40566. */
  40567. readonly rotationInProgress: boolean;
  40568. private _onPrePointerObservableObserver;
  40569. private _onAfterCheckInputsObserver;
  40570. private _attachedCamera;
  40571. private _isPointerDown;
  40572. private _lastFrameTime;
  40573. private _lastInteractionTime;
  40574. private _cameraRotationSpeed;
  40575. /**
  40576. * Initializes the behavior.
  40577. */
  40578. init(): void;
  40579. /**
  40580. * Attaches the behavior to its arc rotate camera.
  40581. * @param camera Defines the camera to attach the behavior to
  40582. */
  40583. attach(camera: ArcRotateCamera): void;
  40584. /**
  40585. * Detaches the behavior from its current arc rotate camera.
  40586. */
  40587. detach(): void;
  40588. /**
  40589. * Returns true if user is scrolling.
  40590. * @return true if user is scrolling.
  40591. */
  40592. private _userIsZooming;
  40593. private _lastFrameRadius;
  40594. private _shouldAnimationStopForInteraction;
  40595. /**
  40596. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40597. */
  40598. private _applyUserInteraction;
  40599. private _userIsMoving;
  40600. }
  40601. }
  40602. declare module BABYLON {
  40603. /**
  40604. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40606. */
  40607. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40608. /**
  40609. * Gets the name of the behavior.
  40610. */
  40611. readonly name: string;
  40612. /**
  40613. * The easing function used by animations
  40614. */
  40615. static EasingFunction: BackEase;
  40616. /**
  40617. * The easing mode used by animations
  40618. */
  40619. static EasingMode: number;
  40620. /**
  40621. * The duration of the animation, in milliseconds
  40622. */
  40623. transitionDuration: number;
  40624. /**
  40625. * Length of the distance animated by the transition when lower radius is reached
  40626. */
  40627. lowerRadiusTransitionRange: number;
  40628. /**
  40629. * Length of the distance animated by the transition when upper radius is reached
  40630. */
  40631. upperRadiusTransitionRange: number;
  40632. private _autoTransitionRange;
  40633. /**
  40634. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40635. */
  40636. /**
  40637. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40638. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40639. */
  40640. autoTransitionRange: boolean;
  40641. private _attachedCamera;
  40642. private _onAfterCheckInputsObserver;
  40643. private _onMeshTargetChangedObserver;
  40644. /**
  40645. * Initializes the behavior.
  40646. */
  40647. init(): void;
  40648. /**
  40649. * Attaches the behavior to its arc rotate camera.
  40650. * @param camera Defines the camera to attach the behavior to
  40651. */
  40652. attach(camera: ArcRotateCamera): void;
  40653. /**
  40654. * Detaches the behavior from its current arc rotate camera.
  40655. */
  40656. detach(): void;
  40657. private _radiusIsAnimating;
  40658. private _radiusBounceTransition;
  40659. private _animatables;
  40660. private _cachedWheelPrecision;
  40661. /**
  40662. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40663. * @param radiusLimit The limit to check against.
  40664. * @return Bool to indicate if at limit.
  40665. */
  40666. private _isRadiusAtLimit;
  40667. /**
  40668. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40669. * @param radiusDelta The delta by which to animate to. Can be negative.
  40670. */
  40671. private _applyBoundRadiusAnimation;
  40672. /**
  40673. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40674. */
  40675. protected _clearAnimationLocks(): void;
  40676. /**
  40677. * Stops and removes all animations that have been applied to the camera
  40678. */
  40679. stopAllAnimations(): void;
  40680. }
  40681. }
  40682. declare module BABYLON {
  40683. /**
  40684. * 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.
  40685. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40686. */
  40687. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40688. /**
  40689. * Gets the name of the behavior.
  40690. */
  40691. readonly name: string;
  40692. private _mode;
  40693. private _radiusScale;
  40694. private _positionScale;
  40695. private _defaultElevation;
  40696. private _elevationReturnTime;
  40697. private _elevationReturnWaitTime;
  40698. private _zoomStopsAnimation;
  40699. private _framingTime;
  40700. /**
  40701. * The easing function used by animations
  40702. */
  40703. static EasingFunction: ExponentialEase;
  40704. /**
  40705. * The easing mode used by animations
  40706. */
  40707. static EasingMode: number;
  40708. /**
  40709. * Sets the current mode used by the behavior
  40710. */
  40711. /**
  40712. * Gets current mode used by the behavior.
  40713. */
  40714. mode: number;
  40715. /**
  40716. * Sets the scale applied to the radius (1 by default)
  40717. */
  40718. /**
  40719. * Gets the scale applied to the radius
  40720. */
  40721. radiusScale: number;
  40722. /**
  40723. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40724. */
  40725. /**
  40726. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40727. */
  40728. positionScale: number;
  40729. /**
  40730. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40731. * behaviour is triggered, in radians.
  40732. */
  40733. /**
  40734. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40735. * behaviour is triggered, in radians.
  40736. */
  40737. defaultElevation: number;
  40738. /**
  40739. * Sets the time (in milliseconds) taken to return to the default beta position.
  40740. * Negative value indicates camera should not return to default.
  40741. */
  40742. /**
  40743. * Gets the time (in milliseconds) taken to return to the default beta position.
  40744. * Negative value indicates camera should not return to default.
  40745. */
  40746. elevationReturnTime: number;
  40747. /**
  40748. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40749. */
  40750. /**
  40751. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40752. */
  40753. elevationReturnWaitTime: number;
  40754. /**
  40755. * Sets the flag that indicates if user zooming should stop animation.
  40756. */
  40757. /**
  40758. * Gets the flag that indicates if user zooming should stop animation.
  40759. */
  40760. zoomStopsAnimation: boolean;
  40761. /**
  40762. * Sets the transition time when framing the mesh, in milliseconds
  40763. */
  40764. /**
  40765. * Gets the transition time when framing the mesh, in milliseconds
  40766. */
  40767. framingTime: number;
  40768. /**
  40769. * Define if the behavior should automatically change the configured
  40770. * camera limits and sensibilities.
  40771. */
  40772. autoCorrectCameraLimitsAndSensibility: boolean;
  40773. private _onPrePointerObservableObserver;
  40774. private _onAfterCheckInputsObserver;
  40775. private _onMeshTargetChangedObserver;
  40776. private _attachedCamera;
  40777. private _isPointerDown;
  40778. private _lastInteractionTime;
  40779. /**
  40780. * Initializes the behavior.
  40781. */
  40782. init(): void;
  40783. /**
  40784. * Attaches the behavior to its arc rotate camera.
  40785. * @param camera Defines the camera to attach the behavior to
  40786. */
  40787. attach(camera: ArcRotateCamera): void;
  40788. /**
  40789. * Detaches the behavior from its current arc rotate camera.
  40790. */
  40791. detach(): void;
  40792. private _animatables;
  40793. private _betaIsAnimating;
  40794. private _betaTransition;
  40795. private _radiusTransition;
  40796. private _vectorTransition;
  40797. /**
  40798. * Targets the given mesh and updates zoom level accordingly.
  40799. * @param mesh The mesh to target.
  40800. * @param radius Optional. If a cached radius position already exists, overrides default.
  40801. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40802. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40803. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40804. */
  40805. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40806. /**
  40807. * Targets the given mesh with its children and updates zoom level accordingly.
  40808. * @param mesh The mesh to target.
  40809. * @param radius Optional. If a cached radius position already exists, overrides default.
  40810. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40811. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40812. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40813. */
  40814. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40815. /**
  40816. * Targets the given meshes with their children and updates zoom level accordingly.
  40817. * @param meshes The mesh to target.
  40818. * @param radius Optional. If a cached radius position already exists, overrides default.
  40819. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40822. */
  40823. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40824. /**
  40825. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40826. * @param minimumWorld Determines the smaller position of the bounding box extend
  40827. * @param maximumWorld Determines the bigger position of the bounding box extend
  40828. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40829. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40830. */
  40831. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40832. /**
  40833. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40834. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40835. * frustum width.
  40836. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40837. * to fully enclose the mesh in the viewing frustum.
  40838. */
  40839. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40840. /**
  40841. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40842. * is automatically returned to its default position (expected to be above ground plane).
  40843. */
  40844. private _maintainCameraAboveGround;
  40845. /**
  40846. * Returns the frustum slope based on the canvas ratio and camera FOV
  40847. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40848. */
  40849. private _getFrustumSlope;
  40850. /**
  40851. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40852. */
  40853. private _clearAnimationLocks;
  40854. /**
  40855. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40856. */
  40857. private _applyUserInteraction;
  40858. /**
  40859. * Stops and removes all animations that have been applied to the camera
  40860. */
  40861. stopAllAnimations(): void;
  40862. /**
  40863. * Gets a value indicating if the user is moving the camera
  40864. */
  40865. readonly isUserIsMoving: boolean;
  40866. /**
  40867. * The camera can move all the way towards the mesh.
  40868. */
  40869. static IgnoreBoundsSizeMode: number;
  40870. /**
  40871. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40872. */
  40873. static FitFrustumSidesMode: number;
  40874. }
  40875. }
  40876. declare module BABYLON {
  40877. /**
  40878. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40879. */
  40880. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40881. private ui;
  40882. /**
  40883. * The name of the behavior
  40884. */
  40885. name: string;
  40886. /**
  40887. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40888. */
  40889. distanceAwayFromFace: number;
  40890. /**
  40891. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40892. */
  40893. distanceAwayFromBottomOfFace: number;
  40894. private _faceVectors;
  40895. private _target;
  40896. private _scene;
  40897. private _onRenderObserver;
  40898. private _tmpMatrix;
  40899. private _tmpVector;
  40900. /**
  40901. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40902. * @param ui The transform node that should be attched to the mesh
  40903. */
  40904. constructor(ui: BABYLON.TransformNode);
  40905. /**
  40906. * Initializes the behavior
  40907. */
  40908. init(): void;
  40909. private _closestFace;
  40910. private _zeroVector;
  40911. private _lookAtTmpMatrix;
  40912. private _lookAtToRef;
  40913. /**
  40914. * Attaches the AttachToBoxBehavior to the passed in mesh
  40915. * @param target The mesh that the specified node will be attached to
  40916. */
  40917. attach(target: BABYLON.Mesh): void;
  40918. /**
  40919. * Detaches the behavior from the mesh
  40920. */
  40921. detach(): void;
  40922. }
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40927. */
  40928. class FadeInOutBehavior implements Behavior<Mesh> {
  40929. /**
  40930. * Time in milliseconds to delay before fading in (Default: 0)
  40931. */
  40932. delay: number;
  40933. /**
  40934. * Time in milliseconds for the mesh to fade in (Default: 300)
  40935. */
  40936. fadeInTime: number;
  40937. private _millisecondsPerFrame;
  40938. private _hovered;
  40939. private _hoverValue;
  40940. private _ownerNode;
  40941. /**
  40942. * Instatiates the FadeInOutBehavior
  40943. */
  40944. constructor();
  40945. /**
  40946. * The name of the behavior
  40947. */
  40948. readonly name: string;
  40949. /**
  40950. * Initializes the behavior
  40951. */
  40952. init(): void;
  40953. /**
  40954. * Attaches the fade behavior on the passed in mesh
  40955. * @param ownerNode The mesh that will be faded in/out once attached
  40956. */
  40957. attach(ownerNode: Mesh): void;
  40958. /**
  40959. * Detaches the behavior from the mesh
  40960. */
  40961. detach(): void;
  40962. /**
  40963. * Triggers the mesh to begin fading in or out
  40964. * @param value if the object should fade in or out (true to fade in)
  40965. */
  40966. fadeIn(value: boolean): void;
  40967. private _update;
  40968. private _setAllVisibility;
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /**
  40973. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40974. */
  40975. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40976. private _dragBehaviorA;
  40977. private _dragBehaviorB;
  40978. private _startDistance;
  40979. private _initialScale;
  40980. private _targetScale;
  40981. private _ownerNode;
  40982. private _sceneRenderObserver;
  40983. /**
  40984. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40985. */
  40986. constructor();
  40987. /**
  40988. * The name of the behavior
  40989. */
  40990. readonly name: string;
  40991. /**
  40992. * Initializes the behavior
  40993. */
  40994. init(): void;
  40995. private _getCurrentDistance;
  40996. /**
  40997. * Attaches the scale behavior the passed in mesh
  40998. * @param ownerNode The mesh that will be scaled around once attached
  40999. */
  41000. attach(ownerNode: Mesh): void;
  41001. /**
  41002. * Detaches the behavior from the mesh
  41003. */
  41004. detach(): void;
  41005. }
  41006. }
  41007. declare module BABYLON {
  41008. /**
  41009. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41010. */
  41011. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41012. private static _AnyMouseID;
  41013. private _attachedNode;
  41014. private _dragPlane;
  41015. private _scene;
  41016. private _pointerObserver;
  41017. private _beforeRenderObserver;
  41018. private static _planeScene;
  41019. /**
  41020. * 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)
  41021. */
  41022. maxDragAngle: number;
  41023. /**
  41024. * @hidden
  41025. */
  41026. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41027. /**
  41028. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41029. */
  41030. currentDraggingPointerID: number;
  41031. /**
  41032. * The last position where the pointer hit the drag plane in world space
  41033. */
  41034. lastDragPosition: Vector3;
  41035. /**
  41036. * If the behavior is currently in a dragging state
  41037. */
  41038. dragging: boolean;
  41039. /**
  41040. * 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)
  41041. */
  41042. dragDeltaRatio: number;
  41043. /**
  41044. * If the drag plane orientation should be updated during the dragging (Default: true)
  41045. */
  41046. updateDragPlane: boolean;
  41047. private _debugMode;
  41048. private _moving;
  41049. /**
  41050. * Fires each time the attached mesh is dragged with the pointer
  41051. * * delta between last drag position and current drag position in world space
  41052. * * dragDistance along the drag axis
  41053. * * dragPlaneNormal normal of the current drag plane used during the drag
  41054. * * dragPlanePoint in world space where the drag intersects the drag plane
  41055. */
  41056. onDragObservable: Observable<{
  41057. delta: Vector3;
  41058. dragPlanePoint: Vector3;
  41059. dragPlaneNormal: Vector3;
  41060. dragDistance: number;
  41061. pointerId: number;
  41062. }>;
  41063. /**
  41064. * Fires each time a drag begins (eg. mouse down on mesh)
  41065. */
  41066. onDragStartObservable: Observable<{
  41067. dragPlanePoint: Vector3;
  41068. pointerId: number;
  41069. }>;
  41070. /**
  41071. * Fires each time a drag ends (eg. mouse release after drag)
  41072. */
  41073. onDragEndObservable: Observable<{
  41074. dragPlanePoint: Vector3;
  41075. pointerId: number;
  41076. }>;
  41077. /**
  41078. * If the attached mesh should be moved when dragged
  41079. */
  41080. moveAttached: boolean;
  41081. /**
  41082. * If the drag behavior will react to drag events (Default: true)
  41083. */
  41084. enabled: boolean;
  41085. /**
  41086. * If camera controls should be detached during the drag
  41087. */
  41088. detachCameraControls: boolean;
  41089. /**
  41090. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41091. */
  41092. useObjectOrienationForDragging: boolean;
  41093. private _options;
  41094. /**
  41095. * Creates a pointer drag behavior that can be attached to a mesh
  41096. * @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)
  41097. */
  41098. constructor(options?: {
  41099. dragAxis?: Vector3;
  41100. dragPlaneNormal?: Vector3;
  41101. });
  41102. /**
  41103. * The name of the behavior
  41104. */
  41105. readonly name: string;
  41106. /**
  41107. * Initializes the behavior
  41108. */
  41109. init(): void;
  41110. private _tmpVector;
  41111. private _alternatePickedPoint;
  41112. private _worldDragAxis;
  41113. private _targetPosition;
  41114. private _attachedElement;
  41115. /**
  41116. * Attaches the drag behavior the passed in mesh
  41117. * @param ownerNode The mesh that will be dragged around once attached
  41118. */
  41119. attach(ownerNode: AbstractMesh): void;
  41120. /**
  41121. * Force relase the drag action by code.
  41122. */
  41123. releaseDrag(): void;
  41124. private _startDragRay;
  41125. private _lastPointerRay;
  41126. /**
  41127. * Simulates the start of a pointer drag event on the behavior
  41128. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41129. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41130. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41131. */
  41132. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41133. private _startDrag;
  41134. private _dragDelta;
  41135. private _moveDrag;
  41136. private _pickWithRayOnDragPlane;
  41137. private _pointA;
  41138. private _pointB;
  41139. private _pointC;
  41140. private _lineA;
  41141. private _lineB;
  41142. private _localAxis;
  41143. private _lookAt;
  41144. private _updateDragPlanePosition;
  41145. /**
  41146. * Detaches the behavior from the mesh
  41147. */
  41148. detach(): void;
  41149. }
  41150. }
  41151. declare module BABYLON {
  41152. /**
  41153. * 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
  41154. */
  41155. class SixDofDragBehavior implements Behavior<Mesh> {
  41156. private static _virtualScene;
  41157. private _ownerNode;
  41158. private _sceneRenderObserver;
  41159. private _scene;
  41160. private _targetPosition;
  41161. private _virtualOriginMesh;
  41162. private _virtualDragMesh;
  41163. private _pointerObserver;
  41164. private _moving;
  41165. private _startingOrientation;
  41166. /**
  41167. * 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)
  41168. */
  41169. private zDragFactor;
  41170. /**
  41171. * If the behavior is currently in a dragging state
  41172. */
  41173. dragging: boolean;
  41174. /**
  41175. * 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)
  41176. */
  41177. dragDeltaRatio: number;
  41178. /**
  41179. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41180. */
  41181. currentDraggingPointerID: number;
  41182. /**
  41183. * If camera controls should be detached during the drag
  41184. */
  41185. detachCameraControls: boolean;
  41186. /**
  41187. * Fires each time a drag starts
  41188. */
  41189. onDragStartObservable: Observable<{}>;
  41190. /**
  41191. * Fires each time a drag ends (eg. mouse release after drag)
  41192. */
  41193. onDragEndObservable: Observable<{}>;
  41194. /**
  41195. * 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
  41196. */
  41197. constructor();
  41198. /**
  41199. * The name of the behavior
  41200. */
  41201. readonly name: string;
  41202. /**
  41203. * Initializes the behavior
  41204. */
  41205. init(): void;
  41206. /**
  41207. * Attaches the scale behavior the passed in mesh
  41208. * @param ownerNode The mesh that will be scaled around once attached
  41209. */
  41210. attach(ownerNode: Mesh): void;
  41211. /**
  41212. * Detaches the behavior from the mesh
  41213. */
  41214. detach(): void;
  41215. }
  41216. }
  41217. declare module BABYLON {
  41218. /**
  41219. * Manage the gamepad inputs to control an arc rotate camera.
  41220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41221. */
  41222. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41223. /**
  41224. * Defines the camera the input is attached to.
  41225. */
  41226. camera: ArcRotateCamera;
  41227. /**
  41228. * Defines the gamepad the input is gathering event from.
  41229. */
  41230. gamepad: Nullable<Gamepad>;
  41231. /**
  41232. * Defines the gamepad rotation sensiblity.
  41233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41234. */
  41235. gamepadRotationSensibility: number;
  41236. /**
  41237. * Defines the gamepad move sensiblity.
  41238. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41239. */
  41240. gamepadMoveSensibility: number;
  41241. private _onGamepadConnectedObserver;
  41242. private _onGamepadDisconnectedObserver;
  41243. /**
  41244. * Attach the input controls to a specific dom element to get the input from.
  41245. * @param element Defines the element the controls should be listened from
  41246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41247. */
  41248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41249. /**
  41250. * Detach the current controls from the specified dom element.
  41251. * @param element Defines the element to stop listening the inputs from
  41252. */
  41253. detachControl(element: Nullable<HTMLElement>): void;
  41254. /**
  41255. * Update the current camera state depending on the inputs that have been used this frame.
  41256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41257. */
  41258. checkInputs(): void;
  41259. /**
  41260. * Gets the class name of the current intput.
  41261. * @returns the class name
  41262. */
  41263. getClassName(): string;
  41264. /**
  41265. * Get the friendly name associated with the input class.
  41266. * @returns the input friendly name
  41267. */
  41268. getSimpleName(): string;
  41269. }
  41270. }
  41271. declare module BABYLON {
  41272. /**
  41273. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41275. */
  41276. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41277. /**
  41278. * Defines the camera the input is attached to.
  41279. */
  41280. camera: ArcRotateCamera;
  41281. /**
  41282. * Defines the list of key codes associated with the up action (increase alpha)
  41283. */
  41284. keysUp: number[];
  41285. /**
  41286. * Defines the list of key codes associated with the down action (decrease alpha)
  41287. */
  41288. keysDown: number[];
  41289. /**
  41290. * Defines the list of key codes associated with the left action (increase beta)
  41291. */
  41292. keysLeft: number[];
  41293. /**
  41294. * Defines the list of key codes associated with the right action (decrease beta)
  41295. */
  41296. keysRight: number[];
  41297. /**
  41298. * Defines the list of key codes associated with the reset action.
  41299. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41300. */
  41301. keysReset: number[];
  41302. /**
  41303. * Defines the panning sensibility of the inputs.
  41304. * (How fast is the camera paning)
  41305. */
  41306. panningSensibility: number;
  41307. /**
  41308. * Defines the zooming sensibility of the inputs.
  41309. * (How fast is the camera zooming)
  41310. */
  41311. zoomingSensibility: number;
  41312. /**
  41313. * Defines wether maintaining the alt key down switch the movement mode from
  41314. * orientation to zoom.
  41315. */
  41316. useAltToZoom: boolean;
  41317. /**
  41318. * Rotation speed of the camera
  41319. */
  41320. angularSpeed: number;
  41321. private _keys;
  41322. private _ctrlPressed;
  41323. private _altPressed;
  41324. private _onCanvasBlurObserver;
  41325. private _onKeyboardObserver;
  41326. private _engine;
  41327. private _scene;
  41328. /**
  41329. * Attach the input controls to a specific dom element to get the input from.
  41330. * @param element Defines the element the controls should be listened from
  41331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41332. */
  41333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41334. /**
  41335. * Detach the current controls from the specified dom element.
  41336. * @param element Defines the element to stop listening the inputs from
  41337. */
  41338. detachControl(element: Nullable<HTMLElement>): void;
  41339. /**
  41340. * Update the current camera state depending on the inputs that have been used this frame.
  41341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41342. */
  41343. checkInputs(): void;
  41344. /**
  41345. * Gets the class name of the current intput.
  41346. * @returns the class name
  41347. */
  41348. getClassName(): string;
  41349. /**
  41350. * Get the friendly name associated with the input class.
  41351. * @returns the input friendly name
  41352. */
  41353. getSimpleName(): string;
  41354. }
  41355. }
  41356. declare module BABYLON {
  41357. /**
  41358. * Manage the mouse wheel inputs to control an arc rotate camera.
  41359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41360. */
  41361. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41362. /**
  41363. * Defines the camera the input is attached to.
  41364. */
  41365. camera: ArcRotateCamera;
  41366. /**
  41367. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41368. */
  41369. wheelPrecision: number;
  41370. /**
  41371. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41372. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41373. */
  41374. wheelDeltaPercentage: number;
  41375. private _wheel;
  41376. private _observer;
  41377. /**
  41378. * Attach the input controls to a specific dom element to get the input from.
  41379. * @param element Defines the element the controls should be listened from
  41380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41381. */
  41382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41383. /**
  41384. * Detach the current controls from the specified dom element.
  41385. * @param element Defines the element to stop listening the inputs from
  41386. */
  41387. detachControl(element: Nullable<HTMLElement>): void;
  41388. /**
  41389. * Gets the class name of the current intput.
  41390. * @returns the class name
  41391. */
  41392. getClassName(): string;
  41393. /**
  41394. * Get the friendly name associated with the input class.
  41395. * @returns the input friendly name
  41396. */
  41397. getSimpleName(): string;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Manage the pointers inputs to control an arc rotate camera.
  41403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41404. */
  41405. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41406. /**
  41407. * Defines the camera the input is attached to.
  41408. */
  41409. camera: ArcRotateCamera;
  41410. /**
  41411. * Defines the buttons associated with the input to handle camera move.
  41412. */
  41413. buttons: number[];
  41414. /**
  41415. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41416. */
  41417. angularSensibilityX: number;
  41418. /**
  41419. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41420. */
  41421. angularSensibilityY: number;
  41422. /**
  41423. * Defines the pointer pinch precision or how fast is the camera zooming.
  41424. */
  41425. pinchPrecision: number;
  41426. /**
  41427. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41428. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41429. */
  41430. pinchDeltaPercentage: number;
  41431. /**
  41432. * Defines the pointer panning sensibility or how fast is the camera moving.
  41433. */
  41434. panningSensibility: number;
  41435. /**
  41436. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41437. */
  41438. multiTouchPanning: boolean;
  41439. /**
  41440. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41441. */
  41442. multiTouchPanAndZoom: boolean;
  41443. /**
  41444. * Revers pinch action direction.
  41445. */
  41446. pinchInwards: boolean;
  41447. private _isPanClick;
  41448. private _pointerInput;
  41449. private _observer;
  41450. private _onMouseMove;
  41451. private _onGestureStart;
  41452. private _onGesture;
  41453. private _MSGestureHandler;
  41454. private _onLostFocus;
  41455. private _onContextMenu;
  41456. /**
  41457. * Attach the input controls to a specific dom element to get the input from.
  41458. * @param element Defines the element the controls should be listened from
  41459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41460. */
  41461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41462. /**
  41463. * Detach the current controls from the specified dom element.
  41464. * @param element Defines the element to stop listening the inputs from
  41465. */
  41466. detachControl(element: Nullable<HTMLElement>): void;
  41467. /**
  41468. * Gets the class name of the current intput.
  41469. * @returns the class name
  41470. */
  41471. getClassName(): string;
  41472. /**
  41473. * Get the friendly name associated with the input class.
  41474. * @returns the input friendly name
  41475. */
  41476. getSimpleName(): string;
  41477. }
  41478. }
  41479. declare module BABYLON {
  41480. /**
  41481. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41483. */
  41484. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41485. /**
  41486. * Defines the camera the input is attached to.
  41487. */
  41488. camera: ArcRotateCamera;
  41489. /**
  41490. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41491. */
  41492. alphaCorrection: number;
  41493. /**
  41494. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41495. */
  41496. gammaCorrection: number;
  41497. private _alpha;
  41498. private _gamma;
  41499. private _dirty;
  41500. private _deviceOrientationHandler;
  41501. /**
  41502. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41503. */
  41504. constructor();
  41505. /**
  41506. * Attach the input controls to a specific dom element to get the input from.
  41507. * @param element Defines the element the controls should be listened from
  41508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41509. */
  41510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41511. /** @hidden */
  41512. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41513. /**
  41514. * Update the current camera state depending on the inputs that have been used this frame.
  41515. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41516. */
  41517. checkInputs(): void;
  41518. /**
  41519. * Detach the current controls from the specified dom element.
  41520. * @param element Defines the element to stop listening the inputs from
  41521. */
  41522. detachControl(element: Nullable<HTMLElement>): void;
  41523. /**
  41524. * Gets the class name of the current intput.
  41525. * @returns the class name
  41526. */
  41527. getClassName(): string;
  41528. /**
  41529. * Get the friendly name associated with the input class.
  41530. * @returns the input friendly name
  41531. */
  41532. getSimpleName(): string;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * Listen to keyboard events to control the camera.
  41538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41539. */
  41540. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41541. /**
  41542. * Defines the camera the input is attached to.
  41543. */
  41544. camera: FlyCamera;
  41545. /**
  41546. * The list of keyboard keys used to control the forward move of the camera.
  41547. */
  41548. keysForward: number[];
  41549. /**
  41550. * The list of keyboard keys used to control the backward move of the camera.
  41551. */
  41552. keysBackward: number[];
  41553. /**
  41554. * The list of keyboard keys used to control the forward move of the camera.
  41555. */
  41556. keysUp: number[];
  41557. /**
  41558. * The list of keyboard keys used to control the backward move of the camera.
  41559. */
  41560. keysDown: number[];
  41561. /**
  41562. * The list of keyboard keys used to control the right strafe move of the camera.
  41563. */
  41564. keysRight: number[];
  41565. /**
  41566. * The list of keyboard keys used to control the left strafe move of the camera.
  41567. */
  41568. keysLeft: number[];
  41569. private _keys;
  41570. private _onCanvasBlurObserver;
  41571. private _onKeyboardObserver;
  41572. private _engine;
  41573. private _scene;
  41574. /**
  41575. * Attach the input controls to a specific dom element to get the input from.
  41576. * @param element Defines the element the controls should be listened from
  41577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41578. */
  41579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41580. /**
  41581. * Detach the current controls from the specified dom element.
  41582. * @param element Defines the element to stop listening the inputs from
  41583. */
  41584. detachControl(element: Nullable<HTMLElement>): void;
  41585. /**
  41586. * Gets the class name of the current intput.
  41587. * @returns the class name
  41588. */
  41589. getClassName(): string;
  41590. /** @hidden */
  41591. _onLostFocus(e: FocusEvent): void;
  41592. /**
  41593. * Get the friendly name associated with the input class.
  41594. * @returns the input friendly name
  41595. */
  41596. getSimpleName(): string;
  41597. /**
  41598. * Update the current camera state depending on the inputs that have been used this frame.
  41599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41600. */
  41601. checkInputs(): void;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * Listen to mouse events to control the camera.
  41607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41608. */
  41609. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41610. /**
  41611. * Defines the camera the input is attached to.
  41612. */
  41613. camera: FlyCamera;
  41614. /**
  41615. * Defines if touch is enabled. (Default is true.)
  41616. */
  41617. touchEnabled: boolean;
  41618. /**
  41619. * Defines the buttons associated with the input to handle camera rotation.
  41620. */
  41621. buttons: number[];
  41622. /**
  41623. * Assign buttons for Yaw control.
  41624. */
  41625. buttonsYaw: number[];
  41626. /**
  41627. * Assign buttons for Pitch control.
  41628. */
  41629. buttonsPitch: number[];
  41630. /**
  41631. * Assign buttons for Roll control.
  41632. */
  41633. buttonsRoll: number[];
  41634. /**
  41635. * Detect if any button is being pressed while mouse is moved.
  41636. * -1 = Mouse locked.
  41637. * 0 = Left button.
  41638. * 1 = Middle Button.
  41639. * 2 = Right Button.
  41640. */
  41641. activeButton: number;
  41642. /**
  41643. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41644. * Higher values reduce its sensitivity.
  41645. */
  41646. angularSensibility: number;
  41647. private _mousemoveCallback;
  41648. private _observer;
  41649. private _rollObserver;
  41650. private previousPosition;
  41651. private noPreventDefault;
  41652. private element;
  41653. /**
  41654. * Listen to mouse events to control the camera.
  41655. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41657. */
  41658. constructor(touchEnabled?: boolean);
  41659. /**
  41660. * Attach the mouse control to the HTML DOM element.
  41661. * @param element Defines the element that listens to the input events.
  41662. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41663. */
  41664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41665. /**
  41666. * Detach the current controls from the specified dom element.
  41667. * @param element Defines the element to stop listening the inputs from
  41668. */
  41669. detachControl(element: Nullable<HTMLElement>): void;
  41670. /**
  41671. * Gets the class name of the current input.
  41672. * @returns the class name.
  41673. */
  41674. getClassName(): string;
  41675. /**
  41676. * Get the friendly name associated with the input class.
  41677. * @returns the input's friendly name.
  41678. */
  41679. getSimpleName(): string;
  41680. private _pointerInput;
  41681. private _onMouseMove;
  41682. /**
  41683. * Rotate camera by mouse offset.
  41684. */
  41685. private rotateCamera;
  41686. }
  41687. }
  41688. declare module BABYLON {
  41689. /**
  41690. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41691. * Screen rotation is taken into account.
  41692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41693. */
  41694. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41695. private _camera;
  41696. private _screenOrientationAngle;
  41697. private _constantTranform;
  41698. private _screenQuaternion;
  41699. private _alpha;
  41700. private _beta;
  41701. private _gamma;
  41702. /**
  41703. * Instantiates a new input
  41704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41705. */
  41706. constructor();
  41707. /**
  41708. * Define the camera controlled by the input.
  41709. */
  41710. camera: FreeCamera;
  41711. /**
  41712. * Attach the input controls to a specific dom element to get the input from.
  41713. * @param element Defines the element the controls should be listened from
  41714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41715. */
  41716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41717. private _orientationChanged;
  41718. private _deviceOrientation;
  41719. /**
  41720. * Detach the current controls from the specified dom element.
  41721. * @param element Defines the element to stop listening the inputs from
  41722. */
  41723. detachControl(element: Nullable<HTMLElement>): void;
  41724. /**
  41725. * Update the current camera state depending on the inputs that have been used this frame.
  41726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41727. */
  41728. checkInputs(): void;
  41729. /**
  41730. * Gets the class name of the current intput.
  41731. * @returns the class name
  41732. */
  41733. getClassName(): string;
  41734. /**
  41735. * Get the friendly name associated with the input class.
  41736. * @returns the input friendly name
  41737. */
  41738. getSimpleName(): string;
  41739. }
  41740. }
  41741. declare module BABYLON {
  41742. /**
  41743. * Manage the gamepad inputs to control a free camera.
  41744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41745. */
  41746. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41747. /**
  41748. * Define the camera the input is attached to.
  41749. */
  41750. camera: FreeCamera;
  41751. /**
  41752. * Define the Gamepad controlling the input
  41753. */
  41754. gamepad: Nullable<Gamepad>;
  41755. /**
  41756. * Defines the gamepad rotation sensiblity.
  41757. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41758. */
  41759. gamepadAngularSensibility: number;
  41760. /**
  41761. * Defines the gamepad move sensiblity.
  41762. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41763. */
  41764. gamepadMoveSensibility: number;
  41765. private _onGamepadConnectedObserver;
  41766. private _onGamepadDisconnectedObserver;
  41767. private _cameraTransform;
  41768. private _deltaTransform;
  41769. private _vector3;
  41770. private _vector2;
  41771. /**
  41772. * Attach the input controls to a specific dom element to get the input from.
  41773. * @param element Defines the element the controls should be listened from
  41774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41775. */
  41776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41777. /**
  41778. * Detach the current controls from the specified dom element.
  41779. * @param element Defines the element to stop listening the inputs from
  41780. */
  41781. detachControl(element: Nullable<HTMLElement>): void;
  41782. /**
  41783. * Update the current camera state depending on the inputs that have been used this frame.
  41784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41785. */
  41786. checkInputs(): void;
  41787. /**
  41788. * Gets the class name of the current intput.
  41789. * @returns the class name
  41790. */
  41791. getClassName(): string;
  41792. /**
  41793. * Get the friendly name associated with the input class.
  41794. * @returns the input friendly name
  41795. */
  41796. getSimpleName(): string;
  41797. }
  41798. }
  41799. declare module BABYLON {
  41800. /**
  41801. * Manage the keyboard inputs to control the movement of a free camera.
  41802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41803. */
  41804. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41805. /**
  41806. * Defines the camera the input is attached to.
  41807. */
  41808. camera: FreeCamera;
  41809. /**
  41810. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41811. */
  41812. keysUp: number[];
  41813. /**
  41814. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41815. */
  41816. keysDown: number[];
  41817. /**
  41818. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41819. */
  41820. keysLeft: number[];
  41821. /**
  41822. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41823. */
  41824. keysRight: number[];
  41825. private _keys;
  41826. private _onCanvasBlurObserver;
  41827. private _onKeyboardObserver;
  41828. private _engine;
  41829. private _scene;
  41830. /**
  41831. * Attach the input controls to a specific dom element to get the input from.
  41832. * @param element Defines the element the controls should be listened from
  41833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41834. */
  41835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41836. /**
  41837. * Detach the current controls from the specified dom element.
  41838. * @param element Defines the element to stop listening the inputs from
  41839. */
  41840. detachControl(element: Nullable<HTMLElement>): void;
  41841. /**
  41842. * Update the current camera state depending on the inputs that have been used this frame.
  41843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41844. */
  41845. checkInputs(): void;
  41846. /**
  41847. * Gets the class name of the current intput.
  41848. * @returns the class name
  41849. */
  41850. getClassName(): string;
  41851. /** @hidden */
  41852. _onLostFocus(e: FocusEvent): void;
  41853. /**
  41854. * Get the friendly name associated with the input class.
  41855. * @returns the input friendly name
  41856. */
  41857. getSimpleName(): string;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. /**
  41862. * Manage the mouse inputs to control the movement of a free camera.
  41863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41864. */
  41865. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41866. /**
  41867. * Define if touch is enabled in the mouse input
  41868. */
  41869. touchEnabled: boolean;
  41870. /**
  41871. * Defines the camera the input is attached to.
  41872. */
  41873. camera: FreeCamera;
  41874. /**
  41875. * Defines the buttons associated with the input to handle camera move.
  41876. */
  41877. buttons: number[];
  41878. /**
  41879. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41880. */
  41881. angularSensibility: number;
  41882. private _pointerInput;
  41883. private _onMouseMove;
  41884. private _observer;
  41885. private previousPosition;
  41886. /**
  41887. * Manage the mouse inputs to control the movement of a free camera.
  41888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41889. * @param touchEnabled Defines if touch is enabled or not
  41890. */
  41891. constructor(
  41892. /**
  41893. * Define if touch is enabled in the mouse input
  41894. */
  41895. touchEnabled?: boolean);
  41896. /**
  41897. * Attach the input controls to a specific dom element to get the input from.
  41898. * @param element Defines the element the controls should be listened from
  41899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41900. */
  41901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41902. /**
  41903. * Detach the current controls from the specified dom element.
  41904. * @param element Defines the element to stop listening the inputs from
  41905. */
  41906. detachControl(element: Nullable<HTMLElement>): void;
  41907. /**
  41908. * Gets the class name of the current intput.
  41909. * @returns the class name
  41910. */
  41911. getClassName(): string;
  41912. /**
  41913. * Get the friendly name associated with the input class.
  41914. * @returns the input friendly name
  41915. */
  41916. getSimpleName(): string;
  41917. }
  41918. }
  41919. declare module BABYLON {
  41920. /**
  41921. * Manage the touch inputs to control the movement of a free camera.
  41922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41923. */
  41924. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41925. /**
  41926. * Defines the camera the input is attached to.
  41927. */
  41928. camera: FreeCamera;
  41929. /**
  41930. * Defines the touch sensibility for rotation.
  41931. * The higher the faster.
  41932. */
  41933. touchAngularSensibility: number;
  41934. /**
  41935. * Defines the touch sensibility for move.
  41936. * The higher the faster.
  41937. */
  41938. touchMoveSensibility: number;
  41939. private _offsetX;
  41940. private _offsetY;
  41941. private _pointerPressed;
  41942. private _pointerInput;
  41943. private _observer;
  41944. private _onLostFocus;
  41945. /**
  41946. * Attach the input controls to a specific dom element to get the input from.
  41947. * @param element Defines the element the controls should be listened from
  41948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41949. */
  41950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41951. /**
  41952. * Detach the current controls from the specified dom element.
  41953. * @param element Defines the element to stop listening the inputs from
  41954. */
  41955. detachControl(element: Nullable<HTMLElement>): void;
  41956. /**
  41957. * Update the current camera state depending on the inputs that have been used this frame.
  41958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41959. */
  41960. checkInputs(): void;
  41961. /**
  41962. * Gets the class name of the current intput.
  41963. * @returns the class name
  41964. */
  41965. getClassName(): string;
  41966. /**
  41967. * Get the friendly name associated with the input class.
  41968. * @returns the input friendly name
  41969. */
  41970. getSimpleName(): string;
  41971. }
  41972. }
  41973. declare module BABYLON {
  41974. /**
  41975. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41977. */
  41978. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41979. /**
  41980. * Defines the camera the input is attached to.
  41981. */
  41982. camera: FreeCamera;
  41983. private _leftjoystick;
  41984. private _rightjoystick;
  41985. /**
  41986. * Gets the left stick of the virtual joystick.
  41987. * @returns The virtual Joystick
  41988. */
  41989. getLeftJoystick(): VirtualJoystick;
  41990. /**
  41991. * Gets the right stick of the virtual joystick.
  41992. * @returns The virtual Joystick
  41993. */
  41994. getRightJoystick(): VirtualJoystick;
  41995. /**
  41996. * Update the current camera state depending on the inputs that have been used this frame.
  41997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41998. */
  41999. checkInputs(): void;
  42000. /**
  42001. * Attach the input controls to a specific dom element to get the input from.
  42002. * @param element Defines the element the controls should be listened from
  42003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42004. */
  42005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42006. /**
  42007. * Detach the current controls from the specified dom element.
  42008. * @param element Defines the element to stop listening the inputs from
  42009. */
  42010. detachControl(element: Nullable<HTMLElement>): void;
  42011. /**
  42012. * Gets the class name of the current intput.
  42013. * @returns the class name
  42014. */
  42015. getClassName(): string;
  42016. /**
  42017. * Get the friendly name associated with the input class.
  42018. * @returns the input friendly name
  42019. */
  42020. getSimpleName(): string;
  42021. }
  42022. }
  42023. declare module BABYLON {
  42024. /**
  42025. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42026. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42027. */
  42028. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42029. /**
  42030. * Creates a new AnaglyphArcRotateCamera
  42031. * @param name defines camera name
  42032. * @param alpha defines alpha angle (in radians)
  42033. * @param beta defines beta angle (in radians)
  42034. * @param radius defines radius
  42035. * @param target defines camera target
  42036. * @param interaxialDistance defines distance between each color axis
  42037. * @param scene defines the hosting scene
  42038. */
  42039. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42040. /**
  42041. * Gets camera class name
  42042. * @returns AnaglyphArcRotateCamera
  42043. */
  42044. getClassName(): string;
  42045. }
  42046. }
  42047. declare module BABYLON {
  42048. /**
  42049. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42050. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42051. */
  42052. class AnaglyphFreeCamera extends FreeCamera {
  42053. /**
  42054. * Creates a new AnaglyphFreeCamera
  42055. * @param name defines camera name
  42056. * @param position defines initial position
  42057. * @param interaxialDistance defines distance between each color axis
  42058. * @param scene defines the hosting scene
  42059. */
  42060. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42061. /**
  42062. * Gets camera class name
  42063. * @returns AnaglyphFreeCamera
  42064. */
  42065. getClassName(): string;
  42066. }
  42067. }
  42068. declare module BABYLON {
  42069. /**
  42070. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42071. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42072. */
  42073. class AnaglyphGamepadCamera extends GamepadCamera {
  42074. /**
  42075. * Creates a new AnaglyphGamepadCamera
  42076. * @param name defines camera name
  42077. * @param position defines initial position
  42078. * @param interaxialDistance defines distance between each color axis
  42079. * @param scene defines the hosting scene
  42080. */
  42081. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42082. /**
  42083. * Gets camera class name
  42084. * @returns AnaglyphGamepadCamera
  42085. */
  42086. getClassName(): string;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42092. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42093. */
  42094. class AnaglyphUniversalCamera extends UniversalCamera {
  42095. /**
  42096. * Creates a new AnaglyphUniversalCamera
  42097. * @param name defines camera name
  42098. * @param position defines initial position
  42099. * @param interaxialDistance defines distance between each color axis
  42100. * @param scene defines the hosting scene
  42101. */
  42102. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42103. /**
  42104. * Gets camera class name
  42105. * @returns AnaglyphUniversalCamera
  42106. */
  42107. getClassName(): string;
  42108. }
  42109. }
  42110. declare module BABYLON {
  42111. /**
  42112. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42113. * @see http://doc.babylonjs.com/features/cameras
  42114. */
  42115. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42116. /**
  42117. * Creates a new StereoscopicArcRotateCamera
  42118. * @param name defines camera name
  42119. * @param alpha defines alpha angle (in radians)
  42120. * @param beta defines beta angle (in radians)
  42121. * @param radius defines radius
  42122. * @param target defines camera target
  42123. * @param interaxialDistance defines distance between each color axis
  42124. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42125. * @param scene defines the hosting scene
  42126. */
  42127. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42128. /**
  42129. * Gets camera class name
  42130. * @returns StereoscopicArcRotateCamera
  42131. */
  42132. getClassName(): string;
  42133. }
  42134. }
  42135. declare module BABYLON {
  42136. /**
  42137. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42138. * @see http://doc.babylonjs.com/features/cameras
  42139. */
  42140. class StereoscopicFreeCamera extends FreeCamera {
  42141. /**
  42142. * Creates a new StereoscopicFreeCamera
  42143. * @param name defines camera name
  42144. * @param position defines initial position
  42145. * @param interaxialDistance defines distance between each color axis
  42146. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42147. * @param scene defines the hosting scene
  42148. */
  42149. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42150. /**
  42151. * Gets camera class name
  42152. * @returns StereoscopicFreeCamera
  42153. */
  42154. getClassName(): string;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /**
  42159. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42160. * @see http://doc.babylonjs.com/features/cameras
  42161. */
  42162. class StereoscopicGamepadCamera extends GamepadCamera {
  42163. /**
  42164. * Creates a new StereoscopicGamepadCamera
  42165. * @param name defines camera name
  42166. * @param position defines initial position
  42167. * @param interaxialDistance defines distance between each color axis
  42168. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42169. * @param scene defines the hosting scene
  42170. */
  42171. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42172. /**
  42173. * Gets camera class name
  42174. * @returns StereoscopicGamepadCamera
  42175. */
  42176. getClassName(): string;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42182. * @see http://doc.babylonjs.com/features/cameras
  42183. */
  42184. class StereoscopicUniversalCamera extends UniversalCamera {
  42185. /**
  42186. * Creates a new StereoscopicUniversalCamera
  42187. * @param name defines camera name
  42188. * @param position defines initial position
  42189. * @param interaxialDistance defines distance between each color axis
  42190. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42191. * @param scene defines the hosting scene
  42192. */
  42193. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42194. /**
  42195. * Gets camera class name
  42196. * @returns StereoscopicUniversalCamera
  42197. */
  42198. getClassName(): string;
  42199. }
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * This represents all the required metrics to create a VR camera.
  42204. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42205. */
  42206. class VRCameraMetrics {
  42207. /**
  42208. * Define the horizontal resolution off the screen.
  42209. */
  42210. hResolution: number;
  42211. /**
  42212. * Define the vertical resolution off the screen.
  42213. */
  42214. vResolution: number;
  42215. /**
  42216. * Define the horizontal screen size.
  42217. */
  42218. hScreenSize: number;
  42219. /**
  42220. * Define the vertical screen size.
  42221. */
  42222. vScreenSize: number;
  42223. /**
  42224. * Define the vertical screen center position.
  42225. */
  42226. vScreenCenter: number;
  42227. /**
  42228. * Define the distance of the eyes to the screen.
  42229. */
  42230. eyeToScreenDistance: number;
  42231. /**
  42232. * Define the distance between both lenses
  42233. */
  42234. lensSeparationDistance: number;
  42235. /**
  42236. * Define the distance between both viewer's eyes.
  42237. */
  42238. interpupillaryDistance: number;
  42239. /**
  42240. * Define the distortion factor of the VR postprocess.
  42241. * Please, touch with care.
  42242. */
  42243. distortionK: number[];
  42244. /**
  42245. * Define the chromatic aberration correction factors for the VR post process.
  42246. */
  42247. chromaAbCorrection: number[];
  42248. /**
  42249. * Define the scale factor of the post process.
  42250. * The smaller the better but the slower.
  42251. */
  42252. postProcessScaleFactor: number;
  42253. /**
  42254. * Define an offset for the lens center.
  42255. */
  42256. lensCenterOffset: number;
  42257. /**
  42258. * Define if the current vr camera should compensate the distortion of the lense or not.
  42259. */
  42260. compensateDistortion: boolean;
  42261. /**
  42262. * Gets the rendering aspect ratio based on the provided resolutions.
  42263. */
  42264. readonly aspectRatio: number;
  42265. /**
  42266. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42267. */
  42268. readonly aspectRatioFov: number;
  42269. /**
  42270. * @hidden
  42271. */
  42272. readonly leftHMatrix: Matrix;
  42273. /**
  42274. * @hidden
  42275. */
  42276. readonly rightHMatrix: Matrix;
  42277. /**
  42278. * @hidden
  42279. */
  42280. readonly leftPreViewMatrix: Matrix;
  42281. /**
  42282. * @hidden
  42283. */
  42284. readonly rightPreViewMatrix: Matrix;
  42285. /**
  42286. * Get the default VRMetrics based on the most generic setup.
  42287. * @returns the default vr metrics
  42288. */
  42289. static GetDefault(): VRCameraMetrics;
  42290. }
  42291. }
  42292. declare module BABYLON {
  42293. /**
  42294. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42295. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42296. */
  42297. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42298. /**
  42299. * Creates a new VRDeviceOrientationArcRotateCamera
  42300. * @param name defines camera name
  42301. * @param alpha defines the camera rotation along the logitudinal axis
  42302. * @param beta defines the camera rotation along the latitudinal axis
  42303. * @param radius defines the camera distance from its target
  42304. * @param target defines the camera target
  42305. * @param scene defines the scene the camera belongs to
  42306. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42307. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42308. */
  42309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42310. /**
  42311. * Gets camera class name
  42312. * @returns VRDeviceOrientationArcRotateCamera
  42313. */
  42314. getClassName(): string;
  42315. }
  42316. }
  42317. declare module BABYLON {
  42318. /**
  42319. * Camera used to simulate VR rendering (based on FreeCamera)
  42320. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42321. */
  42322. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42323. /**
  42324. * Creates a new VRDeviceOrientationFreeCamera
  42325. * @param name defines camera name
  42326. * @param position defines the start position of the camera
  42327. * @param scene defines the scene the camera belongs to
  42328. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42329. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42330. */
  42331. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42332. /**
  42333. * Gets camera class name
  42334. * @returns VRDeviceOrientationFreeCamera
  42335. */
  42336. getClassName(): string;
  42337. }
  42338. }
  42339. declare module BABYLON {
  42340. /**
  42341. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42342. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42343. */
  42344. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42345. /**
  42346. * Creates a new VRDeviceOrientationGamepadCamera
  42347. * @param name defines camera name
  42348. * @param position defines the start position of the camera
  42349. * @param scene defines the scene the camera belongs to
  42350. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42351. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42352. */
  42353. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42354. /**
  42355. * Gets camera class name
  42356. * @returns VRDeviceOrientationGamepadCamera
  42357. */
  42358. getClassName(): string;
  42359. }
  42360. }
  42361. declare module BABYLON {
  42362. /**
  42363. * Options to modify the vr teleportation behavior.
  42364. */
  42365. interface VRTeleportationOptions {
  42366. /**
  42367. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42368. */
  42369. floorMeshName?: string;
  42370. /**
  42371. * A list of meshes to be used as the teleportation floor. (default: empty)
  42372. */
  42373. floorMeshes?: Mesh[];
  42374. }
  42375. /**
  42376. * Options to modify the vr experience helper's behavior.
  42377. */
  42378. interface VRExperienceHelperOptions extends WebVROptions {
  42379. /**
  42380. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42381. */
  42382. createDeviceOrientationCamera?: boolean;
  42383. /**
  42384. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42385. */
  42386. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42387. /**
  42388. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42389. */
  42390. laserToggle?: boolean;
  42391. /**
  42392. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42393. */
  42394. floorMeshes?: Mesh[];
  42395. }
  42396. /**
  42397. * Helps to quickly add VR support to an existing scene.
  42398. * See http://doc.babylonjs.com/how_to/webvr_helper
  42399. */
  42400. class VRExperienceHelper {
  42401. /** Options to modify the vr experience helper's behavior. */
  42402. webVROptions: VRExperienceHelperOptions;
  42403. private _scene;
  42404. private _position;
  42405. private _btnVR;
  42406. private _btnVRDisplayed;
  42407. private _webVRsupported;
  42408. private _webVRready;
  42409. private _webVRrequesting;
  42410. private _webVRpresenting;
  42411. private _hasEnteredVR;
  42412. private _fullscreenVRpresenting;
  42413. private _canvas;
  42414. private _webVRCamera;
  42415. private _vrDeviceOrientationCamera;
  42416. private _deviceOrientationCamera;
  42417. private _existingCamera;
  42418. private _onKeyDown;
  42419. private _onVrDisplayPresentChange;
  42420. private _onVRDisplayChanged;
  42421. private _onVRRequestPresentStart;
  42422. private _onVRRequestPresentComplete;
  42423. /**
  42424. * Observable raised when entering VR.
  42425. */
  42426. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42427. /**
  42428. * Observable raised when exiting VR.
  42429. */
  42430. onExitingVRObservable: Observable<VRExperienceHelper>;
  42431. /**
  42432. * Observable raised when controller mesh is loaded.
  42433. */
  42434. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42435. /** Return this.onEnteringVRObservable
  42436. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42437. */
  42438. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42439. /** Return this.onExitingVRObservable
  42440. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42441. */
  42442. readonly onExitingVR: Observable<VRExperienceHelper>;
  42443. /** Return this.onControllerMeshLoadedObservable
  42444. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42445. */
  42446. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42447. private _rayLength;
  42448. private _useCustomVRButton;
  42449. private _teleportationRequested;
  42450. private _teleportActive;
  42451. private _floorMeshName;
  42452. private _floorMeshesCollection;
  42453. private _rotationAllowed;
  42454. private _teleportBackwardsVector;
  42455. private _teleportationTarget;
  42456. private _isDefaultTeleportationTarget;
  42457. private _postProcessMove;
  42458. private _teleportationFillColor;
  42459. private _teleportationBorderColor;
  42460. private _rotationAngle;
  42461. private _haloCenter;
  42462. private _cameraGazer;
  42463. private _padSensibilityUp;
  42464. private _padSensibilityDown;
  42465. private _leftController;
  42466. private _rightController;
  42467. /**
  42468. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42469. */
  42470. onNewMeshSelected: Observable<AbstractMesh>;
  42471. /**
  42472. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42473. */
  42474. onNewMeshPicked: Observable<PickingInfo>;
  42475. private _circleEase;
  42476. /**
  42477. * Observable raised before camera teleportation
  42478. */
  42479. onBeforeCameraTeleport: Observable<Vector3>;
  42480. /**
  42481. * Observable raised after camera teleportation
  42482. */
  42483. onAfterCameraTeleport: Observable<Vector3>;
  42484. /**
  42485. * Observable raised when current selected mesh gets unselected
  42486. */
  42487. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42488. private _raySelectionPredicate;
  42489. /**
  42490. * To be optionaly changed by user to define custom ray selection
  42491. */
  42492. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42493. /**
  42494. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42495. */
  42496. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42497. /**
  42498. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42499. */
  42500. teleportationEnabled: boolean;
  42501. private _defaultHeight;
  42502. private _teleportationInitialized;
  42503. private _interactionsEnabled;
  42504. private _interactionsRequested;
  42505. private _displayGaze;
  42506. private _displayLaserPointer;
  42507. /**
  42508. * The mesh used to display where the user is going to teleport.
  42509. */
  42510. /**
  42511. * Sets the mesh to be used to display where the user is going to teleport.
  42512. */
  42513. teleportationTarget: Mesh;
  42514. /**
  42515. * 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
  42516. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42517. * See http://doc.babylonjs.com/resources/baking_transformations
  42518. */
  42519. gazeTrackerMesh: Mesh;
  42520. /**
  42521. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42522. */
  42523. updateGazeTrackerScale: boolean;
  42524. /**
  42525. * The gaze tracking mesh corresponding to the left controller
  42526. */
  42527. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42528. /**
  42529. * The gaze tracking mesh corresponding to the right controller
  42530. */
  42531. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42532. /**
  42533. * If the ray of the gaze should be displayed.
  42534. */
  42535. /**
  42536. * Sets if the ray of the gaze should be displayed.
  42537. */
  42538. displayGaze: boolean;
  42539. /**
  42540. * If the ray of the LaserPointer should be displayed.
  42541. */
  42542. /**
  42543. * Sets if the ray of the LaserPointer should be displayed.
  42544. */
  42545. displayLaserPointer: boolean;
  42546. /**
  42547. * The deviceOrientationCamera used as the camera when not in VR.
  42548. */
  42549. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42550. /**
  42551. * Based on the current WebVR support, returns the current VR camera used.
  42552. */
  42553. readonly currentVRCamera: Nullable<Camera>;
  42554. /**
  42555. * The webVRCamera which is used when in VR.
  42556. */
  42557. readonly webVRCamera: WebVRFreeCamera;
  42558. /**
  42559. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42560. */
  42561. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42562. private readonly _teleportationRequestInitiated;
  42563. /**
  42564. * Instantiates a VRExperienceHelper.
  42565. * Helps to quickly add VR support to an existing scene.
  42566. * @param scene The scene the VRExperienceHelper belongs to.
  42567. * @param webVROptions Options to modify the vr experience helper's behavior.
  42568. */
  42569. constructor(scene: Scene,
  42570. /** Options to modify the vr experience helper's behavior. */
  42571. webVROptions?: VRExperienceHelperOptions);
  42572. private _onDefaultMeshLoaded;
  42573. private _onResize;
  42574. private _onFullscreenChange;
  42575. /**
  42576. * Gets a value indicating if we are currently in VR mode.
  42577. */
  42578. readonly isInVRMode: boolean;
  42579. private onVrDisplayPresentChange;
  42580. private onVRDisplayChanged;
  42581. private moveButtonToBottomRight;
  42582. private displayVRButton;
  42583. private updateButtonVisibility;
  42584. private _cachedAngularSensibility;
  42585. /**
  42586. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42587. * Otherwise, will use the fullscreen API.
  42588. */
  42589. enterVR(): void;
  42590. /**
  42591. * Attempt to exit VR, or fullscreen.
  42592. */
  42593. exitVR(): void;
  42594. /**
  42595. * The position of the vr experience helper.
  42596. */
  42597. /**
  42598. * Sets the position of the vr experience helper.
  42599. */
  42600. position: Vector3;
  42601. /**
  42602. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42603. */
  42604. enableInteractions(): void;
  42605. private readonly _noControllerIsActive;
  42606. private beforeRender;
  42607. private _isTeleportationFloor;
  42608. /**
  42609. * Adds a floor mesh to be used for teleportation.
  42610. * @param floorMesh the mesh to be used for teleportation.
  42611. */
  42612. addFloorMesh(floorMesh: Mesh): void;
  42613. /**
  42614. * Removes a floor mesh from being used for teleportation.
  42615. * @param floorMesh the mesh to be removed.
  42616. */
  42617. removeFloorMesh(floorMesh: Mesh): void;
  42618. /**
  42619. * Enables interactions and teleportation using the VR controllers and gaze.
  42620. * @param vrTeleportationOptions options to modify teleportation behavior.
  42621. */
  42622. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42623. private _onNewGamepadConnected;
  42624. private _tryEnableInteractionOnController;
  42625. private _onNewGamepadDisconnected;
  42626. private _enableInteractionOnController;
  42627. private _checkTeleportWithRay;
  42628. private _checkRotate;
  42629. private _checkTeleportBackwards;
  42630. private _enableTeleportationOnController;
  42631. private _createTeleportationCircles;
  42632. private _displayTeleportationTarget;
  42633. private _hideTeleportationTarget;
  42634. private _rotateCamera;
  42635. private _moveTeleportationSelectorTo;
  42636. private _workingVector;
  42637. private _workingQuaternion;
  42638. private _workingMatrix;
  42639. /**
  42640. * Teleports the users feet to the desired location
  42641. * @param location The location where the user's feet should be placed
  42642. */
  42643. teleportCamera(location: Vector3): void;
  42644. private _convertNormalToDirectionOfRay;
  42645. private _castRayAndSelectObject;
  42646. private _notifySelectedMeshUnselected;
  42647. /**
  42648. * Sets the color of the laser ray from the vr controllers.
  42649. * @param color new color for the ray.
  42650. */
  42651. changeLaserColor(color: Color3): void;
  42652. /**
  42653. * Sets the color of the ray from the vr headsets gaze.
  42654. * @param color new color for the ray.
  42655. */
  42656. changeGazeColor(color: Color3): void;
  42657. /**
  42658. * Exits VR and disposes of the vr experience helper
  42659. */
  42660. dispose(): void;
  42661. /**
  42662. * Gets the name of the VRExperienceHelper class
  42663. * @returns "VRExperienceHelper"
  42664. */
  42665. getClassName(): string;
  42666. }
  42667. }
  42668. declare module BABYLON {
  42669. /**
  42670. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42671. * IMPORTANT!! The data is right-hand data.
  42672. * @export
  42673. * @interface DevicePose
  42674. */
  42675. interface DevicePose {
  42676. /**
  42677. * The position of the device, values in array are [x,y,z].
  42678. */
  42679. readonly position: Nullable<Float32Array>;
  42680. /**
  42681. * The linearVelocity of the device, values in array are [x,y,z].
  42682. */
  42683. readonly linearVelocity: Nullable<Float32Array>;
  42684. /**
  42685. * The linearAcceleration of the device, values in array are [x,y,z].
  42686. */
  42687. readonly linearAcceleration: Nullable<Float32Array>;
  42688. /**
  42689. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42690. */
  42691. readonly orientation: Nullable<Float32Array>;
  42692. /**
  42693. * The angularVelocity of the device, values in array are [x,y,z].
  42694. */
  42695. readonly angularVelocity: Nullable<Float32Array>;
  42696. /**
  42697. * The angularAcceleration of the device, values in array are [x,y,z].
  42698. */
  42699. readonly angularAcceleration: Nullable<Float32Array>;
  42700. }
  42701. /**
  42702. * Interface representing a pose controlled object in Babylon.
  42703. * A pose controlled object has both regular pose values as well as pose values
  42704. * from an external device such as a VR head mounted display
  42705. */
  42706. interface PoseControlled {
  42707. /**
  42708. * The position of the object in babylon space.
  42709. */
  42710. position: Vector3;
  42711. /**
  42712. * The rotation quaternion of the object in babylon space.
  42713. */
  42714. rotationQuaternion: Quaternion;
  42715. /**
  42716. * The position of the device in babylon space.
  42717. */
  42718. devicePosition?: Vector3;
  42719. /**
  42720. * The rotation quaternion of the device in babylon space.
  42721. */
  42722. deviceRotationQuaternion: Quaternion;
  42723. /**
  42724. * The raw pose coming from the device.
  42725. */
  42726. rawPose: Nullable<DevicePose>;
  42727. /**
  42728. * The scale of the device to be used when translating from device space to babylon space.
  42729. */
  42730. deviceScaleFactor: number;
  42731. /**
  42732. * Updates the poseControlled values based on the input device pose.
  42733. * @param poseData the pose data to update the object with
  42734. */
  42735. updateFromDevice(poseData: DevicePose): void;
  42736. }
  42737. /**
  42738. * Set of options to customize the webVRCamera
  42739. */
  42740. interface WebVROptions {
  42741. /**
  42742. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42743. */
  42744. trackPosition?: boolean;
  42745. /**
  42746. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42747. */
  42748. positionScale?: number;
  42749. /**
  42750. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42751. */
  42752. displayName?: string;
  42753. /**
  42754. * Should the native controller meshes be initialized. (default: true)
  42755. */
  42756. controllerMeshes?: boolean;
  42757. /**
  42758. * Creating a default HemiLight only on controllers. (default: true)
  42759. */
  42760. defaultLightingOnControllers?: boolean;
  42761. /**
  42762. * If you don't want to use the default VR button of the helper. (default: false)
  42763. */
  42764. useCustomVRButton?: boolean;
  42765. /**
  42766. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42767. */
  42768. customVRButton?: HTMLButtonElement;
  42769. /**
  42770. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42771. */
  42772. rayLength?: number;
  42773. /**
  42774. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42775. */
  42776. defaultHeight?: number;
  42777. }
  42778. /**
  42779. * This represents a WebVR camera.
  42780. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42781. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42782. */
  42783. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42784. private webVROptions;
  42785. /**
  42786. * @hidden
  42787. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42788. */
  42789. _vrDevice: any;
  42790. /**
  42791. * The rawPose of the vrDevice.
  42792. */
  42793. rawPose: Nullable<DevicePose>;
  42794. private _onVREnabled;
  42795. private _specsVersion;
  42796. private _attached;
  42797. private _frameData;
  42798. protected _descendants: Array<Node>;
  42799. private _deviceRoomPosition;
  42800. /** @hidden */
  42801. _deviceRoomRotationQuaternion: Quaternion;
  42802. private _standingMatrix;
  42803. /**
  42804. * Represents device position in babylon space.
  42805. */
  42806. devicePosition: Vector3;
  42807. /**
  42808. * Represents device rotation in babylon space.
  42809. */
  42810. deviceRotationQuaternion: Quaternion;
  42811. /**
  42812. * The scale of the device to be used when translating from device space to babylon space.
  42813. */
  42814. deviceScaleFactor: number;
  42815. private _deviceToWorld;
  42816. private _worldToDevice;
  42817. /**
  42818. * References to the webVR controllers for the vrDevice.
  42819. */
  42820. controllers: Array<WebVRController>;
  42821. /**
  42822. * Emits an event when a controller is attached.
  42823. */
  42824. onControllersAttachedObservable: Observable<WebVRController[]>;
  42825. /**
  42826. * Emits an event when a controller's mesh has been loaded;
  42827. */
  42828. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42829. /**
  42830. * Emits an event when the HMD's pose has been updated.
  42831. */
  42832. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42833. private _poseSet;
  42834. /**
  42835. * If the rig cameras be used as parent instead of this camera.
  42836. */
  42837. rigParenting: boolean;
  42838. private _lightOnControllers;
  42839. private _defaultHeight?;
  42840. /**
  42841. * Instantiates a WebVRFreeCamera.
  42842. * @param name The name of the WebVRFreeCamera
  42843. * @param position The starting anchor position for the camera
  42844. * @param scene The scene the camera belongs to
  42845. * @param webVROptions a set of customizable options for the webVRCamera
  42846. */
  42847. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42848. /**
  42849. * Gets the device distance from the ground in meters.
  42850. * @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.
  42851. */
  42852. deviceDistanceToRoomGround(): number;
  42853. /**
  42854. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42855. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42856. */
  42857. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42858. /**
  42859. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42860. * @returns A promise with a boolean set to if the standing matrix is supported.
  42861. */
  42862. useStandingMatrixAsync(): Promise<boolean>;
  42863. /**
  42864. * Disposes the camera
  42865. */
  42866. dispose(): void;
  42867. /**
  42868. * Gets a vrController by name.
  42869. * @param name The name of the controller to retreive
  42870. * @returns the controller matching the name specified or null if not found
  42871. */
  42872. getControllerByName(name: string): Nullable<WebVRController>;
  42873. private _leftController;
  42874. /**
  42875. * The controller corrisponding to the users left hand.
  42876. */
  42877. readonly leftController: Nullable<WebVRController>;
  42878. private _rightController;
  42879. /**
  42880. * The controller corrisponding to the users right hand.
  42881. */
  42882. readonly rightController: Nullable<WebVRController>;
  42883. /**
  42884. * Casts a ray forward from the vrCamera's gaze.
  42885. * @param length Length of the ray (default: 100)
  42886. * @returns the ray corrisponding to the gaze
  42887. */
  42888. getForwardRay(length?: number): Ray;
  42889. /**
  42890. * @hidden
  42891. * Updates the camera based on device's frame data
  42892. */
  42893. _checkInputs(): void;
  42894. /**
  42895. * Updates the poseControlled values based on the input device pose.
  42896. * @param poseData Pose coming from the device
  42897. */
  42898. updateFromDevice(poseData: DevicePose): void;
  42899. private _htmlElementAttached;
  42900. private _detachIfAttached;
  42901. /**
  42902. * WebVR's attach control will start broadcasting frames to the device.
  42903. * Note that in certain browsers (chrome for example) this function must be called
  42904. * within a user-interaction callback. Example:
  42905. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42906. *
  42907. * @param element html element to attach the vrDevice to
  42908. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42909. */
  42910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42911. /**
  42912. * Detaches the camera from the html element and disables VR
  42913. *
  42914. * @param element html element to detach from
  42915. */
  42916. detachControl(element: HTMLElement): void;
  42917. /**
  42918. * @returns the name of this class
  42919. */
  42920. getClassName(): string;
  42921. /**
  42922. * Calls resetPose on the vrDisplay
  42923. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42924. */
  42925. resetToCurrentRotation(): void;
  42926. /**
  42927. * @hidden
  42928. * Updates the rig cameras (left and right eye)
  42929. */
  42930. _updateRigCameras(): void;
  42931. private _workingVector;
  42932. private _oneVector;
  42933. private _workingMatrix;
  42934. private updateCacheCalled;
  42935. private _correctPositionIfNotTrackPosition;
  42936. /**
  42937. * @hidden
  42938. * Updates the cached values of the camera
  42939. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42940. */
  42941. _updateCache(ignoreParentClass?: boolean): void;
  42942. /**
  42943. * @hidden
  42944. * Get current device position in babylon world
  42945. */
  42946. _computeDevicePosition(): void;
  42947. /**
  42948. * Updates the current device position and rotation in the babylon world
  42949. */
  42950. update(): void;
  42951. /**
  42952. * @hidden
  42953. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42954. * @returns an identity matrix
  42955. */
  42956. _getViewMatrix(): Matrix;
  42957. private _tmpMatrix;
  42958. /**
  42959. * This function is called by the two RIG cameras.
  42960. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42961. */
  42962. protected _getWebVRViewMatrix(): Matrix;
  42963. protected _getWebVRProjectionMatrix(): Matrix;
  42964. private _onGamepadConnectedObserver;
  42965. private _onGamepadDisconnectedObserver;
  42966. private _updateCacheWhenTrackingDisabledObserver;
  42967. /**
  42968. * Initializes the controllers and their meshes
  42969. */
  42970. initControllers(): void;
  42971. }
  42972. }
  42973. declare module BABYLON {
  42974. /**
  42975. * WebXR Camera which holds the views for the xrSession
  42976. * @see https://doc.babylonjs.com/how_to/webxr
  42977. */
  42978. class WebXRCamera extends FreeCamera {
  42979. private static _TmpMatrix;
  42980. /**
  42981. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42982. * @param name the name of the camera
  42983. * @param scene the scene to add the camera to
  42984. */
  42985. constructor(name: string, scene: BABYLON.Scene);
  42986. private _updateNumberOfRigCameras;
  42987. /** @hidden */
  42988. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42989. /**
  42990. * Updates the cameras position from the current pose information of the XR session
  42991. * @param xrSessionManager the session containing pose information
  42992. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42993. */
  42994. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42995. }
  42996. }
  42997. declare module BABYLON {
  42998. /**
  42999. * Button which can be used to enter a different mode of XR
  43000. */
  43001. class WebXREnterExitUIButton {
  43002. /** button element */
  43003. element: HTMLElement;
  43004. /** XR initialization options for the button */
  43005. initializationOptions: XRSessionCreationOptions;
  43006. /**
  43007. * Creates a WebXREnterExitUIButton
  43008. * @param element button element
  43009. * @param initializationOptions XR initialization options for the button
  43010. */
  43011. constructor(
  43012. /** button element */
  43013. element: HTMLElement,
  43014. /** XR initialization options for the button */
  43015. initializationOptions: XRSessionCreationOptions);
  43016. /**
  43017. * Overwritable function which can be used to update the button's visuals when the state changes
  43018. * @param activeButton the current active button in the UI
  43019. */
  43020. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43021. }
  43022. /**
  43023. * Options to create the webXR UI
  43024. */
  43025. class WebXREnterExitUIOptions {
  43026. /**
  43027. * Context to enter xr with
  43028. */
  43029. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43030. /**
  43031. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43032. */
  43033. customButtons?: Array<WebXREnterExitUIButton>;
  43034. }
  43035. /**
  43036. * UI to allow the user to enter/exit XR mode
  43037. */
  43038. class WebXREnterExitUI implements IDisposable {
  43039. private scene;
  43040. private _overlay;
  43041. private _buttons;
  43042. private _activeButton;
  43043. /**
  43044. * Fired every time the active button is changed.
  43045. *
  43046. * When xr is entered via a button that launches xr that button will be the callback parameter
  43047. *
  43048. * When exiting xr the callback parameter will be null)
  43049. */
  43050. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43051. /**
  43052. * Creates UI to allow the user to enter/exit XR mode
  43053. * @param scene the scene to add the ui to
  43054. * @param helper the xr experience helper to enter/exit xr with
  43055. * @param options options to configure the UI
  43056. * @returns the created ui
  43057. */
  43058. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43059. private constructor();
  43060. private _updateButtons;
  43061. /**
  43062. * Disposes of the object
  43063. */
  43064. dispose(): void;
  43065. }
  43066. }
  43067. declare module BABYLON {
  43068. /**
  43069. * States of the webXR experience
  43070. */
  43071. enum WebXRState {
  43072. /**
  43073. * Transitioning to being in XR mode
  43074. */
  43075. ENTERING_XR = 0,
  43076. /**
  43077. * Transitioning to non XR mode
  43078. */
  43079. EXITING_XR = 1,
  43080. /**
  43081. * In XR mode and presenting
  43082. */
  43083. IN_XR = 2,
  43084. /**
  43085. * Not entered XR mode
  43086. */
  43087. NOT_IN_XR = 3
  43088. }
  43089. /**
  43090. * Helper class used to enable XR
  43091. * @see https://doc.babylonjs.com/how_to/webxr
  43092. */
  43093. class WebXRExperienceHelper implements IDisposable {
  43094. private scene;
  43095. /**
  43096. * 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
  43097. */
  43098. container: AbstractMesh;
  43099. /**
  43100. * Camera used to render xr content
  43101. */
  43102. camera: WebXRCamera;
  43103. /**
  43104. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43105. */
  43106. state: WebXRState;
  43107. private _setState;
  43108. private static _TmpVector;
  43109. /**
  43110. * Fires when the state of the experience helper has changed
  43111. */
  43112. onStateChangedObservable: Observable<WebXRState>;
  43113. /** @hidden */
  43114. _sessionManager: WebXRSessionManager;
  43115. private _nonVRCamera;
  43116. private _originalSceneAutoClear;
  43117. private _supported;
  43118. /**
  43119. * Creates the experience helper
  43120. * @param scene the scene to attach the experience helper to
  43121. * @returns a promise for the experience helper
  43122. */
  43123. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43124. /**
  43125. * Creates a WebXRExperienceHelper
  43126. * @param scene The scene the helper should be created in
  43127. */
  43128. private constructor();
  43129. /**
  43130. * Exits XR mode and returns the scene to its original state
  43131. * @returns promise that resolves after xr mode has exited
  43132. */
  43133. exitXRAsync(): Promise<void>;
  43134. /**
  43135. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43136. * @param sessionCreationOptions options for the XR session
  43137. * @param frameOfReference frame of reference of the XR session
  43138. * @returns promise that resolves after xr mode has entered
  43139. */
  43140. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43141. /**
  43142. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43143. * @param ray ray to cast into the environment
  43144. * @returns Promise which resolves with a collision point in the environment if it exists
  43145. */
  43146. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43147. /**
  43148. * Updates the global position of the camera by moving the camera's container
  43149. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43150. * @param position The desired global position of the camera
  43151. */
  43152. setPositionOfCameraUsingContainer(position: Vector3): void;
  43153. /**
  43154. * Rotates the xr camera by rotating the camera's container around the camera's position
  43155. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43156. * @param rotation the desired quaternion rotation to apply to the camera
  43157. */
  43158. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43159. /**
  43160. * Checks if the creation options are supported by the xr session
  43161. * @param options creation options
  43162. * @returns true if supported
  43163. */
  43164. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43165. /**
  43166. * Disposes of the experience helper
  43167. */
  43168. dispose(): void;
  43169. }
  43170. }
  43171. declare module BABYLON {
  43172. /**
  43173. * Represents an XR input
  43174. */
  43175. class WebXRController {
  43176. /**
  43177. * 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
  43178. */
  43179. grip?: BABYLON.AbstractMesh;
  43180. /**
  43181. * Pointer which can be used to select objects or attach a visible laser to
  43182. */
  43183. pointer: BABYLON.AbstractMesh;
  43184. /**
  43185. * Creates the controller
  43186. * @see https://doc.babylonjs.com/how_to/webxr
  43187. * @param scene the scene which the controller should be associated to
  43188. */
  43189. constructor(scene: BABYLON.Scene);
  43190. /**
  43191. * Disposes of the object
  43192. */
  43193. dispose(): void;
  43194. }
  43195. /**
  43196. * XR input used to track XR inputs such as controllers/rays
  43197. */
  43198. class WebXRInput implements IDisposable {
  43199. private helper;
  43200. /**
  43201. * XR controllers being tracked
  43202. */
  43203. controllers: Array<WebXRController>;
  43204. private _tmpMatrix;
  43205. private _frameObserver;
  43206. /**
  43207. * Initializes the WebXRInput
  43208. * @param helper experience helper which the input should be created for
  43209. */
  43210. constructor(helper: WebXRExperienceHelper);
  43211. /**
  43212. * Disposes of the object
  43213. */
  43214. dispose(): void;
  43215. }
  43216. }
  43217. declare module BABYLON {
  43218. /**
  43219. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43220. */
  43221. class WebXRManagedOutputCanvas implements IDisposable {
  43222. private _canvas;
  43223. /**
  43224. * xrpresent context of the canvas which can be used to display/mirror xr content
  43225. */
  43226. canvasContext: Nullable<WebGLRenderingContext>;
  43227. /**
  43228. * Initializes the canvas to be added/removed upon entering/exiting xr
  43229. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43230. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43231. */
  43232. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43233. /**
  43234. * Disposes of the object
  43235. */
  43236. dispose(): void;
  43237. private _setManagedOutputCanvas;
  43238. private _addCanvas;
  43239. private _removeCanvas;
  43240. }
  43241. }
  43242. declare module BABYLON {
  43243. /**
  43244. * Manages an XRSession
  43245. * @see https://doc.babylonjs.com/how_to/webxr
  43246. */
  43247. class WebXRSessionManager implements IDisposable {
  43248. private scene;
  43249. /**
  43250. * Fires every time a new xrFrame arrives which can be used to update the camera
  43251. */
  43252. onXRFrameObservable: Observable<any>;
  43253. /**
  43254. * Fires when the xr session is ended either by the device or manually done
  43255. */
  43256. onXRSessionEnded: Observable<any>;
  43257. /** @hidden */
  43258. _xrSession: XRSession;
  43259. /** @hidden */
  43260. _frameOfReference: XRFrameOfReference;
  43261. /** @hidden */
  43262. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43263. /** @hidden */
  43264. _currentXRFrame: Nullable<XRFrame>;
  43265. private _xrNavigator;
  43266. private _xrDevice;
  43267. private _tmpMatrix;
  43268. /**
  43269. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43270. * @param scene The scene which the session should be created for
  43271. */
  43272. constructor(scene: BABYLON.Scene);
  43273. /**
  43274. * Initializes the manager
  43275. * After initialization enterXR can be called to start an XR session
  43276. * @returns Promise which resolves after it is initialized
  43277. */
  43278. initializeAsync(): Promise<void>;
  43279. /**
  43280. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43281. * @param sessionCreationOptions xr options to create the session with
  43282. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43283. * @returns Promise which resolves after it enters XR
  43284. */
  43285. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43286. /**
  43287. * Stops the xrSession and restores the renderloop
  43288. * @returns Promise which resolves after it exits XR
  43289. */
  43290. exitXRAsync(): Promise<void>;
  43291. /**
  43292. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43293. * @param ray ray to cast into the environment
  43294. * @returns Promise which resolves with a collision point in the environment if it exists
  43295. */
  43296. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43297. /**
  43298. * Checks if a session would be supported for the creation options specified
  43299. * @param options creation options to check if they are supported
  43300. * @returns true if supported
  43301. */
  43302. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43303. /**
  43304. * @hidden
  43305. * Converts the render layer of xrSession to a render target
  43306. * @param session session to create render target for
  43307. * @param scene scene the new render target should be created for
  43308. */
  43309. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43310. /**
  43311. * Disposes of the session manager
  43312. */
  43313. dispose(): void;
  43314. }
  43315. }
  43316. declare module BABYLON {
  43317. /**
  43318. * Contains an array of blocks representing the octree
  43319. */
  43320. interface IOctreeContainer<T> {
  43321. /**
  43322. * Blocks within the octree
  43323. */
  43324. blocks: Array<OctreeBlock<T>>;
  43325. }
  43326. /**
  43327. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43328. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43329. */
  43330. class Octree<T> {
  43331. /** 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.) */
  43332. maxDepth: number;
  43333. /**
  43334. * Blocks within the octree containing objects
  43335. */
  43336. blocks: Array<OctreeBlock<T>>;
  43337. /**
  43338. * Content stored in the octree
  43339. */
  43340. dynamicContent: T[];
  43341. private _maxBlockCapacity;
  43342. private _selectionContent;
  43343. private _creationFunc;
  43344. /**
  43345. * Creates a octree
  43346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43347. * @param creationFunc function to be used to instatiate the octree
  43348. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43349. * @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.)
  43350. */
  43351. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43352. /** 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.) */
  43353. maxDepth?: number);
  43354. /**
  43355. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43356. * @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);
  43357. * @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);
  43358. * @param entries meshes to be added to the octree blocks
  43359. */
  43360. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43361. /**
  43362. * Adds a mesh to the octree
  43363. * @param entry Mesh to add to the octree
  43364. */
  43365. addMesh(entry: T): void;
  43366. /**
  43367. * Selects an array of meshes within the frustum
  43368. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43369. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43370. * @returns array of meshes within the frustum
  43371. */
  43372. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43373. /**
  43374. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43375. * @param sphereCenter defines the bounding sphere center
  43376. * @param sphereRadius defines the bounding sphere radius
  43377. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43378. * @returns an array of objects that intersect the sphere
  43379. */
  43380. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43381. /**
  43382. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43383. * @param ray defines the ray to test with
  43384. * @returns array of intersected objects
  43385. */
  43386. intersectsRay(ray: Ray): SmartArray<T>;
  43387. /**
  43388. * @hidden
  43389. */
  43390. 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;
  43391. /**
  43392. * Adds a mesh into the octree block if it intersects the block
  43393. */
  43394. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43395. /**
  43396. * Adds a submesh into the octree block if it intersects the block
  43397. */
  43398. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43399. }
  43400. }
  43401. declare module BABYLON {
  43402. /**
  43403. * Class used to store a cell in an octree
  43404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43405. */
  43406. class OctreeBlock<T> {
  43407. /**
  43408. * Gets the content of the current block
  43409. */
  43410. entries: T[];
  43411. /**
  43412. * Gets the list of block children
  43413. */
  43414. blocks: Array<OctreeBlock<T>>;
  43415. private _depth;
  43416. private _maxDepth;
  43417. private _capacity;
  43418. private _minPoint;
  43419. private _maxPoint;
  43420. private _boundingVectors;
  43421. private _creationFunc;
  43422. /**
  43423. * Creates a new block
  43424. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43425. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43426. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43427. * @param depth defines the current depth of this block in the octree
  43428. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43429. * @param creationFunc defines a callback to call when an element is added to the block
  43430. */
  43431. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43432. /**
  43433. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43434. */
  43435. readonly capacity: number;
  43436. /**
  43437. * Gets the minimum vector (in world space) of the block's bounding box
  43438. */
  43439. readonly minPoint: Vector3;
  43440. /**
  43441. * Gets the maximum vector (in world space) of the block's bounding box
  43442. */
  43443. readonly maxPoint: Vector3;
  43444. /**
  43445. * Add a new element to this block
  43446. * @param entry defines the element to add
  43447. */
  43448. addEntry(entry: T): void;
  43449. /**
  43450. * Add an array of elements to this block
  43451. * @param entries defines the array of elements to add
  43452. */
  43453. addEntries(entries: T[]): void;
  43454. /**
  43455. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43456. * @param frustumPlanes defines the frustum planes to test
  43457. * @param selection defines the array to store current content if selection is positive
  43458. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43459. */
  43460. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43461. /**
  43462. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43463. * @param sphereCenter defines the bounding sphere center
  43464. * @param sphereRadius defines the bounding sphere radius
  43465. * @param selection defines the array to store current content if selection is positive
  43466. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43467. */
  43468. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43469. /**
  43470. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43471. * @param ray defines the ray to test with
  43472. * @param selection defines the array to store current content if selection is positive
  43473. */
  43474. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43475. /**
  43476. * Subdivide the content into child blocks (this block will then be empty)
  43477. */
  43478. createInnerBlocks(): void;
  43479. }
  43480. }
  43481. declare module BABYLON {
  43482. interface Scene {
  43483. /**
  43484. * @hidden
  43485. * Backing Filed
  43486. */
  43487. _selectionOctree: Octree<AbstractMesh>;
  43488. /**
  43489. * Gets the octree used to boost mesh selection (picking)
  43490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43491. */
  43492. selectionOctree: Octree<AbstractMesh>;
  43493. /**
  43494. * Creates or updates the octree used to boost selection (picking)
  43495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43496. * @param maxCapacity defines the maximum capacity per leaf
  43497. * @param maxDepth defines the maximum depth of the octree
  43498. * @returns an octree of AbstractMesh
  43499. */
  43500. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43501. }
  43502. interface AbstractMesh {
  43503. /**
  43504. * @hidden
  43505. * Backing Field
  43506. */
  43507. _submeshesOctree: Octree<SubMesh>;
  43508. /**
  43509. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43510. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43511. * @param maxCapacity defines the maximum size of each block (64 by default)
  43512. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43513. * @returns the new octree
  43514. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43516. */
  43517. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43518. }
  43519. /**
  43520. * Defines the octree scene component responsible to manage any octrees
  43521. * in a given scene.
  43522. */
  43523. class OctreeSceneComponent {
  43524. /**
  43525. * The component name helpfull to identify the component in the list of scene components.
  43526. */
  43527. readonly name: string;
  43528. /**
  43529. * The scene the component belongs to.
  43530. */
  43531. scene: Scene;
  43532. /**
  43533. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43534. */
  43535. readonly checksIsEnabled: boolean;
  43536. /**
  43537. * Creates a new instance of the component for the given scene
  43538. * @param scene Defines the scene to register the component in
  43539. */
  43540. constructor(scene: Scene);
  43541. /**
  43542. * Registers the component in a given scene
  43543. */
  43544. register(): void;
  43545. /**
  43546. * Return the list of active meshes
  43547. * @returns the list of active meshes
  43548. */
  43549. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43550. /**
  43551. * Return the list of active sub meshes
  43552. * @param mesh The mesh to get the candidates sub meshes from
  43553. * @returns the list of active sub meshes
  43554. */
  43555. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43556. private _tempRay;
  43557. /**
  43558. * Return the list of sub meshes intersecting with a given local ray
  43559. * @param mesh defines the mesh to find the submesh for
  43560. * @param localRay defines the ray in local space
  43561. * @returns the list of intersecting sub meshes
  43562. */
  43563. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43564. /**
  43565. * Return the list of sub meshes colliding with a collider
  43566. * @param mesh defines the mesh to find the submesh for
  43567. * @param collider defines the collider to evaluate the collision against
  43568. * @returns the list of colliding sub meshes
  43569. */
  43570. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43571. /**
  43572. * Rebuilds the elements related to this component in case of
  43573. * context lost for instance.
  43574. */
  43575. rebuild(): void;
  43576. /**
  43577. * Disposes the component and the associated ressources.
  43578. */
  43579. dispose(): void;
  43580. }
  43581. }
  43582. declare module BABYLON {
  43583. /** @hidden */
  43584. class _OcclusionDataStorage {
  43585. /** @hidden */
  43586. occlusionInternalRetryCounter: number;
  43587. /** @hidden */
  43588. isOcclusionQueryInProgress: boolean;
  43589. /** @hidden */
  43590. isOccluded: boolean;
  43591. /** @hidden */
  43592. occlusionRetryCount: number;
  43593. /** @hidden */
  43594. occlusionType: number;
  43595. /** @hidden */
  43596. occlusionQueryAlgorithmType: number;
  43597. }
  43598. interface Engine {
  43599. /**
  43600. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43601. * @return the new query
  43602. */
  43603. createQuery(): WebGLQuery;
  43604. /**
  43605. * Delete and release a webGL query
  43606. * @param query defines the query to delete
  43607. * @return the current engine
  43608. */
  43609. deleteQuery(query: WebGLQuery): Engine;
  43610. /**
  43611. * Check if a given query has resolved and got its value
  43612. * @param query defines the query to check
  43613. * @returns true if the query got its value
  43614. */
  43615. isQueryResultAvailable(query: WebGLQuery): boolean;
  43616. /**
  43617. * Gets the value of a given query
  43618. * @param query defines the query to check
  43619. * @returns the value of the query
  43620. */
  43621. getQueryResult(query: WebGLQuery): number;
  43622. /**
  43623. * Initiates an occlusion query
  43624. * @param algorithmType defines the algorithm to use
  43625. * @param query defines the query to use
  43626. * @returns the current engine
  43627. * @see http://doc.babylonjs.com/features/occlusionquery
  43628. */
  43629. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43630. /**
  43631. * Ends an occlusion query
  43632. * @see http://doc.babylonjs.com/features/occlusionquery
  43633. * @param algorithmType defines the algorithm to use
  43634. * @returns the current engine
  43635. */
  43636. endOcclusionQuery(algorithmType: number): Engine;
  43637. /**
  43638. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43639. * Please note that only one query can be issued at a time
  43640. * @returns a time token used to track the time span
  43641. */
  43642. startTimeQuery(): Nullable<_TimeToken>;
  43643. /**
  43644. * Ends a time query
  43645. * @param token defines the token used to measure the time span
  43646. * @returns the time spent (in ns)
  43647. */
  43648. endTimeQuery(token: _TimeToken): int;
  43649. /** @hidden */
  43650. _currentNonTimestampToken: Nullable<_TimeToken>;
  43651. /** @hidden */
  43652. _createTimeQuery(): WebGLQuery;
  43653. /** @hidden */
  43654. _deleteTimeQuery(query: WebGLQuery): void;
  43655. /** @hidden */
  43656. _getGlAlgorithmType(algorithmType: number): number;
  43657. /** @hidden */
  43658. _getTimeQueryResult(query: WebGLQuery): any;
  43659. /** @hidden */
  43660. _getTimeQueryAvailability(query: WebGLQuery): any;
  43661. }
  43662. interface AbstractMesh {
  43663. /**
  43664. * Backing filed
  43665. * @hidden
  43666. */
  43667. __occlusionDataStorage: _OcclusionDataStorage;
  43668. /**
  43669. * Access property
  43670. * @hidden
  43671. */
  43672. _occlusionDataStorage: _OcclusionDataStorage;
  43673. /**
  43674. * 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.
  43675. * The default value is -1 which means don't break the query and wait till the result
  43676. * @see http://doc.babylonjs.com/features/occlusionquery
  43677. */
  43678. occlusionRetryCount: number;
  43679. /**
  43680. * 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:
  43681. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43682. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43683. * * 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.
  43684. * @see http://doc.babylonjs.com/features/occlusionquery
  43685. */
  43686. occlusionType: number;
  43687. /**
  43688. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43689. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43690. * * 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.
  43691. * @see http://doc.babylonjs.com/features/occlusionquery
  43692. */
  43693. occlusionQueryAlgorithmType: number;
  43694. /**
  43695. * 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
  43696. * @see http://doc.babylonjs.com/features/occlusionquery
  43697. */
  43698. isOccluded: boolean;
  43699. /**
  43700. * Flag to check the progress status of the query
  43701. * @see http://doc.babylonjs.com/features/occlusionquery
  43702. */
  43703. isOcclusionQueryInProgress: boolean;
  43704. }
  43705. }
  43706. declare module BABYLON {
  43707. interface Engine {
  43708. /**
  43709. * Creates a webGL transform feedback object
  43710. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43711. * @returns the webGL transform feedback object
  43712. */
  43713. createTransformFeedback(): WebGLTransformFeedback;
  43714. /**
  43715. * Delete a webGL transform feedback object
  43716. * @param value defines the webGL transform feedback object to delete
  43717. */
  43718. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43719. /**
  43720. * Bind a webGL transform feedback object to the webgl context
  43721. * @param value defines the webGL transform feedback object to bind
  43722. */
  43723. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43724. /**
  43725. * Begins a transform feedback operation
  43726. * @param usePoints defines if points or triangles must be used
  43727. */
  43728. beginTransformFeedback(usePoints: boolean): void;
  43729. /**
  43730. * Ends a transform feedback operation
  43731. */
  43732. endTransformFeedback(): void;
  43733. /**
  43734. * Specify the varyings to use with transform feedback
  43735. * @param program defines the associated webGL program
  43736. * @param value defines the list of strings representing the varying names
  43737. */
  43738. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43739. /**
  43740. * Bind a webGL buffer for a transform feedback operation
  43741. * @param value defines the webGL buffer to bind
  43742. */
  43743. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43744. }
  43745. }
  43746. declare module BABYLON {
  43747. /**
  43748. * Google Daydream controller
  43749. */
  43750. class DaydreamController extends WebVRController {
  43751. /**
  43752. * Base Url for the controller model.
  43753. */
  43754. static MODEL_BASE_URL: string;
  43755. /**
  43756. * File name for the controller model.
  43757. */
  43758. static MODEL_FILENAME: string;
  43759. /**
  43760. * Gamepad Id prefix used to identify Daydream Controller.
  43761. */
  43762. static readonly GAMEPAD_ID_PREFIX: string;
  43763. /**
  43764. * Creates a new DaydreamController from a gamepad
  43765. * @param vrGamepad the gamepad that the controller should be created from
  43766. */
  43767. constructor(vrGamepad: any);
  43768. /**
  43769. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43770. * @param scene scene in which to add meshes
  43771. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43772. */
  43773. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43774. /**
  43775. * Called once for each button that changed state since the last frame
  43776. * @param buttonIdx Which button index changed
  43777. * @param state New state of the button
  43778. * @param changes Which properties on the state changed since last frame
  43779. */
  43780. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43781. }
  43782. }
  43783. declare module BABYLON {
  43784. /**
  43785. * Gear VR Controller
  43786. */
  43787. class GearVRController extends WebVRController {
  43788. /**
  43789. * Base Url for the controller model.
  43790. */
  43791. static MODEL_BASE_URL: string;
  43792. /**
  43793. * File name for the controller model.
  43794. */
  43795. static MODEL_FILENAME: string;
  43796. /**
  43797. * Gamepad Id prefix used to identify this controller.
  43798. */
  43799. static readonly GAMEPAD_ID_PREFIX: string;
  43800. private readonly _buttonIndexToObservableNameMap;
  43801. /**
  43802. * Creates a new GearVRController from a gamepad
  43803. * @param vrGamepad the gamepad that the controller should be created from
  43804. */
  43805. constructor(vrGamepad: any);
  43806. /**
  43807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43808. * @param scene scene in which to add meshes
  43809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43810. */
  43811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43812. /**
  43813. * Called once for each button that changed state since the last frame
  43814. * @param buttonIdx Which button index changed
  43815. * @param state New state of the button
  43816. * @param changes Which properties on the state changed since last frame
  43817. */
  43818. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43819. }
  43820. }
  43821. declare module BABYLON {
  43822. /**
  43823. * Generic Controller
  43824. */
  43825. class GenericController extends WebVRController {
  43826. /**
  43827. * Base Url for the controller model.
  43828. */
  43829. static readonly MODEL_BASE_URL: string;
  43830. /**
  43831. * File name for the controller model.
  43832. */
  43833. static readonly MODEL_FILENAME: string;
  43834. /**
  43835. * Creates a new GenericController from a gamepad
  43836. * @param vrGamepad the gamepad that the controller should be created from
  43837. */
  43838. constructor(vrGamepad: any);
  43839. /**
  43840. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43841. * @param scene scene in which to add meshes
  43842. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43843. */
  43844. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43845. /**
  43846. * Called once for each button that changed state since the last frame
  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. * Oculus Touch Controller
  43857. */
  43858. class OculusTouchController extends WebVRController {
  43859. /**
  43860. * Base Url for the controller model.
  43861. */
  43862. static MODEL_BASE_URL: string;
  43863. /**
  43864. * File name for the left controller model.
  43865. */
  43866. static MODEL_LEFT_FILENAME: string;
  43867. /**
  43868. * File name for the right controller model.
  43869. */
  43870. static MODEL_RIGHT_FILENAME: string;
  43871. /**
  43872. * Fired when the secondary trigger on this controller is modified
  43873. */
  43874. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43875. /**
  43876. * Fired when the thumb rest on this controller is modified
  43877. */
  43878. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43879. /**
  43880. * Creates a new OculusTouchController from a gamepad
  43881. * @param vrGamepad the gamepad that the controller should be created from
  43882. */
  43883. constructor(vrGamepad: any);
  43884. /**
  43885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43886. * @param scene scene in which to add meshes
  43887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43888. */
  43889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43890. /**
  43891. * Fired when the A button on this controller is modified
  43892. */
  43893. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43894. /**
  43895. * Fired when the B button on this controller is modified
  43896. */
  43897. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the X button on this controller is modified
  43900. */
  43901. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43902. /**
  43903. * Fired when the Y button on this controller is modified
  43904. */
  43905. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43906. /**
  43907. * Called once for each button that changed state since the last frame
  43908. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43909. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43910. * 2) secondary trigger (same)
  43911. * 3) A (right) X (left), touch, pressed = value
  43912. * 4) B / Y
  43913. * 5) thumb rest
  43914. * @param buttonIdx Which button index changed
  43915. * @param state New state of the button
  43916. * @param changes Which properties on the state changed since last frame
  43917. */
  43918. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43919. }
  43920. }
  43921. declare module BABYLON {
  43922. /**
  43923. * Defines the types of pose enabled controllers that are supported
  43924. */
  43925. enum PoseEnabledControllerType {
  43926. /**
  43927. * HTC Vive
  43928. */
  43929. VIVE = 0,
  43930. /**
  43931. * Oculus Rift
  43932. */
  43933. OCULUS = 1,
  43934. /**
  43935. * Windows mixed reality
  43936. */
  43937. WINDOWS = 2,
  43938. /**
  43939. * Samsung gear VR
  43940. */
  43941. GEAR_VR = 3,
  43942. /**
  43943. * Google Daydream
  43944. */
  43945. DAYDREAM = 4,
  43946. /**
  43947. * Generic
  43948. */
  43949. GENERIC = 5
  43950. }
  43951. /**
  43952. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43953. */
  43954. interface MutableGamepadButton {
  43955. /**
  43956. * Value of the button/trigger
  43957. */
  43958. value: number;
  43959. /**
  43960. * If the button/trigger is currently touched
  43961. */
  43962. touched: boolean;
  43963. /**
  43964. * If the button/trigger is currently pressed
  43965. */
  43966. pressed: boolean;
  43967. }
  43968. /**
  43969. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43970. * @hidden
  43971. */
  43972. interface ExtendedGamepadButton extends GamepadButton {
  43973. /**
  43974. * If the button/trigger is currently pressed
  43975. */
  43976. readonly pressed: boolean;
  43977. /**
  43978. * If the button/trigger is currently touched
  43979. */
  43980. readonly touched: boolean;
  43981. /**
  43982. * Value of the button/trigger
  43983. */
  43984. readonly value: number;
  43985. }
  43986. /**
  43987. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43988. */
  43989. class PoseEnabledControllerHelper {
  43990. /**
  43991. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43992. * @param vrGamepad the gamepad to initialized
  43993. * @returns a vr controller of the type the gamepad identified as
  43994. */
  43995. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43996. }
  43997. /**
  43998. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43999. */
  44000. class PoseEnabledController extends Gamepad implements PoseControlled {
  44001. private _deviceRoomPosition;
  44002. private _deviceRoomRotationQuaternion;
  44003. /**
  44004. * The device position in babylon space
  44005. */
  44006. devicePosition: Vector3;
  44007. /**
  44008. * The device rotation in babylon space
  44009. */
  44010. deviceRotationQuaternion: Quaternion;
  44011. /**
  44012. * The scale factor of the device in babylon space
  44013. */
  44014. deviceScaleFactor: number;
  44015. /**
  44016. * (Likely devicePosition should be used instead) The device position in its room space
  44017. */
  44018. position: Vector3;
  44019. /**
  44020. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44021. */
  44022. rotationQuaternion: Quaternion;
  44023. /**
  44024. * The type of controller (Eg. Windows mixed reality)
  44025. */
  44026. controllerType: PoseEnabledControllerType;
  44027. protected _calculatedPosition: Vector3;
  44028. private _calculatedRotation;
  44029. /**
  44030. * The raw pose from the device
  44031. */
  44032. rawPose: DevicePose;
  44033. private _trackPosition;
  44034. private _maxRotationDistFromHeadset;
  44035. private _draggedRoomRotation;
  44036. /**
  44037. * @hidden
  44038. */
  44039. _disableTrackPosition(fixedPosition: Vector3): void;
  44040. /**
  44041. * Internal, the mesh attached to the controller
  44042. * @hidden
  44043. */
  44044. _mesh: Nullable<AbstractMesh>;
  44045. private _poseControlledCamera;
  44046. private _leftHandSystemQuaternion;
  44047. /**
  44048. * Internal, matrix used to convert room space to babylon space
  44049. * @hidden
  44050. */
  44051. _deviceToWorld: Matrix;
  44052. /**
  44053. * Node to be used when casting a ray from the controller
  44054. * @hidden
  44055. */
  44056. _pointingPoseNode: Nullable<TransformNode>;
  44057. /**
  44058. * Name of the child mesh that can be used to cast a ray from the controller
  44059. */
  44060. static readonly POINTING_POSE: string;
  44061. /**
  44062. * Creates a new PoseEnabledController from a gamepad
  44063. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44064. */
  44065. constructor(browserGamepad: any);
  44066. private _workingMatrix;
  44067. /**
  44068. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44069. */
  44070. update(): void;
  44071. /**
  44072. * Updates only the pose device and mesh without doing any button event checking
  44073. */
  44074. protected _updatePoseAndMesh(): void;
  44075. /**
  44076. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44077. * @param poseData raw pose fromthe device
  44078. */
  44079. updateFromDevice(poseData: DevicePose): void;
  44080. /**
  44081. * @hidden
  44082. */
  44083. _meshAttachedObservable: Observable<AbstractMesh>;
  44084. /**
  44085. * Attaches a mesh to the controller
  44086. * @param mesh the mesh to be attached
  44087. */
  44088. attachToMesh(mesh: AbstractMesh): void;
  44089. /**
  44090. * Attaches the controllers mesh to a camera
  44091. * @param camera the camera the mesh should be attached to
  44092. */
  44093. attachToPoseControlledCamera(camera: TargetCamera): void;
  44094. /**
  44095. * Disposes of the controller
  44096. */
  44097. dispose(): void;
  44098. /**
  44099. * The mesh that is attached to the controller
  44100. */
  44101. readonly mesh: Nullable<AbstractMesh>;
  44102. /**
  44103. * Gets the ray of the controller in the direction the controller is pointing
  44104. * @param length the length the resulting ray should be
  44105. * @returns a ray in the direction the controller is pointing
  44106. */
  44107. getForwardRay(length?: number): Ray;
  44108. }
  44109. }
  44110. declare module BABYLON {
  44111. /**
  44112. * Vive Controller
  44113. */
  44114. class ViveController extends WebVRController {
  44115. /**
  44116. * Base Url for the controller model.
  44117. */
  44118. static MODEL_BASE_URL: string;
  44119. /**
  44120. * File name for the controller model.
  44121. */
  44122. static MODEL_FILENAME: string;
  44123. /**
  44124. * Creates a new ViveController from a gamepad
  44125. * @param vrGamepad the gamepad that the controller should be created from
  44126. */
  44127. constructor(vrGamepad: any);
  44128. /**
  44129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44130. * @param scene scene in which to add meshes
  44131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44132. */
  44133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44134. /**
  44135. * Fired when the left button on this controller is modified
  44136. */
  44137. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44138. /**
  44139. * Fired when the right button on this controller is modified
  44140. */
  44141. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44142. /**
  44143. * Fired when the menu button on this controller is modified
  44144. */
  44145. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44146. /**
  44147. * Called once for each button that changed state since the last frame
  44148. * Vive mapping:
  44149. * 0: touchpad
  44150. * 1: trigger
  44151. * 2: left AND right buttons
  44152. * 3: menu button
  44153. * @param buttonIdx Which button index changed
  44154. * @param state New state of the button
  44155. * @param changes Which properties on the state changed since last frame
  44156. */
  44157. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44158. }
  44159. }
  44160. declare module BABYLON {
  44161. /**
  44162. * Defines the WebVRController object that represents controllers tracked in 3D space
  44163. */
  44164. abstract class WebVRController extends PoseEnabledController {
  44165. /**
  44166. * Internal, the default controller model for the controller
  44167. */
  44168. protected _defaultModel: AbstractMesh;
  44169. /**
  44170. * Fired when the trigger state has changed
  44171. */
  44172. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44173. /**
  44174. * Fired when the main button state has changed
  44175. */
  44176. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44177. /**
  44178. * Fired when the secondary button state has changed
  44179. */
  44180. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44181. /**
  44182. * Fired when the pad state has changed
  44183. */
  44184. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44185. /**
  44186. * Fired when controllers stick values have changed
  44187. */
  44188. onPadValuesChangedObservable: Observable<StickValues>;
  44189. /**
  44190. * Array of button availible on the controller
  44191. */
  44192. protected _buttons: Array<MutableGamepadButton>;
  44193. private _onButtonStateChange;
  44194. /**
  44195. * Fired when a controller button's state has changed
  44196. * @param callback the callback containing the button that was modified
  44197. */
  44198. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44199. /**
  44200. * X and Y axis corrisponding to the controllers joystick
  44201. */
  44202. pad: StickValues;
  44203. /**
  44204. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44205. */
  44206. hand: string;
  44207. /**
  44208. * The default controller model for the controller
  44209. */
  44210. readonly defaultModel: AbstractMesh;
  44211. /**
  44212. * Creates a new WebVRController from a gamepad
  44213. * @param vrGamepad the gamepad that the WebVRController should be created from
  44214. */
  44215. constructor(vrGamepad: any);
  44216. /**
  44217. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44218. */
  44219. update(): void;
  44220. /**
  44221. * Function to be called when a button is modified
  44222. */
  44223. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44224. /**
  44225. * Loads a mesh and attaches it to the controller
  44226. * @param scene the scene the mesh should be added to
  44227. * @param meshLoaded callback for when the mesh has been loaded
  44228. */
  44229. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44230. private _setButtonValue;
  44231. private _changes;
  44232. private _checkChanges;
  44233. /**
  44234. * Disposes of th webVRCOntroller
  44235. */
  44236. dispose(): void;
  44237. }
  44238. }
  44239. declare module BABYLON {
  44240. /**
  44241. * Defines the WindowsMotionController object that the state of the windows motion controller
  44242. */
  44243. class WindowsMotionController extends WebVRController {
  44244. /**
  44245. * The base url used to load the left and right controller models
  44246. */
  44247. static MODEL_BASE_URL: string;
  44248. /**
  44249. * The name of the left controller model file
  44250. */
  44251. static MODEL_LEFT_FILENAME: string;
  44252. /**
  44253. * The name of the right controller model file
  44254. */
  44255. static MODEL_RIGHT_FILENAME: string;
  44256. /**
  44257. * The controller name prefix for this controller type
  44258. */
  44259. static readonly GAMEPAD_ID_PREFIX: string;
  44260. /**
  44261. * The controller id pattern for this controller type
  44262. */
  44263. private static readonly GAMEPAD_ID_PATTERN;
  44264. private _loadedMeshInfo;
  44265. private readonly _mapping;
  44266. /**
  44267. * Fired when the trackpad on this controller is clicked
  44268. */
  44269. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44270. /**
  44271. * Fired when the trackpad on this controller is modified
  44272. */
  44273. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44274. /**
  44275. * The current x and y values of this controller's trackpad
  44276. */
  44277. trackpad: StickValues;
  44278. /**
  44279. * Creates a new WindowsMotionController from a gamepad
  44280. * @param vrGamepad the gamepad that the controller should be created from
  44281. */
  44282. constructor(vrGamepad: any);
  44283. /**
  44284. * Fired when the trigger on this controller is modified
  44285. */
  44286. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44287. /**
  44288. * Fired when the menu button on this controller is modified
  44289. */
  44290. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44291. /**
  44292. * Fired when the grip button on this controller is modified
  44293. */
  44294. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44295. /**
  44296. * Fired when the thumbstick button on this controller is modified
  44297. */
  44298. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44299. /**
  44300. * Fired when the touchpad button on this controller is modified
  44301. */
  44302. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44303. /**
  44304. * Fired when the touchpad values on this controller are modified
  44305. */
  44306. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44307. private _updateTrackpad;
  44308. /**
  44309. * Called once per frame by the engine.
  44310. */
  44311. update(): void;
  44312. /**
  44313. * Called once for each button that changed state since the last frame
  44314. * @param buttonIdx Which button index changed
  44315. * @param state New state of the button
  44316. * @param changes Which properties on the state changed since last frame
  44317. */
  44318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44319. /**
  44320. * Moves the buttons on the controller mesh based on their current state
  44321. * @param buttonName the name of the button to move
  44322. * @param buttonValue the value of the button which determines the buttons new position
  44323. */
  44324. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44325. /**
  44326. * Moves the axis on the controller mesh based on its current state
  44327. * @param axis the index of the axis
  44328. * @param axisValue the value of the axis which determines the meshes new position
  44329. * @hidden
  44330. */
  44331. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44332. /**
  44333. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44334. * @param scene scene in which to add meshes
  44335. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44336. */
  44337. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44338. /**
  44339. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44340. * can be transformed by button presses and axes values, based on this._mapping.
  44341. *
  44342. * @param scene scene in which the meshes exist
  44343. * @param meshes list of meshes that make up the controller model to process
  44344. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44345. */
  44346. private processModel;
  44347. private createMeshInfo;
  44348. /**
  44349. * Gets the ray of the controller in the direction the controller is pointing
  44350. * @param length the length the resulting ray should be
  44351. * @returns a ray in the direction the controller is pointing
  44352. */
  44353. getForwardRay(length?: number): Ray;
  44354. /**
  44355. * Disposes of the controller
  44356. */
  44357. dispose(): void;
  44358. }
  44359. }
  44360. declare module BABYLON {
  44361. /**
  44362. * Interface to implement to create a shadow generator compatible with BJS.
  44363. */
  44364. interface IShadowGenerator {
  44365. /**
  44366. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44367. * @returns The render target texture if present otherwise, null
  44368. */
  44369. getShadowMap(): Nullable<RenderTargetTexture>;
  44370. /**
  44371. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44372. * @returns The render target texture if the shadow map is present otherwise, null
  44373. */
  44374. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44375. /**
  44376. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44377. * @param subMesh The submesh we want to render in the shadow map
  44378. * @param useInstances Defines wether will draw in the map using instances
  44379. * @returns true if ready otherwise, false
  44380. */
  44381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44382. /**
  44383. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44384. * @param defines Defines of the material we want to update
  44385. * @param lightIndex Index of the light in the enabled light list of the material
  44386. */
  44387. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44388. /**
  44389. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44390. * defined in the generator but impacting the effect).
  44391. * It implies the unifroms available on the materials are the standard BJS ones.
  44392. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44393. * @param effect The effect we are binfing the information for
  44394. */
  44395. bindShadowLight(lightIndex: string, effect: Effect): void;
  44396. /**
  44397. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44398. * (eq to shadow prjection matrix * light transform matrix)
  44399. * @returns The transform matrix used to create the shadow map
  44400. */
  44401. getTransformMatrix(): Matrix;
  44402. /**
  44403. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44404. * Cube and 2D textures for instance.
  44405. */
  44406. recreateShadowMap(): void;
  44407. /**
  44408. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44409. * @param onCompiled Callback triggered at the and of the effects compilation
  44410. * @param options Sets of optional options forcing the compilation with different modes
  44411. */
  44412. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44413. useInstances: boolean;
  44414. }>): void;
  44415. /**
  44416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44417. * @param options Sets of optional options forcing the compilation with different modes
  44418. * @returns A promise that resolves when the compilation completes
  44419. */
  44420. forceCompilationAsync(options?: Partial<{
  44421. useInstances: boolean;
  44422. }>): Promise<void>;
  44423. /**
  44424. * Serializes the shadow generator setup to a json object.
  44425. * @returns The serialized JSON object
  44426. */
  44427. serialize(): any;
  44428. /**
  44429. * Disposes the Shadow map and related Textures and effects.
  44430. */
  44431. dispose(): void;
  44432. }
  44433. /**
  44434. * Default implementation IShadowGenerator.
  44435. * This is the main object responsible of generating shadows in the framework.
  44436. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44437. */
  44438. class ShadowGenerator implements IShadowGenerator {
  44439. /**
  44440. * Shadow generator mode None: no filtering applied.
  44441. */
  44442. static readonly FILTER_NONE: number;
  44443. /**
  44444. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44446. */
  44447. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44448. /**
  44449. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44450. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44451. */
  44452. static readonly FILTER_POISSONSAMPLING: number;
  44453. /**
  44454. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44455. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44456. */
  44457. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44458. /**
  44459. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44460. * edge artifacts on steep falloff.
  44461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44462. */
  44463. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44464. /**
  44465. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44466. * edge artifacts on steep falloff.
  44467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44468. */
  44469. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44470. /**
  44471. * Shadow generator mode PCF: Percentage Closer Filtering
  44472. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44473. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44474. */
  44475. static readonly FILTER_PCF: number;
  44476. /**
  44477. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44479. * Contact Hardening
  44480. */
  44481. static readonly FILTER_PCSS: number;
  44482. /**
  44483. * Reserved for PCF and PCSS
  44484. * Highest Quality.
  44485. *
  44486. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44487. *
  44488. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44489. */
  44490. static readonly QUALITY_HIGH: number;
  44491. /**
  44492. * Reserved for PCF and PCSS
  44493. * Good tradeoff for quality/perf cross devices
  44494. *
  44495. * Execute PCF on a 3*3 kernel.
  44496. *
  44497. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44498. */
  44499. static readonly QUALITY_MEDIUM: number;
  44500. /**
  44501. * Reserved for PCF and PCSS
  44502. * The lowest quality but the fastest.
  44503. *
  44504. * Execute PCF on a 1*1 kernel.
  44505. *
  44506. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44507. */
  44508. static readonly QUALITY_LOW: number;
  44509. private _bias;
  44510. /**
  44511. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44512. */
  44513. /**
  44514. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44515. */
  44516. bias: number;
  44517. private _normalBias;
  44518. /**
  44519. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44520. */
  44521. /**
  44522. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44523. */
  44524. normalBias: number;
  44525. private _blurBoxOffset;
  44526. /**
  44527. * Gets the blur box offset: offset applied during the blur pass.
  44528. * Only useful if useKernelBlur = false
  44529. */
  44530. /**
  44531. * Sets the blur box offset: offset applied during the blur pass.
  44532. * Only useful if useKernelBlur = false
  44533. */
  44534. blurBoxOffset: number;
  44535. private _blurScale;
  44536. /**
  44537. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44538. * 2 means half of the size.
  44539. */
  44540. /**
  44541. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44542. * 2 means half of the size.
  44543. */
  44544. blurScale: number;
  44545. private _blurKernel;
  44546. /**
  44547. * Gets the blur kernel: kernel size of the blur pass.
  44548. * Only useful if useKernelBlur = true
  44549. */
  44550. /**
  44551. * Sets the blur kernel: kernel size of the blur pass.
  44552. * Only useful if useKernelBlur = true
  44553. */
  44554. blurKernel: number;
  44555. private _useKernelBlur;
  44556. /**
  44557. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44558. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44559. */
  44560. /**
  44561. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44562. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44563. */
  44564. useKernelBlur: boolean;
  44565. private _depthScale;
  44566. /**
  44567. * Gets the depth scale used in ESM mode.
  44568. */
  44569. /**
  44570. * Sets the depth scale used in ESM mode.
  44571. * This can override the scale stored on the light.
  44572. */
  44573. depthScale: number;
  44574. private _filter;
  44575. /**
  44576. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44577. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44578. */
  44579. /**
  44580. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44581. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44582. */
  44583. filter: number;
  44584. /**
  44585. * Gets if the current filter is set to Poisson Sampling.
  44586. */
  44587. /**
  44588. * Sets the current filter to Poisson Sampling.
  44589. */
  44590. usePoissonSampling: boolean;
  44591. /**
  44592. * Gets if the current filter is set to ESM.
  44593. */
  44594. /**
  44595. * Sets the current filter is to ESM.
  44596. */
  44597. useExponentialShadowMap: boolean;
  44598. /**
  44599. * Gets if the current filter is set to filtered ESM.
  44600. */
  44601. /**
  44602. * Gets if the current filter is set to filtered ESM.
  44603. */
  44604. useBlurExponentialShadowMap: boolean;
  44605. /**
  44606. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44607. * exponential to prevent steep falloff artifacts).
  44608. */
  44609. /**
  44610. * Sets the current filter to "close ESM" (using the inverse of the
  44611. * exponential to prevent steep falloff artifacts).
  44612. */
  44613. useCloseExponentialShadowMap: boolean;
  44614. /**
  44615. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44616. * exponential to prevent steep falloff artifacts).
  44617. */
  44618. /**
  44619. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44620. * exponential to prevent steep falloff artifacts).
  44621. */
  44622. useBlurCloseExponentialShadowMap: boolean;
  44623. /**
  44624. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44625. */
  44626. /**
  44627. * Sets the current filter to "PCF" (percentage closer filtering).
  44628. */
  44629. usePercentageCloserFiltering: boolean;
  44630. private _filteringQuality;
  44631. /**
  44632. * Gets the PCF or PCSS Quality.
  44633. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44634. */
  44635. /**
  44636. * Sets the PCF or PCSS Quality.
  44637. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44638. */
  44639. filteringQuality: number;
  44640. /**
  44641. * Gets if the current filter is set to "PCSS" (contact hardening).
  44642. */
  44643. /**
  44644. * Sets the current filter to "PCSS" (contact hardening).
  44645. */
  44646. useContactHardeningShadow: boolean;
  44647. private _contactHardeningLightSizeUVRatio;
  44648. /**
  44649. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44650. * Using a ratio helps keeping shape stability independently of the map size.
  44651. *
  44652. * It does not account for the light projection as it was having too much
  44653. * instability during the light setup or during light position changes.
  44654. *
  44655. * Only valid if useContactHardeningShadow is true.
  44656. */
  44657. /**
  44658. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44659. * Using a ratio helps keeping shape stability independently of the map size.
  44660. *
  44661. * It does not account for the light projection as it was having too much
  44662. * instability during the light setup or during light position changes.
  44663. *
  44664. * Only valid if useContactHardeningShadow is true.
  44665. */
  44666. contactHardeningLightSizeUVRatio: number;
  44667. private _darkness;
  44668. /**
  44669. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44670. * 0 means strongest and 1 would means no shadow.
  44671. * @returns the darkness.
  44672. */
  44673. getDarkness(): number;
  44674. /**
  44675. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44676. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44677. * @returns the shadow generator allowing fluent coding.
  44678. */
  44679. setDarkness(darkness: number): ShadowGenerator;
  44680. private _transparencyShadow;
  44681. /**
  44682. * Sets the ability to have transparent shadow (boolean).
  44683. * @param transparent True if transparent else False
  44684. * @returns the shadow generator allowing fluent coding
  44685. */
  44686. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44687. private _shadowMap;
  44688. private _shadowMap2;
  44689. /**
  44690. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44691. * @returns The render target texture if present otherwise, null
  44692. */
  44693. getShadowMap(): Nullable<RenderTargetTexture>;
  44694. /**
  44695. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44696. * @returns The render target texture if the shadow map is present otherwise, null
  44697. */
  44698. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44699. /**
  44700. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44701. * @param mesh Mesh to add
  44702. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44703. * @returns the Shadow Generator itself
  44704. */
  44705. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44706. /**
  44707. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44708. * @param mesh Mesh to remove
  44709. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44710. * @returns the Shadow Generator itself
  44711. */
  44712. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44713. /**
  44714. * Controls the extent to which the shadows fade out at the edge of the frustum
  44715. * Used only by directionals and spots
  44716. */
  44717. frustumEdgeFalloff: number;
  44718. private _light;
  44719. /**
  44720. * Returns the associated light object.
  44721. * @returns the light generating the shadow
  44722. */
  44723. getLight(): IShadowLight;
  44724. /**
  44725. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44726. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44727. * It might on the other hand introduce peter panning.
  44728. */
  44729. forceBackFacesOnly: boolean;
  44730. private _scene;
  44731. private _lightDirection;
  44732. private _effect;
  44733. private _viewMatrix;
  44734. private _projectionMatrix;
  44735. private _transformMatrix;
  44736. private _cachedPosition;
  44737. private _cachedDirection;
  44738. private _cachedDefines;
  44739. private _currentRenderID;
  44740. private _boxBlurPostprocess;
  44741. private _kernelBlurXPostprocess;
  44742. private _kernelBlurYPostprocess;
  44743. private _blurPostProcesses;
  44744. private _mapSize;
  44745. private _currentFaceIndex;
  44746. private _currentFaceIndexCache;
  44747. private _textureType;
  44748. private _defaultTextureMatrix;
  44749. /**
  44750. * Creates a ShadowGenerator object.
  44751. * A ShadowGenerator is the required tool to use the shadows.
  44752. * Each light casting shadows needs to use its own ShadowGenerator.
  44753. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44754. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44755. * @param light The light object generating the shadows.
  44756. * @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.
  44757. */
  44758. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44759. private _initializeGenerator;
  44760. private _initializeShadowMap;
  44761. private _initializeBlurRTTAndPostProcesses;
  44762. private _renderForShadowMap;
  44763. private _renderSubMeshForShadowMap;
  44764. private _applyFilterValues;
  44765. /**
  44766. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44767. * @param onCompiled Callback triggered at the and of the effects compilation
  44768. * @param options Sets of optional options forcing the compilation with different modes
  44769. */
  44770. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44771. useInstances: boolean;
  44772. }>): void;
  44773. /**
  44774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44775. * @param options Sets of optional options forcing the compilation with different modes
  44776. * @returns A promise that resolves when the compilation completes
  44777. */
  44778. forceCompilationAsync(options?: Partial<{
  44779. useInstances: boolean;
  44780. }>): Promise<void>;
  44781. /**
  44782. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44783. * @param subMesh The submesh we want to render in the shadow map
  44784. * @param useInstances Defines wether will draw in the map using instances
  44785. * @returns true if ready otherwise, false
  44786. */
  44787. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44788. /**
  44789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44790. * @param defines Defines of the material we want to update
  44791. * @param lightIndex Index of the light in the enabled light list of the material
  44792. */
  44793. prepareDefines(defines: any, lightIndex: number): void;
  44794. /**
  44795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44796. * defined in the generator but impacting the effect).
  44797. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44798. * @param effect The effect we are binfing the information for
  44799. */
  44800. bindShadowLight(lightIndex: string, effect: Effect): void;
  44801. /**
  44802. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44803. * (eq to shadow prjection matrix * light transform matrix)
  44804. * @returns The transform matrix used to create the shadow map
  44805. */
  44806. getTransformMatrix(): Matrix;
  44807. /**
  44808. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44809. * Cube and 2D textures for instance.
  44810. */
  44811. recreateShadowMap(): void;
  44812. private _disposeBlurPostProcesses;
  44813. private _disposeRTTandPostProcesses;
  44814. /**
  44815. * Disposes the ShadowGenerator.
  44816. * Returns nothing.
  44817. */
  44818. dispose(): void;
  44819. /**
  44820. * Serializes the shadow generator setup to a json object.
  44821. * @returns The serialized JSON object
  44822. */
  44823. serialize(): any;
  44824. /**
  44825. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44826. * @param parsedShadowGenerator The JSON object to parse
  44827. * @param scene The scene to create the shadow map for
  44828. * @returns The parsed shadow generator
  44829. */
  44830. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44831. }
  44832. }
  44833. declare module BABYLON {
  44834. /**
  44835. * Defines the shadow generator component responsible to manage any shadow generators
  44836. * in a given scene.
  44837. */
  44838. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44839. /**
  44840. * The component name helpfull to identify the component in the list of scene components.
  44841. */
  44842. readonly name: string;
  44843. /**
  44844. * The scene the component belongs to.
  44845. */
  44846. scene: Scene;
  44847. /**
  44848. * Creates a new instance of the component for the given scene
  44849. * @param scene Defines the scene to register the component in
  44850. */
  44851. constructor(scene: Scene);
  44852. /**
  44853. * Registers the component in a given scene
  44854. */
  44855. register(): void;
  44856. /**
  44857. * Rebuilds the elements related to this component in case of
  44858. * context lost for instance.
  44859. */
  44860. rebuild(): void;
  44861. /**
  44862. * Serializes the component data to the specified json object
  44863. * @param serializationObject The object to serialize to
  44864. */
  44865. serialize(serializationObject: any): void;
  44866. /**
  44867. * Adds all the element from the container to the scene
  44868. * @param container the container holding the elements
  44869. */
  44870. addFromContainer(container: AbstractScene): void;
  44871. /**
  44872. * Removes all the elements in the container from the scene
  44873. * @param container contains the elements to remove
  44874. */
  44875. removeFromContainer(container: AbstractScene): void;
  44876. /**
  44877. * Rebuilds the elements related to this component in case of
  44878. * context lost for instance.
  44879. */
  44880. dispose(): void;
  44881. private _gatherRenderTargets;
  44882. }
  44883. }
  44884. declare module BABYLON {
  44885. }
  44886. declare module BABYLON {
  44887. /**
  44888. * Background material used to create an efficient environement around your scene.
  44889. */
  44890. class BackgroundMaterial extends PushMaterial {
  44891. /**
  44892. * Standard reflectance value at parallel view angle.
  44893. */
  44894. static StandardReflectance0: number;
  44895. /**
  44896. * Standard reflectance value at grazing angle.
  44897. */
  44898. static StandardReflectance90: number;
  44899. protected _primaryColor: Color3;
  44900. /**
  44901. * Key light Color (multiply against the environement texture)
  44902. */
  44903. primaryColor: Color3;
  44904. protected __perceptualColor: Nullable<Color3>;
  44905. /**
  44906. * Experimental Internal Use Only.
  44907. *
  44908. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44909. * This acts as a helper to set the primary color to a more "human friendly" value.
  44910. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44911. * output color as close as possible from the chosen value.
  44912. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44913. * part of lighting setup.)
  44914. */
  44915. _perceptualColor: Nullable<Color3>;
  44916. protected _primaryColorShadowLevel: float;
  44917. /**
  44918. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44919. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44920. */
  44921. primaryColorShadowLevel: float;
  44922. protected _primaryColorHighlightLevel: float;
  44923. /**
  44924. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44925. * The primary color is used at the level chosen to define what the white area would look.
  44926. */
  44927. primaryColorHighlightLevel: float;
  44928. protected _reflectionTexture: Nullable<BaseTexture>;
  44929. /**
  44930. * Reflection Texture used in the material.
  44931. * Should be author in a specific way for the best result (refer to the documentation).
  44932. */
  44933. reflectionTexture: Nullable<BaseTexture>;
  44934. protected _reflectionBlur: float;
  44935. /**
  44936. * Reflection Texture level of blur.
  44937. *
  44938. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44939. * texture twice.
  44940. */
  44941. reflectionBlur: float;
  44942. protected _diffuseTexture: Nullable<BaseTexture>;
  44943. /**
  44944. * Diffuse Texture used in the material.
  44945. * Should be author in a specific way for the best result (refer to the documentation).
  44946. */
  44947. diffuseTexture: Nullable<BaseTexture>;
  44948. protected _shadowLights: Nullable<IShadowLight[]>;
  44949. /**
  44950. * Specify the list of lights casting shadow on the material.
  44951. * All scene shadow lights will be included if null.
  44952. */
  44953. shadowLights: Nullable<IShadowLight[]>;
  44954. protected _shadowLevel: float;
  44955. /**
  44956. * Helps adjusting the shadow to a softer level if required.
  44957. * 0 means black shadows and 1 means no shadows.
  44958. */
  44959. shadowLevel: float;
  44960. protected _sceneCenter: Vector3;
  44961. /**
  44962. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44963. * It is usually zero but might be interesting to modify according to your setup.
  44964. */
  44965. sceneCenter: Vector3;
  44966. protected _opacityFresnel: boolean;
  44967. /**
  44968. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44969. * This helps ensuring a nice transition when the camera goes under the ground.
  44970. */
  44971. opacityFresnel: boolean;
  44972. protected _reflectionFresnel: boolean;
  44973. /**
  44974. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44975. * This helps adding a mirror texture on the ground.
  44976. */
  44977. reflectionFresnel: boolean;
  44978. protected _reflectionFalloffDistance: number;
  44979. /**
  44980. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44981. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44982. */
  44983. reflectionFalloffDistance: number;
  44984. protected _reflectionAmount: number;
  44985. /**
  44986. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44987. */
  44988. reflectionAmount: number;
  44989. protected _reflectionReflectance0: number;
  44990. /**
  44991. * This specifies the weight of the reflection at grazing angle.
  44992. */
  44993. reflectionReflectance0: number;
  44994. protected _reflectionReflectance90: number;
  44995. /**
  44996. * This specifies the weight of the reflection at a perpendicular point of view.
  44997. */
  44998. reflectionReflectance90: number;
  44999. /**
  45000. * Sets the reflection reflectance fresnel values according to the default standard
  45001. * empirically know to work well :-)
  45002. */
  45003. reflectionStandardFresnelWeight: number;
  45004. protected _useRGBColor: boolean;
  45005. /**
  45006. * Helps to directly use the maps channels instead of their level.
  45007. */
  45008. useRGBColor: boolean;
  45009. protected _enableNoise: boolean;
  45010. /**
  45011. * This helps reducing the banding effect that could occur on the background.
  45012. */
  45013. enableNoise: boolean;
  45014. /**
  45015. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45016. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45017. * Recommended to be keep at 1.0 except for special cases.
  45018. */
  45019. fovMultiplier: number;
  45020. private _fovMultiplier;
  45021. /**
  45022. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45023. */
  45024. useEquirectangularFOV: boolean;
  45025. private _maxSimultaneousLights;
  45026. /**
  45027. * Number of Simultaneous lights allowed on the material.
  45028. */
  45029. maxSimultaneousLights: int;
  45030. /**
  45031. * Default configuration related to image processing available in the Background Material.
  45032. */
  45033. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45034. /**
  45035. * Keep track of the image processing observer to allow dispose and replace.
  45036. */
  45037. private _imageProcessingObserver;
  45038. /**
  45039. * Attaches a new image processing configuration to the PBR Material.
  45040. * @param configuration (if null the scene configuration will be use)
  45041. */
  45042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45043. /**
  45044. * Gets the image processing configuration used either in this material.
  45045. */
  45046. /**
  45047. * Sets the Default image processing configuration used either in the this material.
  45048. *
  45049. * If sets to null, the scene one is in use.
  45050. */
  45051. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45052. /**
  45053. * Gets wether the color curves effect is enabled.
  45054. */
  45055. /**
  45056. * Sets wether the color curves effect is enabled.
  45057. */
  45058. cameraColorCurvesEnabled: boolean;
  45059. /**
  45060. * Gets wether the color grading effect is enabled.
  45061. */
  45062. /**
  45063. * Gets wether the color grading effect is enabled.
  45064. */
  45065. cameraColorGradingEnabled: boolean;
  45066. /**
  45067. * Gets wether tonemapping is enabled or not.
  45068. */
  45069. /**
  45070. * Sets wether tonemapping is enabled or not
  45071. */
  45072. cameraToneMappingEnabled: boolean;
  45073. /**
  45074. * The camera exposure used on this material.
  45075. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45076. * This corresponds to a photographic exposure.
  45077. */
  45078. /**
  45079. * The camera exposure used on this material.
  45080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45081. * This corresponds to a photographic exposure.
  45082. */
  45083. cameraExposure: float;
  45084. /**
  45085. * Gets The camera contrast used on this material.
  45086. */
  45087. /**
  45088. * Sets The camera contrast used on this material.
  45089. */
  45090. cameraContrast: float;
  45091. /**
  45092. * Gets the Color Grading 2D Lookup Texture.
  45093. */
  45094. /**
  45095. * Sets the Color Grading 2D Lookup Texture.
  45096. */
  45097. cameraColorGradingTexture: Nullable<BaseTexture>;
  45098. /**
  45099. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45100. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45101. * 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;
  45102. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45103. */
  45104. /**
  45105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45107. * 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;
  45108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45109. */
  45110. cameraColorCurves: Nullable<ColorCurves>;
  45111. /**
  45112. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45113. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45114. */
  45115. switchToBGR: boolean;
  45116. private _renderTargets;
  45117. private _reflectionControls;
  45118. private _white;
  45119. private _primaryShadowColor;
  45120. private _primaryHighlightColor;
  45121. /**
  45122. * Instantiates a Background Material in the given scene
  45123. * @param name The friendly name of the material
  45124. * @param scene The scene to add the material to
  45125. */
  45126. constructor(name: string, scene: Scene);
  45127. /**
  45128. * Gets a boolean indicating that current material needs to register RTT
  45129. */
  45130. readonly hasRenderTargetTextures: boolean;
  45131. /**
  45132. * The entire material has been created in order to prevent overdraw.
  45133. * @returns false
  45134. */
  45135. needAlphaTesting(): boolean;
  45136. /**
  45137. * The entire material has been created in order to prevent overdraw.
  45138. * @returns true if blending is enable
  45139. */
  45140. needAlphaBlending(): boolean;
  45141. /**
  45142. * Checks wether the material is ready to be rendered for a given mesh.
  45143. * @param mesh The mesh to render
  45144. * @param subMesh The submesh to check against
  45145. * @param useInstances Specify wether or not the material is used with instances
  45146. * @returns true if all the dependencies are ready (Textures, Effects...)
  45147. */
  45148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45149. /**
  45150. * Compute the primary color according to the chosen perceptual color.
  45151. */
  45152. private _computePrimaryColorFromPerceptualColor;
  45153. /**
  45154. * Compute the highlights and shadow colors according to their chosen levels.
  45155. */
  45156. private _computePrimaryColors;
  45157. /**
  45158. * Build the uniform buffer used in the material.
  45159. */
  45160. buildUniformLayout(): void;
  45161. /**
  45162. * Unbind the material.
  45163. */
  45164. unbind(): void;
  45165. /**
  45166. * Bind only the world matrix to the material.
  45167. * @param world The world matrix to bind.
  45168. */
  45169. bindOnlyWorldMatrix(world: Matrix): void;
  45170. /**
  45171. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45172. * @param world The world matrix to bind.
  45173. * @param subMesh The submesh to bind for.
  45174. */
  45175. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45176. /**
  45177. * Dispose the material.
  45178. * @param forceDisposeEffect Force disposal of the associated effect.
  45179. * @param forceDisposeTextures Force disposal of the associated textures.
  45180. */
  45181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45182. /**
  45183. * Clones the material.
  45184. * @param name The cloned name.
  45185. * @returns The cloned material.
  45186. */
  45187. clone(name: string): BackgroundMaterial;
  45188. /**
  45189. * Serializes the current material to its JSON representation.
  45190. * @returns The JSON representation.
  45191. */
  45192. serialize(): any;
  45193. /**
  45194. * Gets the class name of the material
  45195. * @returns "BackgroundMaterial"
  45196. */
  45197. getClassName(): string;
  45198. /**
  45199. * Parse a JSON input to create back a background material.
  45200. * @param source The JSON data to parse
  45201. * @param scene The scene to create the parsed material in
  45202. * @param rootUrl The root url of the assets the material depends upon
  45203. * @returns the instantiated BackgroundMaterial.
  45204. */
  45205. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45206. }
  45207. }
  45208. declare module BABYLON {
  45209. /**
  45210. * The Physically based material base class of BJS.
  45211. *
  45212. * This offers the main features of a standard PBR material.
  45213. * For more information, please refer to the documentation :
  45214. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45215. */
  45216. abstract class PBRBaseMaterial extends PushMaterial {
  45217. /**
  45218. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45219. */
  45220. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45221. /**
  45222. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45223. * to enhance interoperability with other engines.
  45224. */
  45225. static readonly LIGHTFALLOFF_GLTF: number;
  45226. /**
  45227. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45228. * to enhance interoperability with other materials.
  45229. */
  45230. static readonly LIGHTFALLOFF_STANDARD: number;
  45231. /**
  45232. * Intensity of the direct lights e.g. the four lights available in your scene.
  45233. * This impacts both the direct diffuse and specular highlights.
  45234. */
  45235. protected _directIntensity: number;
  45236. /**
  45237. * Intensity of the emissive part of the material.
  45238. * This helps controlling the emissive effect without modifying the emissive color.
  45239. */
  45240. protected _emissiveIntensity: number;
  45241. /**
  45242. * Intensity of the environment e.g. how much the environment will light the object
  45243. * either through harmonics for rough material or through the refelction for shiny ones.
  45244. */
  45245. protected _environmentIntensity: number;
  45246. /**
  45247. * This is a special control allowing the reduction of the specular highlights coming from the
  45248. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45249. */
  45250. protected _specularIntensity: number;
  45251. /**
  45252. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45253. */
  45254. private _lightingInfos;
  45255. /**
  45256. * Debug Control allowing disabling the bump map on this material.
  45257. */
  45258. protected _disableBumpMap: boolean;
  45259. /**
  45260. * AKA Diffuse Texture in standard nomenclature.
  45261. */
  45262. protected _albedoTexture: BaseTexture;
  45263. /**
  45264. * AKA Occlusion Texture in other nomenclature.
  45265. */
  45266. protected _ambientTexture: BaseTexture;
  45267. /**
  45268. * AKA Occlusion Texture Intensity in other nomenclature.
  45269. */
  45270. protected _ambientTextureStrength: number;
  45271. /**
  45272. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45273. * 1 means it completely occludes it
  45274. * 0 mean it has no impact
  45275. */
  45276. protected _ambientTextureImpactOnAnalyticalLights: number;
  45277. /**
  45278. * Stores the alpha values in a texture.
  45279. */
  45280. protected _opacityTexture: BaseTexture;
  45281. /**
  45282. * Stores the reflection values in a texture.
  45283. */
  45284. protected _reflectionTexture: BaseTexture;
  45285. /**
  45286. * Stores the refraction values in a texture.
  45287. */
  45288. protected _refractionTexture: BaseTexture;
  45289. /**
  45290. * Stores the emissive values in a texture.
  45291. */
  45292. protected _emissiveTexture: BaseTexture;
  45293. /**
  45294. * AKA Specular texture in other nomenclature.
  45295. */
  45296. protected _reflectivityTexture: BaseTexture;
  45297. /**
  45298. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45299. */
  45300. protected _metallicTexture: BaseTexture;
  45301. /**
  45302. * Specifies the metallic scalar of the metallic/roughness workflow.
  45303. * Can also be used to scale the metalness values of the metallic texture.
  45304. */
  45305. protected _metallic: Nullable<number>;
  45306. /**
  45307. * Specifies the roughness scalar of the metallic/roughness workflow.
  45308. * Can also be used to scale the roughness values of the metallic texture.
  45309. */
  45310. protected _roughness: Nullable<number>;
  45311. /**
  45312. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45313. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45314. */
  45315. protected _microSurfaceTexture: BaseTexture;
  45316. /**
  45317. * Stores surface normal data used to displace a mesh in a texture.
  45318. */
  45319. protected _bumpTexture: BaseTexture;
  45320. /**
  45321. * Stores the pre-calculated light information of a mesh in a texture.
  45322. */
  45323. protected _lightmapTexture: BaseTexture;
  45324. /**
  45325. * The color of a material in ambient lighting.
  45326. */
  45327. protected _ambientColor: Color3;
  45328. /**
  45329. * AKA Diffuse Color in other nomenclature.
  45330. */
  45331. protected _albedoColor: Color3;
  45332. /**
  45333. * AKA Specular Color in other nomenclature.
  45334. */
  45335. protected _reflectivityColor: Color3;
  45336. /**
  45337. * The color applied when light is reflected from a material.
  45338. */
  45339. protected _reflectionColor: Color3;
  45340. /**
  45341. * The color applied when light is emitted from a material.
  45342. */
  45343. protected _emissiveColor: Color3;
  45344. /**
  45345. * AKA Glossiness in other nomenclature.
  45346. */
  45347. protected _microSurface: number;
  45348. /**
  45349. * source material index of refraction (IOR)' / 'destination material IOR.
  45350. */
  45351. protected _indexOfRefraction: number;
  45352. /**
  45353. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45354. */
  45355. protected _invertRefractionY: boolean;
  45356. /**
  45357. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45358. * Materials half opaque for instance using refraction could benefit from this control.
  45359. */
  45360. protected _linkRefractionWithTransparency: boolean;
  45361. /**
  45362. * Specifies that the material will use the light map as a show map.
  45363. */
  45364. protected _useLightmapAsShadowmap: boolean;
  45365. /**
  45366. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45367. * makes the reflect vector face the model (under horizon).
  45368. */
  45369. protected _useHorizonOcclusion: boolean;
  45370. /**
  45371. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45372. * too much the area relying on ambient texture to define their ambient occlusion.
  45373. */
  45374. protected _useRadianceOcclusion: boolean;
  45375. /**
  45376. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45377. */
  45378. protected _useAlphaFromAlbedoTexture: boolean;
  45379. /**
  45380. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45381. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45382. */
  45383. protected _useSpecularOverAlpha: boolean;
  45384. /**
  45385. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45386. */
  45387. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45388. /**
  45389. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45390. */
  45391. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45392. /**
  45393. * Specifies if the metallic texture contains the roughness information in its green channel.
  45394. */
  45395. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45396. /**
  45397. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45398. */
  45399. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45400. /**
  45401. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45402. */
  45403. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45404. /**
  45405. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45406. */
  45407. protected _useAmbientInGrayScale: boolean;
  45408. /**
  45409. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45410. * The material will try to infer what glossiness each pixel should be.
  45411. */
  45412. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45413. /**
  45414. * Defines the falloff type used in this material.
  45415. * It by default is Physical.
  45416. */
  45417. protected _lightFalloff: number;
  45418. /**
  45419. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45420. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45421. */
  45422. protected _useRadianceOverAlpha: boolean;
  45423. /**
  45424. * Allows using an object space normal map (instead of tangent space).
  45425. */
  45426. protected _useObjectSpaceNormalMap: boolean;
  45427. /**
  45428. * Allows using the bump map in parallax mode.
  45429. */
  45430. protected _useParallax: boolean;
  45431. /**
  45432. * Allows using the bump map in parallax occlusion mode.
  45433. */
  45434. protected _useParallaxOcclusion: boolean;
  45435. /**
  45436. * Controls the scale bias of the parallax mode.
  45437. */
  45438. protected _parallaxScaleBias: number;
  45439. /**
  45440. * If sets to true, disables all the lights affecting the material.
  45441. */
  45442. protected _disableLighting: boolean;
  45443. /**
  45444. * Number of Simultaneous lights allowed on the material.
  45445. */
  45446. protected _maxSimultaneousLights: number;
  45447. /**
  45448. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45449. */
  45450. protected _invertNormalMapX: boolean;
  45451. /**
  45452. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45453. */
  45454. protected _invertNormalMapY: boolean;
  45455. /**
  45456. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45457. */
  45458. protected _twoSidedLighting: boolean;
  45459. /**
  45460. * Defines the alpha limits in alpha test mode.
  45461. */
  45462. protected _alphaCutOff: number;
  45463. /**
  45464. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45465. */
  45466. protected _forceAlphaTest: boolean;
  45467. /**
  45468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45469. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45470. */
  45471. protected _useAlphaFresnel: boolean;
  45472. /**
  45473. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45474. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45475. */
  45476. protected _useLinearAlphaFresnel: boolean;
  45477. /**
  45478. * The transparency mode of the material.
  45479. */
  45480. protected _transparencyMode: Nullable<number>;
  45481. /**
  45482. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45483. * from cos thetav and roughness:
  45484. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45485. */
  45486. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45487. /**
  45488. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45489. */
  45490. protected _forceIrradianceInFragment: boolean;
  45491. /**
  45492. * Force normal to face away from face.
  45493. */
  45494. protected _forceNormalForward: boolean;
  45495. /**
  45496. * Enables specular anti aliasing in the PBR shader.
  45497. * It will both interacts on the Geometry for analytical and IBL lighting.
  45498. * It also prefilter the roughness map based on the bump values.
  45499. */
  45500. protected _enableSpecularAntiAliasing: boolean;
  45501. /**
  45502. * Default configuration related to image processing available in the PBR Material.
  45503. */
  45504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45505. /**
  45506. * Keep track of the image processing observer to allow dispose and replace.
  45507. */
  45508. private _imageProcessingObserver;
  45509. /**
  45510. * Attaches a new image processing configuration to the PBR Material.
  45511. * @param configuration
  45512. */
  45513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45514. /**
  45515. * Stores the available render targets.
  45516. */
  45517. private _renderTargets;
  45518. /**
  45519. * Sets the global ambient color for the material used in lighting calculations.
  45520. */
  45521. private _globalAmbientColor;
  45522. /**
  45523. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45524. */
  45525. private _useLogarithmicDepth;
  45526. /**
  45527. * If set to true, no lighting calculations will be applied.
  45528. */
  45529. private _unlit;
  45530. /**
  45531. * Instantiates a new PBRMaterial instance.
  45532. *
  45533. * @param name The material name
  45534. * @param scene The scene the material will be use in.
  45535. */
  45536. constructor(name: string, scene: Scene);
  45537. /**
  45538. * Gets a boolean indicating that current material needs to register RTT
  45539. */
  45540. readonly hasRenderTargetTextures: boolean;
  45541. /**
  45542. * Gets the name of the material class.
  45543. */
  45544. getClassName(): string;
  45545. /**
  45546. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45547. */
  45548. /**
  45549. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45550. */
  45551. useLogarithmicDepth: boolean;
  45552. /**
  45553. * Gets the current transparency mode.
  45554. */
  45555. /**
  45556. * Sets the transparency mode of the material.
  45557. *
  45558. * | Value | Type | Description |
  45559. * | ----- | ----------------------------------- | ----------- |
  45560. * | 0 | OPAQUE | |
  45561. * | 1 | ALPHATEST | |
  45562. * | 2 | ALPHABLEND | |
  45563. * | 3 | ALPHATESTANDBLEND | |
  45564. *
  45565. */
  45566. transparencyMode: Nullable<number>;
  45567. /**
  45568. * Returns true if alpha blending should be disabled.
  45569. */
  45570. private readonly _disableAlphaBlending;
  45571. /**
  45572. * Specifies whether or not this material should be rendered in alpha blend mode.
  45573. */
  45574. needAlphaBlending(): boolean;
  45575. /**
  45576. * Specifies if the mesh will require alpha blending.
  45577. * @param mesh - BJS mesh.
  45578. */
  45579. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45580. /**
  45581. * Specifies whether or not this material should be rendered in alpha test mode.
  45582. */
  45583. needAlphaTesting(): boolean;
  45584. /**
  45585. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45586. */
  45587. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45588. /**
  45589. * Gets the texture used for the alpha test.
  45590. */
  45591. getAlphaTestTexture(): BaseTexture;
  45592. /**
  45593. * Stores the reflectivity values based on metallic roughness workflow.
  45594. */
  45595. private static _scaledReflectivity;
  45596. /**
  45597. * Specifies that the submesh is ready to be used.
  45598. * @param mesh - BJS mesh.
  45599. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45600. * @param useInstances - Specifies that instances should be used.
  45601. * @returns - boolean indicating that the submesh is ready or not.
  45602. */
  45603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45604. /**
  45605. * Specifies if the material uses metallic roughness workflow.
  45606. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45607. */
  45608. isMetallicWorkflow(): boolean;
  45609. private _prepareEffect;
  45610. private _prepareDefines;
  45611. /**
  45612. * Force shader compilation
  45613. */
  45614. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45615. clipPlane: boolean;
  45616. }>): void;
  45617. /**
  45618. * Initializes the uniform buffer layout for the shader.
  45619. */
  45620. buildUniformLayout(): void;
  45621. /**
  45622. * Unbinds the textures.
  45623. */
  45624. unbind(): void;
  45625. /**
  45626. * Binds the submesh data.
  45627. * @param world - The world matrix.
  45628. * @param mesh - The BJS mesh.
  45629. * @param subMesh - A submesh of the BJS mesh.
  45630. */
  45631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45632. /**
  45633. * Returns the animatable textures.
  45634. * @returns - Array of animatable textures.
  45635. */
  45636. getAnimatables(): IAnimatable[];
  45637. /**
  45638. * Returns the texture used for reflections.
  45639. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45640. */
  45641. private _getReflectionTexture;
  45642. /**
  45643. * Returns the texture used for refraction or null if none is used.
  45644. * @returns - Refection texture if present. If no refraction texture and refraction
  45645. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45646. */
  45647. private _getRefractionTexture;
  45648. /**
  45649. * Disposes the resources of the material.
  45650. * @param forceDisposeEffect - Forces the disposal of effects.
  45651. * @param forceDisposeTextures - Forces the disposal of all textures.
  45652. */
  45653. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45654. }
  45655. }
  45656. declare module BABYLON {
  45657. /**
  45658. * The Physically based simple base material of BJS.
  45659. *
  45660. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45661. * It is used as the base class for both the specGloss and metalRough conventions.
  45662. */
  45663. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45664. /**
  45665. * Number of Simultaneous lights allowed on the material.
  45666. */
  45667. maxSimultaneousLights: number;
  45668. /**
  45669. * If sets to true, disables all the lights affecting the material.
  45670. */
  45671. disableLighting: boolean;
  45672. /**
  45673. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45674. */
  45675. environmentTexture: BaseTexture;
  45676. /**
  45677. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45678. */
  45679. invertNormalMapX: boolean;
  45680. /**
  45681. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45682. */
  45683. invertNormalMapY: boolean;
  45684. /**
  45685. * Normal map used in the model.
  45686. */
  45687. normalTexture: BaseTexture;
  45688. /**
  45689. * Emissivie color used to self-illuminate the model.
  45690. */
  45691. emissiveColor: Color3;
  45692. /**
  45693. * Emissivie texture used to self-illuminate the model.
  45694. */
  45695. emissiveTexture: BaseTexture;
  45696. /**
  45697. * Occlusion Channel Strenght.
  45698. */
  45699. occlusionStrength: number;
  45700. /**
  45701. * Occlusion Texture of the material (adding extra occlusion effects).
  45702. */
  45703. occlusionTexture: BaseTexture;
  45704. /**
  45705. * Defines the alpha limits in alpha test mode.
  45706. */
  45707. alphaCutOff: number;
  45708. /**
  45709. * Gets the current double sided mode.
  45710. */
  45711. /**
  45712. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45713. */
  45714. doubleSided: boolean;
  45715. /**
  45716. * Stores the pre-calculated light information of a mesh in a texture.
  45717. */
  45718. lightmapTexture: BaseTexture;
  45719. /**
  45720. * If true, the light map contains occlusion information instead of lighting info.
  45721. */
  45722. useLightmapAsShadowmap: boolean;
  45723. /**
  45724. * Return the active textures of the material.
  45725. */
  45726. getActiveTextures(): BaseTexture[];
  45727. hasTexture(texture: BaseTexture): boolean;
  45728. /**
  45729. * Instantiates a new PBRMaterial instance.
  45730. *
  45731. * @param name The material name
  45732. * @param scene The scene the material will be use in.
  45733. */
  45734. constructor(name: string, scene: Scene);
  45735. getClassName(): string;
  45736. }
  45737. }
  45738. declare module BABYLON {
  45739. /**
  45740. * The Physically based material of BJS.
  45741. *
  45742. * This offers the main features of a standard PBR material.
  45743. * For more information, please refer to the documentation :
  45744. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45745. */
  45746. class PBRMaterial extends PBRBaseMaterial {
  45747. /**
  45748. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45749. */
  45750. static readonly PBRMATERIAL_OPAQUE: number;
  45751. /**
  45752. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45753. */
  45754. static readonly PBRMATERIAL_ALPHATEST: number;
  45755. /**
  45756. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45757. */
  45758. static readonly PBRMATERIAL_ALPHABLEND: number;
  45759. /**
  45760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45761. * They are also discarded below the alpha cutoff threshold to improve performances.
  45762. */
  45763. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45764. /**
  45765. * Defines the default value of how much AO map is occluding the analytical lights
  45766. * (point spot...).
  45767. */
  45768. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45769. /**
  45770. * Intensity of the direct lights e.g. the four lights available in your scene.
  45771. * This impacts both the direct diffuse and specular highlights.
  45772. */
  45773. directIntensity: number;
  45774. /**
  45775. * Intensity of the emissive part of the material.
  45776. * This helps controlling the emissive effect without modifying the emissive color.
  45777. */
  45778. emissiveIntensity: number;
  45779. /**
  45780. * Intensity of the environment e.g. how much the environment will light the object
  45781. * either through harmonics for rough material or through the refelction for shiny ones.
  45782. */
  45783. environmentIntensity: number;
  45784. /**
  45785. * This is a special control allowing the reduction of the specular highlights coming from the
  45786. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45787. */
  45788. specularIntensity: number;
  45789. /**
  45790. * Debug Control allowing disabling the bump map on this material.
  45791. */
  45792. disableBumpMap: boolean;
  45793. /**
  45794. * AKA Diffuse Texture in standard nomenclature.
  45795. */
  45796. albedoTexture: BaseTexture;
  45797. /**
  45798. * AKA Occlusion Texture in other nomenclature.
  45799. */
  45800. ambientTexture: BaseTexture;
  45801. /**
  45802. * AKA Occlusion Texture Intensity in other nomenclature.
  45803. */
  45804. ambientTextureStrength: number;
  45805. /**
  45806. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45807. * 1 means it completely occludes it
  45808. * 0 mean it has no impact
  45809. */
  45810. ambientTextureImpactOnAnalyticalLights: number;
  45811. /**
  45812. * Stores the alpha values in a texture.
  45813. */
  45814. opacityTexture: BaseTexture;
  45815. /**
  45816. * Stores the reflection values in a texture.
  45817. */
  45818. reflectionTexture: Nullable<BaseTexture>;
  45819. /**
  45820. * Stores the emissive values in a texture.
  45821. */
  45822. emissiveTexture: BaseTexture;
  45823. /**
  45824. * AKA Specular texture in other nomenclature.
  45825. */
  45826. reflectivityTexture: BaseTexture;
  45827. /**
  45828. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45829. */
  45830. metallicTexture: BaseTexture;
  45831. /**
  45832. * Specifies the metallic scalar of the metallic/roughness workflow.
  45833. * Can also be used to scale the metalness values of the metallic texture.
  45834. */
  45835. metallic: Nullable<number>;
  45836. /**
  45837. * Specifies the roughness scalar of the metallic/roughness workflow.
  45838. * Can also be used to scale the roughness values of the metallic texture.
  45839. */
  45840. roughness: Nullable<number>;
  45841. /**
  45842. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45843. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45844. */
  45845. microSurfaceTexture: BaseTexture;
  45846. /**
  45847. * Stores surface normal data used to displace a mesh in a texture.
  45848. */
  45849. bumpTexture: BaseTexture;
  45850. /**
  45851. * Stores the pre-calculated light information of a mesh in a texture.
  45852. */
  45853. lightmapTexture: BaseTexture;
  45854. /**
  45855. * Stores the refracted light information in a texture.
  45856. */
  45857. refractionTexture: BaseTexture;
  45858. /**
  45859. * The color of a material in ambient lighting.
  45860. */
  45861. ambientColor: Color3;
  45862. /**
  45863. * AKA Diffuse Color in other nomenclature.
  45864. */
  45865. albedoColor: Color3;
  45866. /**
  45867. * AKA Specular Color in other nomenclature.
  45868. */
  45869. reflectivityColor: Color3;
  45870. /**
  45871. * The color reflected from the material.
  45872. */
  45873. reflectionColor: Color3;
  45874. /**
  45875. * The color emitted from the material.
  45876. */
  45877. emissiveColor: Color3;
  45878. /**
  45879. * AKA Glossiness in other nomenclature.
  45880. */
  45881. microSurface: number;
  45882. /**
  45883. * source material index of refraction (IOR)' / 'destination material IOR.
  45884. */
  45885. indexOfRefraction: number;
  45886. /**
  45887. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45888. */
  45889. invertRefractionY: boolean;
  45890. /**
  45891. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45892. * Materials half opaque for instance using refraction could benefit from this control.
  45893. */
  45894. linkRefractionWithTransparency: boolean;
  45895. /**
  45896. * If true, the light map contains occlusion information instead of lighting info.
  45897. */
  45898. useLightmapAsShadowmap: boolean;
  45899. /**
  45900. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45901. */
  45902. useAlphaFromAlbedoTexture: boolean;
  45903. /**
  45904. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45905. */
  45906. forceAlphaTest: boolean;
  45907. /**
  45908. * Defines the alpha limits in alpha test mode.
  45909. */
  45910. alphaCutOff: number;
  45911. /**
  45912. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45913. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45914. */
  45915. useSpecularOverAlpha: boolean;
  45916. /**
  45917. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45918. */
  45919. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45920. /**
  45921. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45922. */
  45923. useRoughnessFromMetallicTextureAlpha: boolean;
  45924. /**
  45925. * Specifies if the metallic texture contains the roughness information in its green channel.
  45926. */
  45927. useRoughnessFromMetallicTextureGreen: boolean;
  45928. /**
  45929. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45930. */
  45931. useMetallnessFromMetallicTextureBlue: boolean;
  45932. /**
  45933. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45934. */
  45935. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45936. /**
  45937. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45938. */
  45939. useAmbientInGrayScale: boolean;
  45940. /**
  45941. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45942. * The material will try to infer what glossiness each pixel should be.
  45943. */
  45944. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45945. /**
  45946. * BJS is using an harcoded light falloff based on a manually sets up range.
  45947. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45948. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45949. */
  45950. /**
  45951. * BJS is using an harcoded light falloff based on a manually sets up range.
  45952. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45953. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45954. */
  45955. usePhysicalLightFalloff: boolean;
  45956. /**
  45957. * In order to support the falloff compatibility with gltf, a special mode has been added
  45958. * to reproduce the gltf light falloff.
  45959. */
  45960. /**
  45961. * In order to support the falloff compatibility with gltf, a special mode has been added
  45962. * to reproduce the gltf light falloff.
  45963. */
  45964. useGLTFLightFalloff: boolean;
  45965. /**
  45966. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45967. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45968. */
  45969. useRadianceOverAlpha: boolean;
  45970. /**
  45971. * Allows using an object space normal map (instead of tangent space).
  45972. */
  45973. useObjectSpaceNormalMap: boolean;
  45974. /**
  45975. * Allows using the bump map in parallax mode.
  45976. */
  45977. useParallax: boolean;
  45978. /**
  45979. * Allows using the bump map in parallax occlusion mode.
  45980. */
  45981. useParallaxOcclusion: boolean;
  45982. /**
  45983. * Controls the scale bias of the parallax mode.
  45984. */
  45985. parallaxScaleBias: number;
  45986. /**
  45987. * If sets to true, disables all the lights affecting the material.
  45988. */
  45989. disableLighting: boolean;
  45990. /**
  45991. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45992. */
  45993. forceIrradianceInFragment: boolean;
  45994. /**
  45995. * Number of Simultaneous lights allowed on the material.
  45996. */
  45997. maxSimultaneousLights: number;
  45998. /**
  45999. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46000. */
  46001. invertNormalMapX: boolean;
  46002. /**
  46003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46004. */
  46005. invertNormalMapY: boolean;
  46006. /**
  46007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46008. */
  46009. twoSidedLighting: boolean;
  46010. /**
  46011. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46012. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46013. */
  46014. useAlphaFresnel: boolean;
  46015. /**
  46016. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46017. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46018. */
  46019. useLinearAlphaFresnel: boolean;
  46020. /**
  46021. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46022. * And/Or occlude the blended part.
  46023. */
  46024. environmentBRDFTexture: Nullable<BaseTexture>;
  46025. /**
  46026. * Force normal to face away from face.
  46027. */
  46028. forceNormalForward: boolean;
  46029. /**
  46030. * Enables specular anti aliasing in the PBR shader.
  46031. * It will both interacts on the Geometry for analytical and IBL lighting.
  46032. * It also prefilter the roughness map based on the bump values.
  46033. */
  46034. enableSpecularAntiAliasing: boolean;
  46035. /**
  46036. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46037. * makes the reflect vector face the model (under horizon).
  46038. */
  46039. useHorizonOcclusion: boolean;
  46040. /**
  46041. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46042. * too much the area relying on ambient texture to define their ambient occlusion.
  46043. */
  46044. useRadianceOcclusion: boolean;
  46045. /**
  46046. * If set to true, no lighting calculations will be applied.
  46047. */
  46048. unlit: boolean;
  46049. /**
  46050. * Gets the image processing configuration used either in this material.
  46051. */
  46052. /**
  46053. * Sets the Default image processing configuration used either in the this material.
  46054. *
  46055. * If sets to null, the scene one is in use.
  46056. */
  46057. imageProcessingConfiguration: ImageProcessingConfiguration;
  46058. /**
  46059. * Gets wether the color curves effect is enabled.
  46060. */
  46061. /**
  46062. * Sets wether the color curves effect is enabled.
  46063. */
  46064. cameraColorCurvesEnabled: boolean;
  46065. /**
  46066. * Gets wether the color grading effect is enabled.
  46067. */
  46068. /**
  46069. * Gets wether the color grading effect is enabled.
  46070. */
  46071. cameraColorGradingEnabled: boolean;
  46072. /**
  46073. * Gets wether tonemapping is enabled or not.
  46074. */
  46075. /**
  46076. * Sets wether tonemapping is enabled or not
  46077. */
  46078. cameraToneMappingEnabled: boolean;
  46079. /**
  46080. * The camera exposure used on this material.
  46081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46082. * This corresponds to a photographic exposure.
  46083. */
  46084. /**
  46085. * The camera exposure used on this material.
  46086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46087. * This corresponds to a photographic exposure.
  46088. */
  46089. cameraExposure: number;
  46090. /**
  46091. * Gets The camera contrast used on this material.
  46092. */
  46093. /**
  46094. * Sets The camera contrast used on this material.
  46095. */
  46096. cameraContrast: number;
  46097. /**
  46098. * Gets the Color Grading 2D Lookup Texture.
  46099. */
  46100. /**
  46101. * Sets the Color Grading 2D Lookup Texture.
  46102. */
  46103. cameraColorGradingTexture: Nullable<BaseTexture>;
  46104. /**
  46105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46107. * 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;
  46108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46109. */
  46110. /**
  46111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46113. * 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;
  46114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46115. */
  46116. cameraColorCurves: Nullable<ColorCurves>;
  46117. /**
  46118. * Instantiates a new PBRMaterial instance.
  46119. *
  46120. * @param name The material name
  46121. * @param scene The scene the material will be use in.
  46122. */
  46123. constructor(name: string, scene: Scene);
  46124. /**
  46125. * Returns the name of this material class.
  46126. */
  46127. getClassName(): string;
  46128. /**
  46129. * Returns an array of the actively used textures.
  46130. * @returns - Array of BaseTextures
  46131. */
  46132. getActiveTextures(): BaseTexture[];
  46133. /**
  46134. * Checks to see if a texture is used in the material.
  46135. * @param texture - Base texture to use.
  46136. * @returns - Boolean specifying if a texture is used in the material.
  46137. */
  46138. hasTexture(texture: BaseTexture): boolean;
  46139. /**
  46140. * Makes a duplicate of the current material.
  46141. * @param name - name to use for the new material.
  46142. */
  46143. clone(name: string): PBRMaterial;
  46144. /**
  46145. * Serializes this PBR Material.
  46146. * @returns - An object with the serialized material.
  46147. */
  46148. serialize(): any;
  46149. /**
  46150. * Parses a PBR Material from a serialized object.
  46151. * @param source - Serialized object.
  46152. * @param scene - BJS scene instance.
  46153. * @param rootUrl - url for the scene object
  46154. * @returns - PBRMaterial
  46155. */
  46156. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46157. }
  46158. }
  46159. declare module BABYLON {
  46160. /**
  46161. * The PBR material of BJS following the metal roughness convention.
  46162. *
  46163. * This fits to the PBR convention in the GLTF definition:
  46164. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46165. */
  46166. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46167. /**
  46168. * The base color has two different interpretations depending on the value of metalness.
  46169. * When the material is a metal, the base color is the specific measured reflectance value
  46170. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46171. * of the material.
  46172. */
  46173. baseColor: Color3;
  46174. /**
  46175. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46176. * well as opacity information in the alpha channel.
  46177. */
  46178. baseTexture: BaseTexture;
  46179. /**
  46180. * Specifies the metallic scalar value of the material.
  46181. * Can also be used to scale the metalness values of the metallic texture.
  46182. */
  46183. metallic: number;
  46184. /**
  46185. * Specifies the roughness scalar value of the material.
  46186. * Can also be used to scale the roughness values of the metallic texture.
  46187. */
  46188. roughness: number;
  46189. /**
  46190. * Texture containing both the metallic value in the B channel and the
  46191. * roughness value in the G channel to keep better precision.
  46192. */
  46193. metallicRoughnessTexture: BaseTexture;
  46194. /**
  46195. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46196. *
  46197. * @param name The material name
  46198. * @param scene The scene the material will be use in.
  46199. */
  46200. constructor(name: string, scene: Scene);
  46201. /**
  46202. * Return the currrent class name of the material.
  46203. */
  46204. getClassName(): string;
  46205. /**
  46206. * Return the active textures of the material.
  46207. */
  46208. getActiveTextures(): BaseTexture[];
  46209. /**
  46210. * Checks to see if a texture is used in the material.
  46211. * @param texture - Base texture to use.
  46212. * @returns - Boolean specifying if a texture is used in the material.
  46213. */
  46214. hasTexture(texture: BaseTexture): boolean;
  46215. /**
  46216. * Makes a duplicate of the current material.
  46217. * @param name - name to use for the new material.
  46218. */
  46219. clone(name: string): PBRMetallicRoughnessMaterial;
  46220. /**
  46221. * Serialize the material to a parsable JSON object.
  46222. */
  46223. serialize(): any;
  46224. /**
  46225. * Parses a JSON object correponding to the serialize function.
  46226. */
  46227. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46228. }
  46229. }
  46230. declare module BABYLON {
  46231. /**
  46232. * The PBR material of BJS following the specular glossiness convention.
  46233. *
  46234. * This fits to the PBR convention in the GLTF definition:
  46235. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46236. */
  46237. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46238. /**
  46239. * Specifies the diffuse color of the material.
  46240. */
  46241. diffuseColor: Color3;
  46242. /**
  46243. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46244. * channel.
  46245. */
  46246. diffuseTexture: BaseTexture;
  46247. /**
  46248. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46249. */
  46250. specularColor: Color3;
  46251. /**
  46252. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46253. */
  46254. glossiness: number;
  46255. /**
  46256. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46257. */
  46258. specularGlossinessTexture: BaseTexture;
  46259. /**
  46260. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46261. *
  46262. * @param name The material name
  46263. * @param scene The scene the material will be use in.
  46264. */
  46265. constructor(name: string, scene: Scene);
  46266. /**
  46267. * Return the currrent class name of the material.
  46268. */
  46269. getClassName(): string;
  46270. /**
  46271. * Return the active textures of the material.
  46272. */
  46273. getActiveTextures(): BaseTexture[];
  46274. /**
  46275. * Checks to see if a texture is used in the material.
  46276. * @param texture - Base texture to use.
  46277. * @returns - Boolean specifying if a texture is used in the material.
  46278. */
  46279. hasTexture(texture: BaseTexture): boolean;
  46280. /**
  46281. * Makes a duplicate of the current material.
  46282. * @param name - name to use for the new material.
  46283. */
  46284. clone(name: string): PBRSpecularGlossinessMaterial;
  46285. /**
  46286. * Serialize the material to a parsable JSON object.
  46287. */
  46288. serialize(): any;
  46289. /**
  46290. * Parses a JSON object correponding to the serialize function.
  46291. */
  46292. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46293. }
  46294. }
  46295. declare module BABYLON {
  46296. /**
  46297. * Base class of all the textures in babylon.
  46298. * It groups all the common properties the materials, post process, lights... might need
  46299. * in order to make a correct use of the texture.
  46300. */
  46301. class BaseTexture {
  46302. /**
  46303. * Default anisotropic filtering level for the application.
  46304. * It is set to 4 as a good tradeoff between perf and quality.
  46305. */
  46306. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46307. /**
  46308. * Gets or sets the unique id of the texture
  46309. */
  46310. uniqueId: number;
  46311. /**
  46312. * Define the name of the texture.
  46313. */
  46314. name: string;
  46315. /**
  46316. * Gets or sets an object used to store user defined information.
  46317. */
  46318. metadata: any;
  46319. /**
  46320. * For internal use only. Please do not use.
  46321. */
  46322. reservedDataStore: any;
  46323. private _hasAlpha;
  46324. /**
  46325. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46326. */
  46327. hasAlpha: boolean;
  46328. /**
  46329. * Defines if the alpha value should be determined via the rgb values.
  46330. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46331. */
  46332. getAlphaFromRGB: boolean;
  46333. /**
  46334. * Intensity or strength of the texture.
  46335. * It is commonly used by materials to fine tune the intensity of the texture
  46336. */
  46337. level: number;
  46338. /**
  46339. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46340. * This is part of the texture as textures usually maps to one uv set.
  46341. */
  46342. coordinatesIndex: number;
  46343. private _coordinatesMode;
  46344. /**
  46345. * How a texture is mapped.
  46346. *
  46347. * | Value | Type | Description |
  46348. * | ----- | ----------------------------------- | ----------- |
  46349. * | 0 | EXPLICIT_MODE | |
  46350. * | 1 | SPHERICAL_MODE | |
  46351. * | 2 | PLANAR_MODE | |
  46352. * | 3 | CUBIC_MODE | |
  46353. * | 4 | PROJECTION_MODE | |
  46354. * | 5 | SKYBOX_MODE | |
  46355. * | 6 | INVCUBIC_MODE | |
  46356. * | 7 | EQUIRECTANGULAR_MODE | |
  46357. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46358. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46359. */
  46360. coordinatesMode: number;
  46361. /**
  46362. * | Value | Type | Description |
  46363. * | ----- | ------------------ | ----------- |
  46364. * | 0 | CLAMP_ADDRESSMODE | |
  46365. * | 1 | WRAP_ADDRESSMODE | |
  46366. * | 2 | MIRROR_ADDRESSMODE | |
  46367. */
  46368. wrapU: number;
  46369. /**
  46370. * | Value | Type | Description |
  46371. * | ----- | ------------------ | ----------- |
  46372. * | 0 | CLAMP_ADDRESSMODE | |
  46373. * | 1 | WRAP_ADDRESSMODE | |
  46374. * | 2 | MIRROR_ADDRESSMODE | |
  46375. */
  46376. wrapV: number;
  46377. /**
  46378. * | Value | Type | Description |
  46379. * | ----- | ------------------ | ----------- |
  46380. * | 0 | CLAMP_ADDRESSMODE | |
  46381. * | 1 | WRAP_ADDRESSMODE | |
  46382. * | 2 | MIRROR_ADDRESSMODE | |
  46383. */
  46384. wrapR: number;
  46385. /**
  46386. * With compliant hardware and browser (supporting anisotropic filtering)
  46387. * this defines the level of anisotropic filtering in the texture.
  46388. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46389. */
  46390. anisotropicFilteringLevel: number;
  46391. /**
  46392. * Define if the texture is a cube texture or if false a 2d texture.
  46393. */
  46394. isCube: boolean;
  46395. /**
  46396. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46397. */
  46398. is3D: boolean;
  46399. /**
  46400. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46401. * HDR texture are usually stored in linear space.
  46402. * This only impacts the PBR and Background materials
  46403. */
  46404. gammaSpace: boolean;
  46405. /**
  46406. * Gets whether or not the texture contains RGBD data.
  46407. */
  46408. readonly isRGBD: boolean;
  46409. /**
  46410. * Is Z inverted in the texture (useful in a cube texture).
  46411. */
  46412. invertZ: boolean;
  46413. /**
  46414. * Are mip maps generated for this texture or not.
  46415. */
  46416. readonly noMipmap: boolean;
  46417. /**
  46418. * @hidden
  46419. */
  46420. lodLevelInAlpha: boolean;
  46421. /**
  46422. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46423. */
  46424. lodGenerationOffset: number;
  46425. /**
  46426. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46427. */
  46428. lodGenerationScale: number;
  46429. /**
  46430. * Define if the texture is a render target.
  46431. */
  46432. isRenderTarget: boolean;
  46433. /**
  46434. * Define the unique id of the texture in the scene.
  46435. */
  46436. readonly uid: string;
  46437. /**
  46438. * Return a string representation of the texture.
  46439. * @returns the texture as a string
  46440. */
  46441. toString(): string;
  46442. /**
  46443. * Get the class name of the texture.
  46444. * @returns "BaseTexture"
  46445. */
  46446. getClassName(): string;
  46447. /**
  46448. * Define the list of animation attached to the texture.
  46449. */
  46450. animations: Animation[];
  46451. /**
  46452. * An event triggered when the texture is disposed.
  46453. */
  46454. onDisposeObservable: Observable<BaseTexture>;
  46455. private _onDisposeObserver;
  46456. /**
  46457. * Callback triggered when the texture has been disposed.
  46458. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46459. */
  46460. onDispose: () => void;
  46461. /**
  46462. * Define the current state of the loading sequence when in delayed load mode.
  46463. */
  46464. delayLoadState: number;
  46465. private _scene;
  46466. /** @hidden */
  46467. _samplingMode: number;
  46468. /** @hidden */
  46469. _texture: Nullable<InternalTexture>;
  46470. private _uid;
  46471. /**
  46472. * Define if the texture is preventinga material to render or not.
  46473. * If not and the texture is not ready, the engine will use a default black texture instead.
  46474. */
  46475. readonly isBlocking: boolean;
  46476. /**
  46477. * Instantiates a new BaseTexture.
  46478. * Base class of all the textures in babylon.
  46479. * It groups all the common properties the materials, post process, lights... might need
  46480. * in order to make a correct use of the texture.
  46481. * @param scene Define the scene the texture blongs to
  46482. */
  46483. constructor(scene: Nullable<Scene>);
  46484. /**
  46485. * Get the scene the texture belongs to.
  46486. * @returns the scene or null if undefined
  46487. */
  46488. getScene(): Nullable<Scene>;
  46489. /**
  46490. * Get the texture transform matrix used to offset tile the texture for istance.
  46491. * @returns the transformation matrix
  46492. */
  46493. getTextureMatrix(): Matrix;
  46494. /**
  46495. * Get the texture reflection matrix used to rotate/transform the reflection.
  46496. * @returns the reflection matrix
  46497. */
  46498. getReflectionTextureMatrix(): Matrix;
  46499. /**
  46500. * Get the underlying lower level texture from Babylon.
  46501. * @returns the insternal texture
  46502. */
  46503. getInternalTexture(): Nullable<InternalTexture>;
  46504. /**
  46505. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46506. * @returns true if ready or not blocking
  46507. */
  46508. isReadyOrNotBlocking(): boolean;
  46509. /**
  46510. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46511. * @returns true if fully ready
  46512. */
  46513. isReady(): boolean;
  46514. private _cachedSize;
  46515. /**
  46516. * Get the size of the texture.
  46517. * @returns the texture size.
  46518. */
  46519. getSize(): ISize;
  46520. /**
  46521. * Get the base size of the texture.
  46522. * It can be different from the size if the texture has been resized for POT for instance
  46523. * @returns the base size
  46524. */
  46525. getBaseSize(): ISize;
  46526. /**
  46527. * Update the sampling mode of the texture.
  46528. * Default is Trilinear mode.
  46529. *
  46530. * | Value | Type | Description |
  46531. * | ----- | ------------------ | ----------- |
  46532. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46533. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46534. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46535. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46536. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46537. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46538. * | 7 | NEAREST_LINEAR | |
  46539. * | 8 | NEAREST_NEAREST | |
  46540. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46541. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46542. * | 11 | LINEAR_LINEAR | |
  46543. * | 12 | LINEAR_NEAREST | |
  46544. *
  46545. * > _mag_: magnification filter (close to the viewer)
  46546. * > _min_: minification filter (far from the viewer)
  46547. * > _mip_: filter used between mip map levels
  46548. *@param samplingMode Define the new sampling mode of the texture
  46549. */
  46550. updateSamplingMode(samplingMode: number): void;
  46551. /**
  46552. * Scales the texture if is `canRescale()`
  46553. * @param ratio the resize factor we want to use to rescale
  46554. */
  46555. scale(ratio: number): void;
  46556. /**
  46557. * Get if the texture can rescale.
  46558. */
  46559. readonly canRescale: boolean;
  46560. /** @hidden */
  46561. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46562. /** @hidden */
  46563. _rebuild(): void;
  46564. /**
  46565. * Triggers the load sequence in delayed load mode.
  46566. */
  46567. delayLoad(): void;
  46568. /**
  46569. * Clones the texture.
  46570. * @returns the cloned texture
  46571. */
  46572. clone(): Nullable<BaseTexture>;
  46573. /**
  46574. * Get the texture underlying type (INT, FLOAT...)
  46575. */
  46576. readonly textureType: number;
  46577. /**
  46578. * Get the texture underlying format (RGB, RGBA...)
  46579. */
  46580. readonly textureFormat: number;
  46581. /**
  46582. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46583. * This will returns an RGBA array buffer containing either in values (0-255) or
  46584. * float values (0-1) depending of the underlying buffer type.
  46585. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46586. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46587. * @param buffer defines a user defined buffer to fill with data (can be null)
  46588. * @returns The Array buffer containing the pixels data.
  46589. */
  46590. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46591. /**
  46592. * Release and destroy the underlying lower level texture aka internalTexture.
  46593. */
  46594. releaseInternalTexture(): void;
  46595. /**
  46596. * Get the polynomial representation of the texture data.
  46597. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46598. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46599. */
  46600. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46601. /** @hidden */
  46602. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46603. /** @hidden */
  46604. readonly _lodTextureMid: Nullable<BaseTexture>;
  46605. /** @hidden */
  46606. readonly _lodTextureLow: Nullable<BaseTexture>;
  46607. /**
  46608. * Dispose the texture and release its associated resources.
  46609. */
  46610. dispose(): void;
  46611. /**
  46612. * Serialize the texture into a JSON representation that can be parsed later on.
  46613. * @returns the JSON representation of the texture
  46614. */
  46615. serialize(): any;
  46616. /**
  46617. * Helper function to be called back once a list of texture contains only ready textures.
  46618. * @param textures Define the list of textures to wait for
  46619. * @param callback Define the callback triggered once the entire list will be ready
  46620. */
  46621. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46622. }
  46623. }
  46624. declare module BABYLON {
  46625. /**
  46626. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46627. * It can help converting any input color in a desired output one. This can then be used to create effects
  46628. * from sepia, black and white to sixties or futuristic rendering...
  46629. *
  46630. * The only supported format is currently 3dl.
  46631. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46632. */
  46633. class ColorGradingTexture extends BaseTexture {
  46634. /**
  46635. * The current texture matrix. (will always be identity in color grading texture)
  46636. */
  46637. private _textureMatrix;
  46638. /**
  46639. * The texture URL.
  46640. */
  46641. url: string;
  46642. /**
  46643. * Empty line regex stored for GC.
  46644. */
  46645. private static _noneEmptyLineRegex;
  46646. private _engine;
  46647. /**
  46648. * Instantiates a ColorGradingTexture from the following parameters.
  46649. *
  46650. * @param url The location of the color gradind data (currently only supporting 3dl)
  46651. * @param scene The scene the texture will be used in
  46652. */
  46653. constructor(url: string, scene: Scene);
  46654. /**
  46655. * Returns the texture matrix used in most of the material.
  46656. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46657. */
  46658. getTextureMatrix(): Matrix;
  46659. /**
  46660. * Occurs when the file being loaded is a .3dl LUT file.
  46661. */
  46662. private load3dlTexture;
  46663. /**
  46664. * Starts the loading process of the texture.
  46665. */
  46666. private loadTexture;
  46667. /**
  46668. * Clones the color gradind texture.
  46669. */
  46670. clone(): ColorGradingTexture;
  46671. /**
  46672. * Called during delayed load for textures.
  46673. */
  46674. delayLoad(): void;
  46675. /**
  46676. * Parses a color grading texture serialized by Babylon.
  46677. * @param parsedTexture The texture information being parsedTexture
  46678. * @param scene The scene to load the texture in
  46679. * @param rootUrl The root url of the data assets to load
  46680. * @return A color gradind texture
  46681. */
  46682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46683. /**
  46684. * Serializes the LUT texture to json format.
  46685. */
  46686. serialize(): any;
  46687. }
  46688. }
  46689. declare module BABYLON {
  46690. /**
  46691. * Class for creating a cube texture
  46692. */
  46693. class CubeTexture extends BaseTexture {
  46694. private _delayedOnLoad;
  46695. /**
  46696. * The url of the texture
  46697. */
  46698. url: string;
  46699. /**
  46700. * Gets or sets the center of the bounding box associated with the cube texture.
  46701. * It must define where the camera used to render the texture was set
  46702. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46703. */
  46704. boundingBoxPosition: Vector3;
  46705. private _boundingBoxSize;
  46706. /**
  46707. * Gets or sets the size of the bounding box associated with the cube texture
  46708. * When defined, the cubemap will switch to local mode
  46709. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46710. * @example https://www.babylonjs-playground.com/#RNASML
  46711. */
  46712. /**
  46713. * Returns the bounding box size
  46714. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46715. */
  46716. boundingBoxSize: Vector3;
  46717. protected _rotationY: number;
  46718. /**
  46719. * Sets texture matrix rotation angle around Y axis in radians.
  46720. */
  46721. /**
  46722. * Gets texture matrix rotation angle around Y axis radians.
  46723. */
  46724. rotationY: number;
  46725. /**
  46726. * Are mip maps generated for this texture or not.
  46727. */
  46728. readonly noMipmap: boolean;
  46729. private _noMipmap;
  46730. private _files;
  46731. private _extensions;
  46732. private _textureMatrix;
  46733. private _format;
  46734. private _createPolynomials;
  46735. /** @hidden */
  46736. _prefiltered: boolean;
  46737. /**
  46738. * Creates a cube texture from an array of image urls
  46739. * @param files defines an array of image urls
  46740. * @param scene defines the hosting scene
  46741. * @param noMipmap specifies if mip maps are not used
  46742. * @returns a cube texture
  46743. */
  46744. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46745. /**
  46746. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46747. * @param url defines the url of the prefiltered texture
  46748. * @param scene defines the scene the texture is attached to
  46749. * @param forcedExtension defines the extension of the file if different from the url
  46750. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46751. * @return the prefiltered texture
  46752. */
  46753. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46754. /**
  46755. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46756. * as prefiltered data.
  46757. * @param rootUrl defines the url of the texture or the root name of the six images
  46758. * @param scene defines the scene the texture is attached to
  46759. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46760. * @param noMipmap defines if mipmaps should be created or not
  46761. * @param files defines the six files to load for the different faces
  46762. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46763. * @param onError defines a callback triggered in case of error during load
  46764. * @param format defines the internal format to use for the texture once loaded
  46765. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46766. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46767. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46770. * @return the cube texture
  46771. */
  46772. 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);
  46773. /**
  46774. * Get the current class name of the texture useful for serialization or dynamic coding.
  46775. * @returns "CubeTexture"
  46776. */
  46777. getClassName(): string;
  46778. /**
  46779. * Update the url (and optional buffer) of this texture if url was null during construction.
  46780. * @param url the url of the texture
  46781. * @param forcedExtension defines the extension to use
  46782. * @param onLoad callback called when the texture is loaded (defaults to null)
  46783. */
  46784. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46785. /**
  46786. * Delays loading of the cube texture
  46787. * @param forcedExtension defines the extension to use
  46788. */
  46789. delayLoad(forcedExtension?: string): void;
  46790. /**
  46791. * Returns the reflection texture matrix
  46792. * @returns the reflection texture matrix
  46793. */
  46794. getReflectionTextureMatrix(): Matrix;
  46795. /**
  46796. * Sets the reflection texture matrix
  46797. * @param value Reflection texture matrix
  46798. */
  46799. setReflectionTextureMatrix(value: Matrix): void;
  46800. /**
  46801. * Parses text to create a cube texture
  46802. * @param parsedTexture define the serialized text to read from
  46803. * @param scene defines the hosting scene
  46804. * @param rootUrl defines the root url of the cube texture
  46805. * @returns a cube texture
  46806. */
  46807. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46808. /**
  46809. * Makes a clone, or deep copy, of the cube texture
  46810. * @returns a new cube texture
  46811. */
  46812. clone(): CubeTexture;
  46813. }
  46814. }
  46815. declare module BABYLON {
  46816. /**
  46817. * A class extending Texture allowing drawing on a texture
  46818. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46819. */
  46820. class DynamicTexture extends Texture {
  46821. private _generateMipMaps;
  46822. private _canvas;
  46823. private _context;
  46824. private _engine;
  46825. /**
  46826. * Creates a DynamicTexture
  46827. * @param name defines the name of the texture
  46828. * @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
  46829. * @param scene defines the scene where you want the texture
  46830. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46831. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46832. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46833. */
  46834. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46835. /**
  46836. * Get the current class name of the texture useful for serialization or dynamic coding.
  46837. * @returns "DynamicTexture"
  46838. */
  46839. getClassName(): string;
  46840. /**
  46841. * Gets the current state of canRescale
  46842. */
  46843. readonly canRescale: boolean;
  46844. private _recreate;
  46845. /**
  46846. * Scales the texture
  46847. * @param ratio the scale factor to apply to both width and height
  46848. */
  46849. scale(ratio: number): void;
  46850. /**
  46851. * Resizes the texture
  46852. * @param width the new width
  46853. * @param height the new height
  46854. */
  46855. scaleTo(width: number, height: number): void;
  46856. /**
  46857. * Gets the context of the canvas used by the texture
  46858. * @returns the canvas context of the dynamic texture
  46859. */
  46860. getContext(): CanvasRenderingContext2D;
  46861. /**
  46862. * Clears the texture
  46863. */
  46864. clear(): void;
  46865. /**
  46866. * Updates the texture
  46867. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46868. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46869. */
  46870. update(invertY?: boolean, premulAlpha?: boolean): void;
  46871. /**
  46872. * Draws text onto the texture
  46873. * @param text defines the text to be drawn
  46874. * @param x defines the placement of the text from the left
  46875. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46876. * @param font defines the font to be used with font-style, font-size, font-name
  46877. * @param color defines the color used for the text
  46878. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46879. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46880. * @param update defines whether texture is immediately update (default is true)
  46881. */
  46882. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46883. /**
  46884. * Clones the texture
  46885. * @returns the clone of the texture.
  46886. */
  46887. clone(): DynamicTexture;
  46888. /**
  46889. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46890. * @returns a serialized dynamic texture object
  46891. */
  46892. serialize(): any;
  46893. /** @hidden */
  46894. _rebuild(): void;
  46895. }
  46896. }
  46897. declare module BABYLON {
  46898. /**
  46899. * This represents a texture coming from an HDR input.
  46900. *
  46901. * The only supported format is currently panorama picture stored in RGBE format.
  46902. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46903. */
  46904. class HDRCubeTexture extends BaseTexture {
  46905. private static _facesMapping;
  46906. private _generateHarmonics;
  46907. private _noMipmap;
  46908. private _textureMatrix;
  46909. private _size;
  46910. private _onLoad;
  46911. private _onError;
  46912. /**
  46913. * The texture URL.
  46914. */
  46915. url: string;
  46916. /**
  46917. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46918. */
  46919. coordinatesMode: number;
  46920. protected _isBlocking: boolean;
  46921. /**
  46922. * Sets wether or not the texture is blocking during loading.
  46923. */
  46924. /**
  46925. * Gets wether or not the texture is blocking during loading.
  46926. */
  46927. isBlocking: boolean;
  46928. protected _rotationY: number;
  46929. /**
  46930. * Sets texture matrix rotation angle around Y axis in radians.
  46931. */
  46932. /**
  46933. * Gets texture matrix rotation angle around Y axis radians.
  46934. */
  46935. rotationY: number;
  46936. /**
  46937. * Gets or sets the center of the bounding box associated with the cube texture
  46938. * It must define where the camera used to render the texture was set
  46939. */
  46940. boundingBoxPosition: Vector3;
  46941. private _boundingBoxSize;
  46942. /**
  46943. * Gets or sets the size of the bounding box associated with the cube texture
  46944. * When defined, the cubemap will switch to local mode
  46945. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46946. * @example https://www.babylonjs-playground.com/#RNASML
  46947. */
  46948. boundingBoxSize: Vector3;
  46949. /**
  46950. * Instantiates an HDRTexture from the following parameters.
  46951. *
  46952. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46953. * @param scene The scene the texture will be used in
  46954. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46955. * @param noMipmap Forces to not generate the mipmap if true
  46956. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46957. * @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)
  46958. * @param reserved Reserved flag for internal use.
  46959. */
  46960. 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>);
  46961. /**
  46962. * Get the current class name of the texture useful for serialization or dynamic coding.
  46963. * @returns "HDRCubeTexture"
  46964. */
  46965. getClassName(): string;
  46966. /**
  46967. * Occurs when the file is raw .hdr file.
  46968. */
  46969. private loadTexture;
  46970. clone(): HDRCubeTexture;
  46971. delayLoad(): void;
  46972. /**
  46973. * Get the texture reflection matrix used to rotate/transform the reflection.
  46974. * @returns the reflection matrix
  46975. */
  46976. getReflectionTextureMatrix(): Matrix;
  46977. /**
  46978. * Set the texture reflection matrix used to rotate/transform the reflection.
  46979. * @param value Define the reflection matrix to set
  46980. */
  46981. setReflectionTextureMatrix(value: Matrix): void;
  46982. /**
  46983. * Parses a JSON representation of an HDR Texture in order to create the texture
  46984. * @param parsedTexture Define the JSON representation
  46985. * @param scene Define the scene the texture should be created in
  46986. * @param rootUrl Define the root url in case we need to load relative dependencies
  46987. * @returns the newly created texture after parsing
  46988. */
  46989. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46990. serialize(): any;
  46991. }
  46992. }
  46993. declare module BABYLON {
  46994. /**
  46995. * Class used to store data associated with WebGL texture data for the engine
  46996. * This class should not be used directly
  46997. */
  46998. class InternalTexture implements IInternalTextureTracker {
  46999. /**
  47000. * The source of the texture data is unknown
  47001. */
  47002. static DATASOURCE_UNKNOWN: number;
  47003. /**
  47004. * Texture data comes from an URL
  47005. */
  47006. static DATASOURCE_URL: number;
  47007. /**
  47008. * Texture data is only used for temporary storage
  47009. */
  47010. static DATASOURCE_TEMP: number;
  47011. /**
  47012. * Texture data comes from raw data (ArrayBuffer)
  47013. */
  47014. static DATASOURCE_RAW: number;
  47015. /**
  47016. * Texture content is dynamic (video or dynamic texture)
  47017. */
  47018. static DATASOURCE_DYNAMIC: number;
  47019. /**
  47020. * Texture content is generated by rendering to it
  47021. */
  47022. static DATASOURCE_RENDERTARGET: number;
  47023. /**
  47024. * Texture content is part of a multi render target process
  47025. */
  47026. static DATASOURCE_MULTIRENDERTARGET: number;
  47027. /**
  47028. * Texture data comes from a cube data file
  47029. */
  47030. static DATASOURCE_CUBE: number;
  47031. /**
  47032. * Texture data comes from a raw cube data
  47033. */
  47034. static DATASOURCE_CUBERAW: number;
  47035. /**
  47036. * Texture data come from a prefiltered cube data file
  47037. */
  47038. static DATASOURCE_CUBEPREFILTERED: number;
  47039. /**
  47040. * Texture content is raw 3D data
  47041. */
  47042. static DATASOURCE_RAW3D: number;
  47043. /**
  47044. * Texture content is a depth texture
  47045. */
  47046. static DATASOURCE_DEPTHTEXTURE: number;
  47047. /**
  47048. * Texture data comes from a raw cube data encoded with RGBD
  47049. */
  47050. static DATASOURCE_CUBERAW_RGBD: number;
  47051. /**
  47052. * Defines if the texture is ready
  47053. */
  47054. isReady: boolean;
  47055. /**
  47056. * Defines if the texture is a cube texture
  47057. */
  47058. isCube: boolean;
  47059. /**
  47060. * Defines if the texture contains 3D data
  47061. */
  47062. is3D: boolean;
  47063. /**
  47064. * Gets the URL used to load this texture
  47065. */
  47066. url: string;
  47067. /**
  47068. * Gets the sampling mode of the texture
  47069. */
  47070. samplingMode: number;
  47071. /**
  47072. * Gets a boolean indicating if the texture needs mipmaps generation
  47073. */
  47074. generateMipMaps: boolean;
  47075. /**
  47076. * Gets the number of samples used by the texture (WebGL2+ only)
  47077. */
  47078. samples: number;
  47079. /**
  47080. * Gets the type of the texture (int, float...)
  47081. */
  47082. type: number;
  47083. /**
  47084. * Gets the format of the texture (RGB, RGBA...)
  47085. */
  47086. format: number;
  47087. /**
  47088. * Observable called when the texture is loaded
  47089. */
  47090. onLoadedObservable: Observable<InternalTexture>;
  47091. /**
  47092. * Gets the width of the texture
  47093. */
  47094. width: number;
  47095. /**
  47096. * Gets the height of the texture
  47097. */
  47098. height: number;
  47099. /**
  47100. * Gets the depth of the texture
  47101. */
  47102. depth: number;
  47103. /**
  47104. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47105. */
  47106. baseWidth: number;
  47107. /**
  47108. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47109. */
  47110. baseHeight: number;
  47111. /**
  47112. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47113. */
  47114. baseDepth: number;
  47115. /**
  47116. * Gets a boolean indicating if the texture is inverted on Y axis
  47117. */
  47118. invertY: boolean;
  47119. /**
  47120. * Gets or set the previous tracker in the list
  47121. */
  47122. previous: Nullable<IInternalTextureTracker>;
  47123. /**
  47124. * Gets or set the next tracker in the list
  47125. */
  47126. next: Nullable<IInternalTextureTracker>;
  47127. /** @hidden */
  47128. _initialSlot: number;
  47129. /** @hidden */
  47130. _designatedSlot: number;
  47131. /** @hidden */
  47132. _dataSource: number;
  47133. /** @hidden */
  47134. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47135. /** @hidden */
  47136. _bufferView: Nullable<ArrayBufferView>;
  47137. /** @hidden */
  47138. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47139. /** @hidden */
  47140. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47141. /** @hidden */
  47142. _size: number;
  47143. /** @hidden */
  47144. _extension: string;
  47145. /** @hidden */
  47146. _files: Nullable<string[]>;
  47147. /** @hidden */
  47148. _workingCanvas: HTMLCanvasElement;
  47149. /** @hidden */
  47150. _workingContext: CanvasRenderingContext2D;
  47151. /** @hidden */
  47152. _framebuffer: Nullable<WebGLFramebuffer>;
  47153. /** @hidden */
  47154. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47155. /** @hidden */
  47156. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47157. /** @hidden */
  47158. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47159. /** @hidden */
  47160. _attachments: Nullable<number[]>;
  47161. /** @hidden */
  47162. _cachedCoordinatesMode: Nullable<number>;
  47163. /** @hidden */
  47164. _cachedWrapU: Nullable<number>;
  47165. /** @hidden */
  47166. _cachedWrapV: Nullable<number>;
  47167. /** @hidden */
  47168. _cachedWrapR: Nullable<number>;
  47169. /** @hidden */
  47170. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47171. /** @hidden */
  47172. _isDisabled: boolean;
  47173. /** @hidden */
  47174. _compression: Nullable<string>;
  47175. /** @hidden */
  47176. _generateStencilBuffer: boolean;
  47177. /** @hidden */
  47178. _generateDepthBuffer: boolean;
  47179. /** @hidden */
  47180. _comparisonFunction: number;
  47181. /** @hidden */
  47182. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47183. /** @hidden */
  47184. _lodGenerationScale: number;
  47185. /** @hidden */
  47186. _lodGenerationOffset: number;
  47187. /** @hidden */
  47188. _lodTextureHigh: BaseTexture;
  47189. /** @hidden */
  47190. _lodTextureMid: BaseTexture;
  47191. /** @hidden */
  47192. _lodTextureLow: BaseTexture;
  47193. /** @hidden */
  47194. _isRGBD: boolean;
  47195. /** @hidden */
  47196. _webGLTexture: Nullable<WebGLTexture>;
  47197. /** @hidden */
  47198. _references: number;
  47199. private _engine;
  47200. /**
  47201. * Gets the Engine the texture belongs to.
  47202. * @returns The babylon engine
  47203. */
  47204. getEngine(): Engine;
  47205. /**
  47206. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47207. */
  47208. readonly dataSource: number;
  47209. /**
  47210. * Creates a new InternalTexture
  47211. * @param engine defines the engine to use
  47212. * @param dataSource defines the type of data that will be used
  47213. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47214. */
  47215. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47216. /**
  47217. * Increments the number of references (ie. the number of Texture that point to it)
  47218. */
  47219. incrementReferences(): void;
  47220. /**
  47221. * Change the size of the texture (not the size of the content)
  47222. * @param width defines the new width
  47223. * @param height defines the new height
  47224. * @param depth defines the new depth (1 by default)
  47225. */
  47226. updateSize(width: int, height: int, depth?: int): void;
  47227. /** @hidden */
  47228. _rebuild(): void;
  47229. /** @hidden */
  47230. _swapAndDie(target: InternalTexture): void;
  47231. /**
  47232. * Dispose the current allocated resources
  47233. */
  47234. dispose(): void;
  47235. }
  47236. }
  47237. declare module BABYLON {
  47238. /**
  47239. * This represents the required contract to create a new type of texture loader.
  47240. */
  47241. interface IInternalTextureLoader {
  47242. /**
  47243. * Defines wether the loader supports cascade loading the different faces.
  47244. */
  47245. supportCascades: boolean;
  47246. /**
  47247. * This returns if the loader support the current file information.
  47248. * @param extension defines the file extension of the file being loaded
  47249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47250. * @param fallback defines the fallback internal texture if any
  47251. * @param isBase64 defines whether the texture is encoded as a base64
  47252. * @param isBuffer defines whether the texture data are stored as a buffer
  47253. * @returns true if the loader can load the specified file
  47254. */
  47255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47256. /**
  47257. * Transform the url before loading if required.
  47258. * @param rootUrl the url of the texture
  47259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47260. * @returns the transformed texture
  47261. */
  47262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47263. /**
  47264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47265. * @param rootUrl the url of the texture
  47266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47267. * @returns the fallback texture
  47268. */
  47269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47270. /**
  47271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47272. * @param data contains the texture data
  47273. * @param texture defines the BabylonJS internal texture
  47274. * @param createPolynomials will be true if polynomials have been requested
  47275. * @param onLoad defines the callback to trigger once the texture is ready
  47276. * @param onError defines the callback to trigger in case of error
  47277. */
  47278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47279. /**
  47280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47281. * @param data contains the texture data
  47282. * @param texture defines the BabylonJS internal texture
  47283. * @param callback defines the method to call once ready to upload
  47284. */
  47285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47286. }
  47287. }
  47288. declare module BABYLON {
  47289. /**
  47290. * Internal interface used to track InternalTexture already bound to the GL context
  47291. */
  47292. interface IInternalTextureTracker {
  47293. /**
  47294. * Gets or set the previous tracker in the list
  47295. */
  47296. previous: Nullable<IInternalTextureTracker>;
  47297. /**
  47298. * Gets or set the next tracker in the list
  47299. */
  47300. next: Nullable<IInternalTextureTracker>;
  47301. }
  47302. /**
  47303. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47304. */
  47305. class DummyInternalTextureTracker {
  47306. /**
  47307. * Gets or set the previous tracker in the list
  47308. */
  47309. previous: Nullable<IInternalTextureTracker>;
  47310. /**
  47311. * Gets or set the next tracker in the list
  47312. */
  47313. next: Nullable<IInternalTextureTracker>;
  47314. }
  47315. }
  47316. declare module BABYLON {
  47317. /**
  47318. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47319. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47320. * You can then easily use it as a reflectionTexture on a flat surface.
  47321. * In case the surface is not a plane, please consider relying on reflection probes.
  47322. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47323. */
  47324. class MirrorTexture extends RenderTargetTexture {
  47325. private scene;
  47326. /**
  47327. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47328. * 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.
  47329. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47330. */
  47331. mirrorPlane: Plane;
  47332. /**
  47333. * Define the blur ratio used to blur the reflection if needed.
  47334. */
  47335. blurRatio: number;
  47336. /**
  47337. * Define the adaptive blur kernel used to blur the reflection if needed.
  47338. * This will autocompute the closest best match for the `blurKernel`
  47339. */
  47340. adaptiveBlurKernel: number;
  47341. /**
  47342. * Define the blur kernel used to blur the reflection if needed.
  47343. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47344. */
  47345. blurKernel: number;
  47346. /**
  47347. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47348. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47349. */
  47350. blurKernelX: number;
  47351. /**
  47352. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47353. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47354. */
  47355. blurKernelY: number;
  47356. private _autoComputeBlurKernel;
  47357. protected _onRatioRescale(): void;
  47358. private _updateGammaSpace;
  47359. private _imageProcessingConfigChangeObserver;
  47360. private _transformMatrix;
  47361. private _mirrorMatrix;
  47362. private _savedViewMatrix;
  47363. private _blurX;
  47364. private _blurY;
  47365. private _adaptiveBlurKernel;
  47366. private _blurKernelX;
  47367. private _blurKernelY;
  47368. private _blurRatio;
  47369. /**
  47370. * Instantiates a Mirror Texture.
  47371. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47372. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47373. * You can then easily use it as a reflectionTexture on a flat surface.
  47374. * In case the surface is not a plane, please consider relying on reflection probes.
  47375. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47376. * @param name
  47377. * @param size
  47378. * @param scene
  47379. * @param generateMipMaps
  47380. * @param type
  47381. * @param samplingMode
  47382. * @param generateDepthBuffer
  47383. */
  47384. constructor(name: string, size: number | {
  47385. width: number;
  47386. height: number;
  47387. } | {
  47388. ratio: number;
  47389. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47390. private _preparePostProcesses;
  47391. /**
  47392. * Clone the mirror texture.
  47393. * @returns the cloned texture
  47394. */
  47395. clone(): MirrorTexture;
  47396. /**
  47397. * Serialize the texture to a JSON representation you could use in Parse later on
  47398. * @returns the serialized JSON representation
  47399. */
  47400. serialize(): any;
  47401. /**
  47402. * Dispose the texture and release its associated resources.
  47403. */
  47404. dispose(): void;
  47405. }
  47406. }
  47407. declare module BABYLON {
  47408. /**
  47409. * Creation options of the multi render target texture.
  47410. */
  47411. interface IMultiRenderTargetOptions {
  47412. /**
  47413. * Define if the texture needs to create mip maps after render.
  47414. */
  47415. generateMipMaps?: boolean;
  47416. /**
  47417. * Define the types of all the draw buffers we want to create
  47418. */
  47419. types?: number[];
  47420. /**
  47421. * Define the sampling modes of all the draw buffers we want to create
  47422. */
  47423. samplingModes?: number[];
  47424. /**
  47425. * Define if a depth buffer is required
  47426. */
  47427. generateDepthBuffer?: boolean;
  47428. /**
  47429. * Define if a stencil buffer is required
  47430. */
  47431. generateStencilBuffer?: boolean;
  47432. /**
  47433. * Define if a depth texture is required instead of a depth buffer
  47434. */
  47435. generateDepthTexture?: boolean;
  47436. /**
  47437. * Define the number of desired draw buffers
  47438. */
  47439. textureCount?: number;
  47440. /**
  47441. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47442. */
  47443. doNotChangeAspectRatio?: boolean;
  47444. /**
  47445. * Define the default type of the buffers we are creating
  47446. */
  47447. defaultType?: number;
  47448. }
  47449. /**
  47450. * A multi render target, like a render target provides the ability to render to a texture.
  47451. * Unlike the render target, it can render to several draw buffers in one draw.
  47452. * This is specially interesting in deferred rendering or for any effects requiring more than
  47453. * just one color from a single pass.
  47454. */
  47455. class MultiRenderTarget extends RenderTargetTexture {
  47456. private _internalTextures;
  47457. private _textures;
  47458. private _multiRenderTargetOptions;
  47459. /**
  47460. * Get if draw buffers are currently supported by the used hardware and browser.
  47461. */
  47462. readonly isSupported: boolean;
  47463. /**
  47464. * Get the list of textures generated by the multi render target.
  47465. */
  47466. readonly textures: Texture[];
  47467. /**
  47468. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47469. */
  47470. readonly depthTexture: Texture;
  47471. /**
  47472. * Set the wrapping mode on U of all the textures we are rendering to.
  47473. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47474. */
  47475. wrapU: number;
  47476. /**
  47477. * Set the wrapping mode on V of all the textures we are rendering to.
  47478. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47479. */
  47480. wrapV: number;
  47481. /**
  47482. * Instantiate a new multi render target texture.
  47483. * A multi render target, like a render target provides the ability to render to a texture.
  47484. * Unlike the render target, it can render to several draw buffers in one draw.
  47485. * This is specially interesting in deferred rendering or for any effects requiring more than
  47486. * just one color from a single pass.
  47487. * @param name Define the name of the texture
  47488. * @param size Define the size of the buffers to render to
  47489. * @param count Define the number of target we are rendering into
  47490. * @param scene Define the scene the texture belongs to
  47491. * @param options Define the options used to create the multi render target
  47492. */
  47493. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47494. /** @hidden */
  47495. _rebuild(): void;
  47496. private _createInternalTextures;
  47497. private _createTextures;
  47498. /**
  47499. * Define the number of samples used if MSAA is enabled.
  47500. */
  47501. samples: number;
  47502. /**
  47503. * Resize all the textures in the multi render target.
  47504. * Be carrefull as it will recreate all the data in the new texture.
  47505. * @param size Define the new size
  47506. */
  47507. resize(size: any): void;
  47508. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47509. /**
  47510. * Dispose the render targets and their associated resources
  47511. */
  47512. dispose(): void;
  47513. /**
  47514. * Release all the underlying texture used as draw buffers.
  47515. */
  47516. releaseInternalTextures(): void;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * Raw cube texture where the raw buffers are passed in
  47522. */
  47523. class RawCubeTexture extends CubeTexture {
  47524. /**
  47525. * Creates a cube texture where the raw buffers are passed in.
  47526. * @param scene defines the scene the texture is attached to
  47527. * @param data defines the array of data to use to create each face
  47528. * @param size defines the size of the textures
  47529. * @param format defines the format of the data
  47530. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47531. * @param generateMipMaps defines if the engine should generate the mip levels
  47532. * @param invertY defines if data must be stored with Y axis inverted
  47533. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47534. * @param compression defines the compression used (null by default)
  47535. */
  47536. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47537. /**
  47538. * Updates the raw cube texture.
  47539. * @param data defines the data to store
  47540. * @param format defines the data format
  47541. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47542. * @param invertY defines if data must be stored with Y axis inverted
  47543. * @param compression defines the compression used (null by default)
  47544. * @param level defines which level of the texture to update
  47545. */
  47546. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47547. /**
  47548. * Updates a raw cube texture with RGBD encoded data.
  47549. * @param data defines the array of data [mipmap][face] to use to create each face
  47550. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47553. * @returns a promsie that resolves when the operation is complete
  47554. */
  47555. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47556. /**
  47557. * Clones the raw cube texture.
  47558. * @return a new cube texture
  47559. */
  47560. clone(): CubeTexture;
  47561. /** @hidden */
  47562. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47563. }
  47564. }
  47565. declare module BABYLON {
  47566. /**
  47567. * Raw texture can help creating a texture directly from an array of data.
  47568. * This can be super useful if you either get the data from an uncompressed source or
  47569. * if you wish to create your texture pixel by pixel.
  47570. */
  47571. class RawTexture extends Texture {
  47572. /**
  47573. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47574. */
  47575. format: number;
  47576. private _engine;
  47577. /**
  47578. * Instantiates a new RawTexture.
  47579. * Raw texture can help creating a texture directly from an array of data.
  47580. * This can be super useful if you either get the data from an uncompressed source or
  47581. * if you wish to create your texture pixel by pixel.
  47582. * @param data define the array of data to use to create the texture
  47583. * @param width define the width of the texture
  47584. * @param height define the height of the texture
  47585. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47586. * @param scene define the scene the texture belongs to
  47587. * @param generateMipMaps define whether mip maps should be generated or not
  47588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47590. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47591. */
  47592. constructor(data: ArrayBufferView, width: number, height: number,
  47593. /**
  47594. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47595. */
  47596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47597. /**
  47598. * Updates the texture underlying data.
  47599. * @param data Define the new data of the texture
  47600. */
  47601. update(data: ArrayBufferView): void;
  47602. /**
  47603. * Creates a luminance texture from some data.
  47604. * @param data Define the texture data
  47605. * @param width Define the width of the texture
  47606. * @param height Define the height of the texture
  47607. * @param scene Define the scene the texture belongs to
  47608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47611. * @returns the luminance texture
  47612. */
  47613. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47614. /**
  47615. * Creates a luminance alpha texture from some data.
  47616. * @param data Define the texture data
  47617. * @param width Define the width of the texture
  47618. * @param height Define the height of the texture
  47619. * @param scene Define the scene the texture belongs to
  47620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47623. * @returns the luminance alpha texture
  47624. */
  47625. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47626. /**
  47627. * Creates an alpha texture from some data.
  47628. * @param data Define the texture data
  47629. * @param width Define the width of the texture
  47630. * @param height Define the height of the texture
  47631. * @param scene Define the scene the texture belongs to
  47632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47635. * @returns the alpha texture
  47636. */
  47637. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47638. /**
  47639. * Creates a RGB texture from some data.
  47640. * @param data Define the texture data
  47641. * @param width Define the width of the texture
  47642. * @param height Define the height of the texture
  47643. * @param scene Define the scene the texture belongs to
  47644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47647. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47648. * @returns the RGB alpha texture
  47649. */
  47650. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47651. /**
  47652. * Creates a RGBA texture from some data.
  47653. * @param data Define the texture data
  47654. * @param width Define the width of the texture
  47655. * @param height Define the height of the texture
  47656. * @param scene Define the scene the texture belongs to
  47657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47660. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47661. * @returns the RGBA texture
  47662. */
  47663. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47664. /**
  47665. * Creates a R texture from some data.
  47666. * @param data Define the texture data
  47667. * @param width Define the width of the texture
  47668. * @param height Define the height of the texture
  47669. * @param scene Define the scene the texture belongs to
  47670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47674. * @returns the R texture
  47675. */
  47676. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47677. }
  47678. }
  47679. declare module BABYLON {
  47680. /**
  47681. * Class used to store 3D textures containing user data
  47682. */
  47683. class RawTexture3D extends Texture {
  47684. /** Gets or sets the texture format to use */
  47685. format: number;
  47686. private _engine;
  47687. /**
  47688. * Create a new RawTexture3D
  47689. * @param data defines the data of the texture
  47690. * @param width defines the width of the texture
  47691. * @param height defines the height of the texture
  47692. * @param depth defines the depth of the texture
  47693. * @param format defines the texture format to use
  47694. * @param scene defines the hosting scene
  47695. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47696. * @param invertY defines if texture must be stored with Y axis inverted
  47697. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47698. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47699. */
  47700. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47701. /** Gets or sets the texture format to use */
  47702. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47703. /**
  47704. * Update the texture with new data
  47705. * @param data defines the data to store in the texture
  47706. */
  47707. update(data: ArrayBufferView): void;
  47708. }
  47709. }
  47710. declare module BABYLON {
  47711. /**
  47712. * Creates a refraction texture used by refraction channel of the standard material.
  47713. * It is like a mirror but to see through a material.
  47714. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47715. */
  47716. class RefractionTexture extends RenderTargetTexture {
  47717. /**
  47718. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47719. * 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.
  47720. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47721. */
  47722. refractionPlane: Plane;
  47723. /**
  47724. * Define how deep under the surface we should see.
  47725. */
  47726. depth: number;
  47727. /**
  47728. * Creates a refraction texture used by refraction channel of the standard material.
  47729. * It is like a mirror but to see through a material.
  47730. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47731. * @param name Define the texture name
  47732. * @param size Define the size of the underlying texture
  47733. * @param scene Define the scene the refraction belongs to
  47734. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47735. */
  47736. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47737. /**
  47738. * Clone the refraction texture.
  47739. * @returns the cloned texture
  47740. */
  47741. clone(): RefractionTexture;
  47742. /**
  47743. * Serialize the texture to a JSON representation you could use in Parse later on
  47744. * @returns the serialized JSON representation
  47745. */
  47746. serialize(): any;
  47747. }
  47748. }
  47749. declare module BABYLON {
  47750. /**
  47751. * This Helps creating a texture that will be created from a camera in your scene.
  47752. * It is basically a dynamic texture that could be used to create special effects for instance.
  47753. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47754. */
  47755. class RenderTargetTexture extends Texture {
  47756. isCube: boolean;
  47757. /**
  47758. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47759. */
  47760. static readonly REFRESHRATE_RENDER_ONCE: number;
  47761. /**
  47762. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47763. */
  47764. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47765. /**
  47766. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47767. * the central point of your effect and can save a lot of performances.
  47768. */
  47769. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47770. /**
  47771. * Use this predicate to dynamically define the list of mesh you want to render.
  47772. * If set, the renderList property will be overwritten.
  47773. */
  47774. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47775. private _renderList;
  47776. /**
  47777. * Use this list to define the list of mesh you want to render.
  47778. */
  47779. renderList: Nullable<Array<AbstractMesh>>;
  47780. private _hookArray;
  47781. /**
  47782. * Define if particles should be rendered in your texture.
  47783. */
  47784. renderParticles: boolean;
  47785. /**
  47786. * Define if sprites should be rendered in your texture.
  47787. */
  47788. renderSprites: boolean;
  47789. /**
  47790. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47791. */
  47792. coordinatesMode: number;
  47793. /**
  47794. * Define the camera used to render the texture.
  47795. */
  47796. activeCamera: Nullable<Camera>;
  47797. /**
  47798. * Override the render function of the texture with your own one.
  47799. */
  47800. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47801. /**
  47802. * Define if camera post processes should be use while rendering the texture.
  47803. */
  47804. useCameraPostProcesses: boolean;
  47805. /**
  47806. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47807. */
  47808. ignoreCameraViewport: boolean;
  47809. private _postProcessManager;
  47810. private _postProcesses;
  47811. private _resizeObserver;
  47812. /**
  47813. * An event triggered when the texture is unbind.
  47814. */
  47815. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47816. /**
  47817. * An event triggered when the texture is unbind.
  47818. */
  47819. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47820. private _onAfterUnbindObserver;
  47821. /**
  47822. * Set a after unbind callback in the texture.
  47823. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47824. */
  47825. onAfterUnbind: () => void;
  47826. /**
  47827. * An event triggered before rendering the texture
  47828. */
  47829. onBeforeRenderObservable: Observable<number>;
  47830. private _onBeforeRenderObserver;
  47831. /**
  47832. * Set a before render callback in the texture.
  47833. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47834. */
  47835. onBeforeRender: (faceIndex: number) => void;
  47836. /**
  47837. * An event triggered after rendering the texture
  47838. */
  47839. onAfterRenderObservable: Observable<number>;
  47840. private _onAfterRenderObserver;
  47841. /**
  47842. * Set a after render callback in the texture.
  47843. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47844. */
  47845. onAfterRender: (faceIndex: number) => void;
  47846. /**
  47847. * An event triggered after the texture clear
  47848. */
  47849. onClearObservable: Observable<Engine>;
  47850. private _onClearObserver;
  47851. /**
  47852. * Set a clear callback in the texture.
  47853. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47854. */
  47855. onClear: (Engine: Engine) => void;
  47856. /**
  47857. * Define the clear color of the Render Target if it should be different from the scene.
  47858. */
  47859. clearColor: Color4;
  47860. protected _size: number | {
  47861. width: number;
  47862. height: number;
  47863. };
  47864. protected _initialSizeParameter: number | {
  47865. width: number;
  47866. height: number;
  47867. } | {
  47868. ratio: number;
  47869. };
  47870. protected _sizeRatio: Nullable<number>;
  47871. /** @hidden */
  47872. _generateMipMaps: boolean;
  47873. protected _renderingManager: RenderingManager;
  47874. /** @hidden */
  47875. _waitingRenderList: string[];
  47876. protected _doNotChangeAspectRatio: boolean;
  47877. protected _currentRefreshId: number;
  47878. protected _refreshRate: number;
  47879. protected _textureMatrix: Matrix;
  47880. protected _samples: number;
  47881. protected _renderTargetOptions: RenderTargetCreationOptions;
  47882. /**
  47883. * Gets render target creation options that were used.
  47884. */
  47885. readonly renderTargetOptions: RenderTargetCreationOptions;
  47886. protected _engine: Engine;
  47887. protected _onRatioRescale(): void;
  47888. /**
  47889. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47890. * It must define where the camera used to render the texture is set
  47891. */
  47892. boundingBoxPosition: Vector3;
  47893. private _boundingBoxSize;
  47894. /**
  47895. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47896. * When defined, the cubemap will switch to local mode
  47897. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47898. * @example https://www.babylonjs-playground.com/#RNASML
  47899. */
  47900. boundingBoxSize: Vector3;
  47901. /**
  47902. * In case the RTT has been created with a depth texture, get the associated
  47903. * depth texture.
  47904. * Otherwise, return null.
  47905. */
  47906. depthStencilTexture: Nullable<InternalTexture>;
  47907. /**
  47908. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47909. * or used a shadow, depth texture...
  47910. * @param name The friendly name of the texture
  47911. * @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)
  47912. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47913. * @param generateMipMaps True if mip maps need to be generated after render.
  47914. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47915. * @param type The type of the buffer in the RTT (int, half float, float...)
  47916. * @param isCube True if a cube texture needs to be created
  47917. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47918. * @param generateDepthBuffer True to generate a depth buffer
  47919. * @param generateStencilBuffer True to generate a stencil buffer
  47920. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47921. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47922. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47923. */
  47924. constructor(name: string, size: number | {
  47925. width: number;
  47926. height: number;
  47927. } | {
  47928. ratio: number;
  47929. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47930. /**
  47931. * Creates a depth stencil texture.
  47932. * This is only available in WebGL 2 or with the depth texture extension available.
  47933. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47934. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47935. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47936. */
  47937. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47938. private _processSizeParameter;
  47939. /**
  47940. * Define the number of samples to use in case of MSAA.
  47941. * It defaults to one meaning no MSAA has been enabled.
  47942. */
  47943. samples: number;
  47944. /**
  47945. * Resets the refresh counter of the texture and start bak from scratch.
  47946. * Could be useful to regenerate the texture if it is setup to render only once.
  47947. */
  47948. resetRefreshCounter(): void;
  47949. /**
  47950. * Define the refresh rate of the texture or the rendering frequency.
  47951. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47952. */
  47953. refreshRate: number;
  47954. /**
  47955. * Adds a post process to the render target rendering passes.
  47956. * @param postProcess define the post process to add
  47957. */
  47958. addPostProcess(postProcess: PostProcess): void;
  47959. /**
  47960. * Clear all the post processes attached to the render target
  47961. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47962. */
  47963. clearPostProcesses(dispose?: boolean): void;
  47964. /**
  47965. * Remove one of the post process from the list of attached post processes to the texture
  47966. * @param postProcess define the post process to remove from the list
  47967. */
  47968. removePostProcess(postProcess: PostProcess): void;
  47969. /** @hidden */
  47970. _shouldRender(): boolean;
  47971. /**
  47972. * Gets the actual render size of the texture.
  47973. * @returns the width of the render size
  47974. */
  47975. getRenderSize(): number;
  47976. /**
  47977. * Gets the actual render width of the texture.
  47978. * @returns the width of the render size
  47979. */
  47980. getRenderWidth(): number;
  47981. /**
  47982. * Gets the actual render height of the texture.
  47983. * @returns the height of the render size
  47984. */
  47985. getRenderHeight(): number;
  47986. /**
  47987. * Get if the texture can be rescaled or not.
  47988. */
  47989. readonly canRescale: boolean;
  47990. /**
  47991. * Resize the texture using a ratio.
  47992. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47993. */
  47994. scale(ratio: number): void;
  47995. /**
  47996. * Get the texture reflection matrix used to rotate/transform the reflection.
  47997. * @returns the reflection matrix
  47998. */
  47999. getReflectionTextureMatrix(): Matrix;
  48000. /**
  48001. * Resize the texture to a new desired size.
  48002. * Be carrefull as it will recreate all the data in the new texture.
  48003. * @param size Define the new size. It can be:
  48004. * - a number for squared texture,
  48005. * - an object containing { width: number, height: number }
  48006. * - or an object containing a ratio { ratio: number }
  48007. */
  48008. resize(size: number | {
  48009. width: number;
  48010. height: number;
  48011. } | {
  48012. ratio: number;
  48013. }): void;
  48014. /**
  48015. * Renders all the objects from the render list into the texture.
  48016. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48017. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48018. */
  48019. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48020. private _bestReflectionRenderTargetDimension;
  48021. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48022. private renderToTarget;
  48023. /**
  48024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48025. * This allowed control for front to back rendering or reversly depending of the special needs.
  48026. *
  48027. * @param renderingGroupId The rendering group id corresponding to its index
  48028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48031. */
  48032. 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;
  48033. /**
  48034. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48035. *
  48036. * @param renderingGroupId The rendering group id corresponding to its index
  48037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48038. */
  48039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48040. /**
  48041. * Clones the texture.
  48042. * @returns the cloned texture
  48043. */
  48044. clone(): RenderTargetTexture;
  48045. /**
  48046. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48047. * @returns The JSON representation of the texture
  48048. */
  48049. serialize(): any;
  48050. /**
  48051. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48052. */
  48053. disposeFramebufferObjects(): void;
  48054. /**
  48055. * Dispose the texture and release its associated resources.
  48056. */
  48057. dispose(): void;
  48058. /** @hidden */
  48059. _rebuild(): void;
  48060. /**
  48061. * Clear the info related to rendering groups preventing retention point in material dispose.
  48062. */
  48063. freeRenderingGroups(): void;
  48064. }
  48065. }
  48066. declare module BABYLON {
  48067. /**
  48068. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48069. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48070. */
  48071. class Texture extends BaseTexture {
  48072. /** nearest is mag = nearest and min = nearest and mip = linear */
  48073. static readonly NEAREST_SAMPLINGMODE: number;
  48074. /** nearest is mag = nearest and min = nearest and mip = linear */
  48075. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48077. static readonly BILINEAR_SAMPLINGMODE: number;
  48078. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48079. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48080. /** Trilinear is mag = linear and min = linear and mip = linear */
  48081. static readonly TRILINEAR_SAMPLINGMODE: number;
  48082. /** Trilinear is mag = linear and min = linear and mip = linear */
  48083. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48084. /** mag = nearest and min = nearest and mip = nearest */
  48085. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48086. /** mag = nearest and min = linear and mip = nearest */
  48087. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48088. /** mag = nearest and min = linear and mip = linear */
  48089. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48090. /** mag = nearest and min = linear and mip = none */
  48091. static readonly NEAREST_LINEAR: number;
  48092. /** mag = nearest and min = nearest and mip = none */
  48093. static readonly NEAREST_NEAREST: number;
  48094. /** mag = linear and min = nearest and mip = nearest */
  48095. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48096. /** mag = linear and min = nearest and mip = linear */
  48097. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48098. /** mag = linear and min = linear and mip = none */
  48099. static readonly LINEAR_LINEAR: number;
  48100. /** mag = linear and min = nearest and mip = none */
  48101. static readonly LINEAR_NEAREST: number;
  48102. /** Explicit coordinates mode */
  48103. static readonly EXPLICIT_MODE: number;
  48104. /** Spherical coordinates mode */
  48105. static readonly SPHERICAL_MODE: number;
  48106. /** Planar coordinates mode */
  48107. static readonly PLANAR_MODE: number;
  48108. /** Cubic coordinates mode */
  48109. static readonly CUBIC_MODE: number;
  48110. /** Projection coordinates mode */
  48111. static readonly PROJECTION_MODE: number;
  48112. /** Inverse Cubic coordinates mode */
  48113. static readonly SKYBOX_MODE: number;
  48114. /** Inverse Cubic coordinates mode */
  48115. static readonly INVCUBIC_MODE: number;
  48116. /** Equirectangular coordinates mode */
  48117. static readonly EQUIRECTANGULAR_MODE: number;
  48118. /** Equirectangular Fixed coordinates mode */
  48119. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48120. /** Equirectangular Fixed Mirrored coordinates mode */
  48121. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48122. /** Texture is not repeating outside of 0..1 UVs */
  48123. static readonly CLAMP_ADDRESSMODE: number;
  48124. /** Texture is repeating outside of 0..1 UVs */
  48125. static readonly WRAP_ADDRESSMODE: number;
  48126. /** Texture is repeating and mirrored */
  48127. static readonly MIRROR_ADDRESSMODE: number;
  48128. /**
  48129. * 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
  48130. */
  48131. static UseSerializedUrlIfAny: boolean;
  48132. /**
  48133. * Define the url of the texture.
  48134. */
  48135. url: Nullable<string>;
  48136. /**
  48137. * Define an offset on the texture to offset the u coordinates of the UVs
  48138. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48139. */
  48140. uOffset: number;
  48141. /**
  48142. * Define an offset on the texture to offset the v coordinates of the UVs
  48143. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48144. */
  48145. vOffset: number;
  48146. /**
  48147. * Define an offset on the texture to scale the u coordinates of the UVs
  48148. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48149. */
  48150. uScale: number;
  48151. /**
  48152. * Define an offset on the texture to scale the v coordinates of the UVs
  48153. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48154. */
  48155. vScale: number;
  48156. /**
  48157. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48158. * @see http://doc.babylonjs.com/how_to/more_materials
  48159. */
  48160. uAng: number;
  48161. /**
  48162. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48163. * @see http://doc.babylonjs.com/how_to/more_materials
  48164. */
  48165. vAng: number;
  48166. /**
  48167. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48168. * @see http://doc.babylonjs.com/how_to/more_materials
  48169. */
  48170. wAng: number;
  48171. /**
  48172. * Defines the center of rotation (U)
  48173. */
  48174. uRotationCenter: number;
  48175. /**
  48176. * Defines the center of rotation (V)
  48177. */
  48178. vRotationCenter: number;
  48179. /**
  48180. * Defines the center of rotation (W)
  48181. */
  48182. wRotationCenter: number;
  48183. /**
  48184. * Are mip maps generated for this texture or not.
  48185. */
  48186. readonly noMipmap: boolean;
  48187. private _noMipmap;
  48188. /** @hidden */
  48189. _invertY: boolean;
  48190. private _rowGenerationMatrix;
  48191. private _cachedTextureMatrix;
  48192. private _projectionModeMatrix;
  48193. private _t0;
  48194. private _t1;
  48195. private _t2;
  48196. private _cachedUOffset;
  48197. private _cachedVOffset;
  48198. private _cachedUScale;
  48199. private _cachedVScale;
  48200. private _cachedUAng;
  48201. private _cachedVAng;
  48202. private _cachedWAng;
  48203. private _cachedProjectionMatrixId;
  48204. private _cachedCoordinatesMode;
  48205. /** @hidden */
  48206. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48207. private _deleteBuffer;
  48208. protected _format: Nullable<number>;
  48209. private _delayedOnLoad;
  48210. private _delayedOnError;
  48211. /**
  48212. * Observable triggered once the texture has been loaded.
  48213. */
  48214. onLoadObservable: Observable<Texture>;
  48215. protected _isBlocking: boolean;
  48216. /**
  48217. * Is the texture preventing material to render while loading.
  48218. * If false, a default texture will be used instead of the loading one during the preparation step.
  48219. */
  48220. isBlocking: boolean;
  48221. /**
  48222. * Get the current sampling mode associated with the texture.
  48223. */
  48224. readonly samplingMode: number;
  48225. /**
  48226. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48227. */
  48228. readonly invertY: boolean;
  48229. /**
  48230. * Instantiates a new texture.
  48231. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48232. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48233. * @param url define the url of the picture to load as a texture
  48234. * @param scene define the scene the texture will belong to
  48235. * @param noMipmap define if the texture will require mip maps or not
  48236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48238. * @param onLoad define a callback triggered when the texture has been loaded
  48239. * @param onError define a callback triggered when an error occurred during the loading session
  48240. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48241. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48242. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48243. */
  48244. 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);
  48245. /**
  48246. * Update the url (and optional buffer) of this texture if url was null during construction.
  48247. * @param url the url of the texture
  48248. * @param buffer the buffer of the texture (defaults to null)
  48249. * @param onLoad callback called when the texture is loaded (defaults to null)
  48250. */
  48251. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48252. /**
  48253. * Finish the loading sequence of a texture flagged as delayed load.
  48254. * @hidden
  48255. */
  48256. delayLoad(): void;
  48257. private _prepareRowForTextureGeneration;
  48258. /**
  48259. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48260. * @returns the transform matrix of the texture.
  48261. */
  48262. getTextureMatrix(): Matrix;
  48263. /**
  48264. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48265. * @returns The reflection texture transform
  48266. */
  48267. getReflectionTextureMatrix(): Matrix;
  48268. /**
  48269. * Clones the texture.
  48270. * @returns the cloned texture
  48271. */
  48272. clone(): Texture;
  48273. /**
  48274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48275. * @returns The JSON representation of the texture
  48276. */
  48277. serialize(): any;
  48278. /**
  48279. * Get the current class name of the texture useful for serialization or dynamic coding.
  48280. * @returns "Texture"
  48281. */
  48282. getClassName(): string;
  48283. /**
  48284. * Dispose the texture and release its associated resources.
  48285. */
  48286. dispose(): void;
  48287. /**
  48288. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48289. * @param parsedTexture Define the JSON representation of the texture
  48290. * @param scene Define the scene the parsed texture should be instantiated in
  48291. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48292. * @returns The parsed texture if successful
  48293. */
  48294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48295. /**
  48296. * Creates a texture from its base 64 representation.
  48297. * @param data Define the base64 payload without the data: prefix
  48298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48299. * @param scene Define the scene the texture should belong to
  48300. * @param noMipmap Forces the texture to not create mip map information if true
  48301. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48302. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48303. * @param onLoad define a callback triggered when the texture has been loaded
  48304. * @param onError define a callback triggered when an error occurred during the loading session
  48305. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48306. * @returns the created texture
  48307. */
  48308. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48309. /**
  48310. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48311. * @param data Define the base64 payload without the data: prefix
  48312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48313. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48314. * @param scene Define the scene the texture should belong to
  48315. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48316. * @param noMipmap Forces the texture to not create mip map information if true
  48317. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48318. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48319. * @param onLoad define a callback triggered when the texture has been loaded
  48320. * @param onError define a callback triggered when an error occurred during the loading session
  48321. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48322. * @returns the created texture
  48323. */
  48324. 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;
  48325. }
  48326. }
  48327. declare module BABYLON {
  48328. /**
  48329. * Settings for finer control over video usage
  48330. */
  48331. interface VideoTextureSettings {
  48332. /**
  48333. * Applies `autoplay` to video, if specified
  48334. */
  48335. autoPlay?: boolean;
  48336. /**
  48337. * Applies `loop` to video, if specified
  48338. */
  48339. loop?: boolean;
  48340. /**
  48341. * Automatically updates internal texture from video at every frame in the render loop
  48342. */
  48343. autoUpdateTexture: boolean;
  48344. /**
  48345. * Image src displayed during the video loading or until the user interacts with the video.
  48346. */
  48347. poster?: string;
  48348. }
  48349. /**
  48350. * If you want to display a video in your scene, this is the special texture for that.
  48351. * This special texture works similar to other textures, with the exception of a few parameters.
  48352. * @see https://doc.babylonjs.com/how_to/video_texture
  48353. */
  48354. class VideoTexture extends Texture {
  48355. /**
  48356. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48357. */
  48358. readonly autoUpdateTexture: boolean;
  48359. /**
  48360. * The video instance used by the texture internally
  48361. */
  48362. readonly video: HTMLVideoElement;
  48363. private _onUserActionRequestedObservable;
  48364. /**
  48365. * Event triggerd when a dom action is required by the user to play the video.
  48366. * This happens due to recent changes in browser policies preventing video to auto start.
  48367. */
  48368. readonly onUserActionRequestedObservable: Observable<Texture>;
  48369. private _generateMipMaps;
  48370. private _engine;
  48371. private _stillImageCaptured;
  48372. private _displayingPosterTexture;
  48373. private _settings;
  48374. private _createInternalTextureOnEvent;
  48375. /**
  48376. * Creates a video texture.
  48377. * If you want to display a video in your scene, this is the special texture for that.
  48378. * This special texture works similar to other textures, with the exception of a few parameters.
  48379. * @see https://doc.babylonjs.com/how_to/video_texture
  48380. * @param name optional name, will detect from video source, if not defined
  48381. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48382. * @param scene is obviously the current scene.
  48383. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48384. * @param invertY is false by default but can be used to invert video on Y axis
  48385. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48386. * @param settings allows finer control over video usage
  48387. */
  48388. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48389. private _getName;
  48390. private _getVideo;
  48391. private _createInternalTexture;
  48392. private reset;
  48393. /**
  48394. * @hidden Internal method to initiate `update`.
  48395. */
  48396. _rebuild(): void;
  48397. /**
  48398. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48399. */
  48400. update(): void;
  48401. /**
  48402. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48403. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48404. */
  48405. updateTexture(isVisible: boolean): void;
  48406. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48407. /**
  48408. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48409. * @param url New url.
  48410. */
  48411. updateURL(url: string): void;
  48412. /**
  48413. * Dispose the texture and release its associated resources.
  48414. */
  48415. dispose(): void;
  48416. /**
  48417. * Creates a video texture straight from your WebCam video feed.
  48418. * @param scene Define the scene the texture should be created in
  48419. * @param onReady Define a callback to triggered once the texture will be ready
  48420. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48421. */
  48422. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48423. minWidth: number;
  48424. maxWidth: number;
  48425. minHeight: number;
  48426. maxHeight: number;
  48427. deviceId: string;
  48428. }): void;
  48429. }
  48430. }
  48431. declare var DracoDecoderModule: any;
  48432. declare var WebAssembly: any;
  48433. declare module BABYLON {
  48434. /**
  48435. * Configuration for Draco compression
  48436. */
  48437. interface IDracoCompressionConfiguration {
  48438. /**
  48439. * Configuration for the decoder.
  48440. */
  48441. decoder?: {
  48442. /**
  48443. * The url to the WebAssembly module.
  48444. */
  48445. wasmUrl?: string;
  48446. /**
  48447. * The url to the WebAssembly binary.
  48448. */
  48449. wasmBinaryUrl?: string;
  48450. /**
  48451. * The url to the fallback JavaScript module.
  48452. */
  48453. fallbackUrl?: string;
  48454. };
  48455. }
  48456. /**
  48457. * Draco compression (https://google.github.io/draco/)
  48458. *
  48459. * This class wraps the Draco module.
  48460. *
  48461. * **Encoder**
  48462. *
  48463. * The encoder is not currently implemented.
  48464. *
  48465. * **Decoder**
  48466. *
  48467. * 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.
  48468. *
  48469. * To update the configuration, use the following code:
  48470. * ```javascript
  48471. * BABYLON.DracoCompression.Configuration = {
  48472. * decoder: {
  48473. * wasmUrl: "<url to the WebAssembly library>",
  48474. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48475. * fallbackUrl: "<url to the fallback JavaScript library>",
  48476. * }
  48477. * };
  48478. * ```
  48479. *
  48480. * 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.
  48481. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48482. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48483. *
  48484. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48485. * ```javascript
  48486. * var dracoCompression = new BABYLON.DracoCompression();
  48487. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48488. * [BABYLON.VertexBuffer.PositionKind]: 0
  48489. * });
  48490. * ```
  48491. *
  48492. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48493. */
  48494. class DracoCompression implements IDisposable {
  48495. private static _DecoderModulePromise;
  48496. /**
  48497. * The configuration. Defaults to the following urls:
  48498. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48499. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48500. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48501. */
  48502. static Configuration: IDracoCompressionConfiguration;
  48503. /**
  48504. * Returns true if the decoder is available.
  48505. */
  48506. static readonly DecoderAvailable: boolean;
  48507. /**
  48508. * Constructor
  48509. */
  48510. constructor();
  48511. /**
  48512. * Stop all async operations and release resources.
  48513. */
  48514. dispose(): void;
  48515. /**
  48516. * Decode Draco compressed mesh data to vertex data.
  48517. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48518. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48519. * @returns A promise that resolves with the decoded vertex data
  48520. */
  48521. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48522. [kind: string]: number;
  48523. }): Promise<VertexData>;
  48524. private static _GetDecoderModule;
  48525. private static _LoadScriptAsync;
  48526. private static _LoadFileAsync;
  48527. }
  48528. }
  48529. declare module BABYLON {
  48530. /**
  48531. * Particle emitter emitting particles from the inside of a box.
  48532. * It emits the particles randomly between 2 given directions.
  48533. */
  48534. class BoxParticleEmitter implements IParticleEmitterType {
  48535. /**
  48536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48537. */
  48538. direction1: Vector3;
  48539. /**
  48540. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48541. */
  48542. direction2: Vector3;
  48543. /**
  48544. * 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.
  48545. */
  48546. minEmitBox: Vector3;
  48547. /**
  48548. * 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.
  48549. */
  48550. maxEmitBox: Vector3;
  48551. /**
  48552. * Creates a new instance BoxParticleEmitter
  48553. */
  48554. constructor();
  48555. /**
  48556. * Called by the particle System when the direction is computed for the created particle.
  48557. * @param worldMatrix is the world matrix of the particle system
  48558. * @param directionToUpdate is the direction vector to update with the result
  48559. * @param particle is the particle we are computed the direction for
  48560. */
  48561. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48562. /**
  48563. * Called by the particle System when the position is computed for the created particle.
  48564. * @param worldMatrix is the world matrix of the particle system
  48565. * @param positionToUpdate is the position vector to update with the result
  48566. * @param particle is the particle we are computed the position for
  48567. */
  48568. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48569. /**
  48570. * Clones the current emitter and returns a copy of it
  48571. * @returns the new emitter
  48572. */
  48573. clone(): BoxParticleEmitter;
  48574. /**
  48575. * Called by the GPUParticleSystem to setup the update shader
  48576. * @param effect defines the update shader
  48577. */
  48578. applyToShader(effect: Effect): void;
  48579. /**
  48580. * Returns a string to use to update the GPU particles update shader
  48581. * @returns a string containng the defines string
  48582. */
  48583. getEffectDefines(): string;
  48584. /**
  48585. * Returns the string "BoxParticleEmitter"
  48586. * @returns a string containing the class name
  48587. */
  48588. getClassName(): string;
  48589. /**
  48590. * Serializes the particle system to a JSON object.
  48591. * @returns the JSON object
  48592. */
  48593. serialize(): any;
  48594. /**
  48595. * Parse properties from a JSON object
  48596. * @param serializationObject defines the JSON object
  48597. */
  48598. parse(serializationObject: any): void;
  48599. }
  48600. }
  48601. declare module BABYLON {
  48602. /**
  48603. * Particle emitter emitting particles from the inside of a cone.
  48604. * It emits the particles alongside the cone volume from the base to the particle.
  48605. * The emission direction might be randomized.
  48606. */
  48607. class ConeParticleEmitter implements IParticleEmitterType {
  48608. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48609. directionRandomizer: number;
  48610. private _radius;
  48611. private _angle;
  48612. private _height;
  48613. /**
  48614. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48615. */
  48616. radiusRange: number;
  48617. /**
  48618. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48619. */
  48620. heightRange: number;
  48621. /**
  48622. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48623. */
  48624. emitFromSpawnPointOnly: boolean;
  48625. /**
  48626. * Gets or sets the radius of the emission cone
  48627. */
  48628. radius: number;
  48629. /**
  48630. * Gets or sets the angle of the emission cone
  48631. */
  48632. angle: number;
  48633. private _buildHeight;
  48634. /**
  48635. * Creates a new instance ConeParticleEmitter
  48636. * @param radius the radius of the emission cone (1 by default)
  48637. * @param angles the cone base angle (PI by default)
  48638. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48639. */
  48640. constructor(radius?: number, angle?: number,
  48641. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48642. directionRandomizer?: number);
  48643. /**
  48644. * Called by the particle System when the direction is computed for the created particle.
  48645. * @param worldMatrix is the world matrix of the particle system
  48646. * @param directionToUpdate is the direction vector to update with the result
  48647. * @param particle is the particle we are computed the direction for
  48648. */
  48649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48650. /**
  48651. * Called by the particle System when the position is computed for the created particle.
  48652. * @param worldMatrix is the world matrix of the particle system
  48653. * @param positionToUpdate is the position vector to update with the result
  48654. * @param particle is the particle we are computed the position for
  48655. */
  48656. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48657. /**
  48658. * Clones the current emitter and returns a copy of it
  48659. * @returns the new emitter
  48660. */
  48661. clone(): ConeParticleEmitter;
  48662. /**
  48663. * Called by the GPUParticleSystem to setup the update shader
  48664. * @param effect defines the update shader
  48665. */
  48666. applyToShader(effect: Effect): void;
  48667. /**
  48668. * Returns a string to use to update the GPU particles update shader
  48669. * @returns a string containng the defines string
  48670. */
  48671. getEffectDefines(): string;
  48672. /**
  48673. * Returns the string "ConeParticleEmitter"
  48674. * @returns a string containing the class name
  48675. */
  48676. getClassName(): string;
  48677. /**
  48678. * Serializes the particle system to a JSON object.
  48679. * @returns the JSON object
  48680. */
  48681. serialize(): any;
  48682. /**
  48683. * Parse properties from a JSON object
  48684. * @param serializationObject defines the JSON object
  48685. */
  48686. parse(serializationObject: any): void;
  48687. }
  48688. }
  48689. declare module BABYLON {
  48690. /**
  48691. * Particle emitter emitting particles from the inside of a cylinder.
  48692. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48693. */
  48694. class CylinderParticleEmitter implements IParticleEmitterType {
  48695. /**
  48696. * The radius of the emission cylinder.
  48697. */
  48698. radius: number;
  48699. /**
  48700. * The height of the emission cylinder.
  48701. */
  48702. height: number;
  48703. /**
  48704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48705. */
  48706. radiusRange: number;
  48707. /**
  48708. * How much to randomize the particle direction [0-1].
  48709. */
  48710. directionRandomizer: number;
  48711. /**
  48712. * Creates a new instance CylinderParticleEmitter
  48713. * @param radius the radius of the emission cylinder (1 by default)
  48714. * @param height the height of the emission cylinder (1 by default)
  48715. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48716. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48717. */
  48718. constructor(
  48719. /**
  48720. * The radius of the emission cylinder.
  48721. */
  48722. radius?: number,
  48723. /**
  48724. * The height of the emission cylinder.
  48725. */
  48726. height?: number,
  48727. /**
  48728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48729. */
  48730. radiusRange?: number,
  48731. /**
  48732. * How much to randomize the particle direction [0-1].
  48733. */
  48734. directionRandomizer?: number);
  48735. /**
  48736. * Called by the particle System when the direction is computed for the created particle.
  48737. * @param worldMatrix is the world matrix of the particle system
  48738. * @param directionToUpdate is the direction vector to update with the result
  48739. * @param particle is the particle we are computed the direction for
  48740. */
  48741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48742. /**
  48743. * Called by the particle System when the position is computed for the created particle.
  48744. * @param worldMatrix is the world matrix of the particle system
  48745. * @param positionToUpdate is the position vector to update with the result
  48746. * @param particle is the particle we are computed the position for
  48747. */
  48748. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48749. /**
  48750. * Clones the current emitter and returns a copy of it
  48751. * @returns the new emitter
  48752. */
  48753. clone(): CylinderParticleEmitter;
  48754. /**
  48755. * Called by the GPUParticleSystem to setup the update shader
  48756. * @param effect defines the update shader
  48757. */
  48758. applyToShader(effect: Effect): void;
  48759. /**
  48760. * Returns a string to use to update the GPU particles update shader
  48761. * @returns a string containng the defines string
  48762. */
  48763. getEffectDefines(): string;
  48764. /**
  48765. * Returns the string "CylinderParticleEmitter"
  48766. * @returns a string containing the class name
  48767. */
  48768. getClassName(): string;
  48769. /**
  48770. * Serializes the particle system to a JSON object.
  48771. * @returns the JSON object
  48772. */
  48773. serialize(): any;
  48774. /**
  48775. * Parse properties from a JSON object
  48776. * @param serializationObject defines the JSON object
  48777. */
  48778. parse(serializationObject: any): void;
  48779. }
  48780. /**
  48781. * Particle emitter emitting particles from the inside of a cylinder.
  48782. * It emits the particles randomly between two vectors.
  48783. */
  48784. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48785. /**
  48786. * The min limit of the emission direction.
  48787. */
  48788. direction1: Vector3;
  48789. /**
  48790. * The max limit of the emission direction.
  48791. */
  48792. direction2: Vector3;
  48793. /**
  48794. * Creates a new instance CylinderDirectedParticleEmitter
  48795. * @param radius the radius of the emission cylinder (1 by default)
  48796. * @param height the height of the emission cylinder (1 by default)
  48797. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48798. * @param direction1 the min limit of the emission direction (up vector by default)
  48799. * @param direction2 the max limit of the emission direction (up vector by default)
  48800. */
  48801. constructor(radius?: number, height?: number, radiusRange?: number,
  48802. /**
  48803. * The min limit of the emission direction.
  48804. */
  48805. direction1?: Vector3,
  48806. /**
  48807. * The max limit of the emission direction.
  48808. */
  48809. direction2?: Vector3);
  48810. /**
  48811. * Called by the particle System when the direction is computed for the created particle.
  48812. * @param worldMatrix is the world matrix of the particle system
  48813. * @param directionToUpdate is the direction vector to update with the result
  48814. * @param particle is the particle we are computed the direction for
  48815. */
  48816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48817. /**
  48818. * Clones the current emitter and returns a copy of it
  48819. * @returns the new emitter
  48820. */
  48821. clone(): CylinderDirectedParticleEmitter;
  48822. /**
  48823. * Called by the GPUParticleSystem to setup the update shader
  48824. * @param effect defines the update shader
  48825. */
  48826. applyToShader(effect: Effect): void;
  48827. /**
  48828. * Returns a string to use to update the GPU particles update shader
  48829. * @returns a string containng the defines string
  48830. */
  48831. getEffectDefines(): string;
  48832. /**
  48833. * Returns the string "CylinderDirectedParticleEmitter"
  48834. * @returns a string containing the class name
  48835. */
  48836. getClassName(): string;
  48837. /**
  48838. * Serializes the particle system to a JSON object.
  48839. * @returns the JSON object
  48840. */
  48841. serialize(): any;
  48842. /**
  48843. * Parse properties from a JSON object
  48844. * @param serializationObject defines the JSON object
  48845. */
  48846. parse(serializationObject: any): void;
  48847. }
  48848. }
  48849. declare module BABYLON {
  48850. /**
  48851. * Particle emitter emitting particles from the inside of a hemisphere.
  48852. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48853. */
  48854. class HemisphericParticleEmitter implements IParticleEmitterType {
  48855. /**
  48856. * The radius of the emission hemisphere.
  48857. */
  48858. radius: number;
  48859. /**
  48860. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48861. */
  48862. radiusRange: number;
  48863. /**
  48864. * How much to randomize the particle direction [0-1].
  48865. */
  48866. directionRandomizer: number;
  48867. /**
  48868. * Creates a new instance HemisphericParticleEmitter
  48869. * @param radius the radius of the emission hemisphere (1 by default)
  48870. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48871. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48872. */
  48873. constructor(
  48874. /**
  48875. * The radius of the emission hemisphere.
  48876. */
  48877. radius?: number,
  48878. /**
  48879. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48880. */
  48881. radiusRange?: number,
  48882. /**
  48883. * How much to randomize the particle direction [0-1].
  48884. */
  48885. directionRandomizer?: number);
  48886. /**
  48887. * Called by the particle System when the direction is computed for the created particle.
  48888. * @param worldMatrix is the world matrix of the particle system
  48889. * @param directionToUpdate is the direction vector to update with the result
  48890. * @param particle is the particle we are computed the direction for
  48891. */
  48892. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48893. /**
  48894. * Called by the particle System when the position is computed for the created particle.
  48895. * @param worldMatrix is the world matrix of the particle system
  48896. * @param positionToUpdate is the position vector to update with the result
  48897. * @param particle is the particle we are computed the position for
  48898. */
  48899. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48900. /**
  48901. * Clones the current emitter and returns a copy of it
  48902. * @returns the new emitter
  48903. */
  48904. clone(): HemisphericParticleEmitter;
  48905. /**
  48906. * Called by the GPUParticleSystem to setup the update shader
  48907. * @param effect defines the update shader
  48908. */
  48909. applyToShader(effect: Effect): void;
  48910. /**
  48911. * Returns a string to use to update the GPU particles update shader
  48912. * @returns a string containng the defines string
  48913. */
  48914. getEffectDefines(): string;
  48915. /**
  48916. * Returns the string "HemisphericParticleEmitter"
  48917. * @returns a string containing the class name
  48918. */
  48919. getClassName(): string;
  48920. /**
  48921. * Serializes the particle system to a JSON object.
  48922. * @returns the JSON object
  48923. */
  48924. serialize(): any;
  48925. /**
  48926. * Parse properties from a JSON object
  48927. * @param serializationObject defines the JSON object
  48928. */
  48929. parse(serializationObject: any): void;
  48930. }
  48931. }
  48932. declare module BABYLON {
  48933. /**
  48934. * Particle emitter represents a volume emitting particles.
  48935. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48936. */
  48937. interface IParticleEmitterType {
  48938. /**
  48939. * Called by the particle System when the direction is computed for the created particle.
  48940. * @param worldMatrix is the world matrix of the particle system
  48941. * @param directionToUpdate is the direction vector to update with the result
  48942. * @param particle is the particle we are computed the direction for
  48943. */
  48944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48945. /**
  48946. * Called by the particle System when the position is computed for the created particle.
  48947. * @param worldMatrix is the world matrix of the particle system
  48948. * @param positionToUpdate is the position vector to update with the result
  48949. * @param particle is the particle we are computed the position for
  48950. */
  48951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48952. /**
  48953. * Clones the current emitter and returns a copy of it
  48954. * @returns the new emitter
  48955. */
  48956. clone(): IParticleEmitterType;
  48957. /**
  48958. * Called by the GPUParticleSystem to setup the update shader
  48959. * @param effect defines the update shader
  48960. */
  48961. applyToShader(effect: Effect): void;
  48962. /**
  48963. * Returns a string to use to update the GPU particles update shader
  48964. * @returns the effect defines string
  48965. */
  48966. getEffectDefines(): string;
  48967. /**
  48968. * Returns a string representing the class name
  48969. * @returns a string containing the class name
  48970. */
  48971. getClassName(): string;
  48972. /**
  48973. * Serializes the particle system to a JSON object.
  48974. * @returns the JSON object
  48975. */
  48976. serialize(): any;
  48977. /**
  48978. * Parse properties from a JSON object
  48979. * @param serializationObject defines the JSON object
  48980. */
  48981. parse(serializationObject: any): void;
  48982. }
  48983. }
  48984. declare module BABYLON {
  48985. /**
  48986. * Particle emitter emitting particles from a point.
  48987. * It emits the particles randomly between 2 given directions.
  48988. */
  48989. class PointParticleEmitter implements IParticleEmitterType {
  48990. /**
  48991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48992. */
  48993. direction1: Vector3;
  48994. /**
  48995. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48996. */
  48997. direction2: Vector3;
  48998. /**
  48999. * Creates a new instance PointParticleEmitter
  49000. */
  49001. constructor();
  49002. /**
  49003. * Called by the particle System when the direction is computed for the created particle.
  49004. * @param worldMatrix is the world matrix of the particle system
  49005. * @param directionToUpdate is the direction vector to update with the result
  49006. * @param particle is the particle we are computed the direction for
  49007. */
  49008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49009. /**
  49010. * Called by the particle System when the position is computed for the created particle.
  49011. * @param worldMatrix is the world matrix of the particle system
  49012. * @param positionToUpdate is the position vector to update with the result
  49013. * @param particle is the particle we are computed the position for
  49014. */
  49015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49016. /**
  49017. * Clones the current emitter and returns a copy of it
  49018. * @returns the new emitter
  49019. */
  49020. clone(): PointParticleEmitter;
  49021. /**
  49022. * Called by the GPUParticleSystem to setup the update shader
  49023. * @param effect defines the update shader
  49024. */
  49025. applyToShader(effect: Effect): void;
  49026. /**
  49027. * Returns a string to use to update the GPU particles update shader
  49028. * @returns a string containng the defines string
  49029. */
  49030. getEffectDefines(): string;
  49031. /**
  49032. * Returns the string "PointParticleEmitter"
  49033. * @returns a string containing the class name
  49034. */
  49035. getClassName(): string;
  49036. /**
  49037. * Serializes the particle system to a JSON object.
  49038. * @returns the JSON object
  49039. */
  49040. serialize(): any;
  49041. /**
  49042. * Parse properties from a JSON object
  49043. * @param serializationObject defines the JSON object
  49044. */
  49045. parse(serializationObject: any): void;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /**
  49050. * Particle emitter emitting particles from the inside of a sphere.
  49051. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49052. */
  49053. class SphereParticleEmitter implements IParticleEmitterType {
  49054. /**
  49055. * The radius of the emission sphere.
  49056. */
  49057. radius: number;
  49058. /**
  49059. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49060. */
  49061. radiusRange: number;
  49062. /**
  49063. * How much to randomize the particle direction [0-1].
  49064. */
  49065. directionRandomizer: number;
  49066. /**
  49067. * Creates a new instance SphereParticleEmitter
  49068. * @param radius the radius of the emission sphere (1 by default)
  49069. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49070. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49071. */
  49072. constructor(
  49073. /**
  49074. * The radius of the emission sphere.
  49075. */
  49076. radius?: number,
  49077. /**
  49078. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49079. */
  49080. radiusRange?: number,
  49081. /**
  49082. * How much to randomize the particle direction [0-1].
  49083. */
  49084. directionRandomizer?: number);
  49085. /**
  49086. * Called by the particle System when the direction is computed for the created particle.
  49087. * @param worldMatrix is the world matrix of the particle system
  49088. * @param directionToUpdate is the direction vector to update with the result
  49089. * @param particle is the particle we are computed the direction for
  49090. */
  49091. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49092. /**
  49093. * Called by the particle System when the position is computed for the created particle.
  49094. * @param worldMatrix is the world matrix of the particle system
  49095. * @param positionToUpdate is the position vector to update with the result
  49096. * @param particle is the particle we are computed the position for
  49097. */
  49098. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49099. /**
  49100. * Clones the current emitter and returns a copy of it
  49101. * @returns the new emitter
  49102. */
  49103. clone(): SphereParticleEmitter;
  49104. /**
  49105. * Called by the GPUParticleSystem to setup the update shader
  49106. * @param effect defines the update shader
  49107. */
  49108. applyToShader(effect: Effect): void;
  49109. /**
  49110. * Returns a string to use to update the GPU particles update shader
  49111. * @returns a string containng the defines string
  49112. */
  49113. getEffectDefines(): string;
  49114. /**
  49115. * Returns the string "SphereParticleEmitter"
  49116. * @returns a string containing the class name
  49117. */
  49118. getClassName(): string;
  49119. /**
  49120. * Serializes the particle system to a JSON object.
  49121. * @returns the JSON object
  49122. */
  49123. serialize(): any;
  49124. /**
  49125. * Parse properties from a JSON object
  49126. * @param serializationObject defines the JSON object
  49127. */
  49128. parse(serializationObject: any): void;
  49129. }
  49130. /**
  49131. * Particle emitter emitting particles from the inside of a sphere.
  49132. * It emits the particles randomly between two vectors.
  49133. */
  49134. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49135. /**
  49136. * The min limit of the emission direction.
  49137. */
  49138. direction1: Vector3;
  49139. /**
  49140. * The max limit of the emission direction.
  49141. */
  49142. direction2: Vector3;
  49143. /**
  49144. * Creates a new instance SphereDirectedParticleEmitter
  49145. * @param radius the radius of the emission sphere (1 by default)
  49146. * @param direction1 the min limit of the emission direction (up vector by default)
  49147. * @param direction2 the max limit of the emission direction (up vector by default)
  49148. */
  49149. constructor(radius?: number,
  49150. /**
  49151. * The min limit of the emission direction.
  49152. */
  49153. direction1?: Vector3,
  49154. /**
  49155. * The max limit of the emission direction.
  49156. */
  49157. direction2?: Vector3);
  49158. /**
  49159. * Called by the particle System when the direction is computed for the created particle.
  49160. * @param worldMatrix is the world matrix of the particle system
  49161. * @param directionToUpdate is the direction vector to update with the result
  49162. * @param particle is the particle we are computed the direction for
  49163. */
  49164. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49165. /**
  49166. * Clones the current emitter and returns a copy of it
  49167. * @returns the new emitter
  49168. */
  49169. clone(): SphereDirectedParticleEmitter;
  49170. /**
  49171. * Called by the GPUParticleSystem to setup the update shader
  49172. * @param effect defines the update shader
  49173. */
  49174. applyToShader(effect: Effect): void;
  49175. /**
  49176. * Returns a string to use to update the GPU particles update shader
  49177. * @returns a string containng the defines string
  49178. */
  49179. getEffectDefines(): string;
  49180. /**
  49181. * Returns the string "SphereDirectedParticleEmitter"
  49182. * @returns a string containing the class name
  49183. */
  49184. getClassName(): string;
  49185. /**
  49186. * Serializes the particle system to a JSON object.
  49187. * @returns the JSON object
  49188. */
  49189. serialize(): any;
  49190. /**
  49191. * Parse properties from a JSON object
  49192. * @param serializationObject defines the JSON object
  49193. */
  49194. parse(serializationObject: any): void;
  49195. }
  49196. }
  49197. declare module BABYLON {
  49198. /** @hidden */
  49199. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49200. private _useDeltaForWorldStep;
  49201. world: any;
  49202. name: string;
  49203. private _physicsMaterials;
  49204. private _fixedTimeStep;
  49205. BJSCANNON: any;
  49206. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49207. setGravity(gravity: Vector3): void;
  49208. setTimeStep(timeStep: number): void;
  49209. getTimeStep(): number;
  49210. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49211. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49212. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49213. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49214. private _processChildMeshes;
  49215. removePhysicsBody(impostor: PhysicsImpostor): void;
  49216. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49217. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49218. private _addMaterial;
  49219. private _checkWithEpsilon;
  49220. private _createShape;
  49221. private _createHeightmap;
  49222. private _minus90X;
  49223. private _plus90X;
  49224. private _tmpPosition;
  49225. private _tmpDeltaPosition;
  49226. private _tmpUnityRotation;
  49227. private _updatePhysicsBodyTransformation;
  49228. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49229. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49230. isSupported(): boolean;
  49231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49235. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49236. getBodyMass(impostor: PhysicsImpostor): number;
  49237. getBodyFriction(impostor: PhysicsImpostor): number;
  49238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49239. getBodyRestitution(impostor: PhysicsImpostor): number;
  49240. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49241. sleepBody(impostor: PhysicsImpostor): void;
  49242. wakeUpBody(impostor: PhysicsImpostor): void;
  49243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49244. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49247. getRadius(impostor: PhysicsImpostor): number;
  49248. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49249. dispose(): void;
  49250. private _extendNamespace;
  49251. }
  49252. }
  49253. declare module BABYLON {
  49254. /** @hidden */
  49255. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49256. world: any;
  49257. name: string;
  49258. BJSOIMO: any;
  49259. constructor(iterations?: number);
  49260. setGravity(gravity: Vector3): void;
  49261. setTimeStep(timeStep: number): void;
  49262. getTimeStep(): number;
  49263. private _tmpImpostorsArray;
  49264. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49265. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49266. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49267. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49268. private _tmpPositionVector;
  49269. removePhysicsBody(impostor: PhysicsImpostor): void;
  49270. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49271. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49272. isSupported(): boolean;
  49273. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49274. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49275. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49276. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49277. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49278. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49279. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49280. getBodyMass(impostor: PhysicsImpostor): number;
  49281. getBodyFriction(impostor: PhysicsImpostor): number;
  49282. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49283. getBodyRestitution(impostor: PhysicsImpostor): number;
  49284. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49285. sleepBody(impostor: PhysicsImpostor): void;
  49286. wakeUpBody(impostor: PhysicsImpostor): void;
  49287. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49288. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49289. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49290. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49291. getRadius(impostor: PhysicsImpostor): number;
  49292. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49293. dispose(): void;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * This represents a set of one or more post processes in Babylon.
  49299. * A post process can be used to apply a shader to a texture after it is rendered.
  49300. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49301. */
  49302. class PostProcessRenderEffect {
  49303. private _postProcesses;
  49304. private _getPostProcesses;
  49305. private _singleInstance;
  49306. private _cameras;
  49307. private _indicesForCamera;
  49308. /**
  49309. * Name of the effect
  49310. * @hidden
  49311. */
  49312. _name: string;
  49313. /**
  49314. * Instantiates a post process render effect.
  49315. * A post process can be used to apply a shader to a texture after it is rendered.
  49316. * @param engine The engine the effect is tied to
  49317. * @param name The name of the effect
  49318. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49319. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49320. */
  49321. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49322. /**
  49323. * Checks if all the post processes in the effect are supported.
  49324. */
  49325. readonly isSupported: boolean;
  49326. /**
  49327. * Updates the current state of the effect
  49328. * @hidden
  49329. */
  49330. _update(): void;
  49331. /**
  49332. * Attaches the effect on cameras
  49333. * @param cameras The camera to attach to.
  49334. * @hidden
  49335. */
  49336. _attachCameras(cameras: Camera): void;
  49337. /**
  49338. * Attaches the effect on cameras
  49339. * @param cameras The camera to attach to.
  49340. * @hidden
  49341. */
  49342. _attachCameras(cameras: Camera[]): void;
  49343. /**
  49344. * Detatches the effect on cameras
  49345. * @param cameras The camera to detatch from.
  49346. * @hidden
  49347. */
  49348. _detachCameras(cameras: Camera): void;
  49349. /**
  49350. * Detatches the effect on cameras
  49351. * @param cameras The camera to detatch from.
  49352. * @hidden
  49353. */
  49354. _detachCameras(cameras: Camera[]): void;
  49355. /**
  49356. * Enables the effect on given cameras
  49357. * @param cameras The camera to enable.
  49358. * @hidden
  49359. */
  49360. _enable(cameras: Camera): void;
  49361. /**
  49362. * Enables the effect on given cameras
  49363. * @param cameras The camera to enable.
  49364. * @hidden
  49365. */
  49366. _enable(cameras: Nullable<Camera[]>): void;
  49367. /**
  49368. * Disables the effect on the given cameras
  49369. * @param cameras The camera to disable.
  49370. * @hidden
  49371. */
  49372. _disable(cameras: Camera): void;
  49373. /**
  49374. * Disables the effect on the given cameras
  49375. * @param cameras The camera to disable.
  49376. * @hidden
  49377. */
  49378. _disable(cameras: Nullable<Camera[]>): void;
  49379. /**
  49380. * Gets a list of the post processes contained in the effect.
  49381. * @param camera The camera to get the post processes on.
  49382. * @returns The list of the post processes in the effect.
  49383. */
  49384. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49385. }
  49386. }
  49387. declare module BABYLON {
  49388. /**
  49389. * PostProcessRenderPipeline
  49390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49391. */
  49392. class PostProcessRenderPipeline {
  49393. private engine;
  49394. private _renderEffects;
  49395. private _renderEffectsForIsolatedPass;
  49396. /**
  49397. * @hidden
  49398. */
  49399. protected _cameras: Camera[];
  49400. /** @hidden */
  49401. _name: string;
  49402. /**
  49403. * Initializes a PostProcessRenderPipeline
  49404. * @param engine engine to add the pipeline to
  49405. * @param name name of the pipeline
  49406. */
  49407. constructor(engine: Engine, name: string);
  49408. /**
  49409. * "PostProcessRenderPipeline"
  49410. * @returns "PostProcessRenderPipeline"
  49411. */
  49412. getClassName(): string;
  49413. /**
  49414. * If all the render effects in the pipeline are support
  49415. */
  49416. readonly isSupported: boolean;
  49417. /**
  49418. * Adds an effect to the pipeline
  49419. * @param renderEffect the effect to add
  49420. */
  49421. addEffect(renderEffect: PostProcessRenderEffect): void;
  49422. /** @hidden */
  49423. _rebuild(): void;
  49424. /** @hidden */
  49425. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49426. /** @hidden */
  49427. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49428. /** @hidden */
  49429. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49430. /** @hidden */
  49431. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49432. /** @hidden */
  49433. _attachCameras(cameras: Camera, unique: boolean): void;
  49434. /** @hidden */
  49435. _attachCameras(cameras: Camera[], unique: boolean): void;
  49436. /** @hidden */
  49437. _detachCameras(cameras: Camera): void;
  49438. /** @hidden */
  49439. _detachCameras(cameras: Nullable<Camera[]>): void;
  49440. /** @hidden */
  49441. _update(): void;
  49442. /** @hidden */
  49443. _reset(): void;
  49444. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49445. /**
  49446. * Disposes of the pipeline
  49447. */
  49448. dispose(): void;
  49449. }
  49450. }
  49451. declare module BABYLON {
  49452. /**
  49453. * PostProcessRenderPipelineManager class
  49454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49455. */
  49456. class PostProcessRenderPipelineManager {
  49457. private _renderPipelines;
  49458. /**
  49459. * Initializes a PostProcessRenderPipelineManager
  49460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49461. */
  49462. constructor();
  49463. /**
  49464. * Adds a pipeline to the manager
  49465. * @param renderPipeline The pipeline to add
  49466. */
  49467. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49468. /**
  49469. * Attaches a camera to the pipeline
  49470. * @param renderPipelineName The name of the pipeline to attach to
  49471. * @param cameras the camera to attach
  49472. * @param unique if the camera can be attached multiple times to the pipeline
  49473. */
  49474. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49475. /**
  49476. * Detaches a camera from the pipeline
  49477. * @param renderPipelineName The name of the pipeline to detach from
  49478. * @param cameras the camera to detach
  49479. */
  49480. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49481. /**
  49482. * Enables an effect by name on a pipeline
  49483. * @param renderPipelineName the name of the pipeline to enable the effect in
  49484. * @param renderEffectName the name of the effect to enable
  49485. * @param cameras the cameras that the effect should be enabled on
  49486. */
  49487. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49488. /**
  49489. * Disables an effect by name on a pipeline
  49490. * @param renderPipelineName the name of the pipeline to disable the effect in
  49491. * @param renderEffectName the name of the effect to disable
  49492. * @param cameras the cameras that the effect should be disabled on
  49493. */
  49494. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49495. /**
  49496. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49497. */
  49498. update(): void;
  49499. /** @hidden */
  49500. _rebuild(): void;
  49501. /**
  49502. * Disposes of the manager and pipelines
  49503. */
  49504. dispose(): void;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. interface Scene {
  49509. /** @hidden (Backing field) */
  49510. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49511. /**
  49512. * Gets the postprocess render pipeline manager
  49513. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49514. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49515. */
  49516. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49517. }
  49518. /**
  49519. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49520. */
  49521. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49522. /**
  49523. * The component name helpfull to identify the component in the list of scene components.
  49524. */
  49525. readonly name: string;
  49526. /**
  49527. * The scene the component belongs to.
  49528. */
  49529. scene: Scene;
  49530. /**
  49531. * Creates a new instance of the component for the given scene
  49532. * @param scene Defines the scene to register the component in
  49533. */
  49534. constructor(scene: Scene);
  49535. /**
  49536. * Registers the component in a given scene
  49537. */
  49538. register(): void;
  49539. /**
  49540. * Rebuilds the elements related to this component in case of
  49541. * context lost for instance.
  49542. */
  49543. rebuild(): void;
  49544. /**
  49545. * Disposes the component and the associated ressources
  49546. */
  49547. dispose(): void;
  49548. private _gatherRenderTargets;
  49549. }
  49550. }
  49551. declare module BABYLON {
  49552. /**
  49553. * Helper class dealing with the extraction of spherical polynomial dataArray
  49554. * from a cube map.
  49555. */
  49556. class CubeMapToSphericalPolynomialTools {
  49557. private static FileFaces;
  49558. /**
  49559. * Converts a texture to the according Spherical Polynomial data.
  49560. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49561. *
  49562. * @param texture The texture to extract the information from.
  49563. * @return The Spherical Polynomial data.
  49564. */
  49565. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49566. /**
  49567. * Converts a cubemap to the according Spherical Polynomial data.
  49568. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49569. *
  49570. * @param cubeInfo The Cube map to extract the information from.
  49571. * @return The Spherical Polynomial data.
  49572. */
  49573. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /**
  49578. * Header information of HDR texture files.
  49579. */
  49580. interface HDRInfo {
  49581. /**
  49582. * The height of the texture in pixels.
  49583. */
  49584. height: number;
  49585. /**
  49586. * The width of the texture in pixels.
  49587. */
  49588. width: number;
  49589. /**
  49590. * The index of the beginning of the data in the binary file.
  49591. */
  49592. dataPosition: number;
  49593. }
  49594. /**
  49595. * This groups tools to convert HDR texture to native colors array.
  49596. */
  49597. class HDRTools {
  49598. private static Ldexp;
  49599. private static Rgbe2float;
  49600. private static readStringLine;
  49601. /**
  49602. * Reads header information from an RGBE texture stored in a native array.
  49603. * More information on this format are available here:
  49604. * https://en.wikipedia.org/wiki/RGBE_image_format
  49605. *
  49606. * @param uint8array The binary file stored in native array.
  49607. * @return The header information.
  49608. */
  49609. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49610. /**
  49611. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49612. * This RGBE texture needs to store the information as a panorama.
  49613. *
  49614. * More information on this format are available here:
  49615. * https://en.wikipedia.org/wiki/RGBE_image_format
  49616. *
  49617. * @param buffer The binary file stored in an array buffer.
  49618. * @param size The expected size of the extracted cubemap.
  49619. * @return The Cube Map information.
  49620. */
  49621. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49622. /**
  49623. * Returns the pixels data extracted from an RGBE texture.
  49624. * This pixels will be stored left to right up to down in the R G B order in one array.
  49625. *
  49626. * More information on this format are available here:
  49627. * https://en.wikipedia.org/wiki/RGBE_image_format
  49628. *
  49629. * @param uint8array The binary file stored in an array buffer.
  49630. * @param hdrInfo The header information of the file.
  49631. * @return The pixels data in RGB right to left up to down order.
  49632. */
  49633. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49634. private static RGBE_ReadPixels_RLE;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49640. */
  49641. interface CubeMapInfo {
  49642. /**
  49643. * The pixel array for the front face.
  49644. * This is stored in format, left to right, up to down format.
  49645. */
  49646. front: Nullable<ArrayBufferView>;
  49647. /**
  49648. * The pixel array for the back face.
  49649. * This is stored in format, left to right, up to down format.
  49650. */
  49651. back: Nullable<ArrayBufferView>;
  49652. /**
  49653. * The pixel array for the left face.
  49654. * This is stored in format, left to right, up to down format.
  49655. */
  49656. left: Nullable<ArrayBufferView>;
  49657. /**
  49658. * The pixel array for the right face.
  49659. * This is stored in format, left to right, up to down format.
  49660. */
  49661. right: Nullable<ArrayBufferView>;
  49662. /**
  49663. * The pixel array for the up face.
  49664. * This is stored in format, left to right, up to down format.
  49665. */
  49666. up: Nullable<ArrayBufferView>;
  49667. /**
  49668. * The pixel array for the down face.
  49669. * This is stored in format, left to right, up to down format.
  49670. */
  49671. down: Nullable<ArrayBufferView>;
  49672. /**
  49673. * The size of the cubemap stored.
  49674. *
  49675. * Each faces will be size * size pixels.
  49676. */
  49677. size: number;
  49678. /**
  49679. * The format of the texture.
  49680. *
  49681. * RGBA, RGB.
  49682. */
  49683. format: number;
  49684. /**
  49685. * The type of the texture data.
  49686. *
  49687. * UNSIGNED_INT, FLOAT.
  49688. */
  49689. type: number;
  49690. /**
  49691. * Specifies whether the texture is in gamma space.
  49692. */
  49693. gammaSpace: boolean;
  49694. }
  49695. /**
  49696. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49697. */
  49698. class PanoramaToCubeMapTools {
  49699. private static FACE_FRONT;
  49700. private static FACE_BACK;
  49701. private static FACE_RIGHT;
  49702. private static FACE_LEFT;
  49703. private static FACE_DOWN;
  49704. private static FACE_UP;
  49705. /**
  49706. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49707. *
  49708. * @param float32Array The source data.
  49709. * @param inputWidth The width of the input panorama.
  49710. * @param inputHeight The height of the input panorama.
  49711. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49712. * @return The cubemap data
  49713. */
  49714. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49715. private static CreateCubemapTexture;
  49716. private static CalcProjectionSpherical;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. }
  49721. declare module BABYLON {
  49722. }
  49723. declare module BABYLON {
  49724. }
  49725. declare module BABYLON {
  49726. }
  49727. declare module BABYLON {
  49728. /**
  49729. * 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.
  49730. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49732. */
  49733. class CustomProceduralTexture extends ProceduralTexture {
  49734. private _animate;
  49735. private _time;
  49736. private _config;
  49737. private _texturePath;
  49738. /**
  49739. * Instantiates a new Custom Procedural Texture.
  49740. * 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.
  49741. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49742. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49743. * @param name Define the name of the texture
  49744. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49745. * @param size Define the size of the texture to create
  49746. * @param scene Define the scene the texture belongs to
  49747. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49748. * @param generateMipMaps Define if the texture should creates mip maps or not
  49749. */
  49750. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49751. private _loadJson;
  49752. /**
  49753. * Is the texture ready to be used ? (rendered at least once)
  49754. * @returns true if ready, otherwise, false.
  49755. */
  49756. isReady(): boolean;
  49757. /**
  49758. * Render the texture to its associated render target.
  49759. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49760. */
  49761. render(useCameraPostProcess?: boolean): void;
  49762. /**
  49763. * Update the list of dependant textures samplers in the shader.
  49764. */
  49765. updateTextures(): void;
  49766. /**
  49767. * Update the uniform values of the procedural texture in the shader.
  49768. */
  49769. updateShaderUniforms(): void;
  49770. /**
  49771. * Define if the texture animates or not.
  49772. */
  49773. animate: boolean;
  49774. }
  49775. }
  49776. declare module BABYLON {
  49777. /**
  49778. * Class used to generate noise procedural textures
  49779. */
  49780. class NoiseProceduralTexture extends ProceduralTexture {
  49781. private _time;
  49782. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49783. brightness: number;
  49784. /** Defines the number of octaves to process */
  49785. octaves: number;
  49786. /** Defines the level of persistence (0.8 by default) */
  49787. persistence: number;
  49788. /** Gets or sets animation speed factor (default is 1) */
  49789. animationSpeedFactor: number;
  49790. /**
  49791. * Creates a new NoiseProceduralTexture
  49792. * @param name defines the name fo the texture
  49793. * @param size defines the size of the texture (default is 256)
  49794. * @param scene defines the hosting scene
  49795. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49796. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49797. */
  49798. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49799. private _updateShaderUniforms;
  49800. protected _getDefines(): string;
  49801. /** Generate the current state of the procedural texture */
  49802. render(useCameraPostProcess?: boolean): void;
  49803. /**
  49804. * Serializes this noise procedural texture
  49805. * @returns a serialized noise procedural texture object
  49806. */
  49807. serialize(): any;
  49808. /**
  49809. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49810. * @param parsedTexture defines parsed texture data
  49811. * @param scene defines the current scene
  49812. * @param rootUrl defines the root URL containing noise procedural texture information
  49813. * @returns a parsed NoiseProceduralTexture
  49814. */
  49815. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49816. }
  49817. }
  49818. declare module BABYLON {
  49819. /**
  49820. * 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.
  49821. * This is the base class of any Procedural texture and contains most of the shareable code.
  49822. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49823. */
  49824. class ProceduralTexture extends Texture {
  49825. isCube: boolean;
  49826. /**
  49827. * Define if the texture is enabled or not (disabled texture will not render)
  49828. */
  49829. isEnabled: boolean;
  49830. /**
  49831. * Define if the texture must be cleared before rendering (default is true)
  49832. */
  49833. autoClear: boolean;
  49834. /**
  49835. * Callback called when the texture is generated
  49836. */
  49837. onGenerated: () => void;
  49838. /**
  49839. * Event raised when the texture is generated
  49840. */
  49841. onGeneratedObservable: Observable<ProceduralTexture>;
  49842. /** @hidden */
  49843. _generateMipMaps: boolean;
  49844. /** @hidden **/
  49845. _effect: Effect;
  49846. /** @hidden */
  49847. _textures: {
  49848. [key: string]: Texture;
  49849. };
  49850. private _size;
  49851. private _currentRefreshId;
  49852. private _refreshRate;
  49853. private _vertexBuffers;
  49854. private _indexBuffer;
  49855. private _uniforms;
  49856. private _samplers;
  49857. private _fragment;
  49858. private _floats;
  49859. private _ints;
  49860. private _floatsArrays;
  49861. private _colors3;
  49862. private _colors4;
  49863. private _vectors2;
  49864. private _vectors3;
  49865. private _matrices;
  49866. private _fallbackTexture;
  49867. private _fallbackTextureUsed;
  49868. private _engine;
  49869. private _cachedDefines;
  49870. private _contentUpdateId;
  49871. private _contentData;
  49872. /**
  49873. * Instantiates a new procedural texture.
  49874. * 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.
  49875. * This is the base class of any Procedural texture and contains most of the shareable code.
  49876. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49877. * @param name Define the name of the texture
  49878. * @param size Define the size of the texture to create
  49879. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49880. * @param scene Define the scene the texture belongs to
  49881. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49882. * @param generateMipMaps Define if the texture should creates mip maps or not
  49883. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49884. */
  49885. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49886. /**
  49887. * The effect that is created when initializing the post process.
  49888. * @returns The created effect corrisponding the the postprocess.
  49889. */
  49890. getEffect(): Effect;
  49891. /**
  49892. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49893. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49894. */
  49895. getContent(): Nullable<ArrayBufferView>;
  49896. private _createIndexBuffer;
  49897. /** @hidden */
  49898. _rebuild(): void;
  49899. /**
  49900. * Resets the texture in order to recreate its associated resources.
  49901. * This can be called in case of context loss
  49902. */
  49903. reset(): void;
  49904. protected _getDefines(): string;
  49905. /**
  49906. * Is the texture ready to be used ? (rendered at least once)
  49907. * @returns true if ready, otherwise, false.
  49908. */
  49909. isReady(): boolean;
  49910. /**
  49911. * Resets the refresh counter of the texture and start bak from scratch.
  49912. * Could be useful to regenerate the texture if it is setup to render only once.
  49913. */
  49914. resetRefreshCounter(): void;
  49915. /**
  49916. * Set the fragment shader to use in order to render the texture.
  49917. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49918. */
  49919. setFragment(fragment: any): void;
  49920. /**
  49921. * Define the refresh rate of the texture or the rendering frequency.
  49922. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49923. */
  49924. refreshRate: number;
  49925. /** @hidden */
  49926. _shouldRender(): boolean;
  49927. /**
  49928. * Get the size the texture is rendering at.
  49929. * @returns the size (texture is always squared)
  49930. */
  49931. getRenderSize(): number;
  49932. /**
  49933. * Resize the texture to new value.
  49934. * @param size Define the new size the texture should have
  49935. * @param generateMipMaps Define whether the new texture should create mip maps
  49936. */
  49937. resize(size: number, generateMipMaps: boolean): void;
  49938. private _checkUniform;
  49939. /**
  49940. * Set a texture in the shader program used to render.
  49941. * @param name Define the name of the uniform samplers as defined in the shader
  49942. * @param texture Define the texture to bind to this sampler
  49943. * @return the texture itself allowing "fluent" like uniform updates
  49944. */
  49945. setTexture(name: string, texture: Texture): ProceduralTexture;
  49946. /**
  49947. * Set a float in the shader.
  49948. * @param name Define the name of the uniform as defined in the shader
  49949. * @param value Define the value to give to the uniform
  49950. * @return the texture itself allowing "fluent" like uniform updates
  49951. */
  49952. setFloat(name: string, value: number): ProceduralTexture;
  49953. /**
  49954. * Set a int in the shader.
  49955. * @param name Define the name of the uniform as defined in the shader
  49956. * @param value Define the value to give to the uniform
  49957. * @return the texture itself allowing "fluent" like uniform updates
  49958. */
  49959. setInt(name: string, value: number): ProceduralTexture;
  49960. /**
  49961. * Set an array of floats in the shader.
  49962. * @param name Define the name of the uniform as defined in the shader
  49963. * @param value Define the value to give to the uniform
  49964. * @return the texture itself allowing "fluent" like uniform updates
  49965. */
  49966. setFloats(name: string, value: number[]): ProceduralTexture;
  49967. /**
  49968. * Set a vec3 in the shader from a Color3.
  49969. * @param name Define the name of the uniform as defined in the shader
  49970. * @param value Define the value to give to the uniform
  49971. * @return the texture itself allowing "fluent" like uniform updates
  49972. */
  49973. setColor3(name: string, value: Color3): ProceduralTexture;
  49974. /**
  49975. * Set a vec4 in the shader from a Color4.
  49976. * @param name Define the name of the uniform as defined in the shader
  49977. * @param value Define the value to give to the uniform
  49978. * @return the texture itself allowing "fluent" like uniform updates
  49979. */
  49980. setColor4(name: string, value: Color4): ProceduralTexture;
  49981. /**
  49982. * Set a vec2 in the shader from a Vector2.
  49983. * @param name Define the name of the uniform as defined in the shader
  49984. * @param value Define the value to give to the uniform
  49985. * @return the texture itself allowing "fluent" like uniform updates
  49986. */
  49987. setVector2(name: string, value: Vector2): ProceduralTexture;
  49988. /**
  49989. * Set a vec3 in the shader from a Vector3.
  49990. * @param name Define the name of the uniform as defined in the shader
  49991. * @param value Define the value to give to the uniform
  49992. * @return the texture itself allowing "fluent" like uniform updates
  49993. */
  49994. setVector3(name: string, value: Vector3): ProceduralTexture;
  49995. /**
  49996. * Set a mat4 in the shader from a MAtrix.
  49997. * @param name Define the name of the uniform as defined in the shader
  49998. * @param value Define the value to give to the uniform
  49999. * @return the texture itself allowing "fluent" like uniform updates
  50000. */
  50001. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50002. /**
  50003. * Render the texture to its associated render target.
  50004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50005. */
  50006. render(useCameraPostProcess?: boolean): void;
  50007. /**
  50008. * Clone the texture.
  50009. * @returns the cloned texture
  50010. */
  50011. clone(): ProceduralTexture;
  50012. /**
  50013. * Dispose the texture and release its asoociated resources.
  50014. */
  50015. dispose(): void;
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. interface AbstractScene {
  50020. /**
  50021. * The list of procedural textures added to the scene
  50022. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50023. */
  50024. proceduralTextures: Array<ProceduralTexture>;
  50025. }
  50026. /**
  50027. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50028. * in a given scene.
  50029. */
  50030. class ProceduralTextureSceneComponent implements ISceneComponent {
  50031. /**
  50032. * The component name helpfull to identify the component in the list of scene components.
  50033. */
  50034. readonly name: string;
  50035. /**
  50036. * The scene the component belongs to.
  50037. */
  50038. scene: Scene;
  50039. /**
  50040. * Creates a new instance of the component for the given scene
  50041. * @param scene Defines the scene to register the component in
  50042. */
  50043. constructor(scene: Scene);
  50044. /**
  50045. * Registers the component in a given scene
  50046. */
  50047. register(): void;
  50048. /**
  50049. * Rebuilds the elements related to this component in case of
  50050. * context lost for instance.
  50051. */
  50052. rebuild(): void;
  50053. /**
  50054. * Disposes the component and the associated ressources.
  50055. */
  50056. dispose(): void;
  50057. private _beforeClear;
  50058. }
  50059. }
  50060. declare module BABYLON {
  50061. /**
  50062. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50063. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50064. */
  50065. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50066. private _scene;
  50067. private _camerasToBeAttached;
  50068. /**
  50069. * ID of the sharpen post process,
  50070. */
  50071. private readonly SharpenPostProcessId;
  50072. /**
  50073. * @ignore
  50074. * ID of the image processing post process;
  50075. */
  50076. readonly ImageProcessingPostProcessId: string;
  50077. /**
  50078. * @ignore
  50079. * ID of the Fast Approximate Anti-Aliasing post process;
  50080. */
  50081. readonly FxaaPostProcessId: string;
  50082. /**
  50083. * ID of the chromatic aberration post process,
  50084. */
  50085. private readonly ChromaticAberrationPostProcessId;
  50086. /**
  50087. * ID of the grain post process
  50088. */
  50089. private readonly GrainPostProcessId;
  50090. /**
  50091. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50092. */
  50093. sharpen: SharpenPostProcess;
  50094. private _sharpenEffect;
  50095. private bloom;
  50096. /**
  50097. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50098. */
  50099. depthOfField: DepthOfFieldEffect;
  50100. /**
  50101. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50102. */
  50103. fxaa: FxaaPostProcess;
  50104. /**
  50105. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50106. */
  50107. imageProcessing: ImageProcessingPostProcess;
  50108. /**
  50109. * Chromatic aberration post process which will shift rgb colors in the image
  50110. */
  50111. chromaticAberration: ChromaticAberrationPostProcess;
  50112. private _chromaticAberrationEffect;
  50113. /**
  50114. * Grain post process which add noise to the image
  50115. */
  50116. grain: GrainPostProcess;
  50117. private _grainEffect;
  50118. /**
  50119. * Glow post process which adds a glow to emmisive areas of the image
  50120. */
  50121. private _glowLayer;
  50122. /**
  50123. * Animations which can be used to tweak settings over a period of time
  50124. */
  50125. animations: Animation[];
  50126. private _imageProcessingConfigurationObserver;
  50127. private _sharpenEnabled;
  50128. private _bloomEnabled;
  50129. private _depthOfFieldEnabled;
  50130. private _depthOfFieldBlurLevel;
  50131. private _fxaaEnabled;
  50132. private _imageProcessingEnabled;
  50133. private _defaultPipelineTextureType;
  50134. private _bloomScale;
  50135. private _chromaticAberrationEnabled;
  50136. private _grainEnabled;
  50137. private _buildAllowed;
  50138. /**
  50139. * Enable or disable the sharpen process from the pipeline
  50140. */
  50141. sharpenEnabled: boolean;
  50142. private _resizeObserver;
  50143. private _hardwareScaleLevel;
  50144. private _bloomKernel;
  50145. /**
  50146. * Specifies the size of the bloom blur kernel, relative to the final output size
  50147. */
  50148. bloomKernel: number;
  50149. /**
  50150. * Specifies the weight of the bloom in the final rendering
  50151. */
  50152. private _bloomWeight;
  50153. /**
  50154. * Specifies the luma threshold for the area that will be blurred by the bloom
  50155. */
  50156. private _bloomThreshold;
  50157. private _hdr;
  50158. /**
  50159. * The strength of the bloom.
  50160. */
  50161. bloomWeight: number;
  50162. /**
  50163. * The strength of the bloom.
  50164. */
  50165. bloomThreshold: number;
  50166. /**
  50167. * The scale of the bloom, lower value will provide better performance.
  50168. */
  50169. bloomScale: number;
  50170. /**
  50171. * Enable or disable the bloom from the pipeline
  50172. */
  50173. bloomEnabled: boolean;
  50174. private _rebuildBloom;
  50175. /**
  50176. * If the depth of field is enabled.
  50177. */
  50178. depthOfFieldEnabled: boolean;
  50179. /**
  50180. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50181. */
  50182. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50183. /**
  50184. * If the anti aliasing is enabled.
  50185. */
  50186. fxaaEnabled: boolean;
  50187. private _samples;
  50188. /**
  50189. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50190. */
  50191. samples: number;
  50192. /**
  50193. * If image processing is enabled.
  50194. */
  50195. imageProcessingEnabled: boolean;
  50196. /**
  50197. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50198. */
  50199. glowLayerEnabled: boolean;
  50200. /**
  50201. * Enable or disable the chromaticAberration process from the pipeline
  50202. */
  50203. chromaticAberrationEnabled: boolean;
  50204. /**
  50205. * Enable or disable the grain process from the pipeline
  50206. */
  50207. grainEnabled: boolean;
  50208. /**
  50209. * @constructor
  50210. * @param name - The rendering pipeline name (default: "")
  50211. * @param hdr - If high dynamic range textures should be used (default: true)
  50212. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50213. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50214. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50215. */
  50216. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50217. /**
  50218. * Force the compilation of the entire pipeline.
  50219. */
  50220. prepare(): void;
  50221. private _hasCleared;
  50222. private _prevPostProcess;
  50223. private _prevPrevPostProcess;
  50224. private _setAutoClearAndTextureSharing;
  50225. private _depthOfFieldSceneObserver;
  50226. private _buildPipeline;
  50227. private _disposePostProcesses;
  50228. /**
  50229. * Adds a camera to the pipeline
  50230. * @param camera the camera to be added
  50231. */
  50232. addCamera(camera: Camera): void;
  50233. /**
  50234. * Removes a camera from the pipeline
  50235. * @param camera the camera to remove
  50236. */
  50237. removeCamera(camera: Camera): void;
  50238. /**
  50239. * Dispose of the pipeline and stop all post processes
  50240. */
  50241. dispose(): void;
  50242. /**
  50243. * Serialize the rendering pipeline (Used when exporting)
  50244. * @returns the serialized object
  50245. */
  50246. serialize(): any;
  50247. /**
  50248. * Parse the serialized pipeline
  50249. * @param source Source pipeline.
  50250. * @param scene The scene to load the pipeline to.
  50251. * @param rootUrl The URL of the serialized pipeline.
  50252. * @returns An instantiated pipeline from the serialized object.
  50253. */
  50254. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50255. }
  50256. }
  50257. declare module BABYLON {
  50258. /**
  50259. * BABYLON.JS Chromatic Aberration GLSL Shader
  50260. * Author: Olivier Guyot
  50261. * Separates very slightly R, G and B colors on the edges of the screen
  50262. * Inspired by Francois Tarlier & Martins Upitis
  50263. */
  50264. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50265. /**
  50266. * @ignore
  50267. * The chromatic aberration PostProcess id in the pipeline
  50268. */
  50269. LensChromaticAberrationEffect: string;
  50270. /**
  50271. * @ignore
  50272. * The highlights enhancing PostProcess id in the pipeline
  50273. */
  50274. HighlightsEnhancingEffect: string;
  50275. /**
  50276. * @ignore
  50277. * The depth-of-field PostProcess id in the pipeline
  50278. */
  50279. LensDepthOfFieldEffect: string;
  50280. private _scene;
  50281. private _depthTexture;
  50282. private _grainTexture;
  50283. private _chromaticAberrationPostProcess;
  50284. private _highlightsPostProcess;
  50285. private _depthOfFieldPostProcess;
  50286. private _edgeBlur;
  50287. private _grainAmount;
  50288. private _chromaticAberration;
  50289. private _distortion;
  50290. private _highlightsGain;
  50291. private _highlightsThreshold;
  50292. private _dofDistance;
  50293. private _dofAperture;
  50294. private _dofDarken;
  50295. private _dofPentagon;
  50296. private _blurNoise;
  50297. /**
  50298. * @constructor
  50299. *
  50300. * Effect parameters are as follow:
  50301. * {
  50302. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50303. * edge_blur: number; // from 0 to x (1 for realism)
  50304. * distortion: number; // from 0 to x (1 for realism)
  50305. * grain_amount: number; // from 0 to 1
  50306. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50307. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50308. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50309. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50310. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50311. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50312. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50313. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50314. * }
  50315. * Note: if an effect parameter is unset, effect is disabled
  50316. *
  50317. * @param name The rendering pipeline name
  50318. * @param parameters - An object containing all parameters (see above)
  50319. * @param scene The scene linked to this pipeline
  50320. * @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)
  50321. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50322. */
  50323. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50324. /**
  50325. * Sets the amount of blur at the edges
  50326. * @param amount blur amount
  50327. */
  50328. setEdgeBlur(amount: number): void;
  50329. /**
  50330. * Sets edge blur to 0
  50331. */
  50332. disableEdgeBlur(): void;
  50333. /**
  50334. * Sets the amout of grain
  50335. * @param amount Amount of grain
  50336. */
  50337. setGrainAmount(amount: number): void;
  50338. /**
  50339. * Set grain amount to 0
  50340. */
  50341. disableGrain(): void;
  50342. /**
  50343. * Sets the chromatic aberration amount
  50344. * @param amount amount of chromatic aberration
  50345. */
  50346. setChromaticAberration(amount: number): void;
  50347. /**
  50348. * Sets chromatic aberration amount to 0
  50349. */
  50350. disableChromaticAberration(): void;
  50351. /**
  50352. * Sets the EdgeDistortion amount
  50353. * @param amount amount of EdgeDistortion
  50354. */
  50355. setEdgeDistortion(amount: number): void;
  50356. /**
  50357. * Sets edge distortion to 0
  50358. */
  50359. disableEdgeDistortion(): void;
  50360. /**
  50361. * Sets the FocusDistance amount
  50362. * @param amount amount of FocusDistance
  50363. */
  50364. setFocusDistance(amount: number): void;
  50365. /**
  50366. * Disables depth of field
  50367. */
  50368. disableDepthOfField(): void;
  50369. /**
  50370. * Sets the Aperture amount
  50371. * @param amount amount of Aperture
  50372. */
  50373. setAperture(amount: number): void;
  50374. /**
  50375. * Sets the DarkenOutOfFocus amount
  50376. * @param amount amount of DarkenOutOfFocus
  50377. */
  50378. setDarkenOutOfFocus(amount: number): void;
  50379. /**
  50380. * Creates a pentagon bokeh effect
  50381. */
  50382. enablePentagonBokeh(): void;
  50383. /**
  50384. * Disables the pentagon bokeh effect
  50385. */
  50386. disablePentagonBokeh(): void;
  50387. /**
  50388. * Enables noise blur
  50389. */
  50390. enableNoiseBlur(): void;
  50391. /**
  50392. * Disables noise blur
  50393. */
  50394. disableNoiseBlur(): void;
  50395. /**
  50396. * Sets the HighlightsGain amount
  50397. * @param amount amount of HighlightsGain
  50398. */
  50399. setHighlightsGain(amount: number): void;
  50400. /**
  50401. * Sets the HighlightsThreshold amount
  50402. * @param amount amount of HighlightsThreshold
  50403. */
  50404. setHighlightsThreshold(amount: number): void;
  50405. /**
  50406. * Disables highlights
  50407. */
  50408. disableHighlights(): void;
  50409. /**
  50410. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50411. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50412. */
  50413. dispose(disableDepthRender?: boolean): void;
  50414. private _createChromaticAberrationPostProcess;
  50415. private _createHighlightsPostProcess;
  50416. private _createDepthOfFieldPostProcess;
  50417. private _createGrainTexture;
  50418. }
  50419. }
  50420. declare module BABYLON {
  50421. /**
  50422. * Render pipeline to produce ssao effect
  50423. */
  50424. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50425. /**
  50426. * @ignore
  50427. * The PassPostProcess id in the pipeline that contains the original scene color
  50428. */
  50429. SSAOOriginalSceneColorEffect: string;
  50430. /**
  50431. * @ignore
  50432. * The SSAO PostProcess id in the pipeline
  50433. */
  50434. SSAORenderEffect: string;
  50435. /**
  50436. * @ignore
  50437. * The horizontal blur PostProcess id in the pipeline
  50438. */
  50439. SSAOBlurHRenderEffect: string;
  50440. /**
  50441. * @ignore
  50442. * The vertical blur PostProcess id in the pipeline
  50443. */
  50444. SSAOBlurVRenderEffect: string;
  50445. /**
  50446. * @ignore
  50447. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50448. */
  50449. SSAOCombineRenderEffect: string;
  50450. /**
  50451. * The output strength of the SSAO post-process. Default value is 1.0.
  50452. */
  50453. totalStrength: number;
  50454. /**
  50455. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50456. */
  50457. maxZ: number;
  50458. /**
  50459. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50460. */
  50461. minZAspect: number;
  50462. private _samples;
  50463. /**
  50464. * Number of samples used for the SSAO calculations. Default value is 8
  50465. */
  50466. samples: number;
  50467. private _textureSamples;
  50468. /**
  50469. * Number of samples to use for antialiasing
  50470. */
  50471. textureSamples: number;
  50472. /**
  50473. * Ratio object used for SSAO ratio and blur ratio
  50474. */
  50475. private _ratio;
  50476. /**
  50477. * Dynamically generated sphere sampler.
  50478. */
  50479. private _sampleSphere;
  50480. /**
  50481. * Blur filter offsets
  50482. */
  50483. private _samplerOffsets;
  50484. private _expensiveBlur;
  50485. /**
  50486. * If bilateral blur should be used
  50487. */
  50488. expensiveBlur: boolean;
  50489. /**
  50490. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50491. */
  50492. radius: number;
  50493. /**
  50494. * The base color of the SSAO post-process
  50495. * The final result is "base + ssao" between [0, 1]
  50496. */
  50497. base: number;
  50498. /**
  50499. * Support test.
  50500. */
  50501. static readonly IsSupported: boolean;
  50502. private _scene;
  50503. private _depthTexture;
  50504. private _normalTexture;
  50505. private _randomTexture;
  50506. private _originalColorPostProcess;
  50507. private _ssaoPostProcess;
  50508. private _blurHPostProcess;
  50509. private _blurVPostProcess;
  50510. private _ssaoCombinePostProcess;
  50511. private _firstUpdate;
  50512. /**
  50513. * @constructor
  50514. * @param name The rendering pipeline name
  50515. * @param scene The scene linked to this pipeline
  50516. * @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 }
  50517. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50518. */
  50519. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50520. /**
  50521. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50522. */
  50523. dispose(disableGeometryBufferRenderer?: boolean): void;
  50524. private _createBlurPostProcess;
  50525. /** @hidden */
  50526. _rebuild(): void;
  50527. private _bits;
  50528. private _radicalInverse_VdC;
  50529. private _hammersley;
  50530. private _hemisphereSample_uniform;
  50531. private _generateHemisphere;
  50532. private _createSSAOPostProcess;
  50533. private _createSSAOCombinePostProcess;
  50534. private _createRandomTexture;
  50535. /**
  50536. * Serialize the rendering pipeline (Used when exporting)
  50537. * @returns the serialized object
  50538. */
  50539. serialize(): any;
  50540. /**
  50541. * Parse the serialized pipeline
  50542. * @param source Source pipeline.
  50543. * @param scene The scene to load the pipeline to.
  50544. * @param rootUrl The URL of the serialized pipeline.
  50545. * @returns An instantiated pipeline from the serialized object.
  50546. */
  50547. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50548. }
  50549. }
  50550. declare module BABYLON {
  50551. /**
  50552. * Render pipeline to produce ssao effect
  50553. */
  50554. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50555. /**
  50556. * @ignore
  50557. * The PassPostProcess id in the pipeline that contains the original scene color
  50558. */
  50559. SSAOOriginalSceneColorEffect: string;
  50560. /**
  50561. * @ignore
  50562. * The SSAO PostProcess id in the pipeline
  50563. */
  50564. SSAORenderEffect: string;
  50565. /**
  50566. * @ignore
  50567. * The horizontal blur PostProcess id in the pipeline
  50568. */
  50569. SSAOBlurHRenderEffect: string;
  50570. /**
  50571. * @ignore
  50572. * The vertical blur PostProcess id in the pipeline
  50573. */
  50574. SSAOBlurVRenderEffect: string;
  50575. /**
  50576. * @ignore
  50577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50578. */
  50579. SSAOCombineRenderEffect: string;
  50580. /**
  50581. * The output strength of the SSAO post-process. Default value is 1.0.
  50582. */
  50583. totalStrength: number;
  50584. /**
  50585. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50586. */
  50587. radius: number;
  50588. /**
  50589. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50590. * Must not be equal to fallOff and superior to fallOff.
  50591. * Default value is 0.975
  50592. */
  50593. area: number;
  50594. /**
  50595. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50596. * Must not be equal to area and inferior to area.
  50597. * Default value is 0.0
  50598. */
  50599. fallOff: number;
  50600. /**
  50601. * The base color of the SSAO post-process
  50602. * The final result is "base + ssao" between [0, 1]
  50603. */
  50604. base: number;
  50605. private _scene;
  50606. private _depthTexture;
  50607. private _randomTexture;
  50608. private _originalColorPostProcess;
  50609. private _ssaoPostProcess;
  50610. private _blurHPostProcess;
  50611. private _blurVPostProcess;
  50612. private _ssaoCombinePostProcess;
  50613. private _firstUpdate;
  50614. /**
  50615. * @constructor
  50616. * @param name - The rendering pipeline name
  50617. * @param scene - The scene linked to this pipeline
  50618. * @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 }
  50619. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50620. */
  50621. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50622. /**
  50623. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50624. */
  50625. dispose(disableDepthRender?: boolean): void;
  50626. private _createBlurPostProcess;
  50627. /** @hidden */
  50628. _rebuild(): void;
  50629. private _createSSAOPostProcess;
  50630. private _createSSAOCombinePostProcess;
  50631. private _createRandomTexture;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * Standard rendering pipeline
  50637. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50638. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50639. */
  50640. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50641. /**
  50642. * Public members
  50643. */
  50644. /**
  50645. * Post-process which contains the original scene color before the pipeline applies all the effects
  50646. */
  50647. originalPostProcess: Nullable<PostProcess>;
  50648. /**
  50649. * Post-process used to down scale an image x4
  50650. */
  50651. downSampleX4PostProcess: Nullable<PostProcess>;
  50652. /**
  50653. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50654. */
  50655. brightPassPostProcess: Nullable<PostProcess>;
  50656. /**
  50657. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50658. */
  50659. blurHPostProcesses: PostProcess[];
  50660. /**
  50661. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50662. */
  50663. blurVPostProcesses: PostProcess[];
  50664. /**
  50665. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50666. */
  50667. textureAdderPostProcess: Nullable<PostProcess>;
  50668. /**
  50669. * Post-process used to create volumetric lighting effect
  50670. */
  50671. volumetricLightPostProcess: Nullable<PostProcess>;
  50672. /**
  50673. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50674. */
  50675. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50676. /**
  50677. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50678. */
  50679. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50680. /**
  50681. * Post-process used to merge the volumetric light effect and the real scene color
  50682. */
  50683. volumetricLightMergePostProces: Nullable<PostProcess>;
  50684. /**
  50685. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50686. */
  50687. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50688. /**
  50689. * Base post-process used to calculate the average luminance of the final image for HDR
  50690. */
  50691. luminancePostProcess: Nullable<PostProcess>;
  50692. /**
  50693. * Post-processes used to create down sample post-processes in order to get
  50694. * the average luminance of the final image for HDR
  50695. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50696. */
  50697. luminanceDownSamplePostProcesses: PostProcess[];
  50698. /**
  50699. * Post-process used to create a HDR effect (light adaptation)
  50700. */
  50701. hdrPostProcess: Nullable<PostProcess>;
  50702. /**
  50703. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50704. */
  50705. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50706. /**
  50707. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50708. */
  50709. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50710. /**
  50711. * Post-process used to merge the final HDR post-process and the real scene color
  50712. */
  50713. hdrFinalPostProcess: Nullable<PostProcess>;
  50714. /**
  50715. * Post-process used to create a lens flare effect
  50716. */
  50717. lensFlarePostProcess: Nullable<PostProcess>;
  50718. /**
  50719. * Post-process that merges the result of the lens flare post-process and the real scene color
  50720. */
  50721. lensFlareComposePostProcess: Nullable<PostProcess>;
  50722. /**
  50723. * Post-process used to create a motion blur effect
  50724. */
  50725. motionBlurPostProcess: Nullable<PostProcess>;
  50726. /**
  50727. * Post-process used to create a depth of field effect
  50728. */
  50729. depthOfFieldPostProcess: Nullable<PostProcess>;
  50730. /**
  50731. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50732. */
  50733. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50734. /**
  50735. * Represents the brightness threshold in order to configure the illuminated surfaces
  50736. */
  50737. brightThreshold: number;
  50738. /**
  50739. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50740. */
  50741. blurWidth: number;
  50742. /**
  50743. * Sets if the blur for highlighted surfaces must be only horizontal
  50744. */
  50745. horizontalBlur: boolean;
  50746. /**
  50747. * Sets the overall exposure used by the pipeline
  50748. */
  50749. exposure: number;
  50750. /**
  50751. * Texture used typically to simulate "dirty" on camera lens
  50752. */
  50753. lensTexture: Nullable<Texture>;
  50754. /**
  50755. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50756. */
  50757. volumetricLightCoefficient: number;
  50758. /**
  50759. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50760. */
  50761. volumetricLightPower: number;
  50762. /**
  50763. * Used the set the blur intensity to smooth the volumetric lights
  50764. */
  50765. volumetricLightBlurScale: number;
  50766. /**
  50767. * Light (spot or directional) used to generate the volumetric lights rays
  50768. * The source light must have a shadow generate so the pipeline can get its
  50769. * depth map
  50770. */
  50771. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50772. /**
  50773. * For eye adaptation, represents the minimum luminance the eye can see
  50774. */
  50775. hdrMinimumLuminance: number;
  50776. /**
  50777. * For eye adaptation, represents the decrease luminance speed
  50778. */
  50779. hdrDecreaseRate: number;
  50780. /**
  50781. * For eye adaptation, represents the increase luminance speed
  50782. */
  50783. hdrIncreaseRate: number;
  50784. /**
  50785. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50786. */
  50787. lensColorTexture: Nullable<Texture>;
  50788. /**
  50789. * The overall strengh for the lens flare effect
  50790. */
  50791. lensFlareStrength: number;
  50792. /**
  50793. * Dispersion coefficient for lens flare ghosts
  50794. */
  50795. lensFlareGhostDispersal: number;
  50796. /**
  50797. * Main lens flare halo width
  50798. */
  50799. lensFlareHaloWidth: number;
  50800. /**
  50801. * Based on the lens distortion effect, defines how much the lens flare result
  50802. * is distorted
  50803. */
  50804. lensFlareDistortionStrength: number;
  50805. /**
  50806. * Lens star texture must be used to simulate rays on the flares and is available
  50807. * in the documentation
  50808. */
  50809. lensStarTexture: Nullable<Texture>;
  50810. /**
  50811. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50812. * flare effect by taking account of the dirt texture
  50813. */
  50814. lensFlareDirtTexture: Nullable<Texture>;
  50815. /**
  50816. * Represents the focal length for the depth of field effect
  50817. */
  50818. depthOfFieldDistance: number;
  50819. /**
  50820. * Represents the blur intensity for the blurred part of the depth of field effect
  50821. */
  50822. depthOfFieldBlurWidth: number;
  50823. /**
  50824. * For motion blur, defines how much the image is blurred by the movement
  50825. */
  50826. motionStrength: number;
  50827. /**
  50828. * List of animations for the pipeline (IAnimatable implementation)
  50829. */
  50830. animations: Animation[];
  50831. /**
  50832. * Private members
  50833. */
  50834. private _scene;
  50835. private _currentDepthOfFieldSource;
  50836. private _basePostProcess;
  50837. private _hdrCurrentLuminance;
  50838. private _floatTextureType;
  50839. private _ratio;
  50840. private _bloomEnabled;
  50841. private _depthOfFieldEnabled;
  50842. private _vlsEnabled;
  50843. private _lensFlareEnabled;
  50844. private _hdrEnabled;
  50845. private _motionBlurEnabled;
  50846. private _fxaaEnabled;
  50847. private _motionBlurSamples;
  50848. private _volumetricLightStepsCount;
  50849. private _samples;
  50850. /**
  50851. * @ignore
  50852. * Specifies if the bloom pipeline is enabled
  50853. */
  50854. BloomEnabled: boolean;
  50855. /**
  50856. * @ignore
  50857. * Specifies if the depth of field pipeline is enabed
  50858. */
  50859. DepthOfFieldEnabled: boolean;
  50860. /**
  50861. * @ignore
  50862. * Specifies if the lens flare pipeline is enabed
  50863. */
  50864. LensFlareEnabled: boolean;
  50865. /**
  50866. * @ignore
  50867. * Specifies if the HDR pipeline is enabled
  50868. */
  50869. HDREnabled: boolean;
  50870. /**
  50871. * @ignore
  50872. * Specifies if the volumetric lights scattering effect is enabled
  50873. */
  50874. VLSEnabled: boolean;
  50875. /**
  50876. * @ignore
  50877. * Specifies if the motion blur effect is enabled
  50878. */
  50879. MotionBlurEnabled: boolean;
  50880. /**
  50881. * Specifies if anti-aliasing is enabled
  50882. */
  50883. fxaaEnabled: boolean;
  50884. /**
  50885. * Specifies the number of steps used to calculate the volumetric lights
  50886. * Typically in interval [50, 200]
  50887. */
  50888. volumetricLightStepsCount: number;
  50889. /**
  50890. * Specifies the number of samples used for the motion blur effect
  50891. * Typically in interval [16, 64]
  50892. */
  50893. motionBlurSamples: number;
  50894. /**
  50895. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50896. */
  50897. samples: number;
  50898. /**
  50899. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50900. * @constructor
  50901. * @param name The rendering pipeline name
  50902. * @param scene The scene linked to this pipeline
  50903. * @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)
  50904. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50905. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50906. */
  50907. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50908. private _buildPipeline;
  50909. private _createDownSampleX4PostProcess;
  50910. private _createBrightPassPostProcess;
  50911. private _createBlurPostProcesses;
  50912. private _createTextureAdderPostProcess;
  50913. private _createVolumetricLightPostProcess;
  50914. private _createLuminancePostProcesses;
  50915. private _createHdrPostProcess;
  50916. private _createLensFlarePostProcess;
  50917. private _createDepthOfFieldPostProcess;
  50918. private _createMotionBlurPostProcess;
  50919. private _getDepthTexture;
  50920. private _disposePostProcesses;
  50921. /**
  50922. * Dispose of the pipeline and stop all post processes
  50923. */
  50924. dispose(): void;
  50925. /**
  50926. * Serialize the rendering pipeline (Used when exporting)
  50927. * @returns the serialized object
  50928. */
  50929. serialize(): any;
  50930. /**
  50931. * Parse the serialized pipeline
  50932. * @param source Source pipeline.
  50933. * @param scene The scene to load the pipeline to.
  50934. * @param rootUrl The URL of the serialized pipeline.
  50935. * @returns An instantiated pipeline from the serialized object.
  50936. */
  50937. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50938. /**
  50939. * Luminance steps
  50940. */
  50941. static LuminanceSteps: number;
  50942. }
  50943. }