babylon.d.ts 2.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4310. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** 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 */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** 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 */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** 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 */
  4471. static readonly GEQUAL: number;
  4472. /** 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 */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /** @hidden */
  4960. export class _DevTools {
  4961. static WarnImport(name: string): string;
  4962. }
  4963. }
  4964. declare module BABYLON {
  4965. /**
  4966. * Class used to evalaute queries containing `and` and `or` operators
  4967. */
  4968. export class AndOrNotEvaluator {
  4969. /**
  4970. * Evaluate a query
  4971. * @param query defines the query to evaluate
  4972. * @param evaluateCallback defines the callback used to filter result
  4973. * @returns true if the query matches
  4974. */
  4975. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4976. private static _HandleParenthesisContent;
  4977. private static _SimplifyNegation;
  4978. }
  4979. }
  4980. declare module BABYLON {
  4981. /**
  4982. * Class used to store custom tags
  4983. */
  4984. export class Tags {
  4985. /**
  4986. * Adds support for tags on the given object
  4987. * @param obj defines the object to use
  4988. */
  4989. static EnableFor(obj: any): void;
  4990. /**
  4991. * Removes tags support
  4992. * @param obj defines the object to use
  4993. */
  4994. static DisableFor(obj: any): void;
  4995. /**
  4996. * Gets a boolean indicating if the given object has tags
  4997. * @param obj defines the object to use
  4998. * @returns a boolean
  4999. */
  5000. static HasTags(obj: any): boolean;
  5001. /**
  5002. * Gets the tags available on a given object
  5003. * @param obj defines the object to use
  5004. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5005. * @returns the tags
  5006. */
  5007. static GetTags(obj: any, asString?: boolean): any;
  5008. /**
  5009. * Adds tags to an object
  5010. * @param obj defines the object to use
  5011. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5012. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5013. */
  5014. static AddTagsTo(obj: any, tagsString: string): void;
  5015. /**
  5016. * @hidden
  5017. */
  5018. static _AddTagTo(obj: any, tag: string): void;
  5019. /**
  5020. * Removes specific tags from a specific object
  5021. * @param obj defines the object to use
  5022. * @param tagsString defines the tags to remove
  5023. */
  5024. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5025. /**
  5026. * @hidden
  5027. */
  5028. static _RemoveTagFrom(obj: any, tag: string): void;
  5029. /**
  5030. * Defines if tags hosted on an object match a given query
  5031. * @param obj defines the object to use
  5032. * @param tagsQuery defines the tag query
  5033. * @returns a boolean
  5034. */
  5035. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * Manages the defines for the Material
  5041. */
  5042. export class MaterialDefines {
  5043. private _keys;
  5044. private _isDirty;
  5045. /** @hidden */
  5046. _renderId: number;
  5047. /** @hidden */
  5048. _areLightsDirty: boolean;
  5049. /** @hidden */
  5050. _areAttributesDirty: boolean;
  5051. /** @hidden */
  5052. _areTexturesDirty: boolean;
  5053. /** @hidden */
  5054. _areFresnelDirty: boolean;
  5055. /** @hidden */
  5056. _areMiscDirty: boolean;
  5057. /** @hidden */
  5058. _areImageProcessingDirty: boolean;
  5059. /** @hidden */
  5060. _normals: boolean;
  5061. /** @hidden */
  5062. _uvs: boolean;
  5063. /** @hidden */
  5064. _needNormals: boolean;
  5065. /** @hidden */
  5066. _needUVs: boolean;
  5067. /**
  5068. * Specifies if the material needs to be re-calculated
  5069. */
  5070. readonly isDirty: boolean;
  5071. /**
  5072. * Marks the material to indicate that it has been re-calculated
  5073. */
  5074. markAsProcessed(): void;
  5075. /**
  5076. * Marks the material to indicate that it needs to be re-calculated
  5077. */
  5078. markAsUnprocessed(): void;
  5079. /**
  5080. * Marks the material to indicate all of its defines need to be re-calculated
  5081. */
  5082. markAllAsDirty(): void;
  5083. /**
  5084. * Marks the material to indicate that image processing needs to be re-calculated
  5085. */
  5086. markAsImageProcessingDirty(): void;
  5087. /**
  5088. * Marks the material to indicate the lights need to be re-calculated
  5089. */
  5090. markAsLightDirty(): void;
  5091. /**
  5092. * Marks the attribute state as changed
  5093. */
  5094. markAsAttributesDirty(): void;
  5095. /**
  5096. * Marks the texture state as changed
  5097. */
  5098. markAsTexturesDirty(): void;
  5099. /**
  5100. * Marks the fresnel state as changed
  5101. */
  5102. markAsFresnelDirty(): void;
  5103. /**
  5104. * Marks the misc state as changed
  5105. */
  5106. markAsMiscDirty(): void;
  5107. /**
  5108. * Rebuilds the material defines
  5109. */
  5110. rebuild(): void;
  5111. /**
  5112. * Specifies if two material defines are equal
  5113. * @param other - A material define instance to compare to
  5114. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5115. */
  5116. isEqual(other: MaterialDefines): boolean;
  5117. /**
  5118. * Clones this instance's defines to another instance
  5119. * @param other - material defines to clone values to
  5120. */
  5121. cloneTo(other: MaterialDefines): void;
  5122. /**
  5123. * Resets the material define values
  5124. */
  5125. reset(): void;
  5126. /**
  5127. * Converts the material define values to a string
  5128. * @returns - String of material define information
  5129. */
  5130. toString(): string;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5136. */
  5137. export class PerformanceMonitor {
  5138. private _enabled;
  5139. private _rollingFrameTime;
  5140. private _lastFrameTimeMs;
  5141. /**
  5142. * constructor
  5143. * @param frameSampleSize The number of samples required to saturate the sliding window
  5144. */
  5145. constructor(frameSampleSize?: number);
  5146. /**
  5147. * Samples current frame
  5148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5149. */
  5150. sampleFrame(timeMs?: number): void;
  5151. /**
  5152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTime: number;
  5155. /**
  5156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5157. */
  5158. readonly averageFrameTimeVariance: number;
  5159. /**
  5160. * Returns the frame time of the most recent frame
  5161. */
  5162. readonly instantaneousFrameTime: number;
  5163. /**
  5164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5165. */
  5166. readonly averageFPS: number;
  5167. /**
  5168. * Returns the average framerate in frames per second using the most recent frame time
  5169. */
  5170. readonly instantaneousFPS: number;
  5171. /**
  5172. * Returns true if enough samples have been taken to completely fill the sliding window
  5173. */
  5174. readonly isSaturated: boolean;
  5175. /**
  5176. * Enables contributions to the sliding window sample set
  5177. */
  5178. enable(): void;
  5179. /**
  5180. * Disables contributions to the sliding window sample set
  5181. * Samples will not be interpolated over the disabled period
  5182. */
  5183. disable(): void;
  5184. /**
  5185. * Returns true if sampling is enabled
  5186. */
  5187. readonly isEnabled: boolean;
  5188. /**
  5189. * Resets performance monitor
  5190. */
  5191. reset(): void;
  5192. }
  5193. /**
  5194. * RollingAverage
  5195. *
  5196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5197. */
  5198. export class RollingAverage {
  5199. /**
  5200. * Current average
  5201. */
  5202. average: number;
  5203. /**
  5204. * Current variance
  5205. */
  5206. variance: number;
  5207. protected _samples: Array<number>;
  5208. protected _sampleCount: number;
  5209. protected _pos: number;
  5210. protected _m2: number;
  5211. /**
  5212. * constructor
  5213. * @param length The number of samples required to saturate the sliding window
  5214. */
  5215. constructor(length: number);
  5216. /**
  5217. * Adds a sample to the sample set
  5218. * @param v The sample value
  5219. */
  5220. add(v: number): void;
  5221. /**
  5222. * Returns previously added values or null if outside of history or outside the sliding window domain
  5223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5224. * @return Value previously recorded with add() or null if outside of range
  5225. */
  5226. history(i: number): number;
  5227. /**
  5228. * Returns true if enough samples have been taken to completely fill the sliding window
  5229. * @return true if sample-set saturated
  5230. */
  5231. isSaturated(): boolean;
  5232. /**
  5233. * Resets the rolling average (equivalent to 0 samples taken so far)
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Wraps a value around the sample range boundaries
  5238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5239. * @return Wrapped position in sample range
  5240. */
  5241. protected _wrapPosition(i: number): number;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5247. * The underlying implementation relies on an associative array to ensure the best performances.
  5248. * The value can be anything including 'null' but except 'undefined'
  5249. */
  5250. export class StringDictionary<T> {
  5251. /**
  5252. * This will clear this dictionary and copy the content from the 'source' one.
  5253. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5254. * @param source the dictionary to take the content from and copy to this dictionary
  5255. */
  5256. copyFrom(source: StringDictionary<T>): void;
  5257. /**
  5258. * Get a value based from its key
  5259. * @param key the given key to get the matching value from
  5260. * @return the value if found, otherwise undefined is returned
  5261. */
  5262. get(key: string): T | undefined;
  5263. /**
  5264. * Get a value from its key or add it if it doesn't exist.
  5265. * This method will ensure you that a given key/data will be present in the dictionary.
  5266. * @param key the given key to get the matching value from
  5267. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5268. * The factory will only be invoked if there's no data for the given key.
  5269. * @return the value corresponding to the key.
  5270. */
  5271. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5272. /**
  5273. * Get a value from its key if present in the dictionary otherwise add it
  5274. * @param key the key to get the value from
  5275. * @param val if there's no such key/value pair in the dictionary add it with this value
  5276. * @return the value corresponding to the key
  5277. */
  5278. getOrAdd(key: string, val: T): T;
  5279. /**
  5280. * Check if there's a given key in the dictionary
  5281. * @param key the key to check for
  5282. * @return true if the key is present, false otherwise
  5283. */
  5284. contains(key: string): boolean;
  5285. /**
  5286. * Add a new key and its corresponding value
  5287. * @param key the key to add
  5288. * @param value the value corresponding to the key
  5289. * @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
  5290. */
  5291. add(key: string, value: T): boolean;
  5292. /**
  5293. * Update a specific value associated to a key
  5294. * @param key defines the key to use
  5295. * @param value defines the value to store
  5296. * @returns true if the value was updated (or false if the key was not found)
  5297. */
  5298. set(key: string, value: T): boolean;
  5299. /**
  5300. * Get the element of the given key and remove it from the dictionary
  5301. * @param key defines the key to search
  5302. * @returns the value associated with the key or null if not found
  5303. */
  5304. getAndRemove(key: string): Nullable<T>;
  5305. /**
  5306. * Remove a key/value from the dictionary.
  5307. * @param key the key to remove
  5308. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5309. */
  5310. remove(key: string): boolean;
  5311. /**
  5312. * Clear the whole content of the dictionary
  5313. */
  5314. clear(): void;
  5315. /**
  5316. * Gets the current count
  5317. */
  5318. readonly count: number;
  5319. /**
  5320. * Execute a callback on each key/val of the dictionary.
  5321. * Note that you can remove any element in this dictionary in the callback implementation
  5322. * @param callback the callback to execute on a given key/value pair
  5323. */
  5324. forEach(callback: (key: string, val: T) => void): void;
  5325. /**
  5326. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5327. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5328. * Note that you can remove any element in this dictionary in the callback implementation
  5329. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5330. * @returns the first item
  5331. */
  5332. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5333. private _count;
  5334. private _data;
  5335. }
  5336. }
  5337. declare module BABYLON {
  5338. /**
  5339. * Helper class that provides a small promise polyfill
  5340. */
  5341. export class PromisePolyfill {
  5342. /**
  5343. * Static function used to check if the polyfill is required
  5344. * If this is the case then the function will inject the polyfill to window.Promise
  5345. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5346. */
  5347. static Apply(force?: boolean): void;
  5348. }
  5349. }
  5350. declare module BABYLON {
  5351. /**
  5352. * Class used to store data that will be store in GPU memory
  5353. */
  5354. export class Buffer {
  5355. private _engine;
  5356. private _buffer;
  5357. /** @hidden */
  5358. _data: Nullable<DataArray>;
  5359. private _updatable;
  5360. private _instanced;
  5361. /**
  5362. * Gets the byte stride.
  5363. */
  5364. readonly byteStride: number;
  5365. /**
  5366. * Constructor
  5367. * @param engine the engine
  5368. * @param data the data to use for this buffer
  5369. * @param updatable whether the data is updatable
  5370. * @param stride the stride (optional)
  5371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5372. * @param instanced whether the buffer is instanced (optional)
  5373. * @param useBytes set to true if the stride in in bytes (optional)
  5374. */
  5375. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5376. /**
  5377. * Create a new VertexBuffer based on the current buffer
  5378. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5379. * @param offset defines offset in the buffer (0 by default)
  5380. * @param size defines the size in floats of attributes (position is 3 for instance)
  5381. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5382. * @param instanced defines if the vertex buffer contains indexed data
  5383. * @param useBytes defines if the offset and stride are in bytes
  5384. * @returns the new vertex buffer
  5385. */
  5386. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5387. /**
  5388. * Gets a boolean indicating if the Buffer is updatable?
  5389. * @returns true if the buffer is updatable
  5390. */
  5391. isUpdatable(): boolean;
  5392. /**
  5393. * Gets current buffer's data
  5394. * @returns a DataArray or null
  5395. */
  5396. getData(): Nullable<DataArray>;
  5397. /**
  5398. * Gets underlying native buffer
  5399. * @returns underlying native buffer
  5400. */
  5401. getBuffer(): Nullable<WebGLBuffer>;
  5402. /**
  5403. * Gets the stride in float32 units (i.e. byte stride / 4).
  5404. * May not be an integer if the byte stride is not divisible by 4.
  5405. * DEPRECATED. Use byteStride instead.
  5406. * @returns the stride in float32 units
  5407. */
  5408. getStrideSize(): number;
  5409. /**
  5410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5411. * @param data defines the data to store
  5412. */
  5413. create(data?: Nullable<DataArray>): void;
  5414. /** @hidden */
  5415. _rebuild(): void;
  5416. /**
  5417. * Update current buffer data
  5418. * @param data defines the data to store
  5419. */
  5420. update(data: DataArray): void;
  5421. /**
  5422. * Updates the data directly.
  5423. * @param data the new data
  5424. * @param offset the new offset
  5425. * @param vertexCount the vertex count (optional)
  5426. * @param useBytes set to true if the offset is in bytes
  5427. */
  5428. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5429. /**
  5430. * Release all resources
  5431. */
  5432. dispose(): void;
  5433. }
  5434. /**
  5435. * Specialized buffer used to store vertex data
  5436. */
  5437. export class VertexBuffer {
  5438. /** @hidden */
  5439. _buffer: Buffer;
  5440. private _kind;
  5441. private _size;
  5442. private _ownsBuffer;
  5443. private _instanced;
  5444. private _instanceDivisor;
  5445. /**
  5446. * The byte type.
  5447. */
  5448. static readonly BYTE: number;
  5449. /**
  5450. * The unsigned byte type.
  5451. */
  5452. static readonly UNSIGNED_BYTE: number;
  5453. /**
  5454. * The short type.
  5455. */
  5456. static readonly SHORT: number;
  5457. /**
  5458. * The unsigned short type.
  5459. */
  5460. static readonly UNSIGNED_SHORT: number;
  5461. /**
  5462. * The integer type.
  5463. */
  5464. static readonly INT: number;
  5465. /**
  5466. * The unsigned integer type.
  5467. */
  5468. static readonly UNSIGNED_INT: number;
  5469. /**
  5470. * The float type.
  5471. */
  5472. static readonly FLOAT: number;
  5473. /**
  5474. * Gets or sets the instance divisor when in instanced mode
  5475. */
  5476. instanceDivisor: number;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Gets the byte offset.
  5483. */
  5484. readonly byteOffset: number;
  5485. /**
  5486. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5487. */
  5488. readonly normalized: boolean;
  5489. /**
  5490. * Gets the data type of each component in the array.
  5491. */
  5492. readonly type: number;
  5493. /**
  5494. * Constructor
  5495. * @param engine the engine
  5496. * @param data the data to use for this vertex buffer
  5497. * @param kind the vertex buffer kind
  5498. * @param updatable whether the data is updatable
  5499. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5500. * @param stride the stride (optional)
  5501. * @param instanced whether the buffer is instanced (optional)
  5502. * @param offset the offset of the data (optional)
  5503. * @param size the number of components (optional)
  5504. * @param type the type of the component (optional)
  5505. * @param normalized whether the data contains normalized data (optional)
  5506. * @param useBytes set to true if stride and offset are in bytes (optional)
  5507. */
  5508. 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);
  5509. /** @hidden */
  5510. _rebuild(): void;
  5511. /**
  5512. * Returns the kind of the VertexBuffer (string)
  5513. * @returns a string
  5514. */
  5515. getKind(): string;
  5516. /**
  5517. * Gets a boolean indicating if the VertexBuffer is updatable?
  5518. * @returns true if the buffer is updatable
  5519. */
  5520. isUpdatable(): boolean;
  5521. /**
  5522. * Gets current buffer's data
  5523. * @returns a DataArray or null
  5524. */
  5525. getData(): Nullable<DataArray>;
  5526. /**
  5527. * Gets underlying native buffer
  5528. * @returns underlying native buffer
  5529. */
  5530. getBuffer(): Nullable<WebGLBuffer>;
  5531. /**
  5532. * Gets the stride in float32 units (i.e. byte stride / 4).
  5533. * May not be an integer if the byte stride is not divisible by 4.
  5534. * DEPRECATED. Use byteStride instead.
  5535. * @returns the stride in float32 units
  5536. */
  5537. getStrideSize(): number;
  5538. /**
  5539. * Returns the offset as a multiple of the type byte length.
  5540. * DEPRECATED. Use byteOffset instead.
  5541. * @returns the offset in bytes
  5542. */
  5543. getOffset(): number;
  5544. /**
  5545. * Returns the number of components per vertex attribute (integer)
  5546. * @returns the size in float
  5547. */
  5548. getSize(): number;
  5549. /**
  5550. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5551. * @returns true if this buffer is instanced
  5552. */
  5553. getIsInstanced(): boolean;
  5554. /**
  5555. * Returns the instancing divisor, zero for non-instanced (integer).
  5556. * @returns a number
  5557. */
  5558. getInstanceDivisor(): number;
  5559. /**
  5560. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5561. * @param data defines the data to store
  5562. */
  5563. create(data?: DataArray): void;
  5564. /**
  5565. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5566. * This function will create a new buffer if the current one is not updatable
  5567. * @param data defines the data to store
  5568. */
  5569. update(data: DataArray): void;
  5570. /**
  5571. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5572. * Returns the directly updated WebGLBuffer.
  5573. * @param data the new data
  5574. * @param offset the new offset
  5575. * @param useBytes set to true if the offset is in bytes
  5576. */
  5577. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5578. /**
  5579. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5580. */
  5581. dispose(): void;
  5582. /**
  5583. * Enumerates each value of this vertex buffer as numbers.
  5584. * @param count the number of values to enumerate
  5585. * @param callback the callback function called for each value
  5586. */
  5587. forEach(count: number, callback: (value: number, index: number) => void): void;
  5588. /**
  5589. * Positions
  5590. */
  5591. static readonly PositionKind: string;
  5592. /**
  5593. * Normals
  5594. */
  5595. static readonly NormalKind: string;
  5596. /**
  5597. * Tangents
  5598. */
  5599. static readonly TangentKind: string;
  5600. /**
  5601. * Texture coordinates
  5602. */
  5603. static readonly UVKind: string;
  5604. /**
  5605. * Texture coordinates 2
  5606. */
  5607. static readonly UV2Kind: string;
  5608. /**
  5609. * Texture coordinates 3
  5610. */
  5611. static readonly UV3Kind: string;
  5612. /**
  5613. * Texture coordinates 4
  5614. */
  5615. static readonly UV4Kind: string;
  5616. /**
  5617. * Texture coordinates 5
  5618. */
  5619. static readonly UV5Kind: string;
  5620. /**
  5621. * Texture coordinates 6
  5622. */
  5623. static readonly UV6Kind: string;
  5624. /**
  5625. * Colors
  5626. */
  5627. static readonly ColorKind: string;
  5628. /**
  5629. * Matrix indices (for bones)
  5630. */
  5631. static readonly MatricesIndicesKind: string;
  5632. /**
  5633. * Matrix weights (for bones)
  5634. */
  5635. static readonly MatricesWeightsKind: string;
  5636. /**
  5637. * Additional matrix indices (for bones)
  5638. */
  5639. static readonly MatricesIndicesExtraKind: string;
  5640. /**
  5641. * Additional matrix weights (for bones)
  5642. */
  5643. static readonly MatricesWeightsExtraKind: string;
  5644. /**
  5645. * Deduces the stride given a kind.
  5646. * @param kind The kind string to deduce
  5647. * @returns The deduced stride
  5648. */
  5649. static DeduceStride(kind: string): number;
  5650. /**
  5651. * Gets the byte length of the given type.
  5652. * @param type the type
  5653. * @returns the number of bytes
  5654. */
  5655. static GetTypeByteLength(type: number): number;
  5656. /**
  5657. * Enumerates each value of the given parameters as numbers.
  5658. * @param data the data to enumerate
  5659. * @param byteOffset the byte offset of the data
  5660. * @param byteStride the byte stride of the data
  5661. * @param componentCount the number of components per element
  5662. * @param componentType the type of the component
  5663. * @param count the total number of components
  5664. * @param normalized whether the data is normalized
  5665. * @param callback the callback function called for each value
  5666. */
  5667. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5668. private static _GetFloatValue;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class representing spherical polynomial coefficients to the 3rd degree
  5674. */
  5675. export class SphericalPolynomial {
  5676. /**
  5677. * The x coefficients of the spherical polynomial
  5678. */
  5679. x: Vector3;
  5680. /**
  5681. * The y coefficients of the spherical polynomial
  5682. */
  5683. y: Vector3;
  5684. /**
  5685. * The z coefficients of the spherical polynomial
  5686. */
  5687. z: Vector3;
  5688. /**
  5689. * The xx coefficients of the spherical polynomial
  5690. */
  5691. xx: Vector3;
  5692. /**
  5693. * The yy coefficients of the spherical polynomial
  5694. */
  5695. yy: Vector3;
  5696. /**
  5697. * The zz coefficients of the spherical polynomial
  5698. */
  5699. zz: Vector3;
  5700. /**
  5701. * The xy coefficients of the spherical polynomial
  5702. */
  5703. xy: Vector3;
  5704. /**
  5705. * The yz coefficients of the spherical polynomial
  5706. */
  5707. yz: Vector3;
  5708. /**
  5709. * The zx coefficients of the spherical polynomial
  5710. */
  5711. zx: Vector3;
  5712. /**
  5713. * Adds an ambient color to the spherical polynomial
  5714. * @param color the color to add
  5715. */
  5716. addAmbient(color: Color3): void;
  5717. /**
  5718. * Scales the spherical polynomial by the given amount
  5719. * @param scale the amount to scale
  5720. */
  5721. scale(scale: number): void;
  5722. /**
  5723. * Gets the spherical polynomial from harmonics
  5724. * @param harmonics the spherical harmonics
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5728. /**
  5729. * Constructs a spherical polynomial from an array.
  5730. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5731. * @returns the spherical polynomial
  5732. */
  5733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5734. }
  5735. /**
  5736. * Class representing spherical harmonics coefficients to the 3rd degree
  5737. */
  5738. export class SphericalHarmonics {
  5739. /**
  5740. * The l0,0 coefficients of the spherical harmonics
  5741. */
  5742. l00: Vector3;
  5743. /**
  5744. * The l1,-1 coefficients of the spherical harmonics
  5745. */
  5746. l1_1: Vector3;
  5747. /**
  5748. * The l1,0 coefficients of the spherical harmonics
  5749. */
  5750. l10: Vector3;
  5751. /**
  5752. * The l1,1 coefficients of the spherical harmonics
  5753. */
  5754. l11: Vector3;
  5755. /**
  5756. * The l2,-2 coefficients of the spherical harmonics
  5757. */
  5758. l2_2: Vector3;
  5759. /**
  5760. * The l2,-1 coefficients of the spherical harmonics
  5761. */
  5762. l2_1: Vector3;
  5763. /**
  5764. * The l2,0 coefficients of the spherical harmonics
  5765. */
  5766. l20: Vector3;
  5767. /**
  5768. * The l2,1 coefficients of the spherical harmonics
  5769. */
  5770. l21: Vector3;
  5771. /**
  5772. * The l2,2 coefficients of the spherical harmonics
  5773. */
  5774. lL22: Vector3;
  5775. /**
  5776. * Adds a light to the spherical harmonics
  5777. * @param direction the direction of the light
  5778. * @param color the color of the light
  5779. * @param deltaSolidAngle the delta solid angle of the light
  5780. */
  5781. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5782. /**
  5783. * Scales the spherical harmonics by the given amount
  5784. * @param scale the amount to scale
  5785. */
  5786. scale(scale: number): void;
  5787. /**
  5788. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5789. *
  5790. * ```
  5791. * E_lm = A_l * L_lm
  5792. * ```
  5793. *
  5794. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5795. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5796. * the scaling factors are given in equation 9.
  5797. */
  5798. convertIncidentRadianceToIrradiance(): void;
  5799. /**
  5800. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5801. *
  5802. * ```
  5803. * L = (1/pi) * E * rho
  5804. * ```
  5805. *
  5806. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5807. */
  5808. convertIrradianceToLambertianRadiance(): void;
  5809. /**
  5810. * Gets the spherical harmonics from polynomial
  5811. * @param polynomial the spherical polynomial
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5815. /**
  5816. * Constructs a spherical harmonics from an array.
  5817. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5818. * @returns the spherical harmonics
  5819. */
  5820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. /**
  5907. * Helper class dealing with the extraction of spherical polynomial dataArray
  5908. * from a cube map.
  5909. */
  5910. export class CubeMapToSphericalPolynomialTools {
  5911. private static FileFaces;
  5912. /**
  5913. * Converts a texture to the according Spherical Polynomial data.
  5914. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5915. *
  5916. * @param texture The texture to extract the information from.
  5917. * @return The Spherical Polynomial data.
  5918. */
  5919. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5920. /**
  5921. * Converts a cubemap to the according Spherical Polynomial data.
  5922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5923. *
  5924. * @param cubeInfo The Cube map to extract the information from.
  5925. * @return The Spherical Polynomial data.
  5926. */
  5927. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5928. }
  5929. }
  5930. declare module BABYLON {
  5931. /**
  5932. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5933. * during the life time of the application.
  5934. */
  5935. export class EngineStore {
  5936. /** Gets the list of created engines */
  5937. static Instances: Engine[];
  5938. /**
  5939. * Gets the latest created engine
  5940. */
  5941. static readonly LastCreatedEngine: Nullable<Engine>;
  5942. /**
  5943. * Gets the latest created scene
  5944. */
  5945. static readonly LastCreatedScene: Nullable<Scene>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Define options used to create a render target texture
  5951. */
  5952. export class RenderTargetCreationOptions {
  5953. /**
  5954. * Specifies is mipmaps must be generated
  5955. */
  5956. generateMipMaps?: boolean;
  5957. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5958. generateDepthBuffer?: boolean;
  5959. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5960. generateStencilBuffer?: boolean;
  5961. /** Defines texture type (int by default) */
  5962. type?: number;
  5963. /** Defines sampling mode (trilinear by default) */
  5964. samplingMode?: number;
  5965. /** Defines format (RGBA by default) */
  5966. format?: number;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * @hidden
  5972. **/
  5973. export class _AlphaState {
  5974. private _isAlphaBlendDirty;
  5975. private _isBlendFunctionParametersDirty;
  5976. private _isBlendEquationParametersDirty;
  5977. private _isBlendConstantsDirty;
  5978. private _alphaBlend;
  5979. private _blendFunctionParameters;
  5980. private _blendEquationParameters;
  5981. private _blendConstants;
  5982. /**
  5983. * Initializes the state.
  5984. */
  5985. constructor();
  5986. readonly isDirty: boolean;
  5987. alphaBlend: boolean;
  5988. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5989. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5990. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5991. reset(): void;
  5992. apply(gl: WebGLRenderingContext): void;
  5993. }
  5994. }
  5995. declare module BABYLON {
  5996. /**
  5997. * @hidden
  5998. **/
  5999. export class _DepthCullingState {
  6000. private _isDepthTestDirty;
  6001. private _isDepthMaskDirty;
  6002. private _isDepthFuncDirty;
  6003. private _isCullFaceDirty;
  6004. private _isCullDirty;
  6005. private _isZOffsetDirty;
  6006. private _isFrontFaceDirty;
  6007. private _depthTest;
  6008. private _depthMask;
  6009. private _depthFunc;
  6010. private _cull;
  6011. private _cullFace;
  6012. private _zOffset;
  6013. private _frontFace;
  6014. /**
  6015. * Initializes the state.
  6016. */
  6017. constructor();
  6018. readonly isDirty: boolean;
  6019. zOffset: number;
  6020. cullFace: Nullable<number>;
  6021. cull: Nullable<boolean>;
  6022. depthFunc: Nullable<number>;
  6023. depthMask: boolean;
  6024. depthTest: boolean;
  6025. frontFace: Nullable<number>;
  6026. reset(): void;
  6027. apply(gl: WebGLRenderingContext): void;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _StencilState {
  6035. /** 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 */
  6036. static readonly ALWAYS: number;
  6037. /** Passed to stencilOperation to specify that stencil value must be kept */
  6038. static readonly KEEP: number;
  6039. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6040. static readonly REPLACE: number;
  6041. private _isStencilTestDirty;
  6042. private _isStencilMaskDirty;
  6043. private _isStencilFuncDirty;
  6044. private _isStencilOpDirty;
  6045. private _stencilTest;
  6046. private _stencilMask;
  6047. private _stencilFunc;
  6048. private _stencilFuncRef;
  6049. private _stencilFuncMask;
  6050. private _stencilOpStencilFail;
  6051. private _stencilOpDepthFail;
  6052. private _stencilOpStencilDepthPass;
  6053. readonly isDirty: boolean;
  6054. stencilFunc: number;
  6055. stencilFuncRef: number;
  6056. stencilFuncMask: number;
  6057. stencilOpStencilFail: number;
  6058. stencilOpDepthFail: number;
  6059. stencilOpStencilDepthPass: number;
  6060. stencilMask: number;
  6061. stencilTest: boolean;
  6062. constructor();
  6063. reset(): void;
  6064. apply(gl: WebGLRenderingContext): void;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * @hidden
  6070. **/
  6071. export class _TimeToken {
  6072. _startTimeQuery: Nullable<WebGLQuery>;
  6073. _endTimeQuery: Nullable<WebGLQuery>;
  6074. _timeElapsedQuery: Nullable<WebGLQuery>;
  6075. _timeElapsedQueryEnded: boolean;
  6076. }
  6077. }
  6078. declare module BABYLON {
  6079. /**
  6080. * Internal interface used to track InternalTexture already bound to the GL context
  6081. */
  6082. export interface IInternalTextureTracker {
  6083. /**
  6084. * Gets or set the previous tracker in the list
  6085. */
  6086. previous: Nullable<IInternalTextureTracker>;
  6087. /**
  6088. * Gets or set the next tracker in the list
  6089. */
  6090. next: Nullable<IInternalTextureTracker>;
  6091. }
  6092. /**
  6093. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6094. */
  6095. export class DummyInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Class used to store data associated with WebGL texture data for the engine
  6109. * This class should not be used directly
  6110. */
  6111. export class InternalTexture implements IInternalTextureTracker {
  6112. /** hidden */
  6113. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6114. /**
  6115. * The source of the texture data is unknown
  6116. */
  6117. static DATASOURCE_UNKNOWN: number;
  6118. /**
  6119. * Texture data comes from an URL
  6120. */
  6121. static DATASOURCE_URL: number;
  6122. /**
  6123. * Texture data is only used for temporary storage
  6124. */
  6125. static DATASOURCE_TEMP: number;
  6126. /**
  6127. * Texture data comes from raw data (ArrayBuffer)
  6128. */
  6129. static DATASOURCE_RAW: number;
  6130. /**
  6131. * Texture content is dynamic (video or dynamic texture)
  6132. */
  6133. static DATASOURCE_DYNAMIC: number;
  6134. /**
  6135. * Texture content is generated by rendering to it
  6136. */
  6137. static DATASOURCE_RENDERTARGET: number;
  6138. /**
  6139. * Texture content is part of a multi render target process
  6140. */
  6141. static DATASOURCE_MULTIRENDERTARGET: number;
  6142. /**
  6143. * Texture data comes from a cube data file
  6144. */
  6145. static DATASOURCE_CUBE: number;
  6146. /**
  6147. * Texture data comes from a raw cube data
  6148. */
  6149. static DATASOURCE_CUBERAW: number;
  6150. /**
  6151. * Texture data come from a prefiltered cube data file
  6152. */
  6153. static DATASOURCE_CUBEPREFILTERED: number;
  6154. /**
  6155. * Texture content is raw 3D data
  6156. */
  6157. static DATASOURCE_RAW3D: number;
  6158. /**
  6159. * Texture content is a depth texture
  6160. */
  6161. static DATASOURCE_DEPTHTEXTURE: number;
  6162. /**
  6163. * Texture data comes from a raw cube data encoded with RGBD
  6164. */
  6165. static DATASOURCE_CUBERAW_RGBD: number;
  6166. /**
  6167. * Defines if the texture is ready
  6168. */
  6169. isReady: boolean;
  6170. /**
  6171. * Defines if the texture is a cube texture
  6172. */
  6173. isCube: boolean;
  6174. /**
  6175. * Defines if the texture contains 3D data
  6176. */
  6177. is3D: boolean;
  6178. /**
  6179. * Gets the URL used to load this texture
  6180. */
  6181. url: string;
  6182. /**
  6183. * Gets the sampling mode of the texture
  6184. */
  6185. samplingMode: number;
  6186. /**
  6187. * Gets a boolean indicating if the texture needs mipmaps generation
  6188. */
  6189. generateMipMaps: boolean;
  6190. /**
  6191. * Gets the number of samples used by the texture (WebGL2+ only)
  6192. */
  6193. samples: number;
  6194. /**
  6195. * Gets the type of the texture (int, float...)
  6196. */
  6197. type: number;
  6198. /**
  6199. * Gets the format of the texture (RGB, RGBA...)
  6200. */
  6201. format: number;
  6202. /**
  6203. * Observable called when the texture is loaded
  6204. */
  6205. onLoadedObservable: Observable<InternalTexture>;
  6206. /**
  6207. * Gets the width of the texture
  6208. */
  6209. width: number;
  6210. /**
  6211. * Gets the height of the texture
  6212. */
  6213. height: number;
  6214. /**
  6215. * Gets the depth of the texture
  6216. */
  6217. depth: number;
  6218. /**
  6219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6220. */
  6221. baseWidth: number;
  6222. /**
  6223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6224. */
  6225. baseHeight: number;
  6226. /**
  6227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6228. */
  6229. baseDepth: number;
  6230. /**
  6231. * Gets a boolean indicating if the texture is inverted on Y axis
  6232. */
  6233. invertY: boolean;
  6234. /**
  6235. * Gets or set the previous tracker in the list
  6236. */
  6237. previous: Nullable<IInternalTextureTracker>;
  6238. /**
  6239. * Gets or set the next tracker in the list
  6240. */
  6241. next: Nullable<IInternalTextureTracker>;
  6242. /** @hidden */
  6243. _invertVScale: boolean;
  6244. /** @hidden */
  6245. _initialSlot: number;
  6246. /** @hidden */
  6247. _designatedSlot: number;
  6248. /** @hidden */
  6249. _dataSource: number;
  6250. /** @hidden */
  6251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6252. /** @hidden */
  6253. _bufferView: Nullable<ArrayBufferView>;
  6254. /** @hidden */
  6255. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6256. /** @hidden */
  6257. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6258. /** @hidden */
  6259. _size: number;
  6260. /** @hidden */
  6261. _extension: string;
  6262. /** @hidden */
  6263. _files: Nullable<string[]>;
  6264. /** @hidden */
  6265. _workingCanvas: HTMLCanvasElement;
  6266. /** @hidden */
  6267. _workingContext: CanvasRenderingContext2D;
  6268. /** @hidden */
  6269. _framebuffer: Nullable<WebGLFramebuffer>;
  6270. /** @hidden */
  6271. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6272. /** @hidden */
  6273. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6274. /** @hidden */
  6275. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6276. /** @hidden */
  6277. _attachments: Nullable<number[]>;
  6278. /** @hidden */
  6279. _cachedCoordinatesMode: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedWrapU: Nullable<number>;
  6282. /** @hidden */
  6283. _cachedWrapV: Nullable<number>;
  6284. /** @hidden */
  6285. _cachedWrapR: Nullable<number>;
  6286. /** @hidden */
  6287. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6288. /** @hidden */
  6289. _isDisabled: boolean;
  6290. /** @hidden */
  6291. _compression: Nullable<string>;
  6292. /** @hidden */
  6293. _generateStencilBuffer: boolean;
  6294. /** @hidden */
  6295. _generateDepthBuffer: boolean;
  6296. /** @hidden */
  6297. _comparisonFunction: number;
  6298. /** @hidden */
  6299. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6300. /** @hidden */
  6301. _lodGenerationScale: number;
  6302. /** @hidden */
  6303. _lodGenerationOffset: number;
  6304. /** @hidden */
  6305. _lodTextureHigh: BaseTexture;
  6306. /** @hidden */
  6307. _lodTextureMid: BaseTexture;
  6308. /** @hidden */
  6309. _lodTextureLow: BaseTexture;
  6310. /** @hidden */
  6311. _isRGBD: boolean;
  6312. /** @hidden */
  6313. _webGLTexture: Nullable<WebGLTexture>;
  6314. /** @hidden */
  6315. _references: number;
  6316. private _engine;
  6317. /**
  6318. * Gets the Engine the texture belongs to.
  6319. * @returns The babylon engine
  6320. */
  6321. getEngine(): Engine;
  6322. /**
  6323. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6324. */
  6325. readonly dataSource: number;
  6326. /**
  6327. * Creates a new InternalTexture
  6328. * @param engine defines the engine to use
  6329. * @param dataSource defines the type of data that will be used
  6330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6331. */
  6332. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6333. /**
  6334. * Increments the number of references (ie. the number of Texture that point to it)
  6335. */
  6336. incrementReferences(): void;
  6337. /**
  6338. * Change the size of the texture (not the size of the content)
  6339. * @param width defines the new width
  6340. * @param height defines the new height
  6341. * @param depth defines the new depth (1 by default)
  6342. */
  6343. updateSize(width: int, height: int, depth?: int): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /** @hidden */
  6347. _swapAndDie(target: InternalTexture): void;
  6348. /**
  6349. * Dispose the current allocated resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. }
  6354. declare module BABYLON {
  6355. /**
  6356. * This represents the main contract an easing function should follow.
  6357. * Easing functions are used throughout the animation system.
  6358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6359. */
  6360. export interface IEasingFunction {
  6361. /**
  6362. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6363. * of the easing function.
  6364. * The link below provides some of the most common examples of easing functions.
  6365. * @see https://easings.net/
  6366. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6367. * @returns the corresponding value on the curve defined by the easing function
  6368. */
  6369. ease(gradient: number): number;
  6370. }
  6371. /**
  6372. * Base class used for every default easing function.
  6373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6374. */
  6375. export class EasingFunction implements IEasingFunction {
  6376. /**
  6377. * Interpolation follows the mathematical formula associated with the easing function.
  6378. */
  6379. static readonly EASINGMODE_EASEIN: number;
  6380. /**
  6381. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6382. */
  6383. static readonly EASINGMODE_EASEOUT: number;
  6384. /**
  6385. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6386. */
  6387. static readonly EASINGMODE_EASEINOUT: number;
  6388. private _easingMode;
  6389. /**
  6390. * Sets the easing mode of the current function.
  6391. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6392. */
  6393. setEasingMode(easingMode: number): void;
  6394. /**
  6395. * Gets the current easing mode.
  6396. * @returns the easing mode
  6397. */
  6398. getEasingMode(): number;
  6399. /**
  6400. * @hidden
  6401. */
  6402. easeInCore(gradient: number): number;
  6403. /**
  6404. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6405. * of the easing function.
  6406. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6407. * @returns the corresponding value on the curve defined by the easing function
  6408. */
  6409. ease(gradient: number): number;
  6410. }
  6411. /**
  6412. * Easing function with a circle shape (see link below).
  6413. * @see https://easings.net/#easeInCirc
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export class CircleEase extends EasingFunction implements IEasingFunction {
  6417. /** @hidden */
  6418. easeInCore(gradient: number): number;
  6419. }
  6420. /**
  6421. * Easing function with a ease back shape (see link below).
  6422. * @see https://easings.net/#easeInBack
  6423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6424. */
  6425. export class BackEase extends EasingFunction implements IEasingFunction {
  6426. /** Defines the amplitude of the function */
  6427. amplitude: number;
  6428. /**
  6429. * Instantiates a back ease easing
  6430. * @see https://easings.net/#easeInBack
  6431. * @param amplitude Defines the amplitude of the function
  6432. */
  6433. constructor(
  6434. /** Defines the amplitude of the function */
  6435. amplitude?: number);
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a bouncing shape (see link below).
  6441. * @see https://easings.net/#easeInBounce
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BounceEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the number of bounces */
  6446. bounces: number;
  6447. /** Defines the amplitude of the bounce */
  6448. bounciness: number;
  6449. /**
  6450. * Instantiates a bounce easing
  6451. * @see https://easings.net/#easeInBounce
  6452. * @param bounces Defines the number of bounces
  6453. * @param bounciness Defines the amplitude of the bounce
  6454. */
  6455. constructor(
  6456. /** Defines the number of bounces */
  6457. bounces?: number,
  6458. /** Defines the amplitude of the bounce */
  6459. bounciness?: number);
  6460. /** @hidden */
  6461. easeInCore(gradient: number): number;
  6462. }
  6463. /**
  6464. * Easing function with a power of 3 shape (see link below).
  6465. * @see https://easings.net/#easeInCubic
  6466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6467. */
  6468. export class CubicEase extends EasingFunction implements IEasingFunction {
  6469. /** @hidden */
  6470. easeInCore(gradient: number): number;
  6471. }
  6472. /**
  6473. * Easing function with an elastic shape (see link below).
  6474. * @see https://easings.net/#easeInElastic
  6475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6476. */
  6477. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6478. /** Defines the number of oscillations*/
  6479. oscillations: number;
  6480. /** Defines the amplitude of the oscillations*/
  6481. springiness: number;
  6482. /**
  6483. * Instantiates an elastic easing function
  6484. * @see https://easings.net/#easeInElastic
  6485. * @param oscillations Defines the number of oscillations
  6486. * @param springiness Defines the amplitude of the oscillations
  6487. */
  6488. constructor(
  6489. /** Defines the number of oscillations*/
  6490. oscillations?: number,
  6491. /** Defines the amplitude of the oscillations*/
  6492. springiness?: number);
  6493. /** @hidden */
  6494. easeInCore(gradient: number): number;
  6495. }
  6496. /**
  6497. * Easing function with an exponential shape (see link below).
  6498. * @see https://easings.net/#easeInExpo
  6499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6500. */
  6501. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6502. /** Defines the exponent of the function */
  6503. exponent: number;
  6504. /**
  6505. * Instantiates an exponential easing function
  6506. * @see https://easings.net/#easeInExpo
  6507. * @param exponent Defines the exponent of the function
  6508. */
  6509. constructor(
  6510. /** Defines the exponent of the function */
  6511. exponent?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with a power shape (see link below).
  6517. * @see https://easings.net/#easeInQuad
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class PowerEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the power of the function */
  6522. power: number;
  6523. /**
  6524. * Instantiates an power base easing function
  6525. * @see https://easings.net/#easeInQuad
  6526. * @param power Defines the power of the function
  6527. */
  6528. constructor(
  6529. /** Defines the power of the function */
  6530. power?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power of 2 shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6540. /** @hidden */
  6541. easeInCore(gradient: number): number;
  6542. }
  6543. /**
  6544. * Easing function with a power of 4 shape (see link below).
  6545. * @see https://easings.net/#easeInQuart
  6546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6547. */
  6548. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 5 shape (see link below).
  6554. * @see https://easings.net/#easeInQuint
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a sin shape (see link below).
  6563. * @see https://easings.net/#easeInSine
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class SineEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a bezier shape (see link below).
  6572. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the x component of the start tangent in the bezier curve */
  6577. x1: number;
  6578. /** Defines the y component of the start tangent in the bezier curve */
  6579. y1: number;
  6580. /** Defines the x component of the end tangent in the bezier curve */
  6581. x2: number;
  6582. /** Defines the y component of the end tangent in the bezier curve */
  6583. y2: number;
  6584. /**
  6585. * Instantiates a bezier function
  6586. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6587. * @param x1 Defines the x component of the start tangent in the bezier curve
  6588. * @param y1 Defines the y component of the start tangent in the bezier curve
  6589. * @param x2 Defines the x component of the end tangent in the bezier curve
  6590. * @param y2 Defines the y component of the end tangent in the bezier curve
  6591. */
  6592. constructor(
  6593. /** Defines the x component of the start tangent in the bezier curve */
  6594. x1?: number,
  6595. /** Defines the y component of the start tangent in the bezier curve */
  6596. y1?: number,
  6597. /** Defines the x component of the end tangent in the bezier curve */
  6598. x2?: number,
  6599. /** Defines the y component of the end tangent in the bezier curve */
  6600. y2?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Defines an interface which represents an animation key frame
  6608. */
  6609. export interface IAnimationKey {
  6610. /**
  6611. * Frame of the key frame
  6612. */
  6613. frame: number;
  6614. /**
  6615. * Value at the specifies key frame
  6616. */
  6617. value: any;
  6618. /**
  6619. * The input tangent for the cubic hermite spline
  6620. */
  6621. inTangent?: any;
  6622. /**
  6623. * The output tangent for the cubic hermite spline
  6624. */
  6625. outTangent?: any;
  6626. /**
  6627. * The animation interpolation type
  6628. */
  6629. interpolation?: AnimationKeyInterpolation;
  6630. }
  6631. /**
  6632. * Enum for the animation key frame interpolation type
  6633. */
  6634. export enum AnimationKeyInterpolation {
  6635. /**
  6636. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6637. */
  6638. STEP = 1
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Represents the range of an animation
  6644. */
  6645. export class AnimationRange {
  6646. /**The name of the animation range**/
  6647. name: string;
  6648. /**The starting frame of the animation */
  6649. from: number;
  6650. /**The ending frame of the animation*/
  6651. to: number;
  6652. /**
  6653. * Initializes the range of an animation
  6654. * @param name The name of the animation range
  6655. * @param from The starting frame of the animation
  6656. * @param to The ending frame of the animation
  6657. */
  6658. constructor(
  6659. /**The name of the animation range**/
  6660. name: string,
  6661. /**The starting frame of the animation */
  6662. from: number,
  6663. /**The ending frame of the animation*/
  6664. to: number);
  6665. /**
  6666. * Makes a copy of the animation range
  6667. * @returns A copy of the animation range
  6668. */
  6669. clone(): AnimationRange;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Composed of a frame, and an action function
  6675. */
  6676. export class AnimationEvent {
  6677. /** The frame for which the event is triggered **/
  6678. frame: number;
  6679. /** The event to perform when triggered **/
  6680. action: (currentFrame: number) => void;
  6681. /** Specifies if the event should be triggered only once**/
  6682. onlyOnce?: boolean | undefined;
  6683. /**
  6684. * Specifies if the animation event is done
  6685. */
  6686. isDone: boolean;
  6687. /**
  6688. * Initializes the animation event
  6689. * @param frame The frame for which the event is triggered
  6690. * @param action The event to perform when triggered
  6691. * @param onlyOnce Specifies if the event should be triggered only once
  6692. */
  6693. constructor(
  6694. /** The frame for which the event is triggered **/
  6695. frame: number,
  6696. /** The event to perform when triggered **/
  6697. action: (currentFrame: number) => void,
  6698. /** Specifies if the event should be triggered only once**/
  6699. onlyOnce?: boolean | undefined);
  6700. /** @hidden */
  6701. _clone(): AnimationEvent;
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Interface used to define a behavior
  6707. */
  6708. export interface Behavior<T> {
  6709. /** gets or sets behavior's name */
  6710. name: string;
  6711. /**
  6712. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6713. */
  6714. init(): void;
  6715. /**
  6716. * Called when the behavior is attached to a target
  6717. * @param target defines the target where the behavior is attached to
  6718. */
  6719. attach(target: T): void;
  6720. /**
  6721. * Called when the behavior is detached from its target
  6722. */
  6723. detach(): void;
  6724. }
  6725. /**
  6726. * Interface implemented by classes supporting behaviors
  6727. */
  6728. export interface IBehaviorAware<T> {
  6729. /**
  6730. * Attach a behavior
  6731. * @param behavior defines the behavior to attach
  6732. * @returns the current host
  6733. */
  6734. addBehavior(behavior: Behavior<T>): T;
  6735. /**
  6736. * Remove a behavior from the current object
  6737. * @param behavior defines the behavior to detach
  6738. * @returns the current host
  6739. */
  6740. removeBehavior(behavior: Behavior<T>): T;
  6741. /**
  6742. * Gets a behavior using its name to search
  6743. * @param name defines the name to search
  6744. * @returns the behavior or null if not found
  6745. */
  6746. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module BABYLON {
  6763. /**
  6764. * Class used to store bounding sphere information
  6765. */
  6766. export class BoundingSphere {
  6767. /**
  6768. * Gets the center of the bounding sphere in local space
  6769. */
  6770. readonly center: Vector3;
  6771. /**
  6772. * Radius of the bounding sphere in local space
  6773. */
  6774. radius: number;
  6775. /**
  6776. * Gets the center of the bounding sphere in world space
  6777. */
  6778. readonly centerWorld: Vector3;
  6779. /**
  6780. * Radius of the bounding sphere in world space
  6781. */
  6782. radiusWorld: number;
  6783. /**
  6784. * Gets the minimum vector in local space
  6785. */
  6786. readonly minimum: Vector3;
  6787. /**
  6788. * Gets the maximum vector in local space
  6789. */
  6790. readonly maximum: Vector3;
  6791. private _worldMatrix;
  6792. private static readonly TmpVector3;
  6793. /**
  6794. * Creates a new bounding sphere
  6795. * @param min defines the minimum vector (in local space)
  6796. * @param max defines the maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6800. /**
  6801. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6802. * @param min defines the new minimum vector (in local space)
  6803. * @param max defines the new maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6807. /**
  6808. * Scale the current bounding sphere by applying a scale factor
  6809. * @param factor defines the scale factor to apply
  6810. * @returns the current bounding box
  6811. */
  6812. scale(factor: number): BoundingSphere;
  6813. /**
  6814. * Gets the world matrix of the bounding box
  6815. * @returns a matrix
  6816. */
  6817. getWorldMatrix(): DeepImmutable<Matrix>;
  6818. /** @hidden */
  6819. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */
  6902. _tag: number;
  6903. /**
  6904. * Creates a new bounding box
  6905. * @param min defines the minimum vector (in local space)
  6906. * @param max defines the maximum vector (in local space)
  6907. * @param worldMatrix defines the new world matrix
  6908. */
  6909. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6910. /**
  6911. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6912. * @param min defines the new minimum vector (in local space)
  6913. * @param max defines the new maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6917. /**
  6918. * Scale the current bounding box by applying a scale factor
  6919. * @param factor defines the scale factor to apply
  6920. * @returns the current bounding box
  6921. */
  6922. scale(factor: number): BoundingBox;
  6923. /**
  6924. * Gets the world matrix of the bounding box
  6925. * @returns a matrix
  6926. */
  6927. getWorldMatrix(): DeepImmutable<Matrix>;
  6928. /** @hidden */
  6929. _update(world: DeepImmutable<Matrix>): void;
  6930. /**
  6931. * Tests if the bounding box is intersecting the frustum planes
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if there is an intersection
  6934. */
  6935. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if the bounding box is entirely inside the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an inclusion
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a point is inside the bounding box
  6944. * @param point defines the point to test
  6945. * @returns true if the point is inside the bounding box
  6946. */
  6947. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6948. /**
  6949. * Tests if the bounding box intersects with a bounding sphere
  6950. * @param sphere defines the sphere to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6954. /**
  6955. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6956. * @param min defines the min vector to use
  6957. * @param max defines the max vector to use
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Tests if two bounding boxes are intersections
  6963. * @param box0 defines the first box to test
  6964. * @param box1 defines the second box to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6968. /**
  6969. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6970. * @param minPoint defines the minimum vector of the bounding box
  6971. * @param maxPoint defines the maximum vector of the bounding box
  6972. * @param sphereCenter defines the sphere center
  6973. * @param sphereRadius defines the sphere radius
  6974. * @returns true if there is an intersection
  6975. */
  6976. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6977. /**
  6978. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @return true if there is an inclusion
  6982. */
  6983. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an intersection
  6989. */
  6990. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /** @hidden */
  6995. export class Collider {
  6996. /** Define if a collision was found */
  6997. collisionFound: boolean;
  6998. /**
  6999. * Define last intersection point in local space
  7000. */
  7001. intersectionPoint: Vector3;
  7002. /**
  7003. * Define last collided mesh
  7004. */
  7005. collidedMesh: Nullable<AbstractMesh>;
  7006. private _collisionPoint;
  7007. private _planeIntersectionPoint;
  7008. private _tempVector;
  7009. private _tempVector2;
  7010. private _tempVector3;
  7011. private _tempVector4;
  7012. private _edge;
  7013. private _baseToVertex;
  7014. private _destinationPoint;
  7015. private _slidePlaneNormal;
  7016. private _displacementVector;
  7017. /** @hidden */
  7018. _radius: Vector3;
  7019. /** @hidden */
  7020. _retry: number;
  7021. private _velocity;
  7022. private _basePoint;
  7023. private _epsilon;
  7024. /** @hidden */
  7025. _velocityWorldLength: number;
  7026. /** @hidden */
  7027. _basePointWorld: Vector3;
  7028. private _velocityWorld;
  7029. private _normalizedVelocity;
  7030. /** @hidden */
  7031. _initialVelocity: Vector3;
  7032. /** @hidden */
  7033. _initialPosition: Vector3;
  7034. private _nearestDistance;
  7035. private _collisionMask;
  7036. collisionMask: number;
  7037. /**
  7038. * Gets the plane normal used to compute the sliding response (in local space)
  7039. */
  7040. readonly slidePlaneNormal: Vector3;
  7041. /** @hidden */
  7042. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7043. /** @hidden */
  7044. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7045. /** @hidden */
  7046. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7047. /** @hidden */
  7048. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7049. /** @hidden */
  7050. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7051. /** @hidden */
  7052. _getResponse(pos: Vector3, vel: Vector3): void;
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Interface for cullable objects
  7058. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7059. */
  7060. export interface ICullable {
  7061. /**
  7062. * Checks if the object or part of the object is in the frustum
  7063. * @param frustumPlanes Camera near/planes
  7064. * @returns true if the object is in frustum otherwise false
  7065. */
  7066. isInFrustum(frustumPlanes: Plane[]): boolean;
  7067. /**
  7068. * Checks if a cullable object (mesh...) is in the camera frustum
  7069. * Unlike isInFrustum this cheks the full bounding box
  7070. * @param frustumPlanes Camera near/planes
  7071. * @returns true if the object is in frustum otherwise false
  7072. */
  7073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7074. }
  7075. /**
  7076. * Info for a bounding data of a mesh
  7077. */
  7078. export class BoundingInfo implements ICullable {
  7079. /**
  7080. * Bounding box for the mesh
  7081. */
  7082. readonly boundingBox: BoundingBox;
  7083. /**
  7084. * Bounding sphere for the mesh
  7085. */
  7086. readonly boundingSphere: BoundingSphere;
  7087. private _isLocked;
  7088. private static readonly TmpVector3;
  7089. /**
  7090. * Constructs bounding info
  7091. * @param minimum min vector of the bounding box/sphere
  7092. * @param maximum max vector of the bounding box/sphere
  7093. * @param worldMatrix defines the new world matrix
  7094. */
  7095. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7096. /**
  7097. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7098. * @param min defines the new minimum vector (in local space)
  7099. * @param max defines the new maximum vector (in local space)
  7100. * @param worldMatrix defines the new world matrix
  7101. */
  7102. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7103. /**
  7104. * min vector of the bounding box/sphere
  7105. */
  7106. readonly minimum: Vector3;
  7107. /**
  7108. * max vector of the bounding box/sphere
  7109. */
  7110. readonly maximum: Vector3;
  7111. /**
  7112. * If the info is locked and won't be updated to avoid perf overhead
  7113. */
  7114. isLocked: boolean;
  7115. /**
  7116. * Updates the bounding sphere and box
  7117. * @param world world matrix to be used to update
  7118. */
  7119. update(world: DeepImmutable<Matrix>): void;
  7120. /**
  7121. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7122. * @param center New center of the bounding info
  7123. * @param extend New extend of the bounding info
  7124. * @returns the current bounding info
  7125. */
  7126. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7127. /**
  7128. * Scale the current bounding info by applying a scale factor
  7129. * @param factor defines the scale factor to apply
  7130. * @returns the current bounding info
  7131. */
  7132. scale(factor: number): BoundingInfo;
  7133. /**
  7134. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7135. * @param frustumPlanes defines the frustum to test
  7136. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7137. * @returns true if the bounding info is in the frustum planes
  7138. */
  7139. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7140. /**
  7141. * Gets the world distance between the min and max points of the bounding box
  7142. */
  7143. readonly diagonalLength: number;
  7144. /**
  7145. * Checks if a cullable object (mesh...) is in the camera frustum
  7146. * Unlike isInFrustum this cheks the full bounding box
  7147. * @param frustumPlanes Camera near/planes
  7148. * @returns true if the object is in frustum otherwise false
  7149. */
  7150. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /** @hidden */
  7152. _checkCollision(collider: Collider): boolean;
  7153. /**
  7154. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7155. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7156. * @param point the point to check intersection with
  7157. * @returns if the point intersects
  7158. */
  7159. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7160. /**
  7161. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7162. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7163. * @param boundingInfo the bounding info to check intersection with
  7164. * @param precise if the intersection should be done using OBB
  7165. * @returns if the bounding info intersects
  7166. */
  7167. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7168. }
  7169. }
  7170. declare module BABYLON {
  7171. /**
  7172. * Defines an array and its length.
  7173. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7174. */
  7175. export interface ISmartArrayLike<T> {
  7176. /**
  7177. * The data of the array.
  7178. */
  7179. data: Array<T>;
  7180. /**
  7181. * The active length of the array.
  7182. */
  7183. length: number;
  7184. }
  7185. /**
  7186. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7187. */
  7188. export class SmartArray<T> implements ISmartArrayLike<T> {
  7189. /**
  7190. * The full set of data from the array.
  7191. */
  7192. data: Array<T>;
  7193. /**
  7194. * The active length of the array.
  7195. */
  7196. length: number;
  7197. protected _id: number;
  7198. /**
  7199. * Instantiates a Smart Array.
  7200. * @param capacity defines the default capacity of the array.
  7201. */
  7202. constructor(capacity: number);
  7203. /**
  7204. * Pushes a value at the end of the active data.
  7205. * @param value defines the object to push in the array.
  7206. */
  7207. push(value: T): void;
  7208. /**
  7209. * Iterates over the active data and apply the lambda to them.
  7210. * @param func defines the action to apply on each value.
  7211. */
  7212. forEach(func: (content: T) => void): void;
  7213. /**
  7214. * Sorts the full sets of data.
  7215. * @param compareFn defines the comparison function to apply.
  7216. */
  7217. sort(compareFn: (a: T, b: T) => number): void;
  7218. /**
  7219. * Resets the active data to an empty array.
  7220. */
  7221. reset(): void;
  7222. /**
  7223. * Releases all the data from the array as well as the array.
  7224. */
  7225. dispose(): void;
  7226. /**
  7227. * Concats the active data with a given array.
  7228. * @param array defines the data to concatenate with.
  7229. */
  7230. concat(array: any): void;
  7231. /**
  7232. * Returns the position of a value in the active data.
  7233. * @param value defines the value to find the index for
  7234. * @returns the index if found in the active data otherwise -1
  7235. */
  7236. indexOf(value: T): number;
  7237. /**
  7238. * Returns whether an element is part of the active data.
  7239. * @param value defines the value to look for
  7240. * @returns true if found in the active data otherwise false
  7241. */
  7242. contains(value: T): boolean;
  7243. private static _GlobalId;
  7244. }
  7245. /**
  7246. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7247. * The data in this array can only be present once
  7248. */
  7249. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7250. private _duplicateId;
  7251. /**
  7252. * Pushes a value at the end of the active data.
  7253. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7254. * @param value defines the object to push in the array.
  7255. */
  7256. push(value: T): void;
  7257. /**
  7258. * Pushes a value at the end of the active data.
  7259. * If the data is already present, it won t be added again
  7260. * @param value defines the object to push in the array.
  7261. * @returns true if added false if it was already present
  7262. */
  7263. pushNoDuplicate(value: T): boolean;
  7264. /**
  7265. * Resets the active data to an empty array.
  7266. */
  7267. reset(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * This ensures no dupplicate will be present in the result.
  7271. * @param array defines the data to concatenate with.
  7272. */
  7273. concatWithNoDuplicate(array: any): void;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /**
  7278. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7279. * separate meshes. This can be use to improve performances.
  7280. * @see http://doc.babylonjs.com/how_to/multi_materials
  7281. */
  7282. export class MultiMaterial extends Material {
  7283. private _subMaterials;
  7284. /**
  7285. * Gets or Sets the list of Materials used within the multi material.
  7286. * They need to be ordered according to the submeshes order in the associated mesh
  7287. */
  7288. subMaterials: Nullable<Material>[];
  7289. /**
  7290. * Function used to align with Node.getChildren()
  7291. * @returns the list of Materials used within the multi material
  7292. */
  7293. getChildren(): Nullable<Material>[];
  7294. /**
  7295. * Instantiates a new Multi Material
  7296. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7297. * separate meshes. This can be use to improve performances.
  7298. * @see http://doc.babylonjs.com/how_to/multi_materials
  7299. * @param name Define the name in the scene
  7300. * @param scene Define the scene the material belongs to
  7301. */
  7302. constructor(name: string, scene: Scene);
  7303. private _hookArray;
  7304. /**
  7305. * Get one of the submaterial by its index in the submaterials array
  7306. * @param index The index to look the sub material at
  7307. * @returns The Material if the index has been defined
  7308. */
  7309. getSubMaterial(index: number): Nullable<Material>;
  7310. /**
  7311. * Get the list of active textures for the whole sub materials list.
  7312. * @returns All the textures that will be used during the rendering
  7313. */
  7314. getActiveTextures(): BaseTexture[];
  7315. /**
  7316. * Gets the current class name of the material e.g. "MultiMaterial"
  7317. * Mainly use in serialization.
  7318. * @returns the class name
  7319. */
  7320. getClassName(): string;
  7321. /**
  7322. * Checks if the material is ready to render the requested sub mesh
  7323. * @param mesh Define the mesh the submesh belongs to
  7324. * @param subMesh Define the sub mesh to look readyness for
  7325. * @param useInstances Define whether or not the material is used with instances
  7326. * @returns true if ready, otherwise false
  7327. */
  7328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7329. /**
  7330. * Clones the current material and its related sub materials
  7331. * @param name Define the name of the newly cloned material
  7332. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7333. * @returns the cloned material
  7334. */
  7335. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7336. /**
  7337. * Serializes the materials into a JSON representation.
  7338. * @returns the JSON representation
  7339. */
  7340. serialize(): any;
  7341. /**
  7342. * Dispose the material and release its associated resources
  7343. * @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)
  7344. * @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)
  7345. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7346. */
  7347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7348. /**
  7349. * Creates a MultiMaterial from parsed MultiMaterial data.
  7350. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7351. * @param scene defines the hosting scene
  7352. * @returns a new MultiMaterial
  7353. */
  7354. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * Class used to represent data loading progression
  7360. */
  7361. export class SceneLoaderFlags {
  7362. private static _ForceFullSceneLoadingForIncremental;
  7363. private static _ShowLoadingScreen;
  7364. private static _CleanBoneMatrixWeights;
  7365. private static _loggingLevel;
  7366. /**
  7367. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7368. */
  7369. static ForceFullSceneLoadingForIncremental: boolean;
  7370. /**
  7371. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7372. */
  7373. static ShowLoadingScreen: boolean;
  7374. /**
  7375. * Defines the current logging level (while loading the scene)
  7376. * @ignorenaming
  7377. */
  7378. static loggingLevel: number;
  7379. /**
  7380. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7381. */
  7382. static CleanBoneMatrixWeights: boolean;
  7383. }
  7384. }
  7385. declare module BABYLON {
  7386. /**
  7387. * 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.
  7388. * @see https://doc.babylonjs.com/how_to/transformnode
  7389. */
  7390. export class TransformNode extends Node {
  7391. /**
  7392. * Object will not rotate to face the camera
  7393. */
  7394. static BILLBOARDMODE_NONE: number;
  7395. /**
  7396. * Object will rotate to face the camera but only on the x axis
  7397. */
  7398. static BILLBOARDMODE_X: number;
  7399. /**
  7400. * Object will rotate to face the camera but only on the y axis
  7401. */
  7402. static BILLBOARDMODE_Y: number;
  7403. /**
  7404. * Object will rotate to face the camera but only on the z axis
  7405. */
  7406. static BILLBOARDMODE_Z: number;
  7407. /**
  7408. * Object will rotate to face the camera
  7409. */
  7410. static BILLBOARDMODE_ALL: number;
  7411. private _forward;
  7412. private _forwardInverted;
  7413. private _up;
  7414. private _right;
  7415. private _rightInverted;
  7416. private _position;
  7417. private _rotation;
  7418. private _rotationQuaternion;
  7419. protected _scaling: Vector3;
  7420. protected _isDirty: boolean;
  7421. private _transformToBoneReferal;
  7422. /**
  7423. * Set the billboard mode. Default is 0.
  7424. *
  7425. * | Value | Type | Description |
  7426. * | --- | --- | --- |
  7427. * | 0 | BILLBOARDMODE_NONE | |
  7428. * | 1 | BILLBOARDMODE_X | |
  7429. * | 2 | BILLBOARDMODE_Y | |
  7430. * | 4 | BILLBOARDMODE_Z | |
  7431. * | 7 | BILLBOARDMODE_ALL | |
  7432. *
  7433. */
  7434. billboardMode: number;
  7435. /**
  7436. * 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
  7437. */
  7438. scalingDeterminant: number;
  7439. /**
  7440. * Sets the distance of the object to max, often used by skybox
  7441. */
  7442. infiniteDistance: boolean;
  7443. /**
  7444. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7445. * By default the system will update normals to compensate
  7446. */
  7447. ignoreNonUniformScaling: boolean;
  7448. /** @hidden */
  7449. _poseMatrix: Matrix;
  7450. /** @hidden */
  7451. _localMatrix: Matrix;
  7452. private _absolutePosition;
  7453. private _pivotMatrix;
  7454. private _pivotMatrixInverse;
  7455. protected _postMultiplyPivotMatrix: boolean;
  7456. protected _isWorldMatrixFrozen: boolean;
  7457. /** @hidden */
  7458. _indexInSceneTransformNodesArray: number;
  7459. /**
  7460. * An event triggered after the world matrix is updated
  7461. */
  7462. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7463. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7464. /**
  7465. * Gets a string identifying the name of the class
  7466. * @returns "TransformNode" string
  7467. */
  7468. getClassName(): string;
  7469. /**
  7470. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7471. */
  7472. position: Vector3;
  7473. /**
  7474. * 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)).
  7475. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7476. */
  7477. rotation: Vector3;
  7478. /**
  7479. * 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)).
  7480. */
  7481. scaling: Vector3;
  7482. /**
  7483. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7484. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7485. */
  7486. rotationQuaternion: Nullable<Quaternion>;
  7487. /**
  7488. * The forward direction of that transform in world space.
  7489. */
  7490. readonly forward: Vector3;
  7491. /**
  7492. * The up direction of that transform in world space.
  7493. */
  7494. readonly up: Vector3;
  7495. /**
  7496. * The right direction of that transform in world space.
  7497. */
  7498. readonly right: Vector3;
  7499. /**
  7500. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7501. * @param matrix the matrix to copy the pose from
  7502. * @returns this TransformNode.
  7503. */
  7504. updatePoseMatrix(matrix: Matrix): TransformNode;
  7505. /**
  7506. * Returns the mesh Pose matrix.
  7507. * @returns the pose matrix
  7508. */
  7509. getPoseMatrix(): Matrix;
  7510. /** @hidden */
  7511. _isSynchronized(): boolean;
  7512. /** @hidden */
  7513. _initCache(): void;
  7514. /**
  7515. * Flag the transform node as dirty (Forcing it to update everything)
  7516. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7517. * @returns this transform node
  7518. */
  7519. markAsDirty(property: string): TransformNode;
  7520. /**
  7521. * Returns the current mesh absolute position.
  7522. * Returns a Vector3.
  7523. */
  7524. readonly absolutePosition: Vector3;
  7525. /**
  7526. * Sets a new matrix to apply before all other transformation
  7527. * @param matrix defines the transform matrix
  7528. * @returns the current TransformNode
  7529. */
  7530. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7531. /**
  7532. * Sets a new pivot matrix to the current node
  7533. * @param matrix defines the new pivot matrix to use
  7534. * @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
  7535. * @returns the current TransformNode
  7536. */
  7537. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7538. /**
  7539. * Returns the mesh pivot matrix.
  7540. * Default : Identity.
  7541. * @returns the matrix
  7542. */
  7543. getPivotMatrix(): Matrix;
  7544. /**
  7545. * Prevents the World matrix to be computed any longer.
  7546. * @returns the TransformNode.
  7547. */
  7548. freezeWorldMatrix(): TransformNode;
  7549. /**
  7550. * Allows back the World matrix computation.
  7551. * @returns the TransformNode.
  7552. */
  7553. unfreezeWorldMatrix(): this;
  7554. /**
  7555. * True if the World matrix has been frozen.
  7556. */
  7557. readonly isWorldMatrixFrozen: boolean;
  7558. /**
  7559. * Retuns the mesh absolute position in the World.
  7560. * @returns a Vector3.
  7561. */
  7562. getAbsolutePosition(): Vector3;
  7563. /**
  7564. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7565. * @param absolutePosition the absolute position to set
  7566. * @returns the TransformNode.
  7567. */
  7568. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7569. /**
  7570. * Sets the mesh position in its local space.
  7571. * @param vector3 the position to set in localspace
  7572. * @returns the TransformNode.
  7573. */
  7574. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7575. /**
  7576. * Returns the mesh position in the local space from the current World matrix values.
  7577. * @returns a new Vector3.
  7578. */
  7579. getPositionExpressedInLocalSpace(): Vector3;
  7580. /**
  7581. * Translates the mesh along the passed Vector3 in its local space.
  7582. * @param vector3 the distance to translate in localspace
  7583. * @returns the TransformNode.
  7584. */
  7585. locallyTranslate(vector3: Vector3): TransformNode;
  7586. private static _lookAtVectorCache;
  7587. /**
  7588. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7589. * @param targetPoint the position (must be in same space as current mesh) to look at
  7590. * @param yawCor optional yaw (y-axis) correction in radians
  7591. * @param pitchCor optional pitch (x-axis) correction in radians
  7592. * @param rollCor optional roll (z-axis) correction in radians
  7593. * @param space the choosen space of the target
  7594. * @returns the TransformNode.
  7595. */
  7596. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7597. /**
  7598. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7599. * This Vector3 is expressed in the World space.
  7600. * @param localAxis axis to rotate
  7601. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7602. */
  7603. getDirection(localAxis: Vector3): Vector3;
  7604. /**
  7605. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7606. * localAxis is expressed in the mesh local space.
  7607. * result is computed in the Wordl space from the mesh World matrix.
  7608. * @param localAxis axis to rotate
  7609. * @param result the resulting transformnode
  7610. * @returns this TransformNode.
  7611. */
  7612. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7613. /**
  7614. * Sets this transform node rotation to the given local axis.
  7615. * @param localAxis the axis in local space
  7616. * @param yawCor optional yaw (y-axis) correction in radians
  7617. * @param pitchCor optional pitch (x-axis) correction in radians
  7618. * @param rollCor optional roll (z-axis) correction in radians
  7619. * @returns this TransformNode
  7620. */
  7621. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7622. /**
  7623. * Sets a new pivot point to the current node
  7624. * @param point defines the new pivot point to use
  7625. * @param space defines if the point is in world or local space (local by default)
  7626. * @returns the current TransformNode
  7627. */
  7628. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7629. /**
  7630. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7631. * @returns the pivot point
  7632. */
  7633. getPivotPoint(): Vector3;
  7634. /**
  7635. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7636. * @param result the vector3 to store the result
  7637. * @returns this TransformNode.
  7638. */
  7639. getPivotPointToRef(result: Vector3): TransformNode;
  7640. /**
  7641. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7642. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7643. */
  7644. getAbsolutePivotPoint(): Vector3;
  7645. /**
  7646. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7647. * @param result vector3 to store the result
  7648. * @returns this TransformNode.
  7649. */
  7650. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7651. /**
  7652. * Defines the passed node as the parent of the current node.
  7653. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7654. * @param node the node ot set as the parent
  7655. * @returns this TransformNode.
  7656. */
  7657. setParent(node: Nullable<Node>): TransformNode;
  7658. private _nonUniformScaling;
  7659. /**
  7660. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7661. */
  7662. readonly nonUniformScaling: boolean;
  7663. /** @hidden */
  7664. _updateNonUniformScalingState(value: boolean): boolean;
  7665. /**
  7666. * Attach the current TransformNode to another TransformNode associated with a bone
  7667. * @param bone Bone affecting the TransformNode
  7668. * @param affectedTransformNode TransformNode associated with the bone
  7669. * @returns this object
  7670. */
  7671. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7672. /**
  7673. * Detach the transform node if its associated with a bone
  7674. * @returns this object
  7675. */
  7676. detachFromBone(): TransformNode;
  7677. private static _rotationAxisCache;
  7678. /**
  7679. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7680. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7681. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7682. * The passed axis is also normalized.
  7683. * @param axis the axis to rotate around
  7684. * @param amount the amount to rotate in radians
  7685. * @param space Space to rotate in (Default: local)
  7686. * @returns the TransformNode.
  7687. */
  7688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7689. /**
  7690. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7691. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7692. * The passed axis is also normalized. .
  7693. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7694. * @param point the point to rotate around
  7695. * @param axis the axis to rotate around
  7696. * @param amount the amount to rotate in radians
  7697. * @returns the TransformNode
  7698. */
  7699. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7700. /**
  7701. * Translates the mesh along the axis vector for the passed distance in the given space.
  7702. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7703. * @param axis the axis to translate in
  7704. * @param distance the distance to translate
  7705. * @param space Space to rotate in (Default: local)
  7706. * @returns the TransformNode.
  7707. */
  7708. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7709. /**
  7710. * Adds a rotation step to the mesh current rotation.
  7711. * x, y, z are Euler angles expressed in radians.
  7712. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7713. * This means this rotation is made in the mesh local space only.
  7714. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7715. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7716. * ```javascript
  7717. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7718. * ```
  7719. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7720. * 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.
  7721. * @param x Rotation to add
  7722. * @param y Rotation to add
  7723. * @param z Rotation to add
  7724. * @returns the TransformNode.
  7725. */
  7726. addRotation(x: number, y: number, z: number): TransformNode;
  7727. /**
  7728. * Computes the world matrix of the node
  7729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7730. * @returns the world matrix
  7731. */
  7732. computeWorldMatrix(force?: boolean): Matrix;
  7733. protected _afterComputeWorldMatrix(): void;
  7734. /**
  7735. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7736. * @param func callback function to add
  7737. *
  7738. * @returns the TransformNode.
  7739. */
  7740. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7741. /**
  7742. * Removes a registered callback function.
  7743. * @param func callback function to remove
  7744. * @returns the TransformNode.
  7745. */
  7746. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7747. /**
  7748. * Gets the position of the current mesh in camera space
  7749. * @param camera defines the camera to use
  7750. * @returns a position
  7751. */
  7752. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7753. /**
  7754. * Returns the distance from the mesh to the active camera
  7755. * @param camera defines the camera to use
  7756. * @returns the distance
  7757. */
  7758. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7759. /**
  7760. * Clone the current transform node
  7761. * @param name Name of the new clone
  7762. * @param newParent New parent for the clone
  7763. * @param doNotCloneChildren Do not clone children hierarchy
  7764. * @returns the new transform node
  7765. */
  7766. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7767. /**
  7768. * Serializes the objects information.
  7769. * @param currentSerializationObject defines the object to serialize in
  7770. * @returns the serialized object
  7771. */
  7772. serialize(currentSerializationObject?: any): any;
  7773. /**
  7774. * Returns a new TransformNode object parsed from the source provided.
  7775. * @param parsedTransformNode is the source.
  7776. * @param scene the scne the object belongs to
  7777. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7778. * @returns a new TransformNode object parsed from the source provided.
  7779. */
  7780. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7781. /**
  7782. * Get all child-transformNodes of this node
  7783. * @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
  7784. * @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
  7785. * @returns an array of TransformNode
  7786. */
  7787. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7788. /**
  7789. * Releases resources associated with this transform node.
  7790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7792. */
  7793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7794. }
  7795. }
  7796. declare module BABYLON {
  7797. /**
  7798. * Class used to override all child animations of a given target
  7799. */
  7800. export class AnimationPropertiesOverride {
  7801. /**
  7802. * Gets or sets a value indicating if animation blending must be used
  7803. */
  7804. enableBlending: boolean;
  7805. /**
  7806. * Gets or sets the blending speed to use when enableBlending is true
  7807. */
  7808. blendingSpeed: number;
  7809. /**
  7810. * Gets or sets the default loop mode to use
  7811. */
  7812. loopMode: number;
  7813. }
  7814. }
  7815. declare module BABYLON {
  7816. /**
  7817. * Class used to store bone information
  7818. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7819. */
  7820. export class Bone extends Node {
  7821. /**
  7822. * defines the bone name
  7823. */
  7824. name: string;
  7825. private static _tmpVecs;
  7826. private static _tmpQuat;
  7827. private static _tmpMats;
  7828. /**
  7829. * Gets the list of child bones
  7830. */
  7831. children: Bone[];
  7832. /** Gets the animations associated with this bone */
  7833. animations: Animation[];
  7834. /**
  7835. * Gets or sets bone length
  7836. */
  7837. length: number;
  7838. /**
  7839. * @hidden Internal only
  7840. * Set this value to map this bone to a different index in the transform matrices
  7841. * Set this value to -1 to exclude the bone from the transform matrices
  7842. */
  7843. _index: Nullable<number>;
  7844. private _skeleton;
  7845. private _localMatrix;
  7846. private _restPose;
  7847. private _baseMatrix;
  7848. private _absoluteTransform;
  7849. private _invertedAbsoluteTransform;
  7850. private _parent;
  7851. private _scalingDeterminant;
  7852. private _worldTransform;
  7853. private _localScaling;
  7854. private _localRotation;
  7855. private _localPosition;
  7856. private _needToDecompose;
  7857. private _needToCompose;
  7858. /** @hidden */
  7859. _linkedTransformNode: Nullable<TransformNode>;
  7860. /** @hidden */
  7861. /** @hidden */
  7862. _matrix: Matrix;
  7863. /**
  7864. * Create a new bone
  7865. * @param name defines the bone name
  7866. * @param skeleton defines the parent skeleton
  7867. * @param parentBone defines the parent (can be null if the bone is the root)
  7868. * @param localMatrix defines the local matrix
  7869. * @param restPose defines the rest pose matrix
  7870. * @param baseMatrix defines the base matrix
  7871. * @param index defines index of the bone in the hiearchy
  7872. */
  7873. constructor(
  7874. /**
  7875. * defines the bone name
  7876. */
  7877. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7878. /**
  7879. * Gets the parent skeleton
  7880. * @returns a skeleton
  7881. */
  7882. getSkeleton(): Skeleton;
  7883. /**
  7884. * Gets parent bone
  7885. * @returns a bone or null if the bone is the root of the bone hierarchy
  7886. */
  7887. getParent(): Nullable<Bone>;
  7888. /**
  7889. * Sets the parent bone
  7890. * @param parent defines the parent (can be null if the bone is the root)
  7891. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7892. */
  7893. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7894. /**
  7895. * Gets the local matrix
  7896. * @returns a matrix
  7897. */
  7898. getLocalMatrix(): Matrix;
  7899. /**
  7900. * Gets the base matrix (initial matrix which remains unchanged)
  7901. * @returns a matrix
  7902. */
  7903. getBaseMatrix(): Matrix;
  7904. /**
  7905. * Gets the rest pose matrix
  7906. * @returns a matrix
  7907. */
  7908. getRestPose(): Matrix;
  7909. /**
  7910. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7911. */
  7912. getWorldMatrix(): Matrix;
  7913. /**
  7914. * Sets the local matrix to rest pose matrix
  7915. */
  7916. returnToRest(): void;
  7917. /**
  7918. * Gets the inverse of the absolute transform matrix.
  7919. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7920. * @returns a matrix
  7921. */
  7922. getInvertedAbsoluteTransform(): Matrix;
  7923. /**
  7924. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7925. * @returns a matrix
  7926. */
  7927. getAbsoluteTransform(): Matrix;
  7928. /**
  7929. * Links with the given transform node.
  7930. * The local matrix of this bone is copied from the transform node every frame.
  7931. * @param transformNode defines the transform node to link to
  7932. */
  7933. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7934. /** Gets or sets current position (in local space) */
  7935. position: Vector3;
  7936. /** Gets or sets current rotation (in local space) */
  7937. rotation: Vector3;
  7938. /** Gets or sets current rotation quaternion (in local space) */
  7939. rotationQuaternion: Quaternion;
  7940. /** Gets or sets current scaling (in local space) */
  7941. scaling: Vector3;
  7942. /**
  7943. * Gets the animation properties override
  7944. */
  7945. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7946. private _decompose;
  7947. private _compose;
  7948. /**
  7949. * Update the base and local matrices
  7950. * @param matrix defines the new base or local matrix
  7951. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7952. * @param updateLocalMatrix defines if the local matrix should be updated
  7953. */
  7954. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7955. /** @hidden */
  7956. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7957. /**
  7958. * Flag the bone as dirty (Forcing it to update everything)
  7959. */
  7960. markAsDirty(): void;
  7961. private _markAsDirtyAndCompose;
  7962. private _markAsDirtyAndDecompose;
  7963. /**
  7964. * Translate the bone in local or world space
  7965. * @param vec The amount to translate the bone
  7966. * @param space The space that the translation is in
  7967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7968. */
  7969. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7970. /**
  7971. * Set the postion of the bone in local or world space
  7972. * @param position The position to set the bone
  7973. * @param space The space that the position is in
  7974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7975. */
  7976. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7977. /**
  7978. * Set the absolute position of the bone (world space)
  7979. * @param position The position to set the bone
  7980. * @param mesh The mesh that this bone is attached to
  7981. */
  7982. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  7983. /**
  7984. * Scale the bone on the x, y and z axes (in local space)
  7985. * @param x The amount to scale the bone on the x axis
  7986. * @param y The amount to scale the bone on the y axis
  7987. * @param z The amount to scale the bone on the z axis
  7988. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  7989. */
  7990. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  7991. /**
  7992. * Set the bone scaling in local space
  7993. * @param scale defines the scaling vector
  7994. */
  7995. setScale(scale: Vector3): void;
  7996. /**
  7997. * Gets the current scaling in local space
  7998. * @returns the current scaling vector
  7999. */
  8000. getScale(): Vector3;
  8001. /**
  8002. * Gets the current scaling in local space and stores it in a target vector
  8003. * @param result defines the target vector
  8004. */
  8005. getScaleToRef(result: Vector3): void;
  8006. /**
  8007. * Set the yaw, pitch, and roll of the bone in local or world space
  8008. * @param yaw The rotation of the bone on the y axis
  8009. * @param pitch The rotation of the bone on the x axis
  8010. * @param roll The rotation of the bone on the z axis
  8011. * @param space The space that the axes of rotation are in
  8012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8013. */
  8014. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8015. /**
  8016. * Add a rotation to the bone on an axis in local or world space
  8017. * @param axis The axis to rotate the bone on
  8018. * @param amount The amount to rotate the bone
  8019. * @param space The space that the axis is in
  8020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8021. */
  8022. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8023. /**
  8024. * Set the rotation of the bone to a particular axis angle in local or world space
  8025. * @param axis The axis to rotate the bone on
  8026. * @param angle The angle that the bone should be rotated to
  8027. * @param space The space that the axis is in
  8028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8029. */
  8030. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8031. /**
  8032. * Set the euler rotation of the bone in local of world space
  8033. * @param rotation The euler rotation that the bone should be set to
  8034. * @param space The space that the rotation is in
  8035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8036. */
  8037. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8038. /**
  8039. * Set the quaternion rotation of the bone in local of world space
  8040. * @param quat The quaternion rotation that the bone should be set to
  8041. * @param space The space that the rotation is in
  8042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8043. */
  8044. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8045. /**
  8046. * Set the rotation matrix of the bone in local of world space
  8047. * @param rotMat The rotation matrix that the bone should be set to
  8048. * @param space The space that the rotation is in
  8049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8050. */
  8051. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8052. private _rotateWithMatrix;
  8053. private _getNegativeRotationToRef;
  8054. /**
  8055. * Get the position of the bone in local or world space
  8056. * @param space The space that the returned position is in
  8057. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8058. * @returns The position of the bone
  8059. */
  8060. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8061. /**
  8062. * Copy the position of the bone to a vector3 in local or world space
  8063. * @param space The space that the returned position is in
  8064. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8065. * @param result The vector3 to copy the position to
  8066. */
  8067. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8068. /**
  8069. * Get the absolute position of the bone (world space)
  8070. * @param mesh The mesh that this bone is attached to
  8071. * @returns The absolute position of the bone
  8072. */
  8073. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8074. /**
  8075. * Copy the absolute position of the bone (world space) to the result param
  8076. * @param mesh The mesh that this bone is attached to
  8077. * @param result The vector3 to copy the absolute position to
  8078. */
  8079. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8080. /**
  8081. * Compute the absolute transforms of this bone and its children
  8082. */
  8083. computeAbsoluteTransforms(): void;
  8084. /**
  8085. * Get the world direction from an axis that is in the local space of the bone
  8086. * @param localAxis The local direction that is used to compute the world direction
  8087. * @param mesh The mesh that this bone is attached to
  8088. * @returns The world direction
  8089. */
  8090. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8091. /**
  8092. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8093. * @param localAxis The local direction that is used to compute the world direction
  8094. * @param mesh The mesh that this bone is attached to
  8095. * @param result The vector3 that the world direction will be copied to
  8096. */
  8097. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8098. /**
  8099. * Get the euler rotation of the bone in local or world space
  8100. * @param space The space that the rotation should be in
  8101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8102. * @returns The euler rotation
  8103. */
  8104. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8105. /**
  8106. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8107. * @param space The space that the rotation should be in
  8108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8109. * @param result The vector3 that the rotation should be copied to
  8110. */
  8111. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8112. /**
  8113. * Get the quaternion rotation of the bone in either local or world space
  8114. * @param space The space that the rotation should be in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. * @returns The quaternion rotation
  8117. */
  8118. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8119. /**
  8120. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8121. * @param space The space that the rotation should be in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. * @param result The quaternion that the rotation should be copied to
  8124. */
  8125. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8126. /**
  8127. * Get the rotation matrix of the bone in local or world space
  8128. * @param space The space that the rotation should be in
  8129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8130. * @returns The rotation matrix
  8131. */
  8132. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8133. /**
  8134. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8135. * @param space The space that the rotation should be in
  8136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8137. * @param result The quaternion that the rotation should be copied to
  8138. */
  8139. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8140. /**
  8141. * Get the world position of a point that is in the local space of the bone
  8142. * @param position The local position
  8143. * @param mesh The mesh that this bone is attached to
  8144. * @returns The world position
  8145. */
  8146. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8147. /**
  8148. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8149. * @param position The local position
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @param result The vector3 that the world position should be copied to
  8152. */
  8153. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8154. /**
  8155. * Get the local position of a point that is in world space
  8156. * @param position The world position
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @returns The local position
  8159. */
  8160. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8161. /**
  8162. * Get the local position of a point that is in world space and copy it to the result param
  8163. * @param position The world position
  8164. * @param mesh The mesh that this bone is attached to
  8165. * @param result The vector3 that the local position should be copied to
  8166. */
  8167. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8168. }
  8169. }
  8170. declare module BABYLON {
  8171. /**
  8172. * Class for creating a cube texture
  8173. */
  8174. export class CubeTexture extends BaseTexture {
  8175. private _delayedOnLoad;
  8176. /**
  8177. * The url of the texture
  8178. */
  8179. url: string;
  8180. /**
  8181. * Gets or sets the center of the bounding box associated with the cube texture.
  8182. * It must define where the camera used to render the texture was set
  8183. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8184. */
  8185. boundingBoxPosition: Vector3;
  8186. private _boundingBoxSize;
  8187. /**
  8188. * Gets or sets the size of the bounding box associated with the cube texture
  8189. * When defined, the cubemap will switch to local mode
  8190. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8191. * @example https://www.babylonjs-playground.com/#RNASML
  8192. */
  8193. /**
  8194. * Returns the bounding box size
  8195. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8196. */
  8197. boundingBoxSize: Vector3;
  8198. protected _rotationY: number;
  8199. /**
  8200. * Sets texture matrix rotation angle around Y axis in radians.
  8201. */
  8202. /**
  8203. * Gets texture matrix rotation angle around Y axis radians.
  8204. */
  8205. rotationY: number;
  8206. /**
  8207. * Are mip maps generated for this texture or not.
  8208. */
  8209. readonly noMipmap: boolean;
  8210. private _noMipmap;
  8211. private _files;
  8212. private _extensions;
  8213. private _textureMatrix;
  8214. private _format;
  8215. private _createPolynomials;
  8216. /** @hidden */
  8217. _prefiltered: boolean;
  8218. /**
  8219. * Creates a cube texture from an array of image urls
  8220. * @param files defines an array of image urls
  8221. * @param scene defines the hosting scene
  8222. * @param noMipmap specifies if mip maps are not used
  8223. * @returns a cube texture
  8224. */
  8225. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8226. /**
  8227. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8228. * @param url defines the url of the prefiltered texture
  8229. * @param scene defines the scene the texture is attached to
  8230. * @param forcedExtension defines the extension of the file if different from the url
  8231. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8232. * @return the prefiltered texture
  8233. */
  8234. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8235. /**
  8236. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8237. * as prefiltered data.
  8238. * @param rootUrl defines the url of the texture or the root name of the six images
  8239. * @param scene defines the scene the texture is attached to
  8240. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8241. * @param noMipmap defines if mipmaps should be created or not
  8242. * @param files defines the six files to load for the different faces
  8243. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8244. * @param onError defines a callback triggered in case of error during load
  8245. * @param format defines the internal format to use for the texture once loaded
  8246. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8247. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8248. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8249. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8250. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8251. * @return the cube texture
  8252. */
  8253. 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);
  8254. /**
  8255. * Get the current class name of the texture useful for serialization or dynamic coding.
  8256. * @returns "CubeTexture"
  8257. */
  8258. getClassName(): string;
  8259. /**
  8260. * Update the url (and optional buffer) of this texture if url was null during construction.
  8261. * @param url the url of the texture
  8262. * @param forcedExtension defines the extension to use
  8263. * @param onLoad callback called when the texture is loaded (defaults to null)
  8264. */
  8265. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8266. /**
  8267. * Delays loading of the cube texture
  8268. * @param forcedExtension defines the extension to use
  8269. */
  8270. delayLoad(forcedExtension?: string): void;
  8271. /**
  8272. * Returns the reflection texture matrix
  8273. * @returns the reflection texture matrix
  8274. */
  8275. getReflectionTextureMatrix(): Matrix;
  8276. /**
  8277. * Sets the reflection texture matrix
  8278. * @param value Reflection texture matrix
  8279. */
  8280. setReflectionTextureMatrix(value: Matrix): void;
  8281. /**
  8282. * Parses text to create a cube texture
  8283. * @param parsedTexture define the serialized text to read from
  8284. * @param scene defines the hosting scene
  8285. * @param rootUrl defines the root url of the cube texture
  8286. * @returns a cube texture
  8287. */
  8288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8289. /**
  8290. * Makes a clone, or deep copy, of the cube texture
  8291. * @returns a new cube texture
  8292. */
  8293. clone(): CubeTexture;
  8294. }
  8295. }
  8296. declare module BABYLON {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module BABYLON {
  8304. /**
  8305. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8306. * This is the base of the follow, arc rotate cameras and Free camera
  8307. * @see http://doc.babylonjs.com/features/cameras
  8308. */
  8309. export class TargetCamera extends Camera {
  8310. private static _RigCamTransformMatrix;
  8311. private static _TargetTransformMatrix;
  8312. private static _TargetFocalPoint;
  8313. /**
  8314. * Define the current direction the camera is moving to
  8315. */
  8316. cameraDirection: Vector3;
  8317. /**
  8318. * Define the current rotation the camera is rotating to
  8319. */
  8320. cameraRotation: Vector2;
  8321. /**
  8322. * When set, the up vector of the camera will be updated by the rotation of the camera
  8323. */
  8324. updateUpVectorFromRotation: boolean;
  8325. private _tmpQuaternion;
  8326. /**
  8327. * Define the current rotation of the camera
  8328. */
  8329. rotation: Vector3;
  8330. /**
  8331. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8332. */
  8333. rotationQuaternion: Quaternion;
  8334. /**
  8335. * Define the current speed of the camera
  8336. */
  8337. speed: number;
  8338. /**
  8339. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8340. * around all axis.
  8341. */
  8342. noRotationConstraint: boolean;
  8343. /**
  8344. * Define the current target of the camera as an object or a position.
  8345. */
  8346. lockedTarget: any;
  8347. /** @hidden */
  8348. _currentTarget: Vector3;
  8349. /** @hidden */
  8350. _initialFocalDistance: number;
  8351. /** @hidden */
  8352. _viewMatrix: Matrix;
  8353. /** @hidden */
  8354. _camMatrix: Matrix;
  8355. /** @hidden */
  8356. _cameraTransformMatrix: Matrix;
  8357. /** @hidden */
  8358. _cameraRotationMatrix: Matrix;
  8359. /** @hidden */
  8360. _referencePoint: Vector3;
  8361. /** @hidden */
  8362. _transformedReferencePoint: Vector3;
  8363. protected _globalCurrentTarget: Vector3;
  8364. protected _globalCurrentUpVector: Vector3;
  8365. /** @hidden */
  8366. _reset: () => void;
  8367. private _defaultUp;
  8368. /**
  8369. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8370. * This is the base of the follow, arc rotate cameras and Free camera
  8371. * @see http://doc.babylonjs.com/features/cameras
  8372. * @param name Defines the name of the camera in the scene
  8373. * @param position Defines the start position of the camera in the scene
  8374. * @param scene Defines the scene the camera belongs to
  8375. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8376. */
  8377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8378. /**
  8379. * Gets the position in front of the camera at a given distance.
  8380. * @param distance The distance from the camera we want the position to be
  8381. * @returns the position
  8382. */
  8383. getFrontPosition(distance: number): Vector3;
  8384. /** @hidden */
  8385. _getLockedTargetPosition(): Nullable<Vector3>;
  8386. private _storedPosition;
  8387. private _storedRotation;
  8388. private _storedRotationQuaternion;
  8389. /**
  8390. * Store current camera state of the camera (fov, position, rotation, etc..)
  8391. * @returns the camera
  8392. */
  8393. storeState(): Camera;
  8394. /**
  8395. * Restored camera state. You must call storeState() first
  8396. * @returns whether it was successful or not
  8397. * @hidden
  8398. */
  8399. _restoreStateValues(): boolean;
  8400. /** @hidden */
  8401. _initCache(): void;
  8402. /** @hidden */
  8403. _updateCache(ignoreParentClass?: boolean): void;
  8404. /** @hidden */
  8405. _isSynchronizedViewMatrix(): boolean;
  8406. /** @hidden */
  8407. _computeLocalCameraSpeed(): number;
  8408. /** @hidden */
  8409. setTarget(target: Vector3): void;
  8410. /**
  8411. * Return the current target position of the camera. This value is expressed in local space.
  8412. * @returns the target position
  8413. */
  8414. getTarget(): Vector3;
  8415. /** @hidden */
  8416. _decideIfNeedsToMove(): boolean;
  8417. /** @hidden */
  8418. _updatePosition(): void;
  8419. /** @hidden */
  8420. _checkInputs(): void;
  8421. protected _updateCameraRotationMatrix(): void;
  8422. /**
  8423. * 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)
  8424. * @returns the current camera
  8425. */
  8426. private _rotateUpVectorWithCameraRotationMatrix;
  8427. private _cachedRotationZ;
  8428. private _cachedQuaternionRotationZ;
  8429. /** @hidden */
  8430. _getViewMatrix(): Matrix;
  8431. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8432. /**
  8433. * @hidden
  8434. */
  8435. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8436. /**
  8437. * @hidden
  8438. */
  8439. _updateRigCameras(): void;
  8440. private _getRigCamPositionAndTarget;
  8441. /**
  8442. * Gets the current object class name.
  8443. * @return the class name
  8444. */
  8445. getClassName(): string;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /**
  8450. * @ignore
  8451. * This is a list of all the different input types that are available in the application.
  8452. * Fo instance: ArcRotateCameraGamepadInput...
  8453. */
  8454. export var CameraInputTypes: {};
  8455. /**
  8456. * This is the contract to implement in order to create a new input class.
  8457. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8458. */
  8459. export interface ICameraInput<TCamera extends Camera> {
  8460. /**
  8461. * Defines the camera the input is attached to.
  8462. */
  8463. camera: Nullable<TCamera>;
  8464. /**
  8465. * Gets the class name of the current intput.
  8466. * @returns the class name
  8467. */
  8468. getClassName(): string;
  8469. /**
  8470. * Get the friendly name associated with the input class.
  8471. * @returns the input friendly name
  8472. */
  8473. getSimpleName(): string;
  8474. /**
  8475. * Attach the input controls to a specific dom element to get the input from.
  8476. * @param element Defines the element the controls should be listened from
  8477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8478. */
  8479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8480. /**
  8481. * Detach the current controls from the specified dom element.
  8482. * @param element Defines the element to stop listening the inputs from
  8483. */
  8484. detachControl(element: Nullable<HTMLElement>): void;
  8485. /**
  8486. * Update the current camera state depending on the inputs that have been used this frame.
  8487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8488. */
  8489. checkInputs?: () => void;
  8490. }
  8491. /**
  8492. * Represents a map of input types to input instance or input index to input instance.
  8493. */
  8494. export interface CameraInputsMap<TCamera extends Camera> {
  8495. /**
  8496. * Accessor to the input by input type.
  8497. */
  8498. [name: string]: ICameraInput<TCamera>;
  8499. /**
  8500. * Accessor to the input by input index.
  8501. */
  8502. [idx: number]: ICameraInput<TCamera>;
  8503. }
  8504. /**
  8505. * This represents the input manager used within a camera.
  8506. * It helps dealing with all the different kind of input attached to a camera.
  8507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8508. */
  8509. export class CameraInputsManager<TCamera extends Camera> {
  8510. /**
  8511. * Defines the list of inputs attahed to the camera.
  8512. */
  8513. attached: CameraInputsMap<TCamera>;
  8514. /**
  8515. * Defines the dom element the camera is collecting inputs from.
  8516. * This is null if the controls have not been attached.
  8517. */
  8518. attachedElement: Nullable<HTMLElement>;
  8519. /**
  8520. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8521. */
  8522. noPreventDefault: boolean;
  8523. /**
  8524. * Defined the camera the input manager belongs to.
  8525. */
  8526. camera: TCamera;
  8527. /**
  8528. * Update the current camera state depending on the inputs that have been used this frame.
  8529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8530. */
  8531. checkInputs: () => void;
  8532. /**
  8533. * Instantiate a new Camera Input Manager.
  8534. * @param camera Defines the camera the input manager blongs to
  8535. */
  8536. constructor(camera: TCamera);
  8537. /**
  8538. * Add an input method to a camera
  8539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8540. * @param input camera input method
  8541. */
  8542. add(input: ICameraInput<TCamera>): void;
  8543. /**
  8544. * Remove a specific input method from a camera
  8545. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8546. * @param inputToRemove camera input method
  8547. */
  8548. remove(inputToRemove: ICameraInput<TCamera>): void;
  8549. /**
  8550. * Remove a specific input type from a camera
  8551. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8552. * @param inputType the type of the input to remove
  8553. */
  8554. removeByType(inputType: string): void;
  8555. private _addCheckInputs;
  8556. /**
  8557. * Attach the input controls to the currently attached dom element to listen the events from.
  8558. * @param input Defines the input to attach
  8559. */
  8560. attachInput(input: ICameraInput<TCamera>): void;
  8561. /**
  8562. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8563. * @param element Defines the dom element to collect the events from
  8564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8565. */
  8566. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8567. /**
  8568. * Detach the current manager inputs controls from a specific dom element.
  8569. * @param element Defines the dom element to collect the events from
  8570. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8571. */
  8572. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8573. /**
  8574. * Rebuild the dynamic inputCheck function from the current list of
  8575. * defined inputs in the manager.
  8576. */
  8577. rebuildInputCheck(): void;
  8578. /**
  8579. * Remove all attached input methods from a camera
  8580. */
  8581. clear(): void;
  8582. /**
  8583. * Serialize the current input manager attached to a camera.
  8584. * This ensures than once parsed,
  8585. * the input associated to the camera will be identical to the current ones
  8586. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8587. */
  8588. serialize(serializedCamera: any): void;
  8589. /**
  8590. * Parses an input manager serialized JSON to restore the previous list of inputs
  8591. * and states associated to a camera.
  8592. * @param parsedCamera Defines the JSON to parse
  8593. */
  8594. parse(parsedCamera: any): void;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. /**
  8599. * Gather the list of keyboard event types as constants.
  8600. */
  8601. export class KeyboardEventTypes {
  8602. /**
  8603. * The keydown event is fired when a key becomes active (pressed).
  8604. */
  8605. static readonly KEYDOWN: number;
  8606. /**
  8607. * The keyup event is fired when a key has been released.
  8608. */
  8609. static readonly KEYUP: number;
  8610. }
  8611. /**
  8612. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8613. */
  8614. export class KeyboardInfo {
  8615. /**
  8616. * Defines the type of event (KeyboardEventTypes)
  8617. */
  8618. type: number;
  8619. /**
  8620. * Defines the related dom event
  8621. */
  8622. event: KeyboardEvent;
  8623. /**
  8624. * Instantiates a new keyboard info.
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. * @param type Defines the type of event (KeyboardEventTypes)
  8627. * @param event Defines the related dom event
  8628. */
  8629. constructor(
  8630. /**
  8631. * Defines the type of event (KeyboardEventTypes)
  8632. */
  8633. type: number,
  8634. /**
  8635. * Defines the related dom event
  8636. */
  8637. event: KeyboardEvent);
  8638. }
  8639. /**
  8640. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8641. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8642. */
  8643. export class KeyboardInfoPre extends KeyboardInfo {
  8644. /**
  8645. * Defines the type of event (KeyboardEventTypes)
  8646. */
  8647. type: number;
  8648. /**
  8649. * Defines the related dom event
  8650. */
  8651. event: KeyboardEvent;
  8652. /**
  8653. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8654. */
  8655. skipOnPointerObservable: boolean;
  8656. /**
  8657. * Instantiates a new keyboard pre info.
  8658. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8659. * @param type Defines the type of event (KeyboardEventTypes)
  8660. * @param event Defines the related dom event
  8661. */
  8662. constructor(
  8663. /**
  8664. * Defines the type of event (KeyboardEventTypes)
  8665. */
  8666. type: number,
  8667. /**
  8668. * Defines the related dom event
  8669. */
  8670. event: KeyboardEvent);
  8671. }
  8672. }
  8673. declare module BABYLON {
  8674. /**
  8675. * Manage the keyboard inputs to control the movement of a free camera.
  8676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8677. */
  8678. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8679. /**
  8680. * Defines the camera the input is attached to.
  8681. */
  8682. camera: FreeCamera;
  8683. /**
  8684. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8685. */
  8686. keysUp: number[];
  8687. /**
  8688. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8689. */
  8690. keysDown: number[];
  8691. /**
  8692. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8693. */
  8694. keysLeft: number[];
  8695. /**
  8696. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8697. */
  8698. keysRight: number[];
  8699. private _keys;
  8700. private _onCanvasBlurObserver;
  8701. private _onKeyboardObserver;
  8702. private _engine;
  8703. private _scene;
  8704. /**
  8705. * Attach the input controls to a specific dom element to get the input from.
  8706. * @param element Defines the element the controls should be listened from
  8707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8708. */
  8709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8710. /**
  8711. * Detach the current controls from the specified dom element.
  8712. * @param element Defines the element to stop listening the inputs from
  8713. */
  8714. detachControl(element: Nullable<HTMLElement>): void;
  8715. /**
  8716. * Update the current camera state depending on the inputs that have been used this frame.
  8717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8718. */
  8719. checkInputs(): void;
  8720. /**
  8721. * Gets the class name of the current intput.
  8722. * @returns the class name
  8723. */
  8724. getClassName(): string;
  8725. /** @hidden */
  8726. _onLostFocus(): void;
  8727. /**
  8728. * Get the friendly name associated with the input class.
  8729. * @returns the input friendly name
  8730. */
  8731. getSimpleName(): string;
  8732. }
  8733. }
  8734. declare module BABYLON {
  8735. /**
  8736. * Interface describing all the common properties and methods a shadow light needs to implement.
  8737. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8738. * as well as binding the different shadow properties to the effects.
  8739. */
  8740. export interface IShadowLight extends Light {
  8741. /**
  8742. * The light id in the scene (used in scene.findLighById for instance)
  8743. */
  8744. id: string;
  8745. /**
  8746. * The position the shdow will be casted from.
  8747. */
  8748. position: Vector3;
  8749. /**
  8750. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8751. */
  8752. direction: Vector3;
  8753. /**
  8754. * The transformed position. Position of the light in world space taking parenting in account.
  8755. */
  8756. transformedPosition: Vector3;
  8757. /**
  8758. * The transformed direction. Direction of the light in world space taking parenting in account.
  8759. */
  8760. transformedDirection: Vector3;
  8761. /**
  8762. * The friendly name of the light in the scene.
  8763. */
  8764. name: string;
  8765. /**
  8766. * Defines the shadow projection clipping minimum z value.
  8767. */
  8768. shadowMinZ: number;
  8769. /**
  8770. * Defines the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8775. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8776. */
  8777. computeTransformedInformation(): boolean;
  8778. /**
  8779. * Gets the scene the light belongs to.
  8780. * @returns The scene
  8781. */
  8782. getScene(): Scene;
  8783. /**
  8784. * Callback defining a custom Projection Matrix Builder.
  8785. * This can be used to override the default projection matrix computation.
  8786. */
  8787. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8788. /**
  8789. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8790. * @param matrix The materix to updated with the projection information
  8791. * @param viewMatrix The transform matrix of the light
  8792. * @param renderList The list of mesh to render in the map
  8793. * @returns The current light
  8794. */
  8795. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8796. /**
  8797. * Gets the current depth scale used in ESM.
  8798. * @returns The scale
  8799. */
  8800. getDepthScale(): number;
  8801. /**
  8802. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8803. * @returns true if a cube texture needs to be use
  8804. */
  8805. needCube(): boolean;
  8806. /**
  8807. * Detects if the projection matrix requires to be recomputed this frame.
  8808. * @returns true if it requires to be recomputed otherwise, false.
  8809. */
  8810. needProjectionMatrixCompute(): boolean;
  8811. /**
  8812. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8813. */
  8814. forceProjectionMatrixCompute(): void;
  8815. /**
  8816. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8817. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8818. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8819. */
  8820. getShadowDirection(faceIndex?: number): Vector3;
  8821. /**
  8822. * Gets the minZ used for shadow according to both the scene and the light.
  8823. * @param activeCamera The camera we are returning the min for
  8824. * @returns the depth min z
  8825. */
  8826. getDepthMinZ(activeCamera: Camera): number;
  8827. /**
  8828. * Gets the maxZ used for shadow according to both the scene and the light.
  8829. * @param activeCamera The camera we are returning the max for
  8830. * @returns the depth max z
  8831. */
  8832. getDepthMaxZ(activeCamera: Camera): number;
  8833. }
  8834. /**
  8835. * Base implementation IShadowLight
  8836. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8837. */
  8838. export abstract class ShadowLight extends Light implements IShadowLight {
  8839. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8840. protected _position: Vector3;
  8841. protected _setPosition(value: Vector3): void;
  8842. /**
  8843. * Sets the position the shadow will be casted from. Also use as the light position for both
  8844. * point and spot lights.
  8845. */
  8846. /**
  8847. * Sets the position the shadow will be casted from. Also use as the light position for both
  8848. * point and spot lights.
  8849. */
  8850. position: Vector3;
  8851. protected _direction: Vector3;
  8852. protected _setDirection(value: Vector3): void;
  8853. /**
  8854. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8855. * Also use as the light direction on spot and directional lights.
  8856. */
  8857. /**
  8858. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8859. * Also use as the light direction on spot and directional lights.
  8860. */
  8861. direction: Vector3;
  8862. private _shadowMinZ;
  8863. /**
  8864. * Gets the shadow projection clipping minimum z value.
  8865. */
  8866. /**
  8867. * Sets the shadow projection clipping minimum z value.
  8868. */
  8869. shadowMinZ: number;
  8870. private _shadowMaxZ;
  8871. /**
  8872. * Sets the shadow projection clipping maximum z value.
  8873. */
  8874. /**
  8875. * Gets the shadow projection clipping maximum z value.
  8876. */
  8877. shadowMaxZ: number;
  8878. /**
  8879. * Callback defining a custom Projection Matrix Builder.
  8880. * This can be used to override the default projection matrix computation.
  8881. */
  8882. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8883. /**
  8884. * The transformed position. Position of the light in world space taking parenting in account.
  8885. */
  8886. transformedPosition: Vector3;
  8887. /**
  8888. * The transformed direction. Direction of the light in world space taking parenting in account.
  8889. */
  8890. transformedDirection: Vector3;
  8891. private _needProjectionMatrixCompute;
  8892. /**
  8893. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8894. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8895. */
  8896. computeTransformedInformation(): boolean;
  8897. /**
  8898. * Return the depth scale used for the shadow map.
  8899. * @returns the depth scale.
  8900. */
  8901. getDepthScale(): number;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Returns the ShadowLight absolute position in the World.
  8910. * @returns the position vector in world space
  8911. */
  8912. getAbsolutePosition(): Vector3;
  8913. /**
  8914. * Sets the ShadowLight direction toward the passed target.
  8915. * @param target The point to target in local space
  8916. * @returns the updated ShadowLight direction
  8917. */
  8918. setDirectionToTarget(target: Vector3): Vector3;
  8919. /**
  8920. * Returns the light rotation in euler definition.
  8921. * @returns the x y z rotation in local space.
  8922. */
  8923. getRotation(): Vector3;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /** @hidden */
  8939. _initCache(): void;
  8940. /** @hidden */
  8941. _isSynchronized(): boolean;
  8942. /**
  8943. * Computes the world matrix of the node
  8944. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8945. * @returns the world matrix
  8946. */
  8947. computeWorldMatrix(force?: boolean): Matrix;
  8948. /**
  8949. * Gets the minZ used for shadow according to both the scene and the light.
  8950. * @param activeCamera The camera we are returning the min for
  8951. * @returns the depth min z
  8952. */
  8953. getDepthMinZ(activeCamera: Camera): number;
  8954. /**
  8955. * Gets the maxZ used for shadow according to both the scene and the light.
  8956. * @param activeCamera The camera we are returning the max for
  8957. * @returns the depth max z
  8958. */
  8959. getDepthMaxZ(activeCamera: Camera): number;
  8960. /**
  8961. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8962. * @param matrix The materix to updated with the projection information
  8963. * @param viewMatrix The transform matrix of the light
  8964. * @param renderList The list of mesh to render in the map
  8965. * @returns The current light
  8966. */
  8967. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8968. }
  8969. }
  8970. declare module BABYLON {
  8971. /**
  8972. * "Static Class" containing the most commonly used helper while dealing with material for
  8973. * rendering purpose.
  8974. *
  8975. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8976. *
  8977. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8978. */
  8979. export class MaterialHelper {
  8980. /**
  8981. * Bind the current view position to an effect.
  8982. * @param effect The effect to be bound
  8983. * @param scene The scene the eyes position is used from
  8984. */
  8985. static BindEyePosition(effect: Effect, scene: Scene): void;
  8986. /**
  8987. * Helps preparing the defines values about the UVs in used in the effect.
  8988. * UVs are shared as much as we can accross channels in the shaders.
  8989. * @param texture The texture we are preparing the UVs for
  8990. * @param defines The defines to update
  8991. * @param key The channel key "diffuse", "specular"... used in the shader
  8992. */
  8993. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8994. /**
  8995. * Binds a texture matrix value to its corrsponding uniform
  8996. * @param texture The texture to bind the matrix for
  8997. * @param uniformBuffer The uniform buffer receivin the data
  8998. * @param key The channel key "diffuse", "specular"... used in the shader
  8999. */
  9000. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9001. /**
  9002. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9003. * @param mesh defines the current mesh
  9004. * @param scene defines the current scene
  9005. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9006. * @param pointsCloud defines if point cloud rendering has to be turned on
  9007. * @param fogEnabled defines if fog has to be turned on
  9008. * @param alphaTest defines if alpha testing has to be turned on
  9009. * @param defines defines the current list of defines
  9010. */
  9011. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9012. /**
  9013. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9014. * @param scene defines the current scene
  9015. * @param engine defines the current engine
  9016. * @param defines specifies the list of active defines
  9017. * @param useInstances defines if instances have to be turned on
  9018. * @param useClipPlane defines if clip plane have to be turned on
  9019. */
  9020. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9021. /**
  9022. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9023. * @param mesh The mesh containing the geometry data we will draw
  9024. * @param defines The defines to update
  9025. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9026. * @param useBones Precise whether bones should be used or not (override mesh info)
  9027. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9028. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9029. * @returns false if defines are considered not dirty and have not been checked
  9030. */
  9031. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9032. /**
  9033. * Prepares the defines related to the light information passed in parameter
  9034. * @param scene The scene we are intending to draw
  9035. * @param mesh The mesh the effect is compiling for
  9036. * @param defines The defines to update
  9037. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9038. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9039. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9040. * @returns true if normals will be required for the rest of the effect
  9041. */
  9042. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9043. /**
  9044. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9045. * that won t be acctive due to defines being turned off.
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The samplers list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. /**
  9062. * Prepares the list of attributes required for morph targets according to the effect defines.
  9063. * @param attribs The current list of supported attribs
  9064. * @param mesh The mesh to prepare the morph targets attributes for
  9065. * @param defines The current Defines of the effect
  9066. */
  9067. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9068. /**
  9069. * Prepares the list of attributes required for bones according to the effect defines.
  9070. * @param attribs The current list of supported attribs
  9071. * @param mesh The mesh to prepare the bones attributes for
  9072. * @param defines The current Defines of the effect
  9073. * @param fallbacks The current efffect fallback strategy
  9074. */
  9075. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9076. /**
  9077. * Prepares the list of attributes required for instances according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param defines The current Defines of the effect
  9080. */
  9081. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9082. /**
  9083. * Binds the light shadow information to the effect for the given mesh.
  9084. * @param light The light containing the generator
  9085. * @param scene The scene the lights belongs to
  9086. * @param mesh The mesh we are binding the information to render
  9087. * @param lightIndex The light index in the effect used to render the mesh
  9088. * @param effect The effect we are binding the data to
  9089. */
  9090. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9091. /**
  9092. * Binds the light information to the effect.
  9093. * @param light The light containing the generator
  9094. * @param effect The effect we are binding the data to
  9095. * @param lightIndex The light index in the effect used to render
  9096. */
  9097. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9098. /**
  9099. * Binds the lights information from the scene to the effect for the given mesh.
  9100. * @param scene The scene the lights belongs to
  9101. * @param mesh The mesh we are binding the information to render
  9102. * @param effect The effect we are binding the data to
  9103. * @param defines The generated defines for the effect
  9104. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9105. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9106. */
  9107. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9108. private static _tempFogColor;
  9109. /**
  9110. * Binds the fog information from the scene to the effect for the given mesh.
  9111. * @param scene The scene the lights belongs to
  9112. * @param mesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. * @param linearSpace Defines if the fog effect is applied in linear space
  9115. */
  9116. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9117. /**
  9118. * Binds the bones information from the mesh to the effect.
  9119. * @param mesh The mesh we are binding the information to render
  9120. * @param effect The effect we are binding the data to
  9121. */
  9122. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9123. /**
  9124. * Binds the morph targets information from the mesh to the effect.
  9125. * @param abstractMesh The mesh we are binding the information to render
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9129. /**
  9130. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9131. * @param defines The generated defines used in the effect
  9132. * @param effect The effect we are binding the data to
  9133. * @param scene The scene we are willing to render with logarithmic scale for
  9134. */
  9135. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9136. /**
  9137. * Binds the clip plane information from the scene to the effect.
  9138. * @param scene The scene the clip plane information are extracted from
  9139. * @param effect The effect we are binding the data to
  9140. */
  9141. static BindClipPlane(effect: Effect, scene: Scene): void;
  9142. }
  9143. }
  9144. declare module BABYLON {
  9145. /** @hidden */
  9146. export var kernelBlurVaryingDeclaration: {
  9147. name: string;
  9148. shader: string;
  9149. };
  9150. }
  9151. declare module BABYLON {
  9152. /** @hidden */
  9153. export var kernelBlurFragment: {
  9154. name: string;
  9155. shader: string;
  9156. };
  9157. }
  9158. declare module BABYLON {
  9159. /** @hidden */
  9160. export var kernelBlurFragment2: {
  9161. name: string;
  9162. shader: string;
  9163. };
  9164. }
  9165. declare module BABYLON {
  9166. /** @hidden */
  9167. export var kernelBlurPixelShader: {
  9168. name: string;
  9169. shader: string;
  9170. };
  9171. }
  9172. declare module BABYLON {
  9173. /** @hidden */
  9174. export var kernelBlurVertex: {
  9175. name: string;
  9176. shader: string;
  9177. };
  9178. }
  9179. declare module BABYLON {
  9180. /** @hidden */
  9181. export var kernelBlurVertexShader: {
  9182. name: string;
  9183. shader: string;
  9184. };
  9185. }
  9186. declare module BABYLON {
  9187. /**
  9188. * The Blur Post Process which blurs an image based on a kernel and direction.
  9189. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9190. */
  9191. export class BlurPostProcess extends PostProcess {
  9192. /** The direction in which to blur the image. */
  9193. direction: Vector2;
  9194. private blockCompilation;
  9195. protected _kernel: number;
  9196. protected _idealKernel: number;
  9197. protected _packedFloat: boolean;
  9198. private _staticDefines;
  9199. /**
  9200. * Sets the length in pixels of the blur sample region
  9201. */
  9202. /**
  9203. * Gets the length in pixels of the blur sample region
  9204. */
  9205. kernel: number;
  9206. /**
  9207. * Sets wether or not the blur needs to unpack/repack floats
  9208. */
  9209. /**
  9210. * Gets wether or not the blur is unpacking/repacking floats
  9211. */
  9212. packedFloat: boolean;
  9213. /**
  9214. * Creates a new instance BlurPostProcess
  9215. * @param name The name of the effect.
  9216. * @param direction The direction in which to blur the image.
  9217. * @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.
  9218. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9219. * @param camera The camera to apply the render pass to.
  9220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9221. * @param engine The engine which the post process will be applied. (default: current engine)
  9222. * @param reusable If the post process can be reused on the same frame. (default: false)
  9223. * @param textureType Type of textures used when performing the post process. (default: 0)
  9224. * @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)
  9225. */
  9226. constructor(name: string,
  9227. /** The direction in which to blur the image. */
  9228. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9229. /**
  9230. * Updates the effect with the current post process compile time values and recompiles the shader.
  9231. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9232. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9233. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9234. * @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
  9235. * @param onCompiled Called when the shader has been compiled.
  9236. * @param onError Called if there is an error when compiling a shader.
  9237. */
  9238. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9239. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9240. /**
  9241. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9242. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9243. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9244. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9245. * The gaps between physical kernels are compensated for in the weighting of the samples
  9246. * @param idealKernel Ideal blur kernel.
  9247. * @return Nearest best kernel.
  9248. */
  9249. protected _nearestBestKernel(idealKernel: number): number;
  9250. /**
  9251. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9252. * @param x The point on the Gaussian distribution to sample.
  9253. * @return the value of the Gaussian function at x.
  9254. */
  9255. protected _gaussianWeight(x: number): number;
  9256. /**
  9257. * Generates a string that can be used as a floating point number in GLSL.
  9258. * @param x Value to print.
  9259. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9260. * @return GLSL float string.
  9261. */
  9262. protected _glslFloat(x: number, decimalFigures?: number): string;
  9263. }
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapPixelShader: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var bonesDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertexGlobalDeclaration: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var morphTargetsVertexDeclaration: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var instancesDeclaration: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var helperFunctions: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var morphTargetsVertex: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var instancesVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var bonesVertex: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var shadowMapVertexShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var depthBoxBlurPixelShader: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9345. */
  9346. export interface ICustomShaderOptions {
  9347. /**
  9348. * Gets or sets the custom shader name to use
  9349. */
  9350. shaderName: string;
  9351. /**
  9352. * The list of attribute names used in the shader
  9353. */
  9354. attributes?: string[];
  9355. /**
  9356. * The list of unifrom names used in the shader
  9357. */
  9358. uniforms?: string[];
  9359. /**
  9360. * The list of sampler names used in the shader
  9361. */
  9362. samplers?: string[];
  9363. /**
  9364. * The list of defines used in the shader
  9365. */
  9366. defines?: string[];
  9367. }
  9368. /**
  9369. * Interface to implement to create a shadow generator compatible with BJS.
  9370. */
  9371. export interface IShadowGenerator {
  9372. /**
  9373. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9374. * @returns The render target texture if present otherwise, null
  9375. */
  9376. getShadowMap(): Nullable<RenderTargetTexture>;
  9377. /**
  9378. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9379. * @returns The render target texture if the shadow map is present otherwise, null
  9380. */
  9381. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9382. /**
  9383. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9384. * @param subMesh The submesh we want to render in the shadow map
  9385. * @param useInstances Defines wether will draw in the map using instances
  9386. * @returns true if ready otherwise, false
  9387. */
  9388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9389. /**
  9390. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9391. * @param defines Defines of the material we want to update
  9392. * @param lightIndex Index of the light in the enabled light list of the material
  9393. */
  9394. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9395. /**
  9396. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9397. * defined in the generator but impacting the effect).
  9398. * It implies the unifroms available on the materials are the standard BJS ones.
  9399. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9400. * @param effect The effect we are binfing the information for
  9401. */
  9402. bindShadowLight(lightIndex: string, effect: Effect): void;
  9403. /**
  9404. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9405. * (eq to shadow prjection matrix * light transform matrix)
  9406. * @returns The transform matrix used to create the shadow map
  9407. */
  9408. getTransformMatrix(): Matrix;
  9409. /**
  9410. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9411. * Cube and 2D textures for instance.
  9412. */
  9413. recreateShadowMap(): void;
  9414. /**
  9415. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9416. * @param onCompiled Callback triggered at the and of the effects compilation
  9417. * @param options Sets of optional options forcing the compilation with different modes
  9418. */
  9419. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9420. useInstances: boolean;
  9421. }>): void;
  9422. /**
  9423. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9424. * @param options Sets of optional options forcing the compilation with different modes
  9425. * @returns A promise that resolves when the compilation completes
  9426. */
  9427. forceCompilationAsync(options?: Partial<{
  9428. useInstances: boolean;
  9429. }>): Promise<void>;
  9430. /**
  9431. * Serializes the shadow generator setup to a json object.
  9432. * @returns The serialized JSON object
  9433. */
  9434. serialize(): any;
  9435. /**
  9436. * Disposes the Shadow map and related Textures and effects.
  9437. */
  9438. dispose(): void;
  9439. }
  9440. /**
  9441. * Default implementation IShadowGenerator.
  9442. * This is the main object responsible of generating shadows in the framework.
  9443. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9444. */
  9445. export class ShadowGenerator implements IShadowGenerator {
  9446. /**
  9447. * Shadow generator mode None: no filtering applied.
  9448. */
  9449. static readonly FILTER_NONE: number;
  9450. /**
  9451. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9453. */
  9454. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9455. /**
  9456. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9457. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9458. */
  9459. static readonly FILTER_POISSONSAMPLING: number;
  9460. /**
  9461. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9463. */
  9464. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9465. /**
  9466. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9467. * edge artifacts on steep falloff.
  9468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9469. */
  9470. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9471. /**
  9472. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9473. * edge artifacts on steep falloff.
  9474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9475. */
  9476. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9477. /**
  9478. * Shadow generator mode PCF: Percentage Closer Filtering
  9479. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9480. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9481. */
  9482. static readonly FILTER_PCF: number;
  9483. /**
  9484. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9485. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9486. * Contact Hardening
  9487. */
  9488. static readonly FILTER_PCSS: number;
  9489. /**
  9490. * Reserved for PCF and PCSS
  9491. * Highest Quality.
  9492. *
  9493. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9494. *
  9495. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9496. */
  9497. static readonly QUALITY_HIGH: number;
  9498. /**
  9499. * Reserved for PCF and PCSS
  9500. * Good tradeoff for quality/perf cross devices
  9501. *
  9502. * Execute PCF on a 3*3 kernel.
  9503. *
  9504. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9505. */
  9506. static readonly QUALITY_MEDIUM: number;
  9507. /**
  9508. * Reserved for PCF and PCSS
  9509. * The lowest quality but the fastest.
  9510. *
  9511. * Execute PCF on a 1*1 kernel.
  9512. *
  9513. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9514. */
  9515. static readonly QUALITY_LOW: number;
  9516. /** Gets or sets the custom shader name to use */
  9517. customShaderOptions: ICustomShaderOptions;
  9518. /**
  9519. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9520. */
  9521. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9522. private _bias;
  9523. /**
  9524. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9525. */
  9526. /**
  9527. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9528. */
  9529. bias: number;
  9530. private _normalBias;
  9531. /**
  9532. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9533. */
  9534. /**
  9535. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9536. */
  9537. normalBias: number;
  9538. private _blurBoxOffset;
  9539. /**
  9540. * Gets the blur box offset: offset applied during the blur pass.
  9541. * Only useful if useKernelBlur = false
  9542. */
  9543. /**
  9544. * Sets the blur box offset: offset applied during the blur pass.
  9545. * Only useful if useKernelBlur = false
  9546. */
  9547. blurBoxOffset: number;
  9548. private _blurScale;
  9549. /**
  9550. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9551. * 2 means half of the size.
  9552. */
  9553. /**
  9554. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9555. * 2 means half of the size.
  9556. */
  9557. blurScale: number;
  9558. private _blurKernel;
  9559. /**
  9560. * Gets the blur kernel: kernel size of the blur pass.
  9561. * Only useful if useKernelBlur = true
  9562. */
  9563. /**
  9564. * Sets the blur kernel: kernel size of the blur pass.
  9565. * Only useful if useKernelBlur = true
  9566. */
  9567. blurKernel: number;
  9568. private _useKernelBlur;
  9569. /**
  9570. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9571. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9572. */
  9573. /**
  9574. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9575. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9576. */
  9577. useKernelBlur: boolean;
  9578. private _depthScale;
  9579. /**
  9580. * Gets the depth scale used in ESM mode.
  9581. */
  9582. /**
  9583. * Sets the depth scale used in ESM mode.
  9584. * This can override the scale stored on the light.
  9585. */
  9586. depthScale: number;
  9587. private _filter;
  9588. /**
  9589. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9591. */
  9592. /**
  9593. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9594. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9595. */
  9596. filter: number;
  9597. /**
  9598. * Gets if the current filter is set to Poisson Sampling.
  9599. */
  9600. /**
  9601. * Sets the current filter to Poisson Sampling.
  9602. */
  9603. usePoissonSampling: boolean;
  9604. /**
  9605. * Gets if the current filter is set to ESM.
  9606. */
  9607. /**
  9608. * Sets the current filter is to ESM.
  9609. */
  9610. useExponentialShadowMap: boolean;
  9611. /**
  9612. * Gets if the current filter is set to filtered ESM.
  9613. */
  9614. /**
  9615. * Gets if the current filter is set to filtered ESM.
  9616. */
  9617. useBlurExponentialShadowMap: boolean;
  9618. /**
  9619. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9620. * exponential to prevent steep falloff artifacts).
  9621. */
  9622. /**
  9623. * Sets the current filter to "close ESM" (using the inverse of the
  9624. * exponential to prevent steep falloff artifacts).
  9625. */
  9626. useCloseExponentialShadowMap: boolean;
  9627. /**
  9628. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9629. * exponential to prevent steep falloff artifacts).
  9630. */
  9631. /**
  9632. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. useBlurCloseExponentialShadowMap: boolean;
  9636. /**
  9637. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9638. */
  9639. /**
  9640. * Sets the current filter to "PCF" (percentage closer filtering).
  9641. */
  9642. usePercentageCloserFiltering: boolean;
  9643. private _filteringQuality;
  9644. /**
  9645. * Gets the PCF or PCSS Quality.
  9646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9647. */
  9648. /**
  9649. * Sets the PCF or PCSS Quality.
  9650. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9651. */
  9652. filteringQuality: number;
  9653. /**
  9654. * Gets if the current filter is set to "PCSS" (contact hardening).
  9655. */
  9656. /**
  9657. * Sets the current filter to "PCSS" (contact hardening).
  9658. */
  9659. useContactHardeningShadow: boolean;
  9660. private _contactHardeningLightSizeUVRatio;
  9661. /**
  9662. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9663. * Using a ratio helps keeping shape stability independently of the map size.
  9664. *
  9665. * It does not account for the light projection as it was having too much
  9666. * instability during the light setup or during light position changes.
  9667. *
  9668. * Only valid if useContactHardeningShadow is true.
  9669. */
  9670. /**
  9671. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9672. * Using a ratio helps keeping shape stability independently of the map size.
  9673. *
  9674. * It does not account for the light projection as it was having too much
  9675. * instability during the light setup or during light position changes.
  9676. *
  9677. * Only valid if useContactHardeningShadow is true.
  9678. */
  9679. contactHardeningLightSizeUVRatio: number;
  9680. private _darkness;
  9681. /**
  9682. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9683. * 0 means strongest and 1 would means no shadow.
  9684. * @returns the darkness.
  9685. */
  9686. getDarkness(): number;
  9687. /**
  9688. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9689. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9690. * @returns the shadow generator allowing fluent coding.
  9691. */
  9692. setDarkness(darkness: number): ShadowGenerator;
  9693. private _transparencyShadow;
  9694. /**
  9695. * Sets the ability to have transparent shadow (boolean).
  9696. * @param transparent True if transparent else False
  9697. * @returns the shadow generator allowing fluent coding
  9698. */
  9699. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9700. private _shadowMap;
  9701. private _shadowMap2;
  9702. /**
  9703. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9704. * @returns The render target texture if present otherwise, null
  9705. */
  9706. getShadowMap(): Nullable<RenderTargetTexture>;
  9707. /**
  9708. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9709. * @returns The render target texture if the shadow map is present otherwise, null
  9710. */
  9711. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9712. /**
  9713. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9714. * @param mesh Mesh to add
  9715. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9716. * @returns the Shadow Generator itself
  9717. */
  9718. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9719. /**
  9720. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9721. * @param mesh Mesh to remove
  9722. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9723. * @returns the Shadow Generator itself
  9724. */
  9725. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9726. /**
  9727. * Controls the extent to which the shadows fade out at the edge of the frustum
  9728. * Used only by directionals and spots
  9729. */
  9730. frustumEdgeFalloff: number;
  9731. private _light;
  9732. /**
  9733. * Returns the associated light object.
  9734. * @returns the light generating the shadow
  9735. */
  9736. getLight(): IShadowLight;
  9737. /**
  9738. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9739. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9740. * It might on the other hand introduce peter panning.
  9741. */
  9742. forceBackFacesOnly: boolean;
  9743. private _scene;
  9744. private _lightDirection;
  9745. private _effect;
  9746. private _viewMatrix;
  9747. private _projectionMatrix;
  9748. private _transformMatrix;
  9749. private _cachedPosition;
  9750. private _cachedDirection;
  9751. private _cachedDefines;
  9752. private _currentRenderID;
  9753. private _boxBlurPostprocess;
  9754. private _kernelBlurXPostprocess;
  9755. private _kernelBlurYPostprocess;
  9756. private _blurPostProcesses;
  9757. private _mapSize;
  9758. private _currentFaceIndex;
  9759. private _currentFaceIndexCache;
  9760. private _textureType;
  9761. private _defaultTextureMatrix;
  9762. /** @hidden */
  9763. static _SceneComponentInitialization: (scene: Scene) => void;
  9764. /**
  9765. * Creates a ShadowGenerator object.
  9766. * A ShadowGenerator is the required tool to use the shadows.
  9767. * Each light casting shadows needs to use its own ShadowGenerator.
  9768. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9769. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9770. * @param light The light object generating the shadows.
  9771. * @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.
  9772. */
  9773. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9774. private _initializeGenerator;
  9775. private _initializeShadowMap;
  9776. private _initializeBlurRTTAndPostProcesses;
  9777. private _renderForShadowMap;
  9778. private _renderSubMeshForShadowMap;
  9779. private _applyFilterValues;
  9780. /**
  9781. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9782. * @param onCompiled Callback triggered at the and of the effects compilation
  9783. * @param options Sets of optional options forcing the compilation with different modes
  9784. */
  9785. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9786. useInstances: boolean;
  9787. }>): void;
  9788. /**
  9789. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9790. * @param options Sets of optional options forcing the compilation with different modes
  9791. * @returns A promise that resolves when the compilation completes
  9792. */
  9793. forceCompilationAsync(options?: Partial<{
  9794. useInstances: boolean;
  9795. }>): Promise<void>;
  9796. /**
  9797. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9798. * @param subMesh The submesh we want to render in the shadow map
  9799. * @param useInstances Defines wether will draw in the map using instances
  9800. * @returns true if ready otherwise, false
  9801. */
  9802. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9803. /**
  9804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9805. * @param defines Defines of the material we want to update
  9806. * @param lightIndex Index of the light in the enabled light list of the material
  9807. */
  9808. prepareDefines(defines: any, lightIndex: number): void;
  9809. /**
  9810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9811. * defined in the generator but impacting the effect).
  9812. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9813. * @param effect The effect we are binfing the information for
  9814. */
  9815. bindShadowLight(lightIndex: string, effect: Effect): void;
  9816. /**
  9817. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9818. * (eq to shadow prjection matrix * light transform matrix)
  9819. * @returns The transform matrix used to create the shadow map
  9820. */
  9821. getTransformMatrix(): Matrix;
  9822. /**
  9823. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9824. * Cube and 2D textures for instance.
  9825. */
  9826. recreateShadowMap(): void;
  9827. private _disposeBlurPostProcesses;
  9828. private _disposeRTTandPostProcesses;
  9829. /**
  9830. * Disposes the ShadowGenerator.
  9831. * Returns nothing.
  9832. */
  9833. dispose(): void;
  9834. /**
  9835. * Serializes the shadow generator setup to a json object.
  9836. * @returns The serialized JSON object
  9837. */
  9838. serialize(): any;
  9839. /**
  9840. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9841. * @param parsedShadowGenerator The JSON object to parse
  9842. * @param scene The scene to create the shadow map for
  9843. * @returns The parsed shadow generator
  9844. */
  9845. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9846. }
  9847. }
  9848. declare module BABYLON {
  9849. /**
  9850. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9851. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9852. * 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.
  9853. */
  9854. export abstract class Light extends Node {
  9855. /**
  9856. * Falloff Default: light is falling off following the material specification:
  9857. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9858. */
  9859. static readonly FALLOFF_DEFAULT: number;
  9860. /**
  9861. * Falloff Physical: light is falling off following the inverse squared distance law.
  9862. */
  9863. static readonly FALLOFF_PHYSICAL: number;
  9864. /**
  9865. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9866. * to enhance interoperability with other engines.
  9867. */
  9868. static readonly FALLOFF_GLTF: number;
  9869. /**
  9870. * Falloff Standard: light is falling off like in the standard material
  9871. * to enhance interoperability with other materials.
  9872. */
  9873. static readonly FALLOFF_STANDARD: number;
  9874. /**
  9875. * If every light affecting the material is in this lightmapMode,
  9876. * material.lightmapTexture adds or multiplies
  9877. * (depends on material.useLightmapAsShadowmap)
  9878. * after every other light calculations.
  9879. */
  9880. static readonly LIGHTMAP_DEFAULT: number;
  9881. /**
  9882. * material.lightmapTexture as only diffuse lighting from this light
  9883. * adds only specular lighting from this light
  9884. * adds dynamic shadows
  9885. */
  9886. static readonly LIGHTMAP_SPECULAR: number;
  9887. /**
  9888. * material.lightmapTexture as only lighting
  9889. * no light calculation from this light
  9890. * only adds dynamic shadows from this light
  9891. */
  9892. static readonly LIGHTMAP_SHADOWSONLY: number;
  9893. /**
  9894. * Each light type uses the default quantity according to its type:
  9895. * point/spot lights use luminous intensity
  9896. * directional lights use illuminance
  9897. */
  9898. static readonly INTENSITYMODE_AUTOMATIC: number;
  9899. /**
  9900. * lumen (lm)
  9901. */
  9902. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9903. /**
  9904. * candela (lm/sr)
  9905. */
  9906. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9907. /**
  9908. * lux (lm/m^2)
  9909. */
  9910. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9911. /**
  9912. * nit (cd/m^2)
  9913. */
  9914. static readonly INTENSITYMODE_LUMINANCE: number;
  9915. /**
  9916. * Light type const id of the point light.
  9917. */
  9918. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9919. /**
  9920. * Light type const id of the directional light.
  9921. */
  9922. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9923. /**
  9924. * Light type const id of the spot light.
  9925. */
  9926. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9927. /**
  9928. * Light type const id of the hemispheric light.
  9929. */
  9930. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9931. /**
  9932. * Diffuse gives the basic color to an object.
  9933. */
  9934. diffuse: Color3;
  9935. /**
  9936. * Specular produces a highlight color on an object.
  9937. * Note: This is note affecting PBR materials.
  9938. */
  9939. specular: Color3;
  9940. /**
  9941. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9942. * falling off base on range or angle.
  9943. * This can be set to any values in Light.FALLOFF_x.
  9944. *
  9945. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9946. * other types of materials.
  9947. */
  9948. falloffType: number;
  9949. /**
  9950. * Strength of the light.
  9951. * Note: By default it is define in the framework own unit.
  9952. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9953. */
  9954. intensity: number;
  9955. private _range;
  9956. protected _inverseSquaredRange: number;
  9957. /**
  9958. * Defines how far from the source the light is impacting in scene units.
  9959. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9960. */
  9961. /**
  9962. * Defines how far from the source the light is impacting in scene units.
  9963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9964. */
  9965. range: number;
  9966. /**
  9967. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9968. * of light.
  9969. */
  9970. private _photometricScale;
  9971. private _intensityMode;
  9972. /**
  9973. * Gets the photometric scale used to interpret the intensity.
  9974. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9975. */
  9976. /**
  9977. * Sets the photometric scale used to interpret the intensity.
  9978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9979. */
  9980. intensityMode: number;
  9981. private _radius;
  9982. /**
  9983. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9984. */
  9985. /**
  9986. * sets the light radius used by PBR Materials to simulate soft area lights.
  9987. */
  9988. radius: number;
  9989. private _renderPriority;
  9990. /**
  9991. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9992. * exceeding the number allowed of the materials.
  9993. */
  9994. renderPriority: number;
  9995. private _shadowEnabled;
  9996. /**
  9997. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9998. * the current shadow generator.
  9999. */
  10000. /**
  10001. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10002. * the current shadow generator.
  10003. */
  10004. shadowEnabled: boolean;
  10005. private _includedOnlyMeshes;
  10006. /**
  10007. * Gets the only meshes impacted by this light.
  10008. */
  10009. /**
  10010. * Sets the only meshes impacted by this light.
  10011. */
  10012. includedOnlyMeshes: AbstractMesh[];
  10013. private _excludedMeshes;
  10014. /**
  10015. * Gets the meshes not impacted by this light.
  10016. */
  10017. /**
  10018. * Sets the meshes not impacted by this light.
  10019. */
  10020. excludedMeshes: AbstractMesh[];
  10021. private _excludeWithLayerMask;
  10022. /**
  10023. * Gets the layer id use to find what meshes are not impacted by the light.
  10024. * Inactive if 0
  10025. */
  10026. /**
  10027. * Sets the layer id use to find what meshes are not impacted by the light.
  10028. * Inactive if 0
  10029. */
  10030. excludeWithLayerMask: number;
  10031. private _includeOnlyWithLayerMask;
  10032. /**
  10033. * Gets the layer id use to find what meshes are impacted by the light.
  10034. * Inactive if 0
  10035. */
  10036. /**
  10037. * Sets the layer id use to find what meshes are impacted by the light.
  10038. * Inactive if 0
  10039. */
  10040. includeOnlyWithLayerMask: number;
  10041. private _lightmapMode;
  10042. /**
  10043. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10044. */
  10045. /**
  10046. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10047. */
  10048. lightmapMode: number;
  10049. /**
  10050. * Shadow generator associted to the light.
  10051. * @hidden Internal use only.
  10052. */
  10053. _shadowGenerator: Nullable<IShadowGenerator>;
  10054. /**
  10055. * @hidden Internal use only.
  10056. */
  10057. _excludedMeshesIds: string[];
  10058. /**
  10059. * @hidden Internal use only.
  10060. */
  10061. _includedOnlyMeshesIds: string[];
  10062. /**
  10063. * The current light unifom buffer.
  10064. * @hidden Internal use only.
  10065. */
  10066. _uniformBuffer: UniformBuffer;
  10067. /**
  10068. * Creates a Light object in the scene.
  10069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10070. * @param name The firendly name of the light
  10071. * @param scene The scene the light belongs too
  10072. */
  10073. constructor(name: string, scene: Scene);
  10074. protected abstract _buildUniformLayout(): void;
  10075. /**
  10076. * Sets the passed Effect "effect" with the Light information.
  10077. * @param effect The effect to update
  10078. * @param lightIndex The index of the light in the effect to update
  10079. * @returns The light
  10080. */
  10081. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10082. /**
  10083. * Returns the string "Light".
  10084. * @returns the class name
  10085. */
  10086. getClassName(): string;
  10087. /** @hidden */
  10088. readonly _isLight: boolean;
  10089. /**
  10090. * Converts the light information to a readable string for debug purpose.
  10091. * @param fullDetails Supports for multiple levels of logging within scene loading
  10092. * @returns the human readable light info
  10093. */
  10094. toString(fullDetails?: boolean): string;
  10095. /** @hidden */
  10096. protected _syncParentEnabledState(): void;
  10097. /**
  10098. * Set the enabled state of this node.
  10099. * @param value - the new enabled state
  10100. */
  10101. setEnabled(value: boolean): void;
  10102. /**
  10103. * Returns the Light associated shadow generator if any.
  10104. * @return the associated shadow generator.
  10105. */
  10106. getShadowGenerator(): Nullable<IShadowGenerator>;
  10107. /**
  10108. * Returns a Vector3, the absolute light position in the World.
  10109. * @returns the world space position of the light
  10110. */
  10111. getAbsolutePosition(): Vector3;
  10112. /**
  10113. * Specifies if the light will affect the passed mesh.
  10114. * @param mesh The mesh to test against the light
  10115. * @return true the mesh is affected otherwise, false.
  10116. */
  10117. canAffectMesh(mesh: AbstractMesh): boolean;
  10118. /**
  10119. * Sort function to order lights for rendering.
  10120. * @param a First Light object to compare to second.
  10121. * @param b Second Light object to compare first.
  10122. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10123. */
  10124. static CompareLightsPriority(a: Light, b: Light): number;
  10125. /**
  10126. * Releases resources associated with this node.
  10127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10129. */
  10130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10131. /**
  10132. * Returns the light type ID (integer).
  10133. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10134. */
  10135. getTypeID(): number;
  10136. /**
  10137. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10138. * @returns the scaled intensity in intensity mode unit
  10139. */
  10140. getScaledIntensity(): number;
  10141. /**
  10142. * Returns a new Light object, named "name", from the current one.
  10143. * @param name The name of the cloned light
  10144. * @returns the new created light
  10145. */
  10146. clone(name: string): Nullable<Light>;
  10147. /**
  10148. * Serializes the current light into a Serialization object.
  10149. * @returns the serialized object.
  10150. */
  10151. serialize(): any;
  10152. /**
  10153. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10154. * This new light is named "name" and added to the passed scene.
  10155. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10156. * @param name The friendly name of the light
  10157. * @param scene The scene the new light will belong to
  10158. * @returns the constructor function
  10159. */
  10160. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10161. /**
  10162. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10163. * @param parsedLight The JSON representation of the light
  10164. * @param scene The scene to create the parsed light in
  10165. * @returns the created light after parsing
  10166. */
  10167. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10168. private _hookArrayForExcluded;
  10169. private _hookArrayForIncludedOnly;
  10170. private _resyncMeshes;
  10171. /**
  10172. * Forces the meshes to update their light related information in their rendering used effects
  10173. * @hidden Internal Use Only
  10174. */
  10175. _markMeshesAsLightDirty(): void;
  10176. /**
  10177. * Recomputes the cached photometric scale if needed.
  10178. */
  10179. private _computePhotometricScale;
  10180. /**
  10181. * Returns the Photometric Scale according to the light type and intensity mode.
  10182. */
  10183. private _getPhotometricScale;
  10184. /**
  10185. * Reorder the light in the scene according to their defined priority.
  10186. * @hidden Internal Use Only
  10187. */
  10188. _reorderLightsInScene(): void;
  10189. /**
  10190. * Prepares the list of defines specific to the light type.
  10191. * @param defines the list of defines
  10192. * @param lightIndex defines the index of the light for the effect
  10193. */
  10194. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Interface used to define Action
  10200. */
  10201. export interface IAction {
  10202. /**
  10203. * Trigger for the action
  10204. */
  10205. trigger: number;
  10206. /** Options of the trigger */
  10207. triggerOptions: any;
  10208. /**
  10209. * Gets the trigger parameters
  10210. * @returns the trigger parameters
  10211. */
  10212. getTriggerParameter(): any;
  10213. /**
  10214. * Internal only - executes current action event
  10215. * @hidden
  10216. */
  10217. _executeCurrent(evt?: ActionEvent): void;
  10218. /**
  10219. * Serialize placeholder for child classes
  10220. * @param parent of child
  10221. * @returns the serialized object
  10222. */
  10223. serialize(parent: any): any;
  10224. }
  10225. /**
  10226. * The action to be carried out following a trigger
  10227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10228. */
  10229. export class Action implements IAction {
  10230. /** the trigger, with or without parameters, for the action */
  10231. triggerOptions: any;
  10232. /**
  10233. * Trigger for the action
  10234. */
  10235. trigger: number;
  10236. /**
  10237. * Internal only - manager for action
  10238. * @hidden
  10239. */
  10240. _actionManager: ActionManager;
  10241. private _nextActiveAction;
  10242. private _child;
  10243. private _condition?;
  10244. private _triggerParameter;
  10245. /**
  10246. * An event triggered prior to action being executed.
  10247. */
  10248. onBeforeExecuteObservable: Observable<Action>;
  10249. /**
  10250. * Creates a new Action
  10251. * @param triggerOptions the trigger, with or without parameters, for the action
  10252. * @param condition an optional determinant of action
  10253. */
  10254. constructor(
  10255. /** the trigger, with or without parameters, for the action */
  10256. triggerOptions: any, condition?: Condition);
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _prepare(): void;
  10262. /**
  10263. * Gets the trigger parameters
  10264. * @returns the trigger parameters
  10265. */
  10266. getTriggerParameter(): any;
  10267. /**
  10268. * Internal only - executes current action event
  10269. * @hidden
  10270. */
  10271. _executeCurrent(evt?: ActionEvent): void;
  10272. /**
  10273. * Execute placeholder for child classes
  10274. * @param evt optional action event
  10275. */
  10276. execute(evt?: ActionEvent): void;
  10277. /**
  10278. * Skips to next active action
  10279. */
  10280. skipToNextActiveAction(): void;
  10281. /**
  10282. * Adds action to chain of actions, may be a DoNothingAction
  10283. * @param action defines the next action to execute
  10284. * @returns The action passed in
  10285. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10286. */
  10287. then(action: Action): Action;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. _getProperty(propertyPath: string): string;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _getEffectiveTarget(target: any, propertyPath: string): any;
  10298. /**
  10299. * Serialize placeholder for child classes
  10300. * @param parent of child
  10301. * @returns the serialized object
  10302. */
  10303. serialize(parent: any): any;
  10304. /**
  10305. * Internal only called by serialize
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedAction: any, parent?: any): any;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. static _SerializeValueAsString: (value: any) => string;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. static _GetTargetProperty: (target: Scene | Node) => {
  10319. name: string;
  10320. targetType: string;
  10321. value: string;
  10322. };
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A Condition applied to an Action
  10328. */
  10329. export class Condition {
  10330. /**
  10331. * Internal only - manager for action
  10332. * @hidden
  10333. */
  10334. _actionManager: ActionManager;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. _evaluationId: number;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. _currentResult: boolean;
  10345. /**
  10346. * Creates a new Condition
  10347. * @param actionManager the manager of the action the condition is applied to
  10348. */
  10349. constructor(actionManager: ActionManager);
  10350. /**
  10351. * Check if the current condition is valid
  10352. * @returns a boolean
  10353. */
  10354. isValid(): boolean;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */
  10359. _getProperty(propertyPath: string): string;
  10360. /**
  10361. * Internal only
  10362. * @hidden
  10363. */
  10364. _getEffectiveTarget(target: any, propertyPath: string): any;
  10365. /**
  10366. * Serialize placeholder for child classes
  10367. * @returns the serialized object
  10368. */
  10369. serialize(): any;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */
  10374. protected _serialize(serializedCondition: any): any;
  10375. }
  10376. /**
  10377. * Defines specific conditional operators as extensions of Condition
  10378. */
  10379. export class ValueCondition extends Condition {
  10380. /** path to specify the property of the target the conditional operator uses */
  10381. propertyPath: string;
  10382. /** the value compared by the conditional operator against the current value of the property */
  10383. value: any;
  10384. /** the conditional operator, default ValueCondition.IsEqual */
  10385. operator: number;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. private static _IsEqual;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. private static _IsDifferent;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. private static _IsGreater;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. private static _IsLesser;
  10406. /**
  10407. * returns the number for IsEqual
  10408. */
  10409. static readonly IsEqual: number;
  10410. /**
  10411. * Returns the number for IsDifferent
  10412. */
  10413. static readonly IsDifferent: number;
  10414. /**
  10415. * Returns the number for IsGreater
  10416. */
  10417. static readonly IsGreater: number;
  10418. /**
  10419. * Returns the number for IsLesser
  10420. */
  10421. static readonly IsLesser: number;
  10422. /**
  10423. * Internal only The action manager for the condition
  10424. * @hidden
  10425. */
  10426. _actionManager: ActionManager;
  10427. /**
  10428. * Internal only
  10429. * @hidden
  10430. */
  10431. private _target;
  10432. /**
  10433. * Internal only
  10434. * @hidden
  10435. */
  10436. private _effectiveTarget;
  10437. /**
  10438. * Internal only
  10439. * @hidden
  10440. */
  10441. private _property;
  10442. /**
  10443. * Creates a new ValueCondition
  10444. * @param actionManager manager for the action the condition applies to
  10445. * @param target for the action
  10446. * @param propertyPath path to specify the property of the target the conditional operator uses
  10447. * @param value the value compared by the conditional operator against the current value of the property
  10448. * @param operator the conditional operator, default ValueCondition.IsEqual
  10449. */
  10450. constructor(actionManager: ActionManager, target: any,
  10451. /** path to specify the property of the target the conditional operator uses */
  10452. propertyPath: string,
  10453. /** the value compared by the conditional operator against the current value of the property */
  10454. value: any,
  10455. /** the conditional operator, default ValueCondition.IsEqual */
  10456. operator?: number);
  10457. /**
  10458. * Compares the given value with the property value for the specified conditional operator
  10459. * @returns the result of the comparison
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the ValueCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. /**
  10468. * Gets the name of the conditional operator for the ValueCondition
  10469. * @param operator the conditional operator
  10470. * @returns the name
  10471. */
  10472. static GetOperatorName(operator: number): string;
  10473. }
  10474. /**
  10475. * Defines a predicate condition as an extension of Condition
  10476. */
  10477. export class PredicateCondition extends Condition {
  10478. /** defines the predicate function used to validate the condition */
  10479. predicate: () => boolean;
  10480. /**
  10481. * Internal only - manager for action
  10482. * @hidden
  10483. */
  10484. _actionManager: ActionManager;
  10485. /**
  10486. * Creates a new PredicateCondition
  10487. * @param actionManager manager for the action the condition applies to
  10488. * @param predicate defines the predicate function used to validate the condition
  10489. */
  10490. constructor(actionManager: ActionManager,
  10491. /** defines the predicate function used to validate the condition */
  10492. predicate: () => boolean);
  10493. /**
  10494. * @returns the validity of the predicate condition
  10495. */
  10496. isValid(): boolean;
  10497. }
  10498. /**
  10499. * Defines a state condition as an extension of Condition
  10500. */
  10501. export class StateCondition extends Condition {
  10502. /** Value to compare with target state */
  10503. value: string;
  10504. /**
  10505. * Internal only - manager for action
  10506. * @hidden
  10507. */
  10508. _actionManager: ActionManager;
  10509. /**
  10510. * Internal only
  10511. * @hidden
  10512. */
  10513. private _target;
  10514. /**
  10515. * Creates a new StateCondition
  10516. * @param actionManager manager for the action the condition applies to
  10517. * @param target of the condition
  10518. * @param value to compare with target state
  10519. */
  10520. constructor(actionManager: ActionManager, target: any,
  10521. /** Value to compare with target state */
  10522. value: string);
  10523. /**
  10524. * Gets a boolean indicating if the current condition is met
  10525. * @returns the validity of the state
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Serialize the StateCondition into a JSON compatible object
  10530. * @returns serialization object
  10531. */
  10532. serialize(): any;
  10533. }
  10534. }
  10535. declare module BABYLON {
  10536. /**
  10537. * This defines an action responsible to toggle a boolean once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class SwitchBooleanAction extends Action {
  10541. /**
  10542. * The path to the boolean property in the target object
  10543. */
  10544. propertyPath: string;
  10545. private _target;
  10546. private _effectiveTarget;
  10547. private _property;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the object containing the boolean
  10552. * @param propertyPath defines the path to the boolean property in the target object
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action toggle the boolean value.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to set a the state field of the target
  10571. * to a desired value once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class SetStateAction extends Action {
  10575. /**
  10576. * The value to store in the state field.
  10577. */
  10578. value: string;
  10579. private _target;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the state property
  10584. * @param value defines the value to store in the state field
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10588. /**
  10589. * Execute the action and store the value on the target state property.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to set a property of the target
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class SetValueAction extends Action {
  10605. /**
  10606. * The path of the property to set in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value to set in the property
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to set in the target
  10621. * @param value defines the value to set in the property
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and set the targetted property to the desired value.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to increment the target value
  10640. * to a desired value once triggered.
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10642. */
  10643. export class IncrementValueAction extends Action {
  10644. /**
  10645. * The path of the property to increment in the target.
  10646. */
  10647. propertyPath: string;
  10648. /**
  10649. * The value we should increment the property by.
  10650. */
  10651. value: any;
  10652. private _target;
  10653. private _effectiveTarget;
  10654. private _property;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the object containing the property
  10659. * @param propertyPath defines the path of the property to increment in the target
  10660. * @param value defines the value value we should increment the property by
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and increment the target of the value amount.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to start an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class PlayAnimationAction extends Action {
  10682. /**
  10683. * Where the animation should start (animation frame)
  10684. */
  10685. from: number;
  10686. /**
  10687. * Where the animation should stop (animation frame)
  10688. */
  10689. to: number;
  10690. /**
  10691. * Define if the animation should loop or stop after the first play.
  10692. */
  10693. loop?: boolean;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target animation or animation name
  10699. * @param from defines from where the animation should start (animation frame)
  10700. * @param end defines where the animation should stop (animation frame)
  10701. * @param loop defines if the animation should loop or stop after the first play
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and play the animation.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to stop an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class StopAnimationAction extends Action {
  10723. private _target;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the target animation or animation name
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and stop the animation.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible that does nothing once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class DoNothingAction extends Action {
  10749. /**
  10750. * Instantiate the action
  10751. * @param triggerOptions defines the trigger options
  10752. * @param condition defines the trigger related conditions
  10753. */
  10754. constructor(triggerOptions?: any, condition?: Condition);
  10755. /**
  10756. * Execute the action and do nothing.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to trigger several actions once triggered.
  10768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10769. */
  10770. export class CombineAction extends Action {
  10771. /**
  10772. * The list of aggregated animations to run.
  10773. */
  10774. children: Action[];
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param children defines the list of aggregated animations to run
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10782. /** @hidden */
  10783. _prepare(): void;
  10784. /**
  10785. * Execute the action and executes all the aggregated actions.
  10786. */
  10787. execute(evt: ActionEvent): void;
  10788. /**
  10789. * Serializes the actions and its related information.
  10790. * @param parent defines the object to serialize in
  10791. * @returns the serialized object
  10792. */
  10793. serialize(parent: any): any;
  10794. }
  10795. /**
  10796. * This defines an action responsible to run code (external event) once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ExecuteCodeAction extends Action {
  10800. /**
  10801. * The callback function to run.
  10802. */
  10803. func: (evt: ActionEvent) => void;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param func defines the callback function to run
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10811. /**
  10812. * Execute the action and run the attached code.
  10813. */
  10814. execute(evt: ActionEvent): void;
  10815. }
  10816. /**
  10817. * This defines an action responsible to set the parent property of the target once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class SetParentAction extends Action {
  10821. private _parent;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target containing the parent property
  10827. * @param parent defines from where the animation should start (animation frame)
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and set the parent property.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10848. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class ActionManager extends AbstractActionManager {
  10852. /**
  10853. * Nothing
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly NothingTrigger: number;
  10857. /**
  10858. * On pick
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnPickTrigger: number;
  10862. /**
  10863. * On left pick
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnLeftPickTrigger: number;
  10867. /**
  10868. * On right pick
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnRightPickTrigger: number;
  10872. /**
  10873. * On center pick
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnCenterPickTrigger: number;
  10877. /**
  10878. * On pick down
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnPickDownTrigger: number;
  10882. /**
  10883. * On double pick
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnDoublePickTrigger: number;
  10887. /**
  10888. * On pick up
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickUpTrigger: number;
  10892. /**
  10893. * On pick out.
  10894. * This trigger will only be raised if you also declared a OnPickDown
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickOutTrigger: number;
  10898. /**
  10899. * On long press
  10900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10901. */
  10902. static readonly OnLongPressTrigger: number;
  10903. /**
  10904. * On pointer over
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10906. */
  10907. static readonly OnPointerOverTrigger: number;
  10908. /**
  10909. * On pointer out
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10911. */
  10912. static readonly OnPointerOutTrigger: number;
  10913. /**
  10914. * On every frame
  10915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10916. */
  10917. static readonly OnEveryFrameTrigger: number;
  10918. /**
  10919. * On intersection enter
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnIntersectionEnterTrigger: number;
  10923. /**
  10924. * On intersection exit
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnIntersectionExitTrigger: number;
  10928. /**
  10929. * On key down
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnKeyDownTrigger: number;
  10933. /**
  10934. * On key up
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnKeyUpTrigger: number;
  10938. private _scene;
  10939. /**
  10940. * Creates a new action manager
  10941. * @param scene defines the hosting scene
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Releases all associated resources
  10946. */
  10947. dispose(): void;
  10948. /**
  10949. * Gets hosting scene
  10950. * @returns the hosting scene
  10951. */
  10952. getScene(): Scene;
  10953. /**
  10954. * Does this action manager handles actions of any of the given triggers
  10955. * @param triggers defines the triggers to be tested
  10956. * @return a boolean indicating whether one (or more) of the triggers is handled
  10957. */
  10958. hasSpecificTriggers(triggers: number[]): boolean;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10961. * speed.
  10962. * @param triggerA defines the trigger to be tested
  10963. * @param triggerB defines the trigger to be tested
  10964. * @return a boolean indicating whether one (or more) of the triggers is handled
  10965. */
  10966. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10967. /**
  10968. * Does this action manager handles actions of a given trigger
  10969. * @param trigger defines the trigger to be tested
  10970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10971. * @return whether the trigger is handled
  10972. */
  10973. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10974. /**
  10975. * Does this action manager has pointer triggers
  10976. */
  10977. readonly hasPointerTriggers: boolean;
  10978. /**
  10979. * Does this action manager has pick triggers
  10980. */
  10981. readonly hasPickTriggers: boolean;
  10982. /**
  10983. * Registers an action to this action manager
  10984. * @param action defines the action to be registered
  10985. * @return the action amended (prepared) after registration
  10986. */
  10987. registerAction(action: Action): Nullable<Action>;
  10988. /**
  10989. * Unregisters an action to this action manager
  10990. * @param action defines the action to be unregistered
  10991. * @return a boolean indicating whether the action has been unregistered
  10992. */
  10993. unregisterAction(action: Action): Boolean;
  10994. /**
  10995. * Process a specific trigger
  10996. * @param trigger defines the trigger to process
  10997. * @param evt defines the event details to be processed
  10998. */
  10999. processTrigger(trigger: number, evt?: IActionEvent): void;
  11000. /** @hidden */
  11001. _getEffectiveTarget(target: any, propertyPath: string): any;
  11002. /** @hidden */
  11003. _getProperty(propertyPath: string): string;
  11004. /**
  11005. * Serialize this manager to a JSON object
  11006. * @param name defines the property name to store this manager
  11007. * @returns a JSON representation of this manager
  11008. */
  11009. serialize(name: string): any;
  11010. /**
  11011. * Creates a new ActionManager from a JSON data
  11012. * @param parsedActions defines the JSON data to read from
  11013. * @param object defines the hosting mesh
  11014. * @param scene defines the hosting scene
  11015. */
  11016. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11017. /**
  11018. * Get a trigger name by index
  11019. * @param trigger defines the trigger index
  11020. * @returns a trigger name
  11021. */
  11022. static GetTriggerName(trigger: number): string;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * Class representing a ray with position and direction
  11028. */
  11029. export class Ray {
  11030. /** origin point */
  11031. origin: Vector3;
  11032. /** direction */
  11033. direction: Vector3;
  11034. /** length of the ray */
  11035. length: number;
  11036. private static readonly TmpVector3;
  11037. private _tmpRay;
  11038. /**
  11039. * Creates a new ray
  11040. * @param origin origin point
  11041. * @param direction direction
  11042. * @param length length of the ray
  11043. */
  11044. constructor(
  11045. /** origin point */
  11046. origin: Vector3,
  11047. /** direction */
  11048. direction: Vector3,
  11049. /** length of the ray */
  11050. length?: number);
  11051. /**
  11052. * Checks if the ray intersects a box
  11053. * @param minimum bound of the box
  11054. * @param maximum bound of the box
  11055. * @param intersectionTreshold extra extend to be added to the box in all direction
  11056. * @returns if the box was hit
  11057. */
  11058. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11059. /**
  11060. * Checks if the ray intersects a box
  11061. * @param box the bounding box to check
  11062. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11063. * @returns if the box was hit
  11064. */
  11065. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11066. /**
  11067. * If the ray hits a sphere
  11068. * @param sphere the bounding sphere to check
  11069. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11070. * @returns true if it hits the sphere
  11071. */
  11072. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11073. /**
  11074. * If the ray hits a triange
  11075. * @param vertex0 triangle vertex
  11076. * @param vertex1 triangle vertex
  11077. * @param vertex2 triangle vertex
  11078. * @returns intersection information if hit
  11079. */
  11080. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11081. /**
  11082. * Checks if ray intersects a plane
  11083. * @param plane the plane to check
  11084. * @returns the distance away it was hit
  11085. */
  11086. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11087. /**
  11088. * Checks if ray intersects a mesh
  11089. * @param mesh the mesh to check
  11090. * @param fastCheck if only the bounding box should checked
  11091. * @returns picking info of the intersecton
  11092. */
  11093. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11094. /**
  11095. * Checks if ray intersects a mesh
  11096. * @param meshes the meshes to check
  11097. * @param fastCheck if only the bounding box should checked
  11098. * @param results array to store result in
  11099. * @returns Array of picking infos
  11100. */
  11101. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11102. private _comparePickingInfo;
  11103. private static smallnum;
  11104. private static rayl;
  11105. /**
  11106. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11107. * @param sega the first point of the segment to test the intersection against
  11108. * @param segb the second point of the segment to test the intersection against
  11109. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11110. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11111. */
  11112. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11113. /**
  11114. * Update the ray from viewport position
  11115. * @param x position
  11116. * @param y y position
  11117. * @param viewportWidth viewport width
  11118. * @param viewportHeight viewport height
  11119. * @param world world matrix
  11120. * @param view view matrix
  11121. * @param projection projection matrix
  11122. * @returns this ray updated
  11123. */
  11124. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11125. /**
  11126. * Creates a ray with origin and direction of 0,0,0
  11127. * @returns the new ray
  11128. */
  11129. static Zero(): Ray;
  11130. /**
  11131. * Creates a new ray from screen space and viewport
  11132. * @param x position
  11133. * @param y y position
  11134. * @param viewportWidth viewport width
  11135. * @param viewportHeight viewport height
  11136. * @param world world matrix
  11137. * @param view view matrix
  11138. * @param projection projection matrix
  11139. * @returns new ray
  11140. */
  11141. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11142. /**
  11143. * 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
  11144. * transformed to the given world matrix.
  11145. * @param origin The origin point
  11146. * @param end The end point
  11147. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11148. * @returns the new ray
  11149. */
  11150. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11151. /**
  11152. * Transforms a ray by a matrix
  11153. * @param ray ray to transform
  11154. * @param matrix matrix to apply
  11155. * @returns the resulting new ray
  11156. */
  11157. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11158. /**
  11159. * Transforms a ray by a matrix
  11160. * @param ray ray to transform
  11161. * @param matrix matrix to apply
  11162. * @param result ray to store result in
  11163. */
  11164. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11165. /**
  11166. * Unproject a ray from screen space to object space
  11167. * @param sourceX defines the screen space x coordinate to use
  11168. * @param sourceY defines the screen space y coordinate to use
  11169. * @param viewportWidth defines the current width of the viewport
  11170. * @param viewportHeight defines the current height of the viewport
  11171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11172. * @param view defines the view matrix to use
  11173. * @param projection defines the projection matrix to use
  11174. */
  11175. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11176. }
  11177. interface Scene {
  11178. /** @hidden */
  11179. _tempPickingRay: Nullable<Ray>;
  11180. /** @hidden */
  11181. _cachedRayForTransform: Ray;
  11182. /** @hidden */
  11183. _pickWithRayInverseMatrix: Matrix;
  11184. /** @hidden */
  11185. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11186. /** @hidden */
  11187. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11188. }
  11189. }
  11190. declare module BABYLON {
  11191. /**
  11192. * Groups all the scene component constants in one place to ease maintenance.
  11193. * @hidden
  11194. */
  11195. export class SceneComponentConstants {
  11196. static readonly NAME_EFFECTLAYER: string;
  11197. static readonly NAME_LAYER: string;
  11198. static readonly NAME_LENSFLARESYSTEM: string;
  11199. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11200. static readonly NAME_PARTICLESYSTEM: string;
  11201. static readonly NAME_GAMEPAD: string;
  11202. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11203. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11204. static readonly NAME_DEPTHRENDERER: string;
  11205. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11206. static readonly NAME_SPRITE: string;
  11207. static readonly NAME_OUTLINERENDERER: string;
  11208. static readonly NAME_PROCEDURALTEXTURE: string;
  11209. static readonly NAME_SHADOWGENERATOR: string;
  11210. static readonly NAME_OCTREE: string;
  11211. static readonly NAME_PHYSICSENGINE: string;
  11212. static readonly NAME_AUDIO: string;
  11213. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11214. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11217. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11218. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11219. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11220. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11221. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11222. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11223. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11224. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11225. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11226. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11227. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11228. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11231. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11232. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11233. static readonly STEP_AFTERRENDER_AUDIO: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11236. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11238. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11239. static readonly STEP_POINTERMOVE_SPRITE: number;
  11240. static readonly STEP_POINTERDOWN_SPRITE: number;
  11241. static readonly STEP_POINTERUP_SPRITE: number;
  11242. }
  11243. /**
  11244. * This represents a scene component.
  11245. *
  11246. * This is used to decouple the dependency the scene is having on the different workloads like
  11247. * layers, post processes...
  11248. */
  11249. export interface ISceneComponent {
  11250. /**
  11251. * The name of the component. Each component must have a unique name.
  11252. */
  11253. name: string;
  11254. /**
  11255. * The scene the component belongs to.
  11256. */
  11257. scene: Scene;
  11258. /**
  11259. * Register the component to one instance of a scene.
  11260. */
  11261. register(): void;
  11262. /**
  11263. * Rebuilds the elements related to this component in case of
  11264. * context lost for instance.
  11265. */
  11266. rebuild(): void;
  11267. /**
  11268. * Disposes the component and the associated ressources.
  11269. */
  11270. dispose(): void;
  11271. }
  11272. /**
  11273. * This represents a SERIALIZABLE scene component.
  11274. *
  11275. * This extends Scene Component to add Serialization methods on top.
  11276. */
  11277. export interface ISceneSerializableComponent extends ISceneComponent {
  11278. /**
  11279. * Adds all the element from the container to the scene
  11280. * @param container the container holding the elements
  11281. */
  11282. addFromContainer(container: AbstractScene): void;
  11283. /**
  11284. * Removes all the elements in the container from the scene
  11285. * @param container contains the elements to remove
  11286. */
  11287. removeFromContainer(container: AbstractScene): void;
  11288. /**
  11289. * Serializes the component data to the specified json object
  11290. * @param serializationObject The object to serialize to
  11291. */
  11292. serialize(serializationObject: any): void;
  11293. }
  11294. /**
  11295. * Strong typing of a Mesh related stage step action
  11296. */
  11297. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11298. /**
  11299. * Strong typing of a Evaluate Sub Mesh related stage step action
  11300. */
  11301. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11302. /**
  11303. * Strong typing of a Active Mesh related stage step action
  11304. */
  11305. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11306. /**
  11307. * Strong typing of a Camera related stage step action
  11308. */
  11309. export type CameraStageAction = (camera: Camera) => void;
  11310. /**
  11311. * Strong typing of a Render Target related stage step action
  11312. */
  11313. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11314. /**
  11315. * Strong typing of a RenderingGroup related stage step action
  11316. */
  11317. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11318. /**
  11319. * Strong typing of a Mesh Render related stage step action
  11320. */
  11321. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11322. /**
  11323. * Strong typing of a simple stage step action
  11324. */
  11325. export type SimpleStageAction = () => void;
  11326. /**
  11327. * Strong typing of a render target action.
  11328. */
  11329. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11330. /**
  11331. * Strong typing of a pointer move action.
  11332. */
  11333. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11334. /**
  11335. * Strong typing of a pointer up/down action.
  11336. */
  11337. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11338. /**
  11339. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11340. * @hidden
  11341. */
  11342. export class Stage<T extends Function> extends Array<{
  11343. index: number;
  11344. component: ISceneComponent;
  11345. action: T;
  11346. }> {
  11347. /**
  11348. * Hide ctor from the rest of the world.
  11349. * @param items The items to add.
  11350. */
  11351. private constructor();
  11352. /**
  11353. * Creates a new Stage.
  11354. * @returns A new instance of a Stage
  11355. */
  11356. static Create<T extends Function>(): Stage<T>;
  11357. /**
  11358. * Registers a step in an ordered way in the targeted stage.
  11359. * @param index Defines the position to register the step in
  11360. * @param component Defines the component attached to the step
  11361. * @param action Defines the action to launch during the step
  11362. */
  11363. registerStep(index: number, component: ISceneComponent, action: T): void;
  11364. /**
  11365. * Clears all the steps from the stage.
  11366. */
  11367. clear(): void;
  11368. }
  11369. }
  11370. declare module BABYLON {
  11371. interface Scene {
  11372. /** @hidden */
  11373. _pointerOverSprite: Nullable<Sprite>;
  11374. /** @hidden */
  11375. _pickedDownSprite: Nullable<Sprite>;
  11376. /** @hidden */
  11377. _tempSpritePickingRay: Nullable<Ray>;
  11378. /**
  11379. * All of the sprite managers added to this scene
  11380. * @see http://doc.babylonjs.com/babylon101/sprites
  11381. */
  11382. spriteManagers: Array<ISpriteManager>;
  11383. /**
  11384. * An event triggered when sprites rendering is about to start
  11385. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11386. */
  11387. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11388. /**
  11389. * An event triggered when sprites rendering is done
  11390. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11391. */
  11392. onAfterSpritesRenderingObservable: Observable<Scene>;
  11393. /** @hidden */
  11394. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11395. /** Launch a ray to try to pick a sprite in the scene
  11396. * @param x position on screen
  11397. * @param y position on screen
  11398. * @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
  11399. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11400. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11401. * @returns a PickingInfo
  11402. */
  11403. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11404. /** Use the given ray to pick a sprite in the scene
  11405. * @param ray The ray (in world space) to use to pick meshes
  11406. * @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
  11407. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11408. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11409. * @returns a PickingInfo
  11410. */
  11411. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11412. /**
  11413. * Force the sprite under the pointer
  11414. * @param sprite defines the sprite to use
  11415. */
  11416. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11417. /**
  11418. * Gets the sprite under the pointer
  11419. * @returns a Sprite or null if no sprite is under the pointer
  11420. */
  11421. getPointerOverSprite(): Nullable<Sprite>;
  11422. }
  11423. /**
  11424. * Defines the sprite scene component responsible to manage sprites
  11425. * in a given scene.
  11426. */
  11427. export class SpriteSceneComponent implements ISceneComponent {
  11428. /**
  11429. * The component name helpfull to identify the component in the list of scene components.
  11430. */
  11431. readonly name: string;
  11432. /**
  11433. * The scene the component belongs to.
  11434. */
  11435. scene: Scene;
  11436. /** @hidden */
  11437. private _spritePredicate;
  11438. /**
  11439. * Creates a new instance of the component for the given scene
  11440. * @param scene Defines the scene to register the component in
  11441. */
  11442. constructor(scene: Scene);
  11443. /**
  11444. * Registers the component in a given scene
  11445. */
  11446. register(): void;
  11447. /**
  11448. * Rebuilds the elements related to this component in case of
  11449. * context lost for instance.
  11450. */
  11451. rebuild(): void;
  11452. /**
  11453. * Disposes the component and the associated ressources.
  11454. */
  11455. dispose(): void;
  11456. private _pickSpriteButKeepRay;
  11457. private _pointerMove;
  11458. private _pointerDown;
  11459. private _pointerUp;
  11460. }
  11461. }
  11462. declare module BABYLON {
  11463. /** @hidden */
  11464. export var fogFragmentDeclaration: {
  11465. name: string;
  11466. shader: string;
  11467. };
  11468. }
  11469. declare module BABYLON {
  11470. /** @hidden */
  11471. export var fogFragment: {
  11472. name: string;
  11473. shader: string;
  11474. };
  11475. }
  11476. declare module BABYLON {
  11477. /** @hidden */
  11478. export var spritesPixelShader: {
  11479. name: string;
  11480. shader: string;
  11481. };
  11482. }
  11483. declare module BABYLON {
  11484. /** @hidden */
  11485. export var fogVertexDeclaration: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module BABYLON {
  11491. /** @hidden */
  11492. export var spritesVertexShader: {
  11493. name: string;
  11494. shader: string;
  11495. };
  11496. }
  11497. declare module BABYLON {
  11498. /**
  11499. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11500. */
  11501. export interface ISpriteManager extends IDisposable {
  11502. /**
  11503. * Restricts the camera to viewing objects with the same layerMask.
  11504. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11505. */
  11506. layerMask: number;
  11507. /**
  11508. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11509. */
  11510. isPickable: boolean;
  11511. /**
  11512. * Specifies the rendering group id for this mesh (0 by default)
  11513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11514. */
  11515. renderingGroupId: number;
  11516. /**
  11517. * Defines the list of sprites managed by the manager.
  11518. */
  11519. sprites: Array<Sprite>;
  11520. /**
  11521. * Tests the intersection of a sprite with a specific ray.
  11522. * @param ray The ray we are sending to test the collision
  11523. * @param camera The camera space we are sending rays in
  11524. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11525. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11526. * @returns picking info or null.
  11527. */
  11528. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11529. /**
  11530. * Renders the list of sprites on screen.
  11531. */
  11532. render(): void;
  11533. }
  11534. /**
  11535. * Class used to manage multiple sprites on the same spritesheet
  11536. * @see http://doc.babylonjs.com/babylon101/sprites
  11537. */
  11538. export class SpriteManager implements ISpriteManager {
  11539. /** defines the manager's name */
  11540. name: string;
  11541. /** Gets the list of sprites */
  11542. sprites: Sprite[];
  11543. /** Gets or sets the rendering group id (0 by default) */
  11544. renderingGroupId: number;
  11545. /** Gets or sets camera layer mask */
  11546. layerMask: number;
  11547. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11548. fogEnabled: boolean;
  11549. /** Gets or sets a boolean indicating if the sprites are pickable */
  11550. isPickable: boolean;
  11551. /** Defines the default width of a cell in the spritesheet */
  11552. cellWidth: number;
  11553. /** Defines the default height of a cell in the spritesheet */
  11554. cellHeight: number;
  11555. /**
  11556. * An event triggered when the manager is disposed.
  11557. */
  11558. onDisposeObservable: Observable<SpriteManager>;
  11559. private _onDisposeObserver;
  11560. /**
  11561. * Callback called when the manager is disposed
  11562. */
  11563. onDispose: () => void;
  11564. private _capacity;
  11565. private _spriteTexture;
  11566. private _epsilon;
  11567. private _scene;
  11568. private _vertexData;
  11569. private _buffer;
  11570. private _vertexBuffers;
  11571. private _indexBuffer;
  11572. private _effectBase;
  11573. private _effectFog;
  11574. /**
  11575. * Gets or sets the spritesheet texture
  11576. */
  11577. texture: Texture;
  11578. /**
  11579. * Creates a new sprite manager
  11580. * @param name defines the manager's name
  11581. * @param imgUrl defines the sprite sheet url
  11582. * @param capacity defines the maximum allowed number of sprites
  11583. * @param cellSize defines the size of a sprite cell
  11584. * @param scene defines the hosting scene
  11585. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11586. * @param samplingMode defines the smapling mode to use with spritesheet
  11587. */
  11588. constructor(
  11589. /** defines the manager's name */
  11590. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11591. private _appendSpriteVertex;
  11592. /**
  11593. * Intersects the sprites with a ray
  11594. * @param ray defines the ray to intersect with
  11595. * @param camera defines the current active camera
  11596. * @param predicate defines a predicate used to select candidate sprites
  11597. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11598. * @returns null if no hit or a PickingInfo
  11599. */
  11600. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11601. /**
  11602. * Render all child sprites
  11603. */
  11604. render(): void;
  11605. /**
  11606. * Release associated resources
  11607. */
  11608. dispose(): void;
  11609. }
  11610. }
  11611. declare module BABYLON {
  11612. /**
  11613. * Class used to represent a sprite
  11614. * @see http://doc.babylonjs.com/babylon101/sprites
  11615. */
  11616. export class Sprite {
  11617. /** defines the name */
  11618. name: string;
  11619. /** Gets or sets the current world position */
  11620. position: Vector3;
  11621. /** Gets or sets the main color */
  11622. color: Color4;
  11623. /** Gets or sets the width */
  11624. width: number;
  11625. /** Gets or sets the height */
  11626. height: number;
  11627. /** Gets or sets rotation angle */
  11628. angle: number;
  11629. /** Gets or sets the cell index in the sprite sheet */
  11630. cellIndex: number;
  11631. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11632. invertU: number;
  11633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11634. invertV: number;
  11635. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11636. disposeWhenFinishedAnimating: boolean;
  11637. /** Gets the list of attached animations */
  11638. animations: Animation[];
  11639. /** Gets or sets a boolean indicating if the sprite can be picked */
  11640. isPickable: boolean;
  11641. /**
  11642. * Gets or sets the associated action manager
  11643. */
  11644. actionManager: Nullable<ActionManager>;
  11645. private _animationStarted;
  11646. private _loopAnimation;
  11647. private _fromIndex;
  11648. private _toIndex;
  11649. private _delay;
  11650. private _direction;
  11651. private _manager;
  11652. private _time;
  11653. private _onAnimationEnd;
  11654. /**
  11655. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11656. */
  11657. isVisible: boolean;
  11658. /**
  11659. * Gets or sets the sprite size
  11660. */
  11661. size: number;
  11662. /**
  11663. * Creates a new Sprite
  11664. * @param name defines the name
  11665. * @param manager defines the manager
  11666. */
  11667. constructor(
  11668. /** defines the name */
  11669. name: string, manager: ISpriteManager);
  11670. /**
  11671. * Starts an animation
  11672. * @param from defines the initial key
  11673. * @param to defines the end key
  11674. * @param loop defines if the animation must loop
  11675. * @param delay defines the start delay (in ms)
  11676. * @param onAnimationEnd defines a callback to call when animation ends
  11677. */
  11678. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11679. /** Stops current animation (if any) */
  11680. stopAnimation(): void;
  11681. /** @hidden */
  11682. _animate(deltaTime: number): void;
  11683. /** Release associated resources */
  11684. dispose(): void;
  11685. }
  11686. }
  11687. declare module BABYLON {
  11688. /**
  11689. * Information about the result of picking within a scene
  11690. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11691. */
  11692. export class PickingInfo {
  11693. /** @hidden */
  11694. _pickingUnavailable: boolean;
  11695. /**
  11696. * If the pick collided with an object
  11697. */
  11698. hit: boolean;
  11699. /**
  11700. * Distance away where the pick collided
  11701. */
  11702. distance: number;
  11703. /**
  11704. * The location of pick collision
  11705. */
  11706. pickedPoint: Nullable<Vector3>;
  11707. /**
  11708. * The mesh corresponding the the pick collision
  11709. */
  11710. pickedMesh: Nullable<AbstractMesh>;
  11711. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11712. bu: number;
  11713. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11714. bv: number;
  11715. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11716. faceId: number;
  11717. /** Id of the the submesh that was picked */
  11718. subMeshId: number;
  11719. /** If a sprite was picked, this will be the sprite the pick collided with */
  11720. pickedSprite: Nullable<Sprite>;
  11721. /**
  11722. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11723. */
  11724. originMesh: Nullable<AbstractMesh>;
  11725. /**
  11726. * The ray that was used to perform the picking.
  11727. */
  11728. ray: Nullable<Ray>;
  11729. /**
  11730. * Gets the normal correspodning to the face the pick collided with
  11731. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11732. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11733. * @returns The normal correspodning to the face the pick collided with
  11734. */
  11735. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11736. /**
  11737. * Gets the texture coordinates of where the pick occured
  11738. * @returns the vector containing the coordnates of the texture
  11739. */
  11740. getTextureCoordinates(): Nullable<Vector2>;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. /**
  11745. * Gather the list of pointer event types as constants.
  11746. */
  11747. export class PointerEventTypes {
  11748. /**
  11749. * 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.
  11750. */
  11751. static readonly POINTERDOWN: number;
  11752. /**
  11753. * The pointerup event is fired when a pointer is no longer active.
  11754. */
  11755. static readonly POINTERUP: number;
  11756. /**
  11757. * The pointermove event is fired when a pointer changes coordinates.
  11758. */
  11759. static readonly POINTERMOVE: number;
  11760. /**
  11761. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11762. */
  11763. static readonly POINTERWHEEL: number;
  11764. /**
  11765. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11766. */
  11767. static readonly POINTERPICK: number;
  11768. /**
  11769. * The pointertap event is fired when a the object has been touched and released without drag.
  11770. */
  11771. static readonly POINTERTAP: number;
  11772. /**
  11773. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11774. */
  11775. static readonly POINTERDOUBLETAP: number;
  11776. }
  11777. /**
  11778. * Base class of pointer info types.
  11779. */
  11780. export class PointerInfoBase {
  11781. /**
  11782. * Defines the type of event (PointerEventTypes)
  11783. */
  11784. type: number;
  11785. /**
  11786. * Defines the related dom event
  11787. */
  11788. event: PointerEvent | MouseWheelEvent;
  11789. /**
  11790. * Instantiates the base class of pointers info.
  11791. * @param type Defines the type of event (PointerEventTypes)
  11792. * @param event Defines the related dom event
  11793. */
  11794. constructor(
  11795. /**
  11796. * Defines the type of event (PointerEventTypes)
  11797. */
  11798. type: number,
  11799. /**
  11800. * Defines the related dom event
  11801. */
  11802. event: PointerEvent | MouseWheelEvent);
  11803. }
  11804. /**
  11805. * This class is used to store pointer related info for the onPrePointerObservable event.
  11806. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11807. */
  11808. export class PointerInfoPre extends PointerInfoBase {
  11809. /**
  11810. * Ray from a pointer if availible (eg. 6dof controller)
  11811. */
  11812. ray: Nullable<Ray>;
  11813. /**
  11814. * Defines the local position of the pointer on the canvas.
  11815. */
  11816. localPosition: Vector2;
  11817. /**
  11818. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11819. */
  11820. skipOnPointerObservable: boolean;
  11821. /**
  11822. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11823. * @param type Defines the type of event (PointerEventTypes)
  11824. * @param event Defines the related dom event
  11825. * @param localX Defines the local x coordinates of the pointer when the event occured
  11826. * @param localY Defines the local y coordinates of the pointer when the event occured
  11827. */
  11828. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11829. }
  11830. /**
  11831. * This type contains all the data related to a pointer event in Babylon.js.
  11832. * 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.
  11833. */
  11834. export class PointerInfo extends PointerInfoBase {
  11835. /**
  11836. * Defines the picking info associated to the info (if any)\
  11837. */
  11838. pickInfo: Nullable<PickingInfo>;
  11839. /**
  11840. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11841. * @param type Defines the type of event (PointerEventTypes)
  11842. * @param event Defines the related dom event
  11843. * @param pickInfo Defines the picking info associated to the info (if any)\
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11846. /**
  11847. * Defines the picking info associated to the info (if any)\
  11848. */
  11849. pickInfo: Nullable<PickingInfo>);
  11850. }
  11851. /**
  11852. * Data relating to a touch event on the screen.
  11853. */
  11854. export interface PointerTouch {
  11855. /**
  11856. * X coordinate of touch.
  11857. */
  11858. x: number;
  11859. /**
  11860. * Y coordinate of touch.
  11861. */
  11862. y: number;
  11863. /**
  11864. * Id of touch. Unique for each finger.
  11865. */
  11866. pointerId: number;
  11867. /**
  11868. * Event type passed from DOM.
  11869. */
  11870. type: any;
  11871. }
  11872. }
  11873. declare module BABYLON {
  11874. /**
  11875. * Manage the mouse inputs to control the movement of a free camera.
  11876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11877. */
  11878. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11879. /**
  11880. * Define if touch is enabled in the mouse input
  11881. */
  11882. touchEnabled: boolean;
  11883. /**
  11884. * Defines the camera the input is attached to.
  11885. */
  11886. camera: FreeCamera;
  11887. /**
  11888. * Defines the buttons associated with the input to handle camera move.
  11889. */
  11890. buttons: number[];
  11891. /**
  11892. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11893. */
  11894. angularSensibility: number;
  11895. private _pointerInput;
  11896. private _onMouseMove;
  11897. private _observer;
  11898. private previousPosition;
  11899. /**
  11900. * Manage the mouse inputs to control the movement of a free camera.
  11901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11902. * @param touchEnabled Defines if touch is enabled or not
  11903. */
  11904. constructor(
  11905. /**
  11906. * Define if touch is enabled in the mouse input
  11907. */
  11908. touchEnabled?: boolean);
  11909. /**
  11910. * Attach the input controls to a specific dom element to get the input from.
  11911. * @param element Defines the element the controls should be listened from
  11912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11913. */
  11914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11915. /**
  11916. * Detach the current controls from the specified dom element.
  11917. * @param element Defines the element to stop listening the inputs from
  11918. */
  11919. detachControl(element: Nullable<HTMLElement>): void;
  11920. /**
  11921. * Gets the class name of the current intput.
  11922. * @returns the class name
  11923. */
  11924. getClassName(): string;
  11925. /**
  11926. * Get the friendly name associated with the input class.
  11927. * @returns the input friendly name
  11928. */
  11929. getSimpleName(): string;
  11930. }
  11931. }
  11932. declare module BABYLON {
  11933. /**
  11934. * Manage the touch inputs to control the movement of a free camera.
  11935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11936. */
  11937. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11938. /**
  11939. * Defines the camera the input is attached to.
  11940. */
  11941. camera: FreeCamera;
  11942. /**
  11943. * Defines the touch sensibility for rotation.
  11944. * The higher the faster.
  11945. */
  11946. touchAngularSensibility: number;
  11947. /**
  11948. * Defines the touch sensibility for move.
  11949. * The higher the faster.
  11950. */
  11951. touchMoveSensibility: number;
  11952. private _offsetX;
  11953. private _offsetY;
  11954. private _pointerPressed;
  11955. private _pointerInput;
  11956. private _observer;
  11957. private _onLostFocus;
  11958. /**
  11959. * Attach the input controls to a specific dom element to get the input from.
  11960. * @param element Defines the element the controls should be listened from
  11961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11962. */
  11963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11964. /**
  11965. * Detach the current controls from the specified dom element.
  11966. * @param element Defines the element to stop listening the inputs from
  11967. */
  11968. detachControl(element: Nullable<HTMLElement>): void;
  11969. /**
  11970. * Update the current camera state depending on the inputs that have been used this frame.
  11971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11972. */
  11973. checkInputs(): void;
  11974. /**
  11975. * Gets the class name of the current intput.
  11976. * @returns the class name
  11977. */
  11978. getClassName(): string;
  11979. /**
  11980. * Get the friendly name associated with the input class.
  11981. * @returns the input friendly name
  11982. */
  11983. getSimpleName(): string;
  11984. }
  11985. }
  11986. declare module BABYLON {
  11987. /**
  11988. * Default Inputs manager for the FreeCamera.
  11989. * It groups all the default supported inputs for ease of use.
  11990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11991. */
  11992. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11993. /**
  11994. * Instantiates a new FreeCameraInputsManager.
  11995. * @param camera Defines the camera the inputs belong to
  11996. */
  11997. constructor(camera: FreeCamera);
  11998. /**
  11999. * Add keyboard input support to the input manager.
  12000. * @returns the current input manager
  12001. */
  12002. addKeyboard(): FreeCameraInputsManager;
  12003. /**
  12004. * Add mouse input support to the input manager.
  12005. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12006. * @returns the current input manager
  12007. */
  12008. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12009. /**
  12010. * Add touch input support to the input manager.
  12011. * @returns the current input manager
  12012. */
  12013. addTouch(): FreeCameraInputsManager;
  12014. }
  12015. }
  12016. declare module BABYLON {
  12017. /**
  12018. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12019. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12021. */
  12022. export class FreeCamera extends TargetCamera {
  12023. /**
  12024. * Define the collision ellipsoid of the camera.
  12025. * This is helpful to simulate a camera body like the player body around the camera
  12026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12027. */
  12028. ellipsoid: Vector3;
  12029. /**
  12030. * Define an offset for the position of the ellipsoid around the camera.
  12031. * This can be helpful to determine the center of the body near the gravity center of the body
  12032. * instead of its head.
  12033. */
  12034. ellipsoidOffset: Vector3;
  12035. /**
  12036. * Enable or disable collisions of the camera with the rest of the scene objects.
  12037. */
  12038. checkCollisions: boolean;
  12039. /**
  12040. * Enable or disable gravity on the camera.
  12041. */
  12042. applyGravity: boolean;
  12043. /**
  12044. * Define the input manager associated to the camera.
  12045. */
  12046. inputs: FreeCameraInputsManager;
  12047. /**
  12048. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12049. * Higher values reduce sensitivity.
  12050. */
  12051. /**
  12052. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12053. * Higher values reduce sensitivity.
  12054. */
  12055. angularSensibility: number;
  12056. /**
  12057. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12058. */
  12059. keysUp: number[];
  12060. /**
  12061. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12062. */
  12063. keysDown: number[];
  12064. /**
  12065. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12066. */
  12067. keysLeft: number[];
  12068. /**
  12069. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12070. */
  12071. keysRight: number[];
  12072. /**
  12073. * Event raised when the camera collide with a mesh in the scene.
  12074. */
  12075. onCollide: (collidedMesh: AbstractMesh) => void;
  12076. private _collider;
  12077. private _needMoveForGravity;
  12078. private _oldPosition;
  12079. private _diffPosition;
  12080. private _newPosition;
  12081. /** @hidden */
  12082. _localDirection: Vector3;
  12083. /** @hidden */
  12084. _transformedDirection: Vector3;
  12085. /**
  12086. * Instantiates a Free Camera.
  12087. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12088. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12089. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12090. * @param name Define the name of the camera in the scene
  12091. * @param position Define the start position of the camera in the scene
  12092. * @param scene Define the scene the camera belongs to
  12093. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12094. */
  12095. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12096. /**
  12097. * Attached controls to the current camera.
  12098. * @param element Defines the element the controls should be listened from
  12099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12100. */
  12101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12102. /**
  12103. * Detach the current controls from the camera.
  12104. * The camera will stop reacting to inputs.
  12105. * @param element Defines the element to stop listening the inputs from
  12106. */
  12107. detachControl(element: HTMLElement): void;
  12108. private _collisionMask;
  12109. /**
  12110. * Define a collision mask to limit the list of object the camera can collide with
  12111. */
  12112. collisionMask: number;
  12113. /** @hidden */
  12114. _collideWithWorld(displacement: Vector3): void;
  12115. private _onCollisionPositionChange;
  12116. /** @hidden */
  12117. _checkInputs(): void;
  12118. /** @hidden */
  12119. _decideIfNeedsToMove(): boolean;
  12120. /** @hidden */
  12121. _updatePosition(): void;
  12122. /**
  12123. * Destroy the camera and release the current resources hold by it.
  12124. */
  12125. dispose(): void;
  12126. /**
  12127. * Gets the current object class name.
  12128. * @return the class name
  12129. */
  12130. getClassName(): string;
  12131. }
  12132. }
  12133. declare module BABYLON {
  12134. /**
  12135. * Represents a gamepad control stick position
  12136. */
  12137. export class StickValues {
  12138. /**
  12139. * The x component of the control stick
  12140. */
  12141. x: number;
  12142. /**
  12143. * The y component of the control stick
  12144. */
  12145. y: number;
  12146. /**
  12147. * Initializes the gamepad x and y control stick values
  12148. * @param x The x component of the gamepad control stick value
  12149. * @param y The y component of the gamepad control stick value
  12150. */
  12151. constructor(
  12152. /**
  12153. * The x component of the control stick
  12154. */
  12155. x: number,
  12156. /**
  12157. * The y component of the control stick
  12158. */
  12159. y: number);
  12160. }
  12161. /**
  12162. * An interface which manages callbacks for gamepad button changes
  12163. */
  12164. export interface GamepadButtonChanges {
  12165. /**
  12166. * Called when a gamepad has been changed
  12167. */
  12168. changed: boolean;
  12169. /**
  12170. * Called when a gamepad press event has been triggered
  12171. */
  12172. pressChanged: boolean;
  12173. /**
  12174. * Called when a touch event has been triggered
  12175. */
  12176. touchChanged: boolean;
  12177. /**
  12178. * Called when a value has changed
  12179. */
  12180. valueChanged: boolean;
  12181. }
  12182. /**
  12183. * Represents a gamepad
  12184. */
  12185. export class Gamepad {
  12186. /**
  12187. * The id of the gamepad
  12188. */
  12189. id: string;
  12190. /**
  12191. * The index of the gamepad
  12192. */
  12193. index: number;
  12194. /**
  12195. * The browser gamepad
  12196. */
  12197. browserGamepad: any;
  12198. /**
  12199. * Specifies what type of gamepad this represents
  12200. */
  12201. type: number;
  12202. private _leftStick;
  12203. private _rightStick;
  12204. /** @hidden */
  12205. _isConnected: boolean;
  12206. private _leftStickAxisX;
  12207. private _leftStickAxisY;
  12208. private _rightStickAxisX;
  12209. private _rightStickAxisY;
  12210. /**
  12211. * Triggered when the left control stick has been changed
  12212. */
  12213. private _onleftstickchanged;
  12214. /**
  12215. * Triggered when the right control stick has been changed
  12216. */
  12217. private _onrightstickchanged;
  12218. /**
  12219. * Represents a gamepad controller
  12220. */
  12221. static GAMEPAD: number;
  12222. /**
  12223. * Represents a generic controller
  12224. */
  12225. static GENERIC: number;
  12226. /**
  12227. * Represents an XBox controller
  12228. */
  12229. static XBOX: number;
  12230. /**
  12231. * Represents a pose-enabled controller
  12232. */
  12233. static POSE_ENABLED: number;
  12234. /**
  12235. * Specifies whether the left control stick should be Y-inverted
  12236. */
  12237. protected _invertLeftStickY: boolean;
  12238. /**
  12239. * Specifies if the gamepad has been connected
  12240. */
  12241. readonly isConnected: boolean;
  12242. /**
  12243. * Initializes the gamepad
  12244. * @param id The id of the gamepad
  12245. * @param index The index of the gamepad
  12246. * @param browserGamepad The browser gamepad
  12247. * @param leftStickX The x component of the left joystick
  12248. * @param leftStickY The y component of the left joystick
  12249. * @param rightStickX The x component of the right joystick
  12250. * @param rightStickY The y component of the right joystick
  12251. */
  12252. constructor(
  12253. /**
  12254. * The id of the gamepad
  12255. */
  12256. id: string,
  12257. /**
  12258. * The index of the gamepad
  12259. */
  12260. index: number,
  12261. /**
  12262. * The browser gamepad
  12263. */
  12264. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12265. /**
  12266. * Callback triggered when the left joystick has changed
  12267. * @param callback
  12268. */
  12269. onleftstickchanged(callback: (values: StickValues) => void): void;
  12270. /**
  12271. * Callback triggered when the right joystick has changed
  12272. * @param callback
  12273. */
  12274. onrightstickchanged(callback: (values: StickValues) => void): void;
  12275. /**
  12276. * Gets the left joystick
  12277. */
  12278. /**
  12279. * Sets the left joystick values
  12280. */
  12281. leftStick: StickValues;
  12282. /**
  12283. * Gets the right joystick
  12284. */
  12285. /**
  12286. * Sets the right joystick value
  12287. */
  12288. rightStick: StickValues;
  12289. /**
  12290. * Updates the gamepad joystick positions
  12291. */
  12292. update(): void;
  12293. /**
  12294. * Disposes the gamepad
  12295. */
  12296. dispose(): void;
  12297. }
  12298. /**
  12299. * Represents a generic gamepad
  12300. */
  12301. export class GenericPad extends Gamepad {
  12302. private _buttons;
  12303. private _onbuttondown;
  12304. private _onbuttonup;
  12305. /**
  12306. * Observable triggered when a button has been pressed
  12307. */
  12308. onButtonDownObservable: Observable<number>;
  12309. /**
  12310. * Observable triggered when a button has been released
  12311. */
  12312. onButtonUpObservable: Observable<number>;
  12313. /**
  12314. * Callback triggered when a button has been pressed
  12315. * @param callback Called when a button has been pressed
  12316. */
  12317. onbuttondown(callback: (buttonPressed: number) => void): void;
  12318. /**
  12319. * Callback triggered when a button has been released
  12320. * @param callback Called when a button has been released
  12321. */
  12322. onbuttonup(callback: (buttonReleased: number) => void): void;
  12323. /**
  12324. * Initializes the generic gamepad
  12325. * @param id The id of the generic gamepad
  12326. * @param index The index of the generic gamepad
  12327. * @param browserGamepad The browser gamepad
  12328. */
  12329. constructor(id: string, index: number, browserGamepad: any);
  12330. private _setButtonValue;
  12331. /**
  12332. * Updates the generic gamepad
  12333. */
  12334. update(): void;
  12335. /**
  12336. * Disposes the generic gamepad
  12337. */
  12338. dispose(): void;
  12339. }
  12340. }
  12341. declare module BABYLON {
  12342. /**
  12343. * Defines the types of pose enabled controllers that are supported
  12344. */
  12345. export enum PoseEnabledControllerType {
  12346. /**
  12347. * HTC Vive
  12348. */
  12349. VIVE = 0,
  12350. /**
  12351. * Oculus Rift
  12352. */
  12353. OCULUS = 1,
  12354. /**
  12355. * Windows mixed reality
  12356. */
  12357. WINDOWS = 2,
  12358. /**
  12359. * Samsung gear VR
  12360. */
  12361. GEAR_VR = 3,
  12362. /**
  12363. * Google Daydream
  12364. */
  12365. DAYDREAM = 4,
  12366. /**
  12367. * Generic
  12368. */
  12369. GENERIC = 5
  12370. }
  12371. /**
  12372. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12373. */
  12374. export interface MutableGamepadButton {
  12375. /**
  12376. * Value of the button/trigger
  12377. */
  12378. value: number;
  12379. /**
  12380. * If the button/trigger is currently touched
  12381. */
  12382. touched: boolean;
  12383. /**
  12384. * If the button/trigger is currently pressed
  12385. */
  12386. pressed: boolean;
  12387. }
  12388. /**
  12389. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12390. * @hidden
  12391. */
  12392. export interface ExtendedGamepadButton extends GamepadButton {
  12393. /**
  12394. * If the button/trigger is currently pressed
  12395. */
  12396. readonly pressed: boolean;
  12397. /**
  12398. * If the button/trigger is currently touched
  12399. */
  12400. readonly touched: boolean;
  12401. /**
  12402. * Value of the button/trigger
  12403. */
  12404. readonly value: number;
  12405. }
  12406. /** @hidden */
  12407. export interface _GamePadFactory {
  12408. /**
  12409. * Returns wether or not the current gamepad can be created for this type of controller.
  12410. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12411. * @returns true if it can be created, otherwise false
  12412. */
  12413. canCreate(gamepadInfo: any): boolean;
  12414. /**
  12415. * Creates a new instance of the Gamepad.
  12416. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12417. * @returns the new gamepad instance
  12418. */
  12419. create(gamepadInfo: any): Gamepad;
  12420. }
  12421. /**
  12422. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12423. */
  12424. export class PoseEnabledControllerHelper {
  12425. /** @hidden */
  12426. static _ControllerFactories: _GamePadFactory[];
  12427. /** @hidden */
  12428. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12429. /**
  12430. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12431. * @param vrGamepad the gamepad to initialized
  12432. * @returns a vr controller of the type the gamepad identified as
  12433. */
  12434. static InitiateController(vrGamepad: any): Gamepad;
  12435. }
  12436. /**
  12437. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12438. */
  12439. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12440. private _deviceRoomPosition;
  12441. private _deviceRoomRotationQuaternion;
  12442. /**
  12443. * The device position in babylon space
  12444. */
  12445. devicePosition: Vector3;
  12446. /**
  12447. * The device rotation in babylon space
  12448. */
  12449. deviceRotationQuaternion: Quaternion;
  12450. /**
  12451. * The scale factor of the device in babylon space
  12452. */
  12453. deviceScaleFactor: number;
  12454. /**
  12455. * (Likely devicePosition should be used instead) The device position in its room space
  12456. */
  12457. position: Vector3;
  12458. /**
  12459. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12460. */
  12461. rotationQuaternion: Quaternion;
  12462. /**
  12463. * The type of controller (Eg. Windows mixed reality)
  12464. */
  12465. controllerType: PoseEnabledControllerType;
  12466. protected _calculatedPosition: Vector3;
  12467. private _calculatedRotation;
  12468. /**
  12469. * The raw pose from the device
  12470. */
  12471. rawPose: DevicePose;
  12472. private _trackPosition;
  12473. private _maxRotationDistFromHeadset;
  12474. private _draggedRoomRotation;
  12475. /**
  12476. * @hidden
  12477. */
  12478. _disableTrackPosition(fixedPosition: Vector3): void;
  12479. /**
  12480. * Internal, the mesh attached to the controller
  12481. * @hidden
  12482. */
  12483. _mesh: Nullable<AbstractMesh>;
  12484. private _poseControlledCamera;
  12485. private _leftHandSystemQuaternion;
  12486. /**
  12487. * Internal, matrix used to convert room space to babylon space
  12488. * @hidden
  12489. */
  12490. _deviceToWorld: Matrix;
  12491. /**
  12492. * Node to be used when casting a ray from the controller
  12493. * @hidden
  12494. */
  12495. _pointingPoseNode: Nullable<TransformNode>;
  12496. /**
  12497. * Name of the child mesh that can be used to cast a ray from the controller
  12498. */
  12499. static readonly POINTING_POSE: string;
  12500. /**
  12501. * Creates a new PoseEnabledController from a gamepad
  12502. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12503. */
  12504. constructor(browserGamepad: any);
  12505. private _workingMatrix;
  12506. /**
  12507. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Updates only the pose device and mesh without doing any button event checking
  12512. */
  12513. protected _updatePoseAndMesh(): void;
  12514. /**
  12515. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12516. * @param poseData raw pose fromthe device
  12517. */
  12518. updateFromDevice(poseData: DevicePose): void;
  12519. /**
  12520. * @hidden
  12521. */
  12522. _meshAttachedObservable: Observable<AbstractMesh>;
  12523. /**
  12524. * Attaches a mesh to the controller
  12525. * @param mesh the mesh to be attached
  12526. */
  12527. attachToMesh(mesh: AbstractMesh): void;
  12528. /**
  12529. * Attaches the controllers mesh to a camera
  12530. * @param camera the camera the mesh should be attached to
  12531. */
  12532. attachToPoseControlledCamera(camera: TargetCamera): void;
  12533. /**
  12534. * Disposes of the controller
  12535. */
  12536. dispose(): void;
  12537. /**
  12538. * The mesh that is attached to the controller
  12539. */
  12540. readonly mesh: Nullable<AbstractMesh>;
  12541. /**
  12542. * Gets the ray of the controller in the direction the controller is pointing
  12543. * @param length the length the resulting ray should be
  12544. * @returns a ray in the direction the controller is pointing
  12545. */
  12546. getForwardRay(length?: number): Ray;
  12547. }
  12548. }
  12549. declare module BABYLON {
  12550. /**
  12551. * Defines the WebVRController object that represents controllers tracked in 3D space
  12552. */
  12553. export abstract class WebVRController extends PoseEnabledController {
  12554. /**
  12555. * Internal, the default controller model for the controller
  12556. */
  12557. protected _defaultModel: AbstractMesh;
  12558. /**
  12559. * Fired when the trigger state has changed
  12560. */
  12561. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12562. /**
  12563. * Fired when the main button state has changed
  12564. */
  12565. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12566. /**
  12567. * Fired when the secondary button state has changed
  12568. */
  12569. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12570. /**
  12571. * Fired when the pad state has changed
  12572. */
  12573. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12574. /**
  12575. * Fired when controllers stick values have changed
  12576. */
  12577. onPadValuesChangedObservable: Observable<StickValues>;
  12578. /**
  12579. * Array of button availible on the controller
  12580. */
  12581. protected _buttons: Array<MutableGamepadButton>;
  12582. private _onButtonStateChange;
  12583. /**
  12584. * Fired when a controller button's state has changed
  12585. * @param callback the callback containing the button that was modified
  12586. */
  12587. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12588. /**
  12589. * X and Y axis corrisponding to the controllers joystick
  12590. */
  12591. pad: StickValues;
  12592. /**
  12593. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12594. */
  12595. hand: string;
  12596. /**
  12597. * The default controller model for the controller
  12598. */
  12599. readonly defaultModel: AbstractMesh;
  12600. /**
  12601. * Creates a new WebVRController from a gamepad
  12602. * @param vrGamepad the gamepad that the WebVRController should be created from
  12603. */
  12604. constructor(vrGamepad: any);
  12605. /**
  12606. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12607. */
  12608. update(): void;
  12609. /**
  12610. * Function to be called when a button is modified
  12611. */
  12612. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12613. /**
  12614. * Loads a mesh and attaches it to the controller
  12615. * @param scene the scene the mesh should be added to
  12616. * @param meshLoaded callback for when the mesh has been loaded
  12617. */
  12618. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12619. private _setButtonValue;
  12620. private _changes;
  12621. private _checkChanges;
  12622. /**
  12623. * Disposes of th webVRCOntroller
  12624. */
  12625. dispose(): void;
  12626. }
  12627. }
  12628. declare module BABYLON {
  12629. /**
  12630. * The HemisphericLight simulates the ambient environment light,
  12631. * so the passed direction is the light reflection direction, not the incoming direction.
  12632. */
  12633. export class HemisphericLight extends Light {
  12634. /**
  12635. * The groundColor is the light in the opposite direction to the one specified during creation.
  12636. * 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.
  12637. */
  12638. groundColor: Color3;
  12639. /**
  12640. * The light reflection direction, not the incoming direction.
  12641. */
  12642. direction: Vector3;
  12643. /**
  12644. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12645. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12646. * The HemisphericLight can't cast shadows.
  12647. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12648. * @param name The friendly name of the light
  12649. * @param direction The direction of the light reflection
  12650. * @param scene The scene the light belongs to
  12651. */
  12652. constructor(name: string, direction: Vector3, scene: Scene);
  12653. protected _buildUniformLayout(): void;
  12654. /**
  12655. * Returns the string "HemisphericLight".
  12656. * @return The class name
  12657. */
  12658. getClassName(): string;
  12659. /**
  12660. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12661. * Returns the updated direction.
  12662. * @param target The target the direction should point to
  12663. * @return The computed direction
  12664. */
  12665. setDirectionToTarget(target: Vector3): Vector3;
  12666. /**
  12667. * Returns the shadow generator associated to the light.
  12668. * @returns Always null for hemispheric lights because it does not support shadows.
  12669. */
  12670. getShadowGenerator(): Nullable<IShadowGenerator>;
  12671. /**
  12672. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12673. * @param effect The effect to update
  12674. * @param lightIndex The index of the light in the effect to update
  12675. * @returns The hemispheric light
  12676. */
  12677. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12678. /**
  12679. * Computes the world matrix of the node
  12680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12681. * @param useWasUpdatedFlag defines a reserved property
  12682. * @returns the world matrix
  12683. */
  12684. computeWorldMatrix(): Matrix;
  12685. /**
  12686. * Returns the integer 3.
  12687. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12688. */
  12689. getTypeID(): number;
  12690. /**
  12691. * Prepares the list of defines specific to the light type.
  12692. * @param defines the list of defines
  12693. * @param lightIndex defines the index of the light for the effect
  12694. */
  12695. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12696. }
  12697. }
  12698. declare module BABYLON {
  12699. /**
  12700. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12701. * IMPORTANT!! The data is right-hand data.
  12702. * @export
  12703. * @interface DevicePose
  12704. */
  12705. export interface DevicePose {
  12706. /**
  12707. * The position of the device, values in array are [x,y,z].
  12708. */
  12709. readonly position: Nullable<Float32Array>;
  12710. /**
  12711. * The linearVelocity of the device, values in array are [x,y,z].
  12712. */
  12713. readonly linearVelocity: Nullable<Float32Array>;
  12714. /**
  12715. * The linearAcceleration of the device, values in array are [x,y,z].
  12716. */
  12717. readonly linearAcceleration: Nullable<Float32Array>;
  12718. /**
  12719. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12720. */
  12721. readonly orientation: Nullable<Float32Array>;
  12722. /**
  12723. * The angularVelocity of the device, values in array are [x,y,z].
  12724. */
  12725. readonly angularVelocity: Nullable<Float32Array>;
  12726. /**
  12727. * The angularAcceleration of the device, values in array are [x,y,z].
  12728. */
  12729. readonly angularAcceleration: Nullable<Float32Array>;
  12730. }
  12731. /**
  12732. * Interface representing a pose controlled object in Babylon.
  12733. * A pose controlled object has both regular pose values as well as pose values
  12734. * from an external device such as a VR head mounted display
  12735. */
  12736. export interface PoseControlled {
  12737. /**
  12738. * The position of the object in babylon space.
  12739. */
  12740. position: Vector3;
  12741. /**
  12742. * The rotation quaternion of the object in babylon space.
  12743. */
  12744. rotationQuaternion: Quaternion;
  12745. /**
  12746. * The position of the device in babylon space.
  12747. */
  12748. devicePosition?: Vector3;
  12749. /**
  12750. * The rotation quaternion of the device in babylon space.
  12751. */
  12752. deviceRotationQuaternion: Quaternion;
  12753. /**
  12754. * The raw pose coming from the device.
  12755. */
  12756. rawPose: Nullable<DevicePose>;
  12757. /**
  12758. * The scale of the device to be used when translating from device space to babylon space.
  12759. */
  12760. deviceScaleFactor: number;
  12761. /**
  12762. * Updates the poseControlled values based on the input device pose.
  12763. * @param poseData the pose data to update the object with
  12764. */
  12765. updateFromDevice(poseData: DevicePose): void;
  12766. }
  12767. /**
  12768. * Set of options to customize the webVRCamera
  12769. */
  12770. export interface WebVROptions {
  12771. /**
  12772. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12773. */
  12774. trackPosition?: boolean;
  12775. /**
  12776. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12777. */
  12778. positionScale?: number;
  12779. /**
  12780. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12781. */
  12782. displayName?: string;
  12783. /**
  12784. * Should the native controller meshes be initialized. (default: true)
  12785. */
  12786. controllerMeshes?: boolean;
  12787. /**
  12788. * Creating a default HemiLight only on controllers. (default: true)
  12789. */
  12790. defaultLightingOnControllers?: boolean;
  12791. /**
  12792. * If you don't want to use the default VR button of the helper. (default: false)
  12793. */
  12794. useCustomVRButton?: boolean;
  12795. /**
  12796. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12797. */
  12798. customVRButton?: HTMLButtonElement;
  12799. /**
  12800. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12801. */
  12802. rayLength?: number;
  12803. /**
  12804. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12805. */
  12806. defaultHeight?: number;
  12807. }
  12808. /**
  12809. * This represents a WebVR camera.
  12810. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12811. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12812. */
  12813. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12814. private webVROptions;
  12815. /**
  12816. * @hidden
  12817. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12818. */
  12819. _vrDevice: any;
  12820. /**
  12821. * The rawPose of the vrDevice.
  12822. */
  12823. rawPose: Nullable<DevicePose>;
  12824. private _onVREnabled;
  12825. private _specsVersion;
  12826. private _attached;
  12827. private _frameData;
  12828. protected _descendants: Array<Node>;
  12829. private _deviceRoomPosition;
  12830. /** @hidden */
  12831. _deviceRoomRotationQuaternion: Quaternion;
  12832. private _standingMatrix;
  12833. /**
  12834. * Represents device position in babylon space.
  12835. */
  12836. devicePosition: Vector3;
  12837. /**
  12838. * Represents device rotation in babylon space.
  12839. */
  12840. deviceRotationQuaternion: Quaternion;
  12841. /**
  12842. * The scale of the device to be used when translating from device space to babylon space.
  12843. */
  12844. deviceScaleFactor: number;
  12845. private _deviceToWorld;
  12846. private _worldToDevice;
  12847. /**
  12848. * References to the webVR controllers for the vrDevice.
  12849. */
  12850. controllers: Array<WebVRController>;
  12851. /**
  12852. * Emits an event when a controller is attached.
  12853. */
  12854. onControllersAttachedObservable: Observable<WebVRController[]>;
  12855. /**
  12856. * Emits an event when a controller's mesh has been loaded;
  12857. */
  12858. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12859. /**
  12860. * Emits an event when the HMD's pose has been updated.
  12861. */
  12862. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12863. private _poseSet;
  12864. /**
  12865. * If the rig cameras be used as parent instead of this camera.
  12866. */
  12867. rigParenting: boolean;
  12868. private _lightOnControllers;
  12869. private _defaultHeight?;
  12870. /**
  12871. * Instantiates a WebVRFreeCamera.
  12872. * @param name The name of the WebVRFreeCamera
  12873. * @param position The starting anchor position for the camera
  12874. * @param scene The scene the camera belongs to
  12875. * @param webVROptions a set of customizable options for the webVRCamera
  12876. */
  12877. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  12878. /**
  12879. * Gets the device distance from the ground in meters.
  12880. * @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.
  12881. */
  12882. deviceDistanceToRoomGround(): number;
  12883. /**
  12884. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12885. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  12886. */
  12887. useStandingMatrix(callback?: (bool: boolean) => void): void;
  12888. /**
  12889. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  12890. * @returns A promise with a boolean set to if the standing matrix is supported.
  12891. */
  12892. useStandingMatrixAsync(): Promise<boolean>;
  12893. /**
  12894. * Disposes the camera
  12895. */
  12896. dispose(): void;
  12897. /**
  12898. * Gets a vrController by name.
  12899. * @param name The name of the controller to retreive
  12900. * @returns the controller matching the name specified or null if not found
  12901. */
  12902. getControllerByName(name: string): Nullable<WebVRController>;
  12903. private _leftController;
  12904. /**
  12905. * The controller corrisponding to the users left hand.
  12906. */
  12907. readonly leftController: Nullable<WebVRController>;
  12908. private _rightController;
  12909. /**
  12910. * The controller corrisponding to the users right hand.
  12911. */
  12912. readonly rightController: Nullable<WebVRController>;
  12913. /**
  12914. * Casts a ray forward from the vrCamera's gaze.
  12915. * @param length Length of the ray (default: 100)
  12916. * @returns the ray corrisponding to the gaze
  12917. */
  12918. getForwardRay(length?: number): Ray;
  12919. /**
  12920. * @hidden
  12921. * Updates the camera based on device's frame data
  12922. */
  12923. _checkInputs(): void;
  12924. /**
  12925. * Updates the poseControlled values based on the input device pose.
  12926. * @param poseData Pose coming from the device
  12927. */
  12928. updateFromDevice(poseData: DevicePose): void;
  12929. private _htmlElementAttached;
  12930. private _detachIfAttached;
  12931. /**
  12932. * WebVR's attach control will start broadcasting frames to the device.
  12933. * Note that in certain browsers (chrome for example) this function must be called
  12934. * within a user-interaction callback. Example:
  12935. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  12936. *
  12937. * @param element html element to attach the vrDevice to
  12938. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  12939. */
  12940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12941. /**
  12942. * Detaches the camera from the html element and disables VR
  12943. *
  12944. * @param element html element to detach from
  12945. */
  12946. detachControl(element: HTMLElement): void;
  12947. /**
  12948. * @returns the name of this class
  12949. */
  12950. getClassName(): string;
  12951. /**
  12952. * Calls resetPose on the vrDisplay
  12953. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  12954. */
  12955. resetToCurrentRotation(): void;
  12956. /**
  12957. * @hidden
  12958. * Updates the rig cameras (left and right eye)
  12959. */
  12960. _updateRigCameras(): void;
  12961. private _workingVector;
  12962. private _oneVector;
  12963. private _workingMatrix;
  12964. private updateCacheCalled;
  12965. private _correctPositionIfNotTrackPosition;
  12966. /**
  12967. * @hidden
  12968. * Updates the cached values of the camera
  12969. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  12970. */
  12971. _updateCache(ignoreParentClass?: boolean): void;
  12972. /**
  12973. * @hidden
  12974. * Get current device position in babylon world
  12975. */
  12976. _computeDevicePosition(): void;
  12977. /**
  12978. * Updates the current device position and rotation in the babylon world
  12979. */
  12980. update(): void;
  12981. /**
  12982. * @hidden
  12983. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12984. * @returns an identity matrix
  12985. */
  12986. _getViewMatrix(): Matrix;
  12987. private _tmpMatrix;
  12988. /**
  12989. * This function is called by the two RIG cameras.
  12990. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12991. * @hidden
  12992. */
  12993. _getWebVRViewMatrix(): Matrix;
  12994. /** @hidden */
  12995. _getWebVRProjectionMatrix(): Matrix;
  12996. private _onGamepadConnectedObserver;
  12997. private _onGamepadDisconnectedObserver;
  12998. private _updateCacheWhenTrackingDisabledObserver;
  12999. /**
  13000. * Initializes the controllers and their meshes
  13001. */
  13002. initControllers(): void;
  13003. }
  13004. }
  13005. declare module BABYLON {
  13006. /**
  13007. * Size options for a post process
  13008. */
  13009. export type PostProcessOptions = {
  13010. width: number;
  13011. height: number;
  13012. };
  13013. /**
  13014. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13015. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13016. */
  13017. export class PostProcess {
  13018. /** Name of the PostProcess. */
  13019. name: string;
  13020. /**
  13021. * Gets or sets the unique id of the post process
  13022. */
  13023. uniqueId: number;
  13024. /**
  13025. * Width of the texture to apply the post process on
  13026. */
  13027. width: number;
  13028. /**
  13029. * Height of the texture to apply the post process on
  13030. */
  13031. height: number;
  13032. /**
  13033. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13034. * @hidden
  13035. */
  13036. _outputTexture: Nullable<InternalTexture>;
  13037. /**
  13038. * Sampling mode used by the shader
  13039. * See https://doc.babylonjs.com/classes/3.1/texture
  13040. */
  13041. renderTargetSamplingMode: number;
  13042. /**
  13043. * Clear color to use when screen clearing
  13044. */
  13045. clearColor: Color4;
  13046. /**
  13047. * If the buffer needs to be cleared before applying the post process. (default: true)
  13048. * Should be set to false if shader will overwrite all previous pixels.
  13049. */
  13050. autoClear: boolean;
  13051. /**
  13052. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13053. */
  13054. alphaMode: number;
  13055. /**
  13056. * Sets the setAlphaBlendConstants of the babylon engine
  13057. */
  13058. alphaConstants: Color4;
  13059. /**
  13060. * Animations to be used for the post processing
  13061. */
  13062. animations: Animation[];
  13063. /**
  13064. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13065. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13066. */
  13067. enablePixelPerfectMode: boolean;
  13068. /**
  13069. * Force the postprocess to be applied without taking in account viewport
  13070. */
  13071. forceFullscreenViewport: boolean;
  13072. /**
  13073. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13074. *
  13075. * | Value | Type | Description |
  13076. * | ----- | ----------------------------------- | ----------- |
  13077. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13078. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13079. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13080. *
  13081. */
  13082. scaleMode: number;
  13083. /**
  13084. * Force textures to be a power of two (default: false)
  13085. */
  13086. alwaysForcePOT: boolean;
  13087. private _samples;
  13088. /**
  13089. * Number of sample textures (default: 1)
  13090. */
  13091. samples: number;
  13092. /**
  13093. * Modify the scale of the post process to be the same as the viewport (default: false)
  13094. */
  13095. adaptScaleToCurrentViewport: boolean;
  13096. private _camera;
  13097. private _scene;
  13098. private _engine;
  13099. private _options;
  13100. private _reusable;
  13101. private _textureType;
  13102. /**
  13103. * Smart array of input and output textures for the post process.
  13104. * @hidden
  13105. */
  13106. _textures: SmartArray<InternalTexture>;
  13107. /**
  13108. * The index in _textures that corresponds to the output texture.
  13109. * @hidden
  13110. */
  13111. _currentRenderTextureInd: number;
  13112. private _effect;
  13113. private _samplers;
  13114. private _fragmentUrl;
  13115. private _vertexUrl;
  13116. private _parameters;
  13117. private _scaleRatio;
  13118. protected _indexParameters: any;
  13119. private _shareOutputWithPostProcess;
  13120. private _texelSize;
  13121. private _forcedOutputTexture;
  13122. /**
  13123. * Returns the fragment url or shader name used in the post process.
  13124. * @returns the fragment url or name in the shader store.
  13125. */
  13126. getEffectName(): string;
  13127. /**
  13128. * An event triggered when the postprocess is activated.
  13129. */
  13130. onActivateObservable: Observable<Camera>;
  13131. private _onActivateObserver;
  13132. /**
  13133. * A function that is added to the onActivateObservable
  13134. */
  13135. onActivate: Nullable<(camera: Camera) => void>;
  13136. /**
  13137. * An event triggered when the postprocess changes its size.
  13138. */
  13139. onSizeChangedObservable: Observable<PostProcess>;
  13140. private _onSizeChangedObserver;
  13141. /**
  13142. * A function that is added to the onSizeChangedObservable
  13143. */
  13144. onSizeChanged: (postProcess: PostProcess) => void;
  13145. /**
  13146. * An event triggered when the postprocess applies its effect.
  13147. */
  13148. onApplyObservable: Observable<Effect>;
  13149. private _onApplyObserver;
  13150. /**
  13151. * A function that is added to the onApplyObservable
  13152. */
  13153. onApply: (effect: Effect) => void;
  13154. /**
  13155. * An event triggered before rendering the postprocess
  13156. */
  13157. onBeforeRenderObservable: Observable<Effect>;
  13158. private _onBeforeRenderObserver;
  13159. /**
  13160. * A function that is added to the onBeforeRenderObservable
  13161. */
  13162. onBeforeRender: (effect: Effect) => void;
  13163. /**
  13164. * An event triggered after rendering the postprocess
  13165. */
  13166. onAfterRenderObservable: Observable<Effect>;
  13167. private _onAfterRenderObserver;
  13168. /**
  13169. * A function that is added to the onAfterRenderObservable
  13170. */
  13171. onAfterRender: (efect: Effect) => void;
  13172. /**
  13173. * 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
  13174. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13175. */
  13176. inputTexture: InternalTexture;
  13177. /**
  13178. * Gets the camera which post process is applied to.
  13179. * @returns The camera the post process is applied to.
  13180. */
  13181. getCamera(): Camera;
  13182. /**
  13183. * Gets the texel size of the postprocess.
  13184. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13185. */
  13186. readonly texelSize: Vector2;
  13187. /**
  13188. * Creates a new instance PostProcess
  13189. * @param name The name of the PostProcess.
  13190. * @param fragmentUrl The url of the fragment shader to be used.
  13191. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13192. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13193. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13194. * @param camera The camera to apply the render pass to.
  13195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13196. * @param engine The engine which the post process will be applied. (default: current engine)
  13197. * @param reusable If the post process can be reused on the same frame. (default: false)
  13198. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13199. * @param textureType Type of textures used when performing the post process. (default: 0)
  13200. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13201. * @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
  13202. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13203. */
  13204. constructor(
  13205. /** Name of the PostProcess. */
  13206. 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);
  13207. /**
  13208. * Gets a string idenfifying the name of the class
  13209. * @returns "PostProcess" string
  13210. */
  13211. getClassName(): string;
  13212. /**
  13213. * Gets the engine which this post process belongs to.
  13214. * @returns The engine the post process was enabled with.
  13215. */
  13216. getEngine(): Engine;
  13217. /**
  13218. * The effect that is created when initializing the post process.
  13219. * @returns The created effect corrisponding the the postprocess.
  13220. */
  13221. getEffect(): Effect;
  13222. /**
  13223. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13224. * @param postProcess The post process to share the output with.
  13225. * @returns This post process.
  13226. */
  13227. shareOutputWith(postProcess: PostProcess): PostProcess;
  13228. /**
  13229. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13230. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13231. */
  13232. useOwnOutput(): void;
  13233. /**
  13234. * Updates the effect with the current post process compile time values and recompiles the shader.
  13235. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13236. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13237. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13238. * @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
  13239. * @param onCompiled Called when the shader has been compiled.
  13240. * @param onError Called if there is an error when compiling a shader.
  13241. */
  13242. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13243. /**
  13244. * The post process is reusable if it can be used multiple times within one frame.
  13245. * @returns If the post process is reusable
  13246. */
  13247. isReusable(): boolean;
  13248. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13249. markTextureDirty(): void;
  13250. /**
  13251. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13252. * 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.
  13253. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13254. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13255. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13256. * @returns The target texture that was bound to be written to.
  13257. */
  13258. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13259. /**
  13260. * If the post process is supported.
  13261. */
  13262. readonly isSupported: boolean;
  13263. /**
  13264. * The aspect ratio of the output texture.
  13265. */
  13266. readonly aspectRatio: number;
  13267. /**
  13268. * Get a value indicating if the post-process is ready to be used
  13269. * @returns true if the post-process is ready (shader is compiled)
  13270. */
  13271. isReady(): boolean;
  13272. /**
  13273. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13274. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13275. */
  13276. apply(): Nullable<Effect>;
  13277. private _disposeTextures;
  13278. /**
  13279. * Disposes the post process.
  13280. * @param camera The camera to dispose the post process on.
  13281. */
  13282. dispose(camera?: Camera): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13288. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13289. */
  13290. export class PostProcessManager {
  13291. private _scene;
  13292. private _indexBuffer;
  13293. private _vertexBuffers;
  13294. /**
  13295. * Creates a new instance PostProcess
  13296. * @param scene The scene that the post process is associated with.
  13297. */
  13298. constructor(scene: Scene);
  13299. private _prepareBuffers;
  13300. private _buildIndexBuffer;
  13301. /**
  13302. * Rebuilds the vertex buffers of the manager.
  13303. * @hidden
  13304. */
  13305. _rebuild(): void;
  13306. /**
  13307. * Prepares a frame to be run through a post process.
  13308. * @param sourceTexture The input texture to the post procesess. (default: null)
  13309. * @param postProcesses An array of post processes to be run. (default: null)
  13310. * @returns True if the post processes were able to be run.
  13311. * @hidden
  13312. */
  13313. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13314. /**
  13315. * Manually render a set of post processes to a texture.
  13316. * @param postProcesses An array of post processes to be run.
  13317. * @param targetTexture The target texture to render to.
  13318. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13319. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13320. * @param lodLevel defines which lod of the texture to render to
  13321. */
  13322. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13323. /**
  13324. * Finalize the result of the output of the postprocesses.
  13325. * @param doNotPresent If true the result will not be displayed to the screen.
  13326. * @param targetTexture The target texture to render to.
  13327. * @param faceIndex The index of the face to bind the target texture to.
  13328. * @param postProcesses The array of post processes to render.
  13329. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13330. * @hidden
  13331. */
  13332. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13333. /**
  13334. * Disposes of the post process manager.
  13335. */
  13336. dispose(): void;
  13337. }
  13338. }
  13339. declare module BABYLON {
  13340. interface AbstractScene {
  13341. /**
  13342. * The list of layers (background and foreground) of the scene
  13343. */
  13344. layers: Array<Layer>;
  13345. }
  13346. /**
  13347. * Defines the layer scene component responsible to manage any layers
  13348. * in a given scene.
  13349. */
  13350. export class LayerSceneComponent implements ISceneComponent {
  13351. /**
  13352. * The component name helpfull to identify the component in the list of scene components.
  13353. */
  13354. readonly name: string;
  13355. /**
  13356. * The scene the component belongs to.
  13357. */
  13358. scene: Scene;
  13359. private _engine;
  13360. /**
  13361. * Creates a new instance of the component for the given scene
  13362. * @param scene Defines the scene to register the component in
  13363. */
  13364. constructor(scene: Scene);
  13365. /**
  13366. * Registers the component in a given scene
  13367. */
  13368. register(): void;
  13369. /**
  13370. * Rebuilds the elements related to this component in case of
  13371. * context lost for instance.
  13372. */
  13373. rebuild(): void;
  13374. /**
  13375. * Disposes the component and the associated ressources.
  13376. */
  13377. dispose(): void;
  13378. private _draw;
  13379. private _drawCameraPredicate;
  13380. private _drawCameraBackground;
  13381. private _drawCameraForeground;
  13382. private _drawRenderTargetPredicate;
  13383. private _drawRenderTargetBackground;
  13384. private _drawRenderTargetForeground;
  13385. }
  13386. }
  13387. declare module BABYLON {
  13388. /** @hidden */
  13389. export var layerPixelShader: {
  13390. name: string;
  13391. shader: string;
  13392. };
  13393. }
  13394. declare module BABYLON {
  13395. /** @hidden */
  13396. export var layerVertexShader: {
  13397. name: string;
  13398. shader: string;
  13399. };
  13400. }
  13401. declare module BABYLON {
  13402. /**
  13403. * This represents a full screen 2d layer.
  13404. * This can be useful to display a picture in the background of your scene for instance.
  13405. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13406. */
  13407. export class Layer {
  13408. /**
  13409. * Define the name of the layer.
  13410. */
  13411. name: string;
  13412. /**
  13413. * Define the texture the layer should display.
  13414. */
  13415. texture: Nullable<Texture>;
  13416. /**
  13417. * Is the layer in background or foreground.
  13418. */
  13419. isBackground: boolean;
  13420. /**
  13421. * Define the color of the layer (instead of texture).
  13422. */
  13423. color: Color4;
  13424. /**
  13425. * Define the scale of the layer in order to zoom in out of the texture.
  13426. */
  13427. scale: Vector2;
  13428. /**
  13429. * Define an offset for the layer in order to shift the texture.
  13430. */
  13431. offset: Vector2;
  13432. /**
  13433. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13434. */
  13435. alphaBlendingMode: number;
  13436. /**
  13437. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13438. * Alpha test will not mix with the background color in case of transparency.
  13439. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13440. */
  13441. alphaTest: boolean;
  13442. /**
  13443. * Define a mask to restrict the layer to only some of the scene cameras.
  13444. */
  13445. layerMask: number;
  13446. /**
  13447. * Define the list of render target the layer is visible into.
  13448. */
  13449. renderTargetTextures: RenderTargetTexture[];
  13450. /**
  13451. * Define if the layer is only used in renderTarget or if it also
  13452. * renders in the main frame buffer of the canvas.
  13453. */
  13454. renderOnlyInRenderTargetTextures: boolean;
  13455. private _scene;
  13456. private _vertexBuffers;
  13457. private _indexBuffer;
  13458. private _effect;
  13459. private _alphaTestEffect;
  13460. /**
  13461. * An event triggered when the layer is disposed.
  13462. */
  13463. onDisposeObservable: Observable<Layer>;
  13464. private _onDisposeObserver;
  13465. /**
  13466. * Back compatibility with callback before the onDisposeObservable existed.
  13467. * The set callback will be triggered when the layer has been disposed.
  13468. */
  13469. onDispose: () => void;
  13470. /**
  13471. * An event triggered before rendering the scene
  13472. */
  13473. onBeforeRenderObservable: Observable<Layer>;
  13474. private _onBeforeRenderObserver;
  13475. /**
  13476. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13477. * The set callback will be triggered just before rendering the layer.
  13478. */
  13479. onBeforeRender: () => void;
  13480. /**
  13481. * An event triggered after rendering the scene
  13482. */
  13483. onAfterRenderObservable: Observable<Layer>;
  13484. private _onAfterRenderObserver;
  13485. /**
  13486. * Back compatibility with callback before the onAfterRenderObservable existed.
  13487. * The set callback will be triggered just after rendering the layer.
  13488. */
  13489. onAfterRender: () => void;
  13490. /**
  13491. * Instantiates a new layer.
  13492. * This represents a full screen 2d layer.
  13493. * This can be useful to display a picture in the background of your scene for instance.
  13494. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13495. * @param name Define the name of the layer in the scene
  13496. * @param imgUrl Define the url of the texture to display in the layer
  13497. * @param scene Define the scene the layer belongs to
  13498. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13499. * @param color Defines a color for the layer
  13500. */
  13501. constructor(
  13502. /**
  13503. * Define the name of the layer.
  13504. */
  13505. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13506. private _createIndexBuffer;
  13507. /** @hidden */
  13508. _rebuild(): void;
  13509. /**
  13510. * Renders the layer in the scene.
  13511. */
  13512. render(): void;
  13513. /**
  13514. * Disposes and releases the associated ressources.
  13515. */
  13516. dispose(): void;
  13517. }
  13518. }
  13519. declare module BABYLON {
  13520. interface AbstractScene {
  13521. /**
  13522. * The list of procedural textures added to the scene
  13523. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13524. */
  13525. proceduralTextures: Array<ProceduralTexture>;
  13526. }
  13527. /**
  13528. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13529. * in a given scene.
  13530. */
  13531. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13532. /**
  13533. * The component name helpfull to identify the component in the list of scene components.
  13534. */
  13535. readonly name: string;
  13536. /**
  13537. * The scene the component belongs to.
  13538. */
  13539. scene: Scene;
  13540. /**
  13541. * Creates a new instance of the component for the given scene
  13542. * @param scene Defines the scene to register the component in
  13543. */
  13544. constructor(scene: Scene);
  13545. /**
  13546. * Registers the component in a given scene
  13547. */
  13548. register(): void;
  13549. /**
  13550. * Rebuilds the elements related to this component in case of
  13551. * context lost for instance.
  13552. */
  13553. rebuild(): void;
  13554. /**
  13555. * Disposes the component and the associated ressources.
  13556. */
  13557. dispose(): void;
  13558. private _beforeClear;
  13559. }
  13560. }
  13561. declare module BABYLON {
  13562. /** @hidden */
  13563. export var proceduralVertexShader: {
  13564. name: string;
  13565. shader: string;
  13566. };
  13567. }
  13568. declare module BABYLON {
  13569. /**
  13570. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13571. * This is the base class of any Procedural texture and contains most of the shareable code.
  13572. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13573. */
  13574. export class ProceduralTexture extends Texture {
  13575. isCube: boolean;
  13576. /**
  13577. * Define if the texture is enabled or not (disabled texture will not render)
  13578. */
  13579. isEnabled: boolean;
  13580. /**
  13581. * Define if the texture must be cleared before rendering (default is true)
  13582. */
  13583. autoClear: boolean;
  13584. /**
  13585. * Callback called when the texture is generated
  13586. */
  13587. onGenerated: () => void;
  13588. /**
  13589. * Event raised when the texture is generated
  13590. */
  13591. onGeneratedObservable: Observable<ProceduralTexture>;
  13592. /** @hidden */
  13593. _generateMipMaps: boolean;
  13594. /** @hidden **/
  13595. _effect: Effect;
  13596. /** @hidden */
  13597. _textures: {
  13598. [key: string]: Texture;
  13599. };
  13600. private _size;
  13601. private _currentRefreshId;
  13602. private _refreshRate;
  13603. private _vertexBuffers;
  13604. private _indexBuffer;
  13605. private _uniforms;
  13606. private _samplers;
  13607. private _fragment;
  13608. private _floats;
  13609. private _ints;
  13610. private _floatsArrays;
  13611. private _colors3;
  13612. private _colors4;
  13613. private _vectors2;
  13614. private _vectors3;
  13615. private _matrices;
  13616. private _fallbackTexture;
  13617. private _fallbackTextureUsed;
  13618. private _engine;
  13619. private _cachedDefines;
  13620. private _contentUpdateId;
  13621. private _contentData;
  13622. /**
  13623. * Instantiates a new procedural texture.
  13624. * 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.
  13625. * This is the base class of any Procedural texture and contains most of the shareable code.
  13626. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13627. * @param name Define the name of the texture
  13628. * @param size Define the size of the texture to create
  13629. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13630. * @param scene Define the scene the texture belongs to
  13631. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13632. * @param generateMipMaps Define if the texture should creates mip maps or not
  13633. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13634. */
  13635. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13636. /**
  13637. * The effect that is created when initializing the post process.
  13638. * @returns The created effect corrisponding the the postprocess.
  13639. */
  13640. getEffect(): Effect;
  13641. /**
  13642. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13643. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13644. */
  13645. getContent(): Nullable<ArrayBufferView>;
  13646. private _createIndexBuffer;
  13647. /** @hidden */
  13648. _rebuild(): void;
  13649. /**
  13650. * Resets the texture in order to recreate its associated resources.
  13651. * This can be called in case of context loss
  13652. */
  13653. reset(): void;
  13654. protected _getDefines(): string;
  13655. /**
  13656. * Is the texture ready to be used ? (rendered at least once)
  13657. * @returns true if ready, otherwise, false.
  13658. */
  13659. isReady(): boolean;
  13660. /**
  13661. * Resets the refresh counter of the texture and start bak from scratch.
  13662. * Could be useful to regenerate the texture if it is setup to render only once.
  13663. */
  13664. resetRefreshCounter(): void;
  13665. /**
  13666. * Set the fragment shader to use in order to render the texture.
  13667. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13668. */
  13669. setFragment(fragment: any): void;
  13670. /**
  13671. * Define the refresh rate of the texture or the rendering frequency.
  13672. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13673. */
  13674. refreshRate: number;
  13675. /** @hidden */
  13676. _shouldRender(): boolean;
  13677. /**
  13678. * Get the size the texture is rendering at.
  13679. * @returns the size (texture is always squared)
  13680. */
  13681. getRenderSize(): number;
  13682. /**
  13683. * Resize the texture to new value.
  13684. * @param size Define the new size the texture should have
  13685. * @param generateMipMaps Define whether the new texture should create mip maps
  13686. */
  13687. resize(size: number, generateMipMaps: boolean): void;
  13688. private _checkUniform;
  13689. /**
  13690. * Set a texture in the shader program used to render.
  13691. * @param name Define the name of the uniform samplers as defined in the shader
  13692. * @param texture Define the texture to bind to this sampler
  13693. * @return the texture itself allowing "fluent" like uniform updates
  13694. */
  13695. setTexture(name: string, texture: Texture): ProceduralTexture;
  13696. /**
  13697. * Set a float in the shader.
  13698. * @param name Define the name of the uniform as defined in the shader
  13699. * @param value Define the value to give to the uniform
  13700. * @return the texture itself allowing "fluent" like uniform updates
  13701. */
  13702. setFloat(name: string, value: number): ProceduralTexture;
  13703. /**
  13704. * Set a int in the shader.
  13705. * @param name Define the name of the uniform as defined in the shader
  13706. * @param value Define the value to give to the uniform
  13707. * @return the texture itself allowing "fluent" like uniform updates
  13708. */
  13709. setInt(name: string, value: number): ProceduralTexture;
  13710. /**
  13711. * Set an array of floats in the shader.
  13712. * @param name Define the name of the uniform as defined in the shader
  13713. * @param value Define the value to give to the uniform
  13714. * @return the texture itself allowing "fluent" like uniform updates
  13715. */
  13716. setFloats(name: string, value: number[]): ProceduralTexture;
  13717. /**
  13718. * Set a vec3 in the shader from a Color3.
  13719. * @param name Define the name of the uniform as defined in the shader
  13720. * @param value Define the value to give to the uniform
  13721. * @return the texture itself allowing "fluent" like uniform updates
  13722. */
  13723. setColor3(name: string, value: Color3): ProceduralTexture;
  13724. /**
  13725. * Set a vec4 in the shader from a Color4.
  13726. * @param name Define the name of the uniform as defined in the shader
  13727. * @param value Define the value to give to the uniform
  13728. * @return the texture itself allowing "fluent" like uniform updates
  13729. */
  13730. setColor4(name: string, value: Color4): ProceduralTexture;
  13731. /**
  13732. * Set a vec2 in the shader from a Vector2.
  13733. * @param name Define the name of the uniform as defined in the shader
  13734. * @param value Define the value to give to the uniform
  13735. * @return the texture itself allowing "fluent" like uniform updates
  13736. */
  13737. setVector2(name: string, value: Vector2): ProceduralTexture;
  13738. /**
  13739. * Set a vec3 in the shader from a Vector3.
  13740. * @param name Define the name of the uniform as defined in the shader
  13741. * @param value Define the value to give to the uniform
  13742. * @return the texture itself allowing "fluent" like uniform updates
  13743. */
  13744. setVector3(name: string, value: Vector3): ProceduralTexture;
  13745. /**
  13746. * Set a mat4 in the shader from a MAtrix.
  13747. * @param name Define the name of the uniform as defined in the shader
  13748. * @param value Define the value to give to the uniform
  13749. * @return the texture itself allowing "fluent" like uniform updates
  13750. */
  13751. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13752. /**
  13753. * Render the texture to its associated render target.
  13754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13755. */
  13756. render(useCameraPostProcess?: boolean): void;
  13757. /**
  13758. * Clone the texture.
  13759. * @returns the cloned texture
  13760. */
  13761. clone(): ProceduralTexture;
  13762. /**
  13763. * Dispose the texture and release its asoociated resources.
  13764. */
  13765. dispose(): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. /**
  13770. * This represents the base class for particle system in Babylon.
  13771. * 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.
  13772. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13773. * @example https://doc.babylonjs.com/babylon101/particles
  13774. */
  13775. export class BaseParticleSystem {
  13776. /**
  13777. * Source color is added to the destination color without alpha affecting the result
  13778. */
  13779. static BLENDMODE_ONEONE: number;
  13780. /**
  13781. * Blend current color and particle color using particle’s alpha
  13782. */
  13783. static BLENDMODE_STANDARD: number;
  13784. /**
  13785. * Add current color and particle color multiplied by particle’s alpha
  13786. */
  13787. static BLENDMODE_ADD: number;
  13788. /**
  13789. * Multiply current color with particle color
  13790. */
  13791. static BLENDMODE_MULTIPLY: number;
  13792. /**
  13793. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13794. */
  13795. static BLENDMODE_MULTIPLYADD: number;
  13796. /**
  13797. * List of animations used by the particle system.
  13798. */
  13799. animations: Animation[];
  13800. /**
  13801. * The id of the Particle system.
  13802. */
  13803. id: string;
  13804. /**
  13805. * The friendly name of the Particle system.
  13806. */
  13807. name: string;
  13808. /**
  13809. * The rendering group used by the Particle system to chose when to render.
  13810. */
  13811. renderingGroupId: number;
  13812. /**
  13813. * The emitter represents the Mesh or position we are attaching the particle system to.
  13814. */
  13815. emitter: Nullable<AbstractMesh | Vector3>;
  13816. /**
  13817. * The maximum number of particles to emit per frame
  13818. */
  13819. emitRate: number;
  13820. /**
  13821. * If you want to launch only a few particles at once, that can be done, as well.
  13822. */
  13823. manualEmitCount: number;
  13824. /**
  13825. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13826. */
  13827. updateSpeed: number;
  13828. /**
  13829. * The amount of time the particle system is running (depends of the overall update speed).
  13830. */
  13831. targetStopDuration: number;
  13832. /**
  13833. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13834. */
  13835. disposeOnStop: boolean;
  13836. /**
  13837. * Minimum power of emitting particles.
  13838. */
  13839. minEmitPower: number;
  13840. /**
  13841. * Maximum power of emitting particles.
  13842. */
  13843. maxEmitPower: number;
  13844. /**
  13845. * Minimum life time of emitting particles.
  13846. */
  13847. minLifeTime: number;
  13848. /**
  13849. * Maximum life time of emitting particles.
  13850. */
  13851. maxLifeTime: number;
  13852. /**
  13853. * Minimum Size of emitting particles.
  13854. */
  13855. minSize: number;
  13856. /**
  13857. * Maximum Size of emitting particles.
  13858. */
  13859. maxSize: number;
  13860. /**
  13861. * Minimum scale of emitting particles on X axis.
  13862. */
  13863. minScaleX: number;
  13864. /**
  13865. * Maximum scale of emitting particles on X axis.
  13866. */
  13867. maxScaleX: number;
  13868. /**
  13869. * Minimum scale of emitting particles on Y axis.
  13870. */
  13871. minScaleY: number;
  13872. /**
  13873. * Maximum scale of emitting particles on Y axis.
  13874. */
  13875. maxScaleY: number;
  13876. /**
  13877. * Gets or sets the minimal initial rotation in radians.
  13878. */
  13879. minInitialRotation: number;
  13880. /**
  13881. * Gets or sets the maximal initial rotation in radians.
  13882. */
  13883. maxInitialRotation: number;
  13884. /**
  13885. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13886. */
  13887. minAngularSpeed: number;
  13888. /**
  13889. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13890. */
  13891. maxAngularSpeed: number;
  13892. /**
  13893. * The texture used to render each particle. (this can be a spritesheet)
  13894. */
  13895. particleTexture: Nullable<Texture>;
  13896. /**
  13897. * The layer mask we are rendering the particles through.
  13898. */
  13899. layerMask: number;
  13900. /**
  13901. * This can help using your own shader to render the particle system.
  13902. * The according effect will be created
  13903. */
  13904. customShader: any;
  13905. /**
  13906. * By default particle system starts as soon as they are created. This prevents the
  13907. * automatic start to happen and let you decide when to start emitting particles.
  13908. */
  13909. preventAutoStart: boolean;
  13910. private _noiseTexture;
  13911. /**
  13912. * Gets or sets a texture used to add random noise to particle positions
  13913. */
  13914. noiseTexture: Nullable<ProceduralTexture>;
  13915. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13916. noiseStrength: Vector3;
  13917. /**
  13918. * Callback triggered when the particle animation is ending.
  13919. */
  13920. onAnimationEnd: Nullable<() => void>;
  13921. /**
  13922. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13923. */
  13924. blendMode: number;
  13925. /**
  13926. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13927. * to override the particles.
  13928. */
  13929. forceDepthWrite: boolean;
  13930. /** 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 */
  13931. preWarmCycles: number;
  13932. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13933. preWarmStepOffset: number;
  13934. /**
  13935. * 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)
  13936. */
  13937. spriteCellChangeSpeed: number;
  13938. /**
  13939. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13940. */
  13941. startSpriteCellID: number;
  13942. /**
  13943. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13944. */
  13945. endSpriteCellID: number;
  13946. /**
  13947. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13948. */
  13949. spriteCellWidth: number;
  13950. /**
  13951. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13952. */
  13953. spriteCellHeight: number;
  13954. /**
  13955. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13956. */
  13957. spriteRandomStartCell: boolean;
  13958. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13959. translationPivot: Vector2;
  13960. /** @hidden */
  13961. protected _isAnimationSheetEnabled: boolean;
  13962. /**
  13963. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13964. */
  13965. beginAnimationOnStart: boolean;
  13966. /**
  13967. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13968. */
  13969. beginAnimationFrom: number;
  13970. /**
  13971. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13972. */
  13973. beginAnimationTo: number;
  13974. /**
  13975. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13976. */
  13977. beginAnimationLoop: boolean;
  13978. /**
  13979. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13980. */
  13981. isAnimationSheetEnabled: boolean;
  13982. /**
  13983. * Get hosting scene
  13984. * @returns the scene
  13985. */
  13986. getScene(): Scene;
  13987. /**
  13988. * You can use gravity if you want to give an orientation to your particles.
  13989. */
  13990. gravity: Vector3;
  13991. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13992. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13993. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13994. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13995. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13996. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13997. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13998. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13999. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14000. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14001. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14002. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14003. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14004. /**
  14005. * Defines the delay in milliseconds before starting the system (0 by default)
  14006. */
  14007. startDelay: number;
  14008. /**
  14009. * Gets the current list of drag gradients.
  14010. * You must use addDragGradient and removeDragGradient to udpate this list
  14011. * @returns the list of drag gradients
  14012. */
  14013. getDragGradients(): Nullable<Array<FactorGradient>>;
  14014. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14015. limitVelocityDamping: number;
  14016. /**
  14017. * Gets the current list of limit velocity gradients.
  14018. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14019. * @returns the list of limit velocity gradients
  14020. */
  14021. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14022. /**
  14023. * Gets the current list of color gradients.
  14024. * You must use addColorGradient and removeColorGradient to udpate this list
  14025. * @returns the list of color gradients
  14026. */
  14027. getColorGradients(): Nullable<Array<ColorGradient>>;
  14028. /**
  14029. * Gets the current list of size gradients.
  14030. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14031. * @returns the list of size gradients
  14032. */
  14033. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14034. /**
  14035. * Gets the current list of color remap gradients.
  14036. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14037. * @returns the list of color remap gradients
  14038. */
  14039. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14040. /**
  14041. * Gets the current list of alpha remap gradients.
  14042. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14043. * @returns the list of alpha remap gradients
  14044. */
  14045. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14046. /**
  14047. * Gets the current list of life time gradients.
  14048. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14049. * @returns the list of life time gradients
  14050. */
  14051. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14052. /**
  14053. * Gets the current list of angular speed gradients.
  14054. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14055. * @returns the list of angular speed gradients
  14056. */
  14057. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14058. /**
  14059. * Gets the current list of velocity gradients.
  14060. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14061. * @returns the list of velocity gradients
  14062. */
  14063. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14064. /**
  14065. * Gets the current list of start size gradients.
  14066. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14067. * @returns the list of start size gradients
  14068. */
  14069. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14070. /**
  14071. * Gets the current list of emit rate gradients.
  14072. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14073. * @returns the list of emit rate gradients
  14074. */
  14075. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14076. /**
  14077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14078. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14079. */
  14080. direction1: Vector3;
  14081. /**
  14082. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14083. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14084. */
  14085. direction2: Vector3;
  14086. /**
  14087. * 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.
  14088. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14089. */
  14090. minEmitBox: Vector3;
  14091. /**
  14092. * 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.
  14093. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14094. */
  14095. maxEmitBox: Vector3;
  14096. /**
  14097. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14098. */
  14099. color1: Color4;
  14100. /**
  14101. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14102. */
  14103. color2: Color4;
  14104. /**
  14105. * Color the particle will have at the end of its lifetime
  14106. */
  14107. colorDead: Color4;
  14108. /**
  14109. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14110. */
  14111. textureMask: Color4;
  14112. /**
  14113. * The particle emitter type defines the emitter used by the particle system.
  14114. * It can be for example box, sphere, or cone...
  14115. */
  14116. particleEmitterType: IParticleEmitterType;
  14117. /** @hidden */
  14118. _isSubEmitter: boolean;
  14119. /**
  14120. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14121. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14122. */
  14123. billboardMode: number;
  14124. protected _isBillboardBased: boolean;
  14125. /**
  14126. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14127. */
  14128. isBillboardBased: boolean;
  14129. /**
  14130. * The scene the particle system belongs to.
  14131. */
  14132. protected _scene: Scene;
  14133. /**
  14134. * Local cache of defines for image processing.
  14135. */
  14136. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14137. /**
  14138. * Default configuration related to image processing available in the standard Material.
  14139. */
  14140. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14141. /**
  14142. * Gets the image processing configuration used either in this material.
  14143. */
  14144. /**
  14145. * Sets the Default image processing configuration used either in the this material.
  14146. *
  14147. * If sets to null, the scene one is in use.
  14148. */
  14149. imageProcessingConfiguration: ImageProcessingConfiguration;
  14150. /**
  14151. * Attaches a new image processing configuration to the Standard Material.
  14152. * @param configuration
  14153. */
  14154. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14155. /** @hidden */
  14156. protected _reset(): void;
  14157. /** @hidden */
  14158. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14159. /**
  14160. * Instantiates a particle system.
  14161. * 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.
  14162. * @param name The name of the particle system
  14163. */
  14164. constructor(name: string);
  14165. /**
  14166. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14169. * @returns the emitter
  14170. */
  14171. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14172. /**
  14173. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14174. * @param radius The radius of the hemisphere to emit from
  14175. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14176. * @returns the emitter
  14177. */
  14178. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14179. /**
  14180. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14181. * @param radius The radius of the sphere to emit from
  14182. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14183. * @returns the emitter
  14184. */
  14185. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14186. /**
  14187. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14188. * @param radius The radius of the sphere to emit from
  14189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14191. * @returns the emitter
  14192. */
  14193. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14194. /**
  14195. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14196. * @param radius The radius of the emission cylinder
  14197. * @param height The height of the emission cylinder
  14198. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14199. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14200. * @returns the emitter
  14201. */
  14202. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14203. /**
  14204. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14205. * @param radius The radius of the cylinder to emit from
  14206. * @param height The height of the emission cylinder
  14207. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14208. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14209. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14210. * @returns the emitter
  14211. */
  14212. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14213. /**
  14214. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14215. * @param radius The radius of the cone to emit from
  14216. * @param angle The base angle of the cone
  14217. * @returns the emitter
  14218. */
  14219. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14220. /**
  14221. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14224. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14225. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14226. * @returns the emitter
  14227. */
  14228. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14229. }
  14230. }
  14231. declare module BABYLON {
  14232. /**
  14233. * Type of sub emitter
  14234. */
  14235. export enum SubEmitterType {
  14236. /**
  14237. * Attached to the particle over it's lifetime
  14238. */
  14239. ATTACHED = 0,
  14240. /**
  14241. * Created when the particle dies
  14242. */
  14243. END = 1
  14244. }
  14245. /**
  14246. * Sub emitter class used to emit particles from an existing particle
  14247. */
  14248. export class SubEmitter {
  14249. /**
  14250. * the particle system to be used by the sub emitter
  14251. */
  14252. particleSystem: ParticleSystem;
  14253. /**
  14254. * Type of the submitter (Default: END)
  14255. */
  14256. type: SubEmitterType;
  14257. /**
  14258. * 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)
  14259. * Note: This only is supported when using an emitter of type Mesh
  14260. */
  14261. inheritDirection: boolean;
  14262. /**
  14263. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14264. */
  14265. inheritedVelocityAmount: number;
  14266. /**
  14267. * Creates a sub emitter
  14268. * @param particleSystem the particle system to be used by the sub emitter
  14269. */
  14270. constructor(
  14271. /**
  14272. * the particle system to be used by the sub emitter
  14273. */
  14274. particleSystem: ParticleSystem);
  14275. /**
  14276. * Clones the sub emitter
  14277. * @returns the cloned sub emitter
  14278. */
  14279. clone(): SubEmitter;
  14280. /**
  14281. * Serialize current object to a JSON object
  14282. * @returns the serialized object
  14283. */
  14284. serialize(): any;
  14285. /** @hidden */
  14286. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14287. /**
  14288. * Creates a new SubEmitter from a serialized JSON version
  14289. * @param serializationObject defines the JSON object to read from
  14290. * @param scene defines the hosting scene
  14291. * @param rootUrl defines the rootUrl for data loading
  14292. * @returns a new SubEmitter
  14293. */
  14294. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14295. /** Release associated resources */
  14296. dispose(): void;
  14297. }
  14298. }
  14299. declare module BABYLON {
  14300. /** @hidden */
  14301. export var clipPlaneFragmentDeclaration: {
  14302. name: string;
  14303. shader: string;
  14304. };
  14305. }
  14306. declare module BABYLON {
  14307. /** @hidden */
  14308. export var imageProcessingDeclaration: {
  14309. name: string;
  14310. shader: string;
  14311. };
  14312. }
  14313. declare module BABYLON {
  14314. /** @hidden */
  14315. export var imageProcessingFunctions: {
  14316. name: string;
  14317. shader: string;
  14318. };
  14319. }
  14320. declare module BABYLON {
  14321. /** @hidden */
  14322. export var clipPlaneFragment: {
  14323. name: string;
  14324. shader: string;
  14325. };
  14326. }
  14327. declare module BABYLON {
  14328. /** @hidden */
  14329. export var particlesPixelShader: {
  14330. name: string;
  14331. shader: string;
  14332. };
  14333. }
  14334. declare module BABYLON {
  14335. /** @hidden */
  14336. export var clipPlaneVertexDeclaration: {
  14337. name: string;
  14338. shader: string;
  14339. };
  14340. }
  14341. declare module BABYLON {
  14342. /** @hidden */
  14343. export var clipPlaneVertex: {
  14344. name: string;
  14345. shader: string;
  14346. };
  14347. }
  14348. declare module BABYLON {
  14349. /** @hidden */
  14350. export var particlesVertexShader: {
  14351. name: string;
  14352. shader: string;
  14353. };
  14354. }
  14355. declare module BABYLON {
  14356. /**
  14357. * This represents a particle system in Babylon.
  14358. * 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.
  14359. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14360. * @example https://doc.babylonjs.com/babylon101/particles
  14361. */
  14362. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14363. /**
  14364. * Billboard mode will only apply to Y axis
  14365. */
  14366. static readonly BILLBOARDMODE_Y: number;
  14367. /**
  14368. * Billboard mode will apply to all axes
  14369. */
  14370. static readonly BILLBOARDMODE_ALL: number;
  14371. /**
  14372. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14373. */
  14374. static readonly BILLBOARDMODE_STRETCHED: number;
  14375. /**
  14376. * This function can be defined to provide custom update for active particles.
  14377. * This function will be called instead of regular update (age, position, color, etc.).
  14378. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14379. */
  14380. updateFunction: (particles: Particle[]) => void;
  14381. private _emitterWorldMatrix;
  14382. /**
  14383. * This function can be defined to specify initial direction for every new particle.
  14384. * It by default use the emitterType defined function
  14385. */
  14386. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14387. /**
  14388. * This function can be defined to specify initial position for every new particle.
  14389. * It by default use the emitterType defined function
  14390. */
  14391. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14392. /**
  14393. * @hidden
  14394. */
  14395. _inheritedVelocityOffset: Vector3;
  14396. /**
  14397. * An event triggered when the system is disposed
  14398. */
  14399. onDisposeObservable: Observable<ParticleSystem>;
  14400. private _onDisposeObserver;
  14401. /**
  14402. * Sets a callback that will be triggered when the system is disposed
  14403. */
  14404. onDispose: () => void;
  14405. private _particles;
  14406. private _epsilon;
  14407. private _capacity;
  14408. private _stockParticles;
  14409. private _newPartsExcess;
  14410. private _vertexData;
  14411. private _vertexBuffer;
  14412. private _vertexBuffers;
  14413. private _spriteBuffer;
  14414. private _indexBuffer;
  14415. private _effect;
  14416. private _customEffect;
  14417. private _cachedDefines;
  14418. private _scaledColorStep;
  14419. private _colorDiff;
  14420. private _scaledDirection;
  14421. private _scaledGravity;
  14422. private _currentRenderId;
  14423. private _alive;
  14424. private _useInstancing;
  14425. private _started;
  14426. private _stopped;
  14427. private _actualFrame;
  14428. private _scaledUpdateSpeed;
  14429. private _vertexBufferSize;
  14430. /** @hidden */
  14431. _currentEmitRateGradient: Nullable<FactorGradient>;
  14432. /** @hidden */
  14433. _currentEmitRate1: number;
  14434. /** @hidden */
  14435. _currentEmitRate2: number;
  14436. /** @hidden */
  14437. _currentStartSizeGradient: Nullable<FactorGradient>;
  14438. /** @hidden */
  14439. _currentStartSize1: number;
  14440. /** @hidden */
  14441. _currentStartSize2: number;
  14442. private readonly _rawTextureWidth;
  14443. private _rampGradientsTexture;
  14444. private _useRampGradients;
  14445. /** Gets or sets a boolean indicating that ramp gradients must be used
  14446. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14447. */
  14448. useRampGradients: boolean;
  14449. /**
  14450. * 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.
  14451. * 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: [])
  14452. */
  14453. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14454. private _subEmitters;
  14455. /**
  14456. * @hidden
  14457. * If the particle systems emitter should be disposed when the particle system is disposed
  14458. */
  14459. _disposeEmitterOnDispose: boolean;
  14460. /**
  14461. * The current active Sub-systems, this property is used by the root particle system only.
  14462. */
  14463. activeSubSystems: Array<ParticleSystem>;
  14464. private _rootParticleSystem;
  14465. /**
  14466. * Gets the current list of active particles
  14467. */
  14468. readonly particles: Particle[];
  14469. /**
  14470. * Returns the string "ParticleSystem"
  14471. * @returns a string containing the class name
  14472. */
  14473. getClassName(): string;
  14474. /**
  14475. * Instantiates a particle system.
  14476. * 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.
  14477. * @param name The name of the particle system
  14478. * @param capacity The max number of particles alive at the same time
  14479. * @param scene The scene the particle system belongs to
  14480. * @param customEffect a custom effect used to change the way particles are rendered by default
  14481. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14482. * @param epsilon Offset used to render the particles
  14483. */
  14484. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14485. private _addFactorGradient;
  14486. private _removeFactorGradient;
  14487. /**
  14488. * Adds a new life time gradient
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param factor defines the life time factor to affect to the specified gradient
  14491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14492. * @returns the current particle system
  14493. */
  14494. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14495. /**
  14496. * Remove a specific life time gradient
  14497. * @param gradient defines the gradient to remove
  14498. * @returns the current particle system
  14499. */
  14500. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14501. /**
  14502. * Adds a new size gradient
  14503. * @param gradient defines the gradient to use (between 0 and 1)
  14504. * @param factor defines the size factor to affect to the specified gradient
  14505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14506. * @returns the current particle system
  14507. */
  14508. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14509. /**
  14510. * Remove a specific size gradient
  14511. * @param gradient defines the gradient to remove
  14512. * @returns the current particle system
  14513. */
  14514. removeSizeGradient(gradient: number): IParticleSystem;
  14515. /**
  14516. * Adds a new color remap gradient
  14517. * @param gradient defines the gradient to use (between 0 and 1)
  14518. * @param min defines the color remap minimal range
  14519. * @param max defines the color remap maximal range
  14520. * @returns the current particle system
  14521. */
  14522. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14523. /**
  14524. * Remove a specific color remap gradient
  14525. * @param gradient defines the gradient to remove
  14526. * @returns the current particle system
  14527. */
  14528. removeColorRemapGradient(gradient: number): IParticleSystem;
  14529. /**
  14530. * Adds a new alpha remap gradient
  14531. * @param gradient defines the gradient to use (between 0 and 1)
  14532. * @param min defines the alpha remap minimal range
  14533. * @param max defines the alpha remap maximal range
  14534. * @returns the current particle system
  14535. */
  14536. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14537. /**
  14538. * Remove a specific alpha remap gradient
  14539. * @param gradient defines the gradient to remove
  14540. * @returns the current particle system
  14541. */
  14542. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14543. /**
  14544. * Adds a new angular speed gradient
  14545. * @param gradient defines the gradient to use (between 0 and 1)
  14546. * @param factor defines the angular speed to affect to the specified gradient
  14547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14548. * @returns the current particle system
  14549. */
  14550. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14551. /**
  14552. * Remove a specific angular speed gradient
  14553. * @param gradient defines the gradient to remove
  14554. * @returns the current particle system
  14555. */
  14556. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14557. /**
  14558. * Adds a new velocity gradient
  14559. * @param gradient defines the gradient to use (between 0 and 1)
  14560. * @param factor defines the velocity to affect to the specified gradient
  14561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14562. * @returns the current particle system
  14563. */
  14564. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14565. /**
  14566. * Remove a specific velocity gradient
  14567. * @param gradient defines the gradient to remove
  14568. * @returns the current particle system
  14569. */
  14570. removeVelocityGradient(gradient: number): IParticleSystem;
  14571. /**
  14572. * Adds a new limit velocity gradient
  14573. * @param gradient defines the gradient to use (between 0 and 1)
  14574. * @param factor defines the limit velocity value to affect to the specified gradient
  14575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14576. * @returns the current particle system
  14577. */
  14578. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14579. /**
  14580. * Remove a specific limit velocity gradient
  14581. * @param gradient defines the gradient to remove
  14582. * @returns the current particle system
  14583. */
  14584. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14585. /**
  14586. * Adds a new drag gradient
  14587. * @param gradient defines the gradient to use (between 0 and 1)
  14588. * @param factor defines the drag value to affect to the specified gradient
  14589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14590. * @returns the current particle system
  14591. */
  14592. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14593. /**
  14594. * Remove a specific drag gradient
  14595. * @param gradient defines the gradient to remove
  14596. * @returns the current particle system
  14597. */
  14598. removeDragGradient(gradient: number): IParticleSystem;
  14599. /**
  14600. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14601. * @param gradient defines the gradient to use (between 0 and 1)
  14602. * @param factor defines the emit rate value to affect to the specified gradient
  14603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14604. * @returns the current particle system
  14605. */
  14606. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14607. /**
  14608. * Remove a specific emit rate gradient
  14609. * @param gradient defines the gradient to remove
  14610. * @returns the current particle system
  14611. */
  14612. removeEmitRateGradient(gradient: number): IParticleSystem;
  14613. /**
  14614. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param factor defines the start size value to affect to the specified gradient
  14617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14618. * @returns the current particle system
  14619. */
  14620. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14621. /**
  14622. * Remove a specific start size gradient
  14623. * @param gradient defines the gradient to remove
  14624. * @returns the current particle system
  14625. */
  14626. removeStartSizeGradient(gradient: number): IParticleSystem;
  14627. private _createRampGradientTexture;
  14628. /**
  14629. * Gets the current list of ramp gradients.
  14630. * You must use addRampGradient and removeRampGradient to udpate this list
  14631. * @returns the list of ramp gradients
  14632. */
  14633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14634. /**
  14635. * Adds a new ramp gradient used to remap particle colors
  14636. * @param gradient defines the gradient to use (between 0 and 1)
  14637. * @param color defines the color to affect to the specified gradient
  14638. * @returns the current particle system
  14639. */
  14640. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14641. /**
  14642. * Remove a specific ramp gradient
  14643. * @param gradient defines the gradient to remove
  14644. * @returns the current particle system
  14645. */
  14646. removeRampGradient(gradient: number): ParticleSystem;
  14647. /**
  14648. * Adds a new color gradient
  14649. * @param gradient defines the gradient to use (between 0 and 1)
  14650. * @param color1 defines the color to affect to the specified gradient
  14651. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14652. * @returns this particle system
  14653. */
  14654. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14655. /**
  14656. * Remove a specific color gradient
  14657. * @param gradient defines the gradient to remove
  14658. * @returns this particle system
  14659. */
  14660. removeColorGradient(gradient: number): IParticleSystem;
  14661. private _fetchR;
  14662. protected _reset(): void;
  14663. private _resetEffect;
  14664. private _createVertexBuffers;
  14665. private _createIndexBuffer;
  14666. /**
  14667. * Gets the maximum number of particles active at the same time.
  14668. * @returns The max number of active particles.
  14669. */
  14670. getCapacity(): number;
  14671. /**
  14672. * Gets whether there are still active particles in the system.
  14673. * @returns True if it is alive, otherwise false.
  14674. */
  14675. isAlive(): boolean;
  14676. /**
  14677. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14678. * @returns True if it has been started, otherwise false.
  14679. */
  14680. isStarted(): boolean;
  14681. private _prepareSubEmitterInternalArray;
  14682. /**
  14683. * Starts the particle system and begins to emit
  14684. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14685. */
  14686. start(delay?: number): void;
  14687. /**
  14688. * Stops the particle system.
  14689. * @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.
  14690. */
  14691. stop(stopSubEmitters?: boolean): void;
  14692. /**
  14693. * Remove all active particles
  14694. */
  14695. reset(): void;
  14696. /**
  14697. * @hidden (for internal use only)
  14698. */
  14699. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14700. /**
  14701. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14702. * Its lifetime will start back at 0.
  14703. */
  14704. recycleParticle: (particle: Particle) => void;
  14705. private _stopSubEmitters;
  14706. private _createParticle;
  14707. private _removeFromRoot;
  14708. private _emitFromParticle;
  14709. private _update;
  14710. /** @hidden */
  14711. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14712. /** @hidden */
  14713. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14714. /** @hidden */
  14715. private _getEffect;
  14716. /**
  14717. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14718. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14719. */
  14720. animate(preWarmOnly?: boolean): void;
  14721. private _appendParticleVertices;
  14722. /**
  14723. * Rebuilds the particle system.
  14724. */
  14725. rebuild(): void;
  14726. /**
  14727. * Is this system ready to be used/rendered
  14728. * @return true if the system is ready
  14729. */
  14730. isReady(): boolean;
  14731. private _render;
  14732. /**
  14733. * Renders the particle system in its current state.
  14734. * @returns the current number of particles
  14735. */
  14736. render(): number;
  14737. /**
  14738. * Disposes the particle system and free the associated resources
  14739. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14740. */
  14741. dispose(disposeTexture?: boolean): void;
  14742. /**
  14743. * Clones the particle system.
  14744. * @param name The name of the cloned object
  14745. * @param newEmitter The new emitter to use
  14746. * @returns the cloned particle system
  14747. */
  14748. clone(name: string, newEmitter: any): ParticleSystem;
  14749. /**
  14750. * Serializes the particle system to a JSON object.
  14751. * @returns the JSON object
  14752. */
  14753. serialize(): any;
  14754. /** @hidden */
  14755. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14756. /** @hidden */
  14757. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14758. /**
  14759. * Parses a JSON object to create a particle system.
  14760. * @param parsedParticleSystem The JSON object to parse
  14761. * @param scene The scene to create the particle system in
  14762. * @param rootUrl The root url to use to load external dependencies like texture
  14763. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14764. * @returns the Parsed particle system
  14765. */
  14766. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14767. }
  14768. }
  14769. declare module BABYLON {
  14770. /**
  14771. * A particle represents one of the element emitted by a particle system.
  14772. * This is mainly define by its coordinates, direction, velocity and age.
  14773. */
  14774. export class Particle {
  14775. /**
  14776. * The particle system the particle belongs to.
  14777. */
  14778. particleSystem: ParticleSystem;
  14779. private static _Count;
  14780. /**
  14781. * Unique ID of the particle
  14782. */
  14783. id: number;
  14784. /**
  14785. * The world position of the particle in the scene.
  14786. */
  14787. position: Vector3;
  14788. /**
  14789. * The world direction of the particle in the scene.
  14790. */
  14791. direction: Vector3;
  14792. /**
  14793. * The color of the particle.
  14794. */
  14795. color: Color4;
  14796. /**
  14797. * The color change of the particle per step.
  14798. */
  14799. colorStep: Color4;
  14800. /**
  14801. * Defines how long will the life of the particle be.
  14802. */
  14803. lifeTime: number;
  14804. /**
  14805. * The current age of the particle.
  14806. */
  14807. age: number;
  14808. /**
  14809. * The current size of the particle.
  14810. */
  14811. size: number;
  14812. /**
  14813. * The current scale of the particle.
  14814. */
  14815. scale: Vector2;
  14816. /**
  14817. * The current angle of the particle.
  14818. */
  14819. angle: number;
  14820. /**
  14821. * Defines how fast is the angle changing.
  14822. */
  14823. angularSpeed: number;
  14824. /**
  14825. * Defines the cell index used by the particle to be rendered from a sprite.
  14826. */
  14827. cellIndex: number;
  14828. /**
  14829. * The information required to support color remapping
  14830. */
  14831. remapData: Vector4;
  14832. /** @hidden */
  14833. _randomCellOffset?: number;
  14834. /** @hidden */
  14835. _initialDirection: Nullable<Vector3>;
  14836. /** @hidden */
  14837. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14838. /** @hidden */
  14839. _initialStartSpriteCellID: number;
  14840. /** @hidden */
  14841. _initialEndSpriteCellID: number;
  14842. /** @hidden */
  14843. _currentColorGradient: Nullable<ColorGradient>;
  14844. /** @hidden */
  14845. _currentColor1: Color4;
  14846. /** @hidden */
  14847. _currentColor2: Color4;
  14848. /** @hidden */
  14849. _currentSizeGradient: Nullable<FactorGradient>;
  14850. /** @hidden */
  14851. _currentSize1: number;
  14852. /** @hidden */
  14853. _currentSize2: number;
  14854. /** @hidden */
  14855. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14856. /** @hidden */
  14857. _currentAngularSpeed1: number;
  14858. /** @hidden */
  14859. _currentAngularSpeed2: number;
  14860. /** @hidden */
  14861. _currentVelocityGradient: Nullable<FactorGradient>;
  14862. /** @hidden */
  14863. _currentVelocity1: number;
  14864. /** @hidden */
  14865. _currentVelocity2: number;
  14866. /** @hidden */
  14867. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14868. /** @hidden */
  14869. _currentLimitVelocity1: number;
  14870. /** @hidden */
  14871. _currentLimitVelocity2: number;
  14872. /** @hidden */
  14873. _currentDragGradient: Nullable<FactorGradient>;
  14874. /** @hidden */
  14875. _currentDrag1: number;
  14876. /** @hidden */
  14877. _currentDrag2: number;
  14878. /** @hidden */
  14879. _randomNoiseCoordinates1: Vector3;
  14880. /** @hidden */
  14881. _randomNoiseCoordinates2: Vector3;
  14882. /**
  14883. * Creates a new instance Particle
  14884. * @param particleSystem the particle system the particle belongs to
  14885. */
  14886. constructor(
  14887. /**
  14888. * The particle system the particle belongs to.
  14889. */
  14890. particleSystem: ParticleSystem);
  14891. private updateCellInfoFromSystem;
  14892. /**
  14893. * Defines how the sprite cell index is updated for the particle
  14894. */
  14895. updateCellIndex(): void;
  14896. /** @hidden */
  14897. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14898. /** @hidden */
  14899. _inheritParticleInfoToSubEmitters(): void;
  14900. /** @hidden */
  14901. _reset(): void;
  14902. /**
  14903. * Copy the properties of particle to another one.
  14904. * @param other the particle to copy the information to.
  14905. */
  14906. copyTo(other: Particle): void;
  14907. }
  14908. }
  14909. declare module BABYLON {
  14910. /**
  14911. * Particle emitter represents a volume emitting particles.
  14912. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14913. */
  14914. export interface IParticleEmitterType {
  14915. /**
  14916. * Called by the particle System when the direction is computed for the created particle.
  14917. * @param worldMatrix is the world matrix of the particle system
  14918. * @param directionToUpdate is the direction vector to update with the result
  14919. * @param particle is the particle we are computed the direction for
  14920. */
  14921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14922. /**
  14923. * Called by the particle System when the position is computed for the created particle.
  14924. * @param worldMatrix is the world matrix of the particle system
  14925. * @param positionToUpdate is the position vector to update with the result
  14926. * @param particle is the particle we are computed the position for
  14927. */
  14928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14929. /**
  14930. * Clones the current emitter and returns a copy of it
  14931. * @returns the new emitter
  14932. */
  14933. clone(): IParticleEmitterType;
  14934. /**
  14935. * Called by the GPUParticleSystem to setup the update shader
  14936. * @param effect defines the update shader
  14937. */
  14938. applyToShader(effect: Effect): void;
  14939. /**
  14940. * Returns a string to use to update the GPU particles update shader
  14941. * @returns the effect defines string
  14942. */
  14943. getEffectDefines(): string;
  14944. /**
  14945. * Returns a string representing the class name
  14946. * @returns a string containing the class name
  14947. */
  14948. getClassName(): string;
  14949. /**
  14950. * Serializes the particle system to a JSON object.
  14951. * @returns the JSON object
  14952. */
  14953. serialize(): any;
  14954. /**
  14955. * Parse properties from a JSON object
  14956. * @param serializationObject defines the JSON object
  14957. */
  14958. parse(serializationObject: any): void;
  14959. }
  14960. }
  14961. declare module BABYLON {
  14962. /**
  14963. * Particle emitter emitting particles from the inside of a box.
  14964. * It emits the particles randomly between 2 given directions.
  14965. */
  14966. export class BoxParticleEmitter implements IParticleEmitterType {
  14967. /**
  14968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14969. */
  14970. direction1: Vector3;
  14971. /**
  14972. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14973. */
  14974. direction2: Vector3;
  14975. /**
  14976. * 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.
  14977. */
  14978. minEmitBox: Vector3;
  14979. /**
  14980. * 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.
  14981. */
  14982. maxEmitBox: Vector3;
  14983. /**
  14984. * Creates a new instance BoxParticleEmitter
  14985. */
  14986. constructor();
  14987. /**
  14988. * Called by the particle System when the direction is computed for the created particle.
  14989. * @param worldMatrix is the world matrix of the particle system
  14990. * @param directionToUpdate is the direction vector to update with the result
  14991. * @param particle is the particle we are computed the direction for
  14992. */
  14993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14994. /**
  14995. * Called by the particle System when the position is computed for the created particle.
  14996. * @param worldMatrix is the world matrix of the particle system
  14997. * @param positionToUpdate is the position vector to update with the result
  14998. * @param particle is the particle we are computed the position for
  14999. */
  15000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15001. /**
  15002. * Clones the current emitter and returns a copy of it
  15003. * @returns the new emitter
  15004. */
  15005. clone(): BoxParticleEmitter;
  15006. /**
  15007. * Called by the GPUParticleSystem to setup the update shader
  15008. * @param effect defines the update shader
  15009. */
  15010. applyToShader(effect: Effect): void;
  15011. /**
  15012. * Returns a string to use to update the GPU particles update shader
  15013. * @returns a string containng the defines string
  15014. */
  15015. getEffectDefines(): string;
  15016. /**
  15017. * Returns the string "BoxParticleEmitter"
  15018. * @returns a string containing the class name
  15019. */
  15020. getClassName(): string;
  15021. /**
  15022. * Serializes the particle system to a JSON object.
  15023. * @returns the JSON object
  15024. */
  15025. serialize(): any;
  15026. /**
  15027. * Parse properties from a JSON object
  15028. * @param serializationObject defines the JSON object
  15029. */
  15030. parse(serializationObject: any): void;
  15031. }
  15032. }
  15033. declare module BABYLON {
  15034. /**
  15035. * Particle emitter emitting particles from the inside of a cone.
  15036. * It emits the particles alongside the cone volume from the base to the particle.
  15037. * The emission direction might be randomized.
  15038. */
  15039. export class ConeParticleEmitter implements IParticleEmitterType {
  15040. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15041. directionRandomizer: number;
  15042. private _radius;
  15043. private _angle;
  15044. private _height;
  15045. /**
  15046. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15047. */
  15048. radiusRange: number;
  15049. /**
  15050. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15051. */
  15052. heightRange: number;
  15053. /**
  15054. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15055. */
  15056. emitFromSpawnPointOnly: boolean;
  15057. /**
  15058. * Gets or sets the radius of the emission cone
  15059. */
  15060. radius: number;
  15061. /**
  15062. * Gets or sets the angle of the emission cone
  15063. */
  15064. angle: number;
  15065. private _buildHeight;
  15066. /**
  15067. * Creates a new instance ConeParticleEmitter
  15068. * @param radius the radius of the emission cone (1 by default)
  15069. * @param angle the cone base angle (PI by default)
  15070. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15071. */
  15072. constructor(radius?: number, angle?: number,
  15073. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15074. directionRandomizer?: number);
  15075. /**
  15076. * Called by the particle System when the direction is computed for the created particle.
  15077. * @param worldMatrix is the world matrix of the particle system
  15078. * @param directionToUpdate is the direction vector to update with the result
  15079. * @param particle is the particle we are computed the direction for
  15080. */
  15081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15082. /**
  15083. * Called by the particle System when the position is computed for the created particle.
  15084. * @param worldMatrix is the world matrix of the particle system
  15085. * @param positionToUpdate is the position vector to update with the result
  15086. * @param particle is the particle we are computed the position for
  15087. */
  15088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15089. /**
  15090. * Clones the current emitter and returns a copy of it
  15091. * @returns the new emitter
  15092. */
  15093. clone(): ConeParticleEmitter;
  15094. /**
  15095. * Called by the GPUParticleSystem to setup the update shader
  15096. * @param effect defines the update shader
  15097. */
  15098. applyToShader(effect: Effect): void;
  15099. /**
  15100. * Returns a string to use to update the GPU particles update shader
  15101. * @returns a string containng the defines string
  15102. */
  15103. getEffectDefines(): string;
  15104. /**
  15105. * Returns the string "ConeParticleEmitter"
  15106. * @returns a string containing the class name
  15107. */
  15108. getClassName(): string;
  15109. /**
  15110. * Serializes the particle system to a JSON object.
  15111. * @returns the JSON object
  15112. */
  15113. serialize(): any;
  15114. /**
  15115. * Parse properties from a JSON object
  15116. * @param serializationObject defines the JSON object
  15117. */
  15118. parse(serializationObject: any): void;
  15119. }
  15120. }
  15121. declare module BABYLON {
  15122. /**
  15123. * Particle emitter emitting particles from the inside of a cylinder.
  15124. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15125. */
  15126. export class CylinderParticleEmitter implements IParticleEmitterType {
  15127. /**
  15128. * The radius of the emission cylinder.
  15129. */
  15130. radius: number;
  15131. /**
  15132. * The height of the emission cylinder.
  15133. */
  15134. height: number;
  15135. /**
  15136. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15137. */
  15138. radiusRange: number;
  15139. /**
  15140. * How much to randomize the particle direction [0-1].
  15141. */
  15142. directionRandomizer: number;
  15143. /**
  15144. * Creates a new instance CylinderParticleEmitter
  15145. * @param radius the radius of the emission cylinder (1 by default)
  15146. * @param height the height of the emission cylinder (1 by default)
  15147. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15148. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15149. */
  15150. constructor(
  15151. /**
  15152. * The radius of the emission cylinder.
  15153. */
  15154. radius?: number,
  15155. /**
  15156. * The height of the emission cylinder.
  15157. */
  15158. height?: number,
  15159. /**
  15160. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15161. */
  15162. radiusRange?: number,
  15163. /**
  15164. * How much to randomize the particle direction [0-1].
  15165. */
  15166. directionRandomizer?: number);
  15167. /**
  15168. * Called by the particle System when the direction is computed for the created particle.
  15169. * @param worldMatrix is the world matrix of the particle system
  15170. * @param directionToUpdate is the direction vector to update with the result
  15171. * @param particle is the particle we are computed the direction for
  15172. */
  15173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15174. /**
  15175. * Called by the particle System when the position is computed for the created particle.
  15176. * @param worldMatrix is the world matrix of the particle system
  15177. * @param positionToUpdate is the position vector to update with the result
  15178. * @param particle is the particle we are computed the position for
  15179. */
  15180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15181. /**
  15182. * Clones the current emitter and returns a copy of it
  15183. * @returns the new emitter
  15184. */
  15185. clone(): CylinderParticleEmitter;
  15186. /**
  15187. * Called by the GPUParticleSystem to setup the update shader
  15188. * @param effect defines the update shader
  15189. */
  15190. applyToShader(effect: Effect): void;
  15191. /**
  15192. * Returns a string to use to update the GPU particles update shader
  15193. * @returns a string containng the defines string
  15194. */
  15195. getEffectDefines(): string;
  15196. /**
  15197. * Returns the string "CylinderParticleEmitter"
  15198. * @returns a string containing the class name
  15199. */
  15200. getClassName(): string;
  15201. /**
  15202. * Serializes the particle system to a JSON object.
  15203. * @returns the JSON object
  15204. */
  15205. serialize(): any;
  15206. /**
  15207. * Parse properties from a JSON object
  15208. * @param serializationObject defines the JSON object
  15209. */
  15210. parse(serializationObject: any): void;
  15211. }
  15212. /**
  15213. * Particle emitter emitting particles from the inside of a cylinder.
  15214. * It emits the particles randomly between two vectors.
  15215. */
  15216. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15217. /**
  15218. * The min limit of the emission direction.
  15219. */
  15220. direction1: Vector3;
  15221. /**
  15222. * The max limit of the emission direction.
  15223. */
  15224. direction2: Vector3;
  15225. /**
  15226. * Creates a new instance CylinderDirectedParticleEmitter
  15227. * @param radius the radius of the emission cylinder (1 by default)
  15228. * @param height the height of the emission cylinder (1 by default)
  15229. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15230. * @param direction1 the min limit of the emission direction (up vector by default)
  15231. * @param direction2 the max limit of the emission direction (up vector by default)
  15232. */
  15233. constructor(radius?: number, height?: number, radiusRange?: number,
  15234. /**
  15235. * The min limit of the emission direction.
  15236. */
  15237. direction1?: Vector3,
  15238. /**
  15239. * The max limit of the emission direction.
  15240. */
  15241. direction2?: Vector3);
  15242. /**
  15243. * Called by the particle System when the direction is computed for the created particle.
  15244. * @param worldMatrix is the world matrix of the particle system
  15245. * @param directionToUpdate is the direction vector to update with the result
  15246. * @param particle is the particle we are computed the direction for
  15247. */
  15248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15249. /**
  15250. * Clones the current emitter and returns a copy of it
  15251. * @returns the new emitter
  15252. */
  15253. clone(): CylinderDirectedParticleEmitter;
  15254. /**
  15255. * Called by the GPUParticleSystem to setup the update shader
  15256. * @param effect defines the update shader
  15257. */
  15258. applyToShader(effect: Effect): void;
  15259. /**
  15260. * Returns a string to use to update the GPU particles update shader
  15261. * @returns a string containng the defines string
  15262. */
  15263. getEffectDefines(): string;
  15264. /**
  15265. * Returns the string "CylinderDirectedParticleEmitter"
  15266. * @returns a string containing the class name
  15267. */
  15268. getClassName(): string;
  15269. /**
  15270. * Serializes the particle system to a JSON object.
  15271. * @returns the JSON object
  15272. */
  15273. serialize(): any;
  15274. /**
  15275. * Parse properties from a JSON object
  15276. * @param serializationObject defines the JSON object
  15277. */
  15278. parse(serializationObject: any): void;
  15279. }
  15280. }
  15281. declare module BABYLON {
  15282. /**
  15283. * Particle emitter emitting particles from the inside of a hemisphere.
  15284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15285. */
  15286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15287. /**
  15288. * The radius of the emission hemisphere.
  15289. */
  15290. radius: number;
  15291. /**
  15292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15293. */
  15294. radiusRange: number;
  15295. /**
  15296. * How much to randomize the particle direction [0-1].
  15297. */
  15298. directionRandomizer: number;
  15299. /**
  15300. * Creates a new instance HemisphericParticleEmitter
  15301. * @param radius the radius of the emission hemisphere (1 by default)
  15302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15304. */
  15305. constructor(
  15306. /**
  15307. * The radius of the emission hemisphere.
  15308. */
  15309. radius?: number,
  15310. /**
  15311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15312. */
  15313. radiusRange?: number,
  15314. /**
  15315. * How much to randomize the particle direction [0-1].
  15316. */
  15317. directionRandomizer?: number);
  15318. /**
  15319. * Called by the particle System when the direction is computed for the created particle.
  15320. * @param worldMatrix is the world matrix of the particle system
  15321. * @param directionToUpdate is the direction vector to update with the result
  15322. * @param particle is the particle we are computed the direction for
  15323. */
  15324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15325. /**
  15326. * Called by the particle System when the position is computed for the created particle.
  15327. * @param worldMatrix is the world matrix of the particle system
  15328. * @param positionToUpdate is the position vector to update with the result
  15329. * @param particle is the particle we are computed the position for
  15330. */
  15331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15332. /**
  15333. * Clones the current emitter and returns a copy of it
  15334. * @returns the new emitter
  15335. */
  15336. clone(): HemisphericParticleEmitter;
  15337. /**
  15338. * Called by the GPUParticleSystem to setup the update shader
  15339. * @param effect defines the update shader
  15340. */
  15341. applyToShader(effect: Effect): void;
  15342. /**
  15343. * Returns a string to use to update the GPU particles update shader
  15344. * @returns a string containng the defines string
  15345. */
  15346. getEffectDefines(): string;
  15347. /**
  15348. * Returns the string "HemisphericParticleEmitter"
  15349. * @returns a string containing the class name
  15350. */
  15351. getClassName(): string;
  15352. /**
  15353. * Serializes the particle system to a JSON object.
  15354. * @returns the JSON object
  15355. */
  15356. serialize(): any;
  15357. /**
  15358. * Parse properties from a JSON object
  15359. * @param serializationObject defines the JSON object
  15360. */
  15361. parse(serializationObject: any): void;
  15362. }
  15363. }
  15364. declare module BABYLON {
  15365. /**
  15366. * Particle emitter emitting particles from a point.
  15367. * It emits the particles randomly between 2 given directions.
  15368. */
  15369. export class PointParticleEmitter implements IParticleEmitterType {
  15370. /**
  15371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15372. */
  15373. direction1: Vector3;
  15374. /**
  15375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15376. */
  15377. direction2: Vector3;
  15378. /**
  15379. * Creates a new instance PointParticleEmitter
  15380. */
  15381. constructor();
  15382. /**
  15383. * Called by the particle System when the direction is computed for the created particle.
  15384. * @param worldMatrix is the world matrix of the particle system
  15385. * @param directionToUpdate is the direction vector to update with the result
  15386. * @param particle is the particle we are computed the direction for
  15387. */
  15388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15389. /**
  15390. * Called by the particle System when the position is computed for the created particle.
  15391. * @param worldMatrix is the world matrix of the particle system
  15392. * @param positionToUpdate is the position vector to update with the result
  15393. * @param particle is the particle we are computed the position for
  15394. */
  15395. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15396. /**
  15397. * Clones the current emitter and returns a copy of it
  15398. * @returns the new emitter
  15399. */
  15400. clone(): PointParticleEmitter;
  15401. /**
  15402. * Called by the GPUParticleSystem to setup the update shader
  15403. * @param effect defines the update shader
  15404. */
  15405. applyToShader(effect: Effect): void;
  15406. /**
  15407. * Returns a string to use to update the GPU particles update shader
  15408. * @returns a string containng the defines string
  15409. */
  15410. getEffectDefines(): string;
  15411. /**
  15412. * Returns the string "PointParticleEmitter"
  15413. * @returns a string containing the class name
  15414. */
  15415. getClassName(): string;
  15416. /**
  15417. * Serializes the particle system to a JSON object.
  15418. * @returns the JSON object
  15419. */
  15420. serialize(): any;
  15421. /**
  15422. * Parse properties from a JSON object
  15423. * @param serializationObject defines the JSON object
  15424. */
  15425. parse(serializationObject: any): void;
  15426. }
  15427. }
  15428. declare module BABYLON {
  15429. /**
  15430. * Particle emitter emitting particles from the inside of a sphere.
  15431. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15432. */
  15433. export class SphereParticleEmitter implements IParticleEmitterType {
  15434. /**
  15435. * The radius of the emission sphere.
  15436. */
  15437. radius: number;
  15438. /**
  15439. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15440. */
  15441. radiusRange: number;
  15442. /**
  15443. * How much to randomize the particle direction [0-1].
  15444. */
  15445. directionRandomizer: number;
  15446. /**
  15447. * Creates a new instance SphereParticleEmitter
  15448. * @param radius the radius of the emission sphere (1 by default)
  15449. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15451. */
  15452. constructor(
  15453. /**
  15454. * The radius of the emission sphere.
  15455. */
  15456. radius?: number,
  15457. /**
  15458. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15459. */
  15460. radiusRange?: number,
  15461. /**
  15462. * How much to randomize the particle direction [0-1].
  15463. */
  15464. directionRandomizer?: number);
  15465. /**
  15466. * Called by the particle System when the direction is computed for the created particle.
  15467. * @param worldMatrix is the world matrix of the particle system
  15468. * @param directionToUpdate is the direction vector to update with the result
  15469. * @param particle is the particle we are computed the direction for
  15470. */
  15471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15472. /**
  15473. * Called by the particle System when the position is computed for the created particle.
  15474. * @param worldMatrix is the world matrix of the particle system
  15475. * @param positionToUpdate is the position vector to update with the result
  15476. * @param particle is the particle we are computed the position for
  15477. */
  15478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15479. /**
  15480. * Clones the current emitter and returns a copy of it
  15481. * @returns the new emitter
  15482. */
  15483. clone(): SphereParticleEmitter;
  15484. /**
  15485. * Called by the GPUParticleSystem to setup the update shader
  15486. * @param effect defines the update shader
  15487. */
  15488. applyToShader(effect: Effect): void;
  15489. /**
  15490. * Returns a string to use to update the GPU particles update shader
  15491. * @returns a string containng the defines string
  15492. */
  15493. getEffectDefines(): string;
  15494. /**
  15495. * Returns the string "SphereParticleEmitter"
  15496. * @returns a string containing the class name
  15497. */
  15498. getClassName(): string;
  15499. /**
  15500. * Serializes the particle system to a JSON object.
  15501. * @returns the JSON object
  15502. */
  15503. serialize(): any;
  15504. /**
  15505. * Parse properties from a JSON object
  15506. * @param serializationObject defines the JSON object
  15507. */
  15508. parse(serializationObject: any): void;
  15509. }
  15510. /**
  15511. * Particle emitter emitting particles from the inside of a sphere.
  15512. * It emits the particles randomly between two vectors.
  15513. */
  15514. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15515. /**
  15516. * The min limit of the emission direction.
  15517. */
  15518. direction1: Vector3;
  15519. /**
  15520. * The max limit of the emission direction.
  15521. */
  15522. direction2: Vector3;
  15523. /**
  15524. * Creates a new instance SphereDirectedParticleEmitter
  15525. * @param radius the radius of the emission sphere (1 by default)
  15526. * @param direction1 the min limit of the emission direction (up vector by default)
  15527. * @param direction2 the max limit of the emission direction (up vector by default)
  15528. */
  15529. constructor(radius?: number,
  15530. /**
  15531. * The min limit of the emission direction.
  15532. */
  15533. direction1?: Vector3,
  15534. /**
  15535. * The max limit of the emission direction.
  15536. */
  15537. direction2?: Vector3);
  15538. /**
  15539. * Called by the particle System when the direction is computed for the created particle.
  15540. * @param worldMatrix is the world matrix of the particle system
  15541. * @param directionToUpdate is the direction vector to update with the result
  15542. * @param particle is the particle we are computed the direction for
  15543. */
  15544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15545. /**
  15546. * Clones the current emitter and returns a copy of it
  15547. * @returns the new emitter
  15548. */
  15549. clone(): SphereDirectedParticleEmitter;
  15550. /**
  15551. * Called by the GPUParticleSystem to setup the update shader
  15552. * @param effect defines the update shader
  15553. */
  15554. applyToShader(effect: Effect): void;
  15555. /**
  15556. * Returns a string to use to update the GPU particles update shader
  15557. * @returns a string containng the defines string
  15558. */
  15559. getEffectDefines(): string;
  15560. /**
  15561. * Returns the string "SphereDirectedParticleEmitter"
  15562. * @returns a string containing the class name
  15563. */
  15564. getClassName(): string;
  15565. /**
  15566. * Serializes the particle system to a JSON object.
  15567. * @returns the JSON object
  15568. */
  15569. serialize(): any;
  15570. /**
  15571. * Parse properties from a JSON object
  15572. * @param serializationObject defines the JSON object
  15573. */
  15574. parse(serializationObject: any): void;
  15575. }
  15576. }
  15577. declare module BABYLON {
  15578. /**
  15579. * Interface representing a particle system in Babylon.js.
  15580. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15581. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15582. */
  15583. export interface IParticleSystem {
  15584. /**
  15585. * List of animations used by the particle system.
  15586. */
  15587. animations: Animation[];
  15588. /**
  15589. * The id of the Particle system.
  15590. */
  15591. id: string;
  15592. /**
  15593. * The name of the Particle system.
  15594. */
  15595. name: string;
  15596. /**
  15597. * The emitter represents the Mesh or position we are attaching the particle system to.
  15598. */
  15599. emitter: Nullable<AbstractMesh | Vector3>;
  15600. /**
  15601. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15602. */
  15603. isBillboardBased: boolean;
  15604. /**
  15605. * The rendering group used by the Particle system to chose when to render.
  15606. */
  15607. renderingGroupId: number;
  15608. /**
  15609. * The layer mask we are rendering the particles through.
  15610. */
  15611. layerMask: number;
  15612. /**
  15613. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15614. */
  15615. updateSpeed: number;
  15616. /**
  15617. * The amount of time the particle system is running (depends of the overall update speed).
  15618. */
  15619. targetStopDuration: number;
  15620. /**
  15621. * The texture used to render each particle. (this can be a spritesheet)
  15622. */
  15623. particleTexture: Nullable<Texture>;
  15624. /**
  15625. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15626. */
  15627. blendMode: number;
  15628. /**
  15629. * Minimum life time of emitting particles.
  15630. */
  15631. minLifeTime: number;
  15632. /**
  15633. * Maximum life time of emitting particles.
  15634. */
  15635. maxLifeTime: number;
  15636. /**
  15637. * Minimum Size of emitting particles.
  15638. */
  15639. minSize: number;
  15640. /**
  15641. * Maximum Size of emitting particles.
  15642. */
  15643. maxSize: number;
  15644. /**
  15645. * Minimum scale of emitting particles on X axis.
  15646. */
  15647. minScaleX: number;
  15648. /**
  15649. * Maximum scale of emitting particles on X axis.
  15650. */
  15651. maxScaleX: number;
  15652. /**
  15653. * Minimum scale of emitting particles on Y axis.
  15654. */
  15655. minScaleY: number;
  15656. /**
  15657. * Maximum scale of emitting particles on Y axis.
  15658. */
  15659. maxScaleY: number;
  15660. /**
  15661. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15662. */
  15663. color1: Color4;
  15664. /**
  15665. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15666. */
  15667. color2: Color4;
  15668. /**
  15669. * Color the particle will have at the end of its lifetime.
  15670. */
  15671. colorDead: Color4;
  15672. /**
  15673. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15674. */
  15675. emitRate: number;
  15676. /**
  15677. * You can use gravity if you want to give an orientation to your particles.
  15678. */
  15679. gravity: Vector3;
  15680. /**
  15681. * Minimum power of emitting particles.
  15682. */
  15683. minEmitPower: number;
  15684. /**
  15685. * Maximum power of emitting particles.
  15686. */
  15687. maxEmitPower: number;
  15688. /**
  15689. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15690. */
  15691. minAngularSpeed: number;
  15692. /**
  15693. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15694. */
  15695. maxAngularSpeed: number;
  15696. /**
  15697. * Gets or sets the minimal initial rotation in radians.
  15698. */
  15699. minInitialRotation: number;
  15700. /**
  15701. * Gets or sets the maximal initial rotation in radians.
  15702. */
  15703. maxInitialRotation: number;
  15704. /**
  15705. * The particle emitter type defines the emitter used by the particle system.
  15706. * It can be for example box, sphere, or cone...
  15707. */
  15708. particleEmitterType: Nullable<IParticleEmitterType>;
  15709. /**
  15710. * Defines the delay in milliseconds before starting the system (0 by default)
  15711. */
  15712. startDelay: number;
  15713. /**
  15714. * 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
  15715. */
  15716. preWarmCycles: number;
  15717. /**
  15718. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15719. */
  15720. preWarmStepOffset: number;
  15721. /**
  15722. * 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)
  15723. */
  15724. spriteCellChangeSpeed: number;
  15725. /**
  15726. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15727. */
  15728. startSpriteCellID: number;
  15729. /**
  15730. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15731. */
  15732. endSpriteCellID: number;
  15733. /**
  15734. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15735. */
  15736. spriteCellWidth: number;
  15737. /**
  15738. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15739. */
  15740. spriteCellHeight: number;
  15741. /**
  15742. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15743. */
  15744. spriteRandomStartCell: boolean;
  15745. /**
  15746. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15747. */
  15748. isAnimationSheetEnabled: boolean;
  15749. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15750. translationPivot: Vector2;
  15751. /**
  15752. * Gets or sets a texture used to add random noise to particle positions
  15753. */
  15754. noiseTexture: Nullable<BaseTexture>;
  15755. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15756. noiseStrength: Vector3;
  15757. /**
  15758. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15759. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15760. */
  15761. billboardMode: number;
  15762. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15763. limitVelocityDamping: number;
  15764. /**
  15765. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15766. */
  15767. beginAnimationOnStart: boolean;
  15768. /**
  15769. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15770. */
  15771. beginAnimationFrom: number;
  15772. /**
  15773. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15774. */
  15775. beginAnimationTo: number;
  15776. /**
  15777. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15778. */
  15779. beginAnimationLoop: boolean;
  15780. /**
  15781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15782. */
  15783. disposeOnStop: boolean;
  15784. /**
  15785. * Gets the maximum number of particles active at the same time.
  15786. * @returns The max number of active particles.
  15787. */
  15788. getCapacity(): number;
  15789. /**
  15790. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15791. * @returns True if it has been started, otherwise false.
  15792. */
  15793. isStarted(): boolean;
  15794. /**
  15795. * Animates the particle system for this frame.
  15796. */
  15797. animate(): void;
  15798. /**
  15799. * Renders the particle system in its current state.
  15800. * @returns the current number of particles
  15801. */
  15802. render(): number;
  15803. /**
  15804. * Dispose the particle system and frees its associated resources.
  15805. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15806. */
  15807. dispose(disposeTexture?: boolean): void;
  15808. /**
  15809. * Clones the particle system.
  15810. * @param name The name of the cloned object
  15811. * @param newEmitter The new emitter to use
  15812. * @returns the cloned particle system
  15813. */
  15814. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15815. /**
  15816. * Serializes the particle system to a JSON object.
  15817. * @returns the JSON object
  15818. */
  15819. serialize(): any;
  15820. /**
  15821. * Rebuild the particle system
  15822. */
  15823. rebuild(): void;
  15824. /**
  15825. * Starts the particle system and begins to emit
  15826. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15827. */
  15828. start(delay?: number): void;
  15829. /**
  15830. * Stops the particle system.
  15831. */
  15832. stop(): void;
  15833. /**
  15834. * Remove all active particles
  15835. */
  15836. reset(): void;
  15837. /**
  15838. * Is this system ready to be used/rendered
  15839. * @return true if the system is ready
  15840. */
  15841. isReady(): boolean;
  15842. /**
  15843. * Adds a new color gradient
  15844. * @param gradient defines the gradient to use (between 0 and 1)
  15845. * @param color1 defines the color to affect to the specified gradient
  15846. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15847. * @returns the current particle system
  15848. */
  15849. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15850. /**
  15851. * Remove a specific color gradient
  15852. * @param gradient defines the gradient to remove
  15853. * @returns the current particle system
  15854. */
  15855. removeColorGradient(gradient: number): IParticleSystem;
  15856. /**
  15857. * Adds a new size gradient
  15858. * @param gradient defines the gradient to use (between 0 and 1)
  15859. * @param factor defines the size factor to affect to the specified gradient
  15860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15861. * @returns the current particle system
  15862. */
  15863. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15864. /**
  15865. * Remove a specific size gradient
  15866. * @param gradient defines the gradient to remove
  15867. * @returns the current particle system
  15868. */
  15869. removeSizeGradient(gradient: number): IParticleSystem;
  15870. /**
  15871. * Gets the current list of color gradients.
  15872. * You must use addColorGradient and removeColorGradient to udpate this list
  15873. * @returns the list of color gradients
  15874. */
  15875. getColorGradients(): Nullable<Array<ColorGradient>>;
  15876. /**
  15877. * Gets the current list of size gradients.
  15878. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15879. * @returns the list of size gradients
  15880. */
  15881. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15882. /**
  15883. * Gets the current list of angular speed gradients.
  15884. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15885. * @returns the list of angular speed gradients
  15886. */
  15887. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15888. /**
  15889. * Adds a new angular speed gradient
  15890. * @param gradient defines the gradient to use (between 0 and 1)
  15891. * @param factor defines the angular speed to affect to the specified gradient
  15892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15893. * @returns the current particle system
  15894. */
  15895. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15896. /**
  15897. * Remove a specific angular speed gradient
  15898. * @param gradient defines the gradient to remove
  15899. * @returns the current particle system
  15900. */
  15901. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15902. /**
  15903. * Gets the current list of velocity gradients.
  15904. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15905. * @returns the list of velocity gradients
  15906. */
  15907. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15908. /**
  15909. * Adds a new velocity gradient
  15910. * @param gradient defines the gradient to use (between 0 and 1)
  15911. * @param factor defines the velocity to affect to the specified gradient
  15912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15913. * @returns the current particle system
  15914. */
  15915. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15916. /**
  15917. * Remove a specific velocity gradient
  15918. * @param gradient defines the gradient to remove
  15919. * @returns the current particle system
  15920. */
  15921. removeVelocityGradient(gradient: number): IParticleSystem;
  15922. /**
  15923. * Gets the current list of limit velocity gradients.
  15924. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15925. * @returns the list of limit velocity gradients
  15926. */
  15927. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15928. /**
  15929. * Adds a new limit velocity gradient
  15930. * @param gradient defines the gradient to use (between 0 and 1)
  15931. * @param factor defines the limit velocity to affect to the specified gradient
  15932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15933. * @returns the current particle system
  15934. */
  15935. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15936. /**
  15937. * Remove a specific limit velocity gradient
  15938. * @param gradient defines the gradient to remove
  15939. * @returns the current particle system
  15940. */
  15941. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15942. /**
  15943. * Adds a new drag gradient
  15944. * @param gradient defines the gradient to use (between 0 and 1)
  15945. * @param factor defines the drag to affect to the specified gradient
  15946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15947. * @returns the current particle system
  15948. */
  15949. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15950. /**
  15951. * Remove a specific drag gradient
  15952. * @param gradient defines the gradient to remove
  15953. * @returns the current particle system
  15954. */
  15955. removeDragGradient(gradient: number): IParticleSystem;
  15956. /**
  15957. * Gets the current list of drag gradients.
  15958. * You must use addDragGradient and removeDragGradient to udpate this list
  15959. * @returns the list of drag gradients
  15960. */
  15961. getDragGradients(): Nullable<Array<FactorGradient>>;
  15962. /**
  15963. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15964. * @param gradient defines the gradient to use (between 0 and 1)
  15965. * @param factor defines the emit rate to affect to the specified gradient
  15966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15967. * @returns the current particle system
  15968. */
  15969. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15970. /**
  15971. * Remove a specific emit rate gradient
  15972. * @param gradient defines the gradient to remove
  15973. * @returns the current particle system
  15974. */
  15975. removeEmitRateGradient(gradient: number): IParticleSystem;
  15976. /**
  15977. * Gets the current list of emit rate gradients.
  15978. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15979. * @returns the list of emit rate gradients
  15980. */
  15981. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15982. /**
  15983. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15984. * @param gradient defines the gradient to use (between 0 and 1)
  15985. * @param factor defines the start size to affect to the specified gradient
  15986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15987. * @returns the current particle system
  15988. */
  15989. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15990. /**
  15991. * Remove a specific start size gradient
  15992. * @param gradient defines the gradient to remove
  15993. * @returns the current particle system
  15994. */
  15995. removeStartSizeGradient(gradient: number): IParticleSystem;
  15996. /**
  15997. * Gets the current list of start size gradients.
  15998. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15999. * @returns the list of start size gradients
  16000. */
  16001. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16002. /**
  16003. * Adds a new life time gradient
  16004. * @param gradient defines the gradient to use (between 0 and 1)
  16005. * @param factor defines the life time factor to affect to the specified gradient
  16006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16007. * @returns the current particle system
  16008. */
  16009. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16010. /**
  16011. * Remove a specific life time gradient
  16012. * @param gradient defines the gradient to remove
  16013. * @returns the current particle system
  16014. */
  16015. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16016. /**
  16017. * Gets the current list of life time gradients.
  16018. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16019. * @returns the list of life time gradients
  16020. */
  16021. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16022. /**
  16023. * Gets the current list of color gradients.
  16024. * You must use addColorGradient and removeColorGradient to udpate this list
  16025. * @returns the list of color gradients
  16026. */
  16027. getColorGradients(): Nullable<Array<ColorGradient>>;
  16028. /**
  16029. * Adds a new ramp gradient used to remap particle colors
  16030. * @param gradient defines the gradient to use (between 0 and 1)
  16031. * @param color defines the color to affect to the specified gradient
  16032. * @returns the current particle system
  16033. */
  16034. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16035. /**
  16036. * Gets the current list of ramp gradients.
  16037. * You must use addRampGradient and removeRampGradient to udpate this list
  16038. * @returns the list of ramp gradients
  16039. */
  16040. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16041. /** Gets or sets a boolean indicating that ramp gradients must be used
  16042. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16043. */
  16044. useRampGradients: boolean;
  16045. /**
  16046. * Adds a new color remap gradient
  16047. * @param gradient defines the gradient to use (between 0 and 1)
  16048. * @param min defines the color remap minimal range
  16049. * @param max defines the color remap maximal range
  16050. * @returns the current particle system
  16051. */
  16052. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16053. /**
  16054. * Gets the current list of color remap gradients.
  16055. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16056. * @returns the list of color remap gradients
  16057. */
  16058. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16059. /**
  16060. * Adds a new alpha remap gradient
  16061. * @param gradient defines the gradient to use (between 0 and 1)
  16062. * @param min defines the alpha remap minimal range
  16063. * @param max defines the alpha remap maximal range
  16064. * @returns the current particle system
  16065. */
  16066. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16067. /**
  16068. * Gets the current list of alpha remap gradients.
  16069. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16070. * @returns the list of alpha remap gradients
  16071. */
  16072. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16073. /**
  16074. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16075. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16076. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16077. * @returns the emitter
  16078. */
  16079. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16080. /**
  16081. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16082. * @param radius The radius of the hemisphere to emit from
  16083. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16084. * @returns the emitter
  16085. */
  16086. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16087. /**
  16088. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16089. * @param radius The radius of the sphere to emit from
  16090. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16091. * @returns the emitter
  16092. */
  16093. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16094. /**
  16095. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16096. * @param radius The radius of the sphere to emit from
  16097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16099. * @returns the emitter
  16100. */
  16101. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16102. /**
  16103. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16104. * @param radius The radius of the emission cylinder
  16105. * @param height The height of the emission cylinder
  16106. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16107. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16108. * @returns the emitter
  16109. */
  16110. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16111. /**
  16112. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16113. * @param radius The radius of the cylinder to emit from
  16114. * @param height The height of the emission cylinder
  16115. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16116. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16117. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16118. * @returns the emitter
  16119. */
  16120. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16121. /**
  16122. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16123. * @param radius The radius of the cone to emit from
  16124. * @param angle The base angle of the cone
  16125. * @returns the emitter
  16126. */
  16127. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16128. /**
  16129. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16130. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16131. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16132. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16133. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16134. * @returns the emitter
  16135. */
  16136. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16137. /**
  16138. * Get hosting scene
  16139. * @returns the scene
  16140. */
  16141. getScene(): Scene;
  16142. }
  16143. }
  16144. declare module BABYLON {
  16145. /**
  16146. * Creates an instance based on a source mesh.
  16147. */
  16148. export class InstancedMesh extends AbstractMesh {
  16149. private _sourceMesh;
  16150. private _currentLOD;
  16151. /** @hidden */
  16152. _indexInSourceMeshInstanceArray: number;
  16153. constructor(name: string, source: Mesh);
  16154. /**
  16155. * Returns the string "InstancedMesh".
  16156. */
  16157. getClassName(): string;
  16158. /**
  16159. * If the source mesh receives shadows
  16160. */
  16161. readonly receiveShadows: boolean;
  16162. /**
  16163. * The material of the source mesh
  16164. */
  16165. readonly material: Nullable<Material>;
  16166. /**
  16167. * Visibility of the source mesh
  16168. */
  16169. readonly visibility: number;
  16170. /**
  16171. * Skeleton of the source mesh
  16172. */
  16173. readonly skeleton: Nullable<Skeleton>;
  16174. /**
  16175. * Rendering ground id of the source mesh
  16176. */
  16177. renderingGroupId: number;
  16178. /**
  16179. * Returns the total number of vertices (integer).
  16180. */
  16181. getTotalVertices(): number;
  16182. /**
  16183. * Returns a positive integer : the total number of indices in this mesh geometry.
  16184. * @returns the numner of indices or zero if the mesh has no geometry.
  16185. */
  16186. getTotalIndices(): number;
  16187. /**
  16188. * The source mesh of the instance
  16189. */
  16190. readonly sourceMesh: Mesh;
  16191. /**
  16192. * Is this node ready to be used/rendered
  16193. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16194. * @return {boolean} is it ready
  16195. */
  16196. isReady(completeCheck?: boolean): boolean;
  16197. /**
  16198. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16199. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16200. * @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.
  16201. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16202. */
  16203. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16204. /**
  16205. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16206. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16207. * The `data` are either a numeric array either a Float32Array.
  16208. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16209. * 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).
  16210. * Note that a new underlying VertexBuffer object is created each call.
  16211. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16212. *
  16213. * Possible `kind` values :
  16214. * - VertexBuffer.PositionKind
  16215. * - VertexBuffer.UVKind
  16216. * - VertexBuffer.UV2Kind
  16217. * - VertexBuffer.UV3Kind
  16218. * - VertexBuffer.UV4Kind
  16219. * - VertexBuffer.UV5Kind
  16220. * - VertexBuffer.UV6Kind
  16221. * - VertexBuffer.ColorKind
  16222. * - VertexBuffer.MatricesIndicesKind
  16223. * - VertexBuffer.MatricesIndicesExtraKind
  16224. * - VertexBuffer.MatricesWeightsKind
  16225. * - VertexBuffer.MatricesWeightsExtraKind
  16226. *
  16227. * Returns the Mesh.
  16228. */
  16229. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16230. /**
  16231. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16232. * If the mesh has no geometry, it is simply returned as it is.
  16233. * The `data` are either a numeric array either a Float32Array.
  16234. * No new underlying VertexBuffer object is created.
  16235. * 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.
  16236. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16237. *
  16238. * Possible `kind` values :
  16239. * - VertexBuffer.PositionKind
  16240. * - VertexBuffer.UVKind
  16241. * - VertexBuffer.UV2Kind
  16242. * - VertexBuffer.UV3Kind
  16243. * - VertexBuffer.UV4Kind
  16244. * - VertexBuffer.UV5Kind
  16245. * - VertexBuffer.UV6Kind
  16246. * - VertexBuffer.ColorKind
  16247. * - VertexBuffer.MatricesIndicesKind
  16248. * - VertexBuffer.MatricesIndicesExtraKind
  16249. * - VertexBuffer.MatricesWeightsKind
  16250. * - VertexBuffer.MatricesWeightsExtraKind
  16251. *
  16252. * Returns the Mesh.
  16253. */
  16254. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16255. /**
  16256. * Sets the mesh indices.
  16257. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16258. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16259. * This method creates a new index buffer each call.
  16260. * Returns the Mesh.
  16261. */
  16262. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16263. /**
  16264. * Boolean : True if the mesh owns the requested kind of data.
  16265. */
  16266. isVerticesDataPresent(kind: string): boolean;
  16267. /**
  16268. * Returns an array of indices (IndicesArray).
  16269. */
  16270. getIndices(): Nullable<IndicesArray>;
  16271. readonly _positions: Nullable<Vector3[]>;
  16272. /**
  16273. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16274. * This means the mesh underlying bounding box and sphere are recomputed.
  16275. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16276. * @returns the current mesh
  16277. */
  16278. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16279. /** @hidden */
  16280. _preActivate(): InstancedMesh;
  16281. /** @hidden */
  16282. _activate(renderId: number): InstancedMesh;
  16283. /**
  16284. * Returns the current associated LOD AbstractMesh.
  16285. */
  16286. getLOD(camera: Camera): AbstractMesh;
  16287. /** @hidden */
  16288. _syncSubMeshes(): InstancedMesh;
  16289. /** @hidden */
  16290. _generatePointsArray(): boolean;
  16291. /**
  16292. * Creates a new InstancedMesh from the current mesh.
  16293. * - name (string) : the cloned mesh name
  16294. * - newParent (optional Node) : the optional Node to parent the clone to.
  16295. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16296. *
  16297. * Returns the clone.
  16298. */
  16299. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16300. /**
  16301. * Disposes the InstancedMesh.
  16302. * Returns nothing.
  16303. */
  16304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16305. }
  16306. }
  16307. declare module BABYLON {
  16308. /**
  16309. * Defines the options associated with the creation of a shader material.
  16310. */
  16311. export interface IShaderMaterialOptions {
  16312. /**
  16313. * Does the material work in alpha blend mode
  16314. */
  16315. needAlphaBlending: boolean;
  16316. /**
  16317. * Does the material work in alpha test mode
  16318. */
  16319. needAlphaTesting: boolean;
  16320. /**
  16321. * The list of attribute names used in the shader
  16322. */
  16323. attributes: string[];
  16324. /**
  16325. * The list of unifrom names used in the shader
  16326. */
  16327. uniforms: string[];
  16328. /**
  16329. * The list of UBO names used in the shader
  16330. */
  16331. uniformBuffers: string[];
  16332. /**
  16333. * The list of sampler names used in the shader
  16334. */
  16335. samplers: string[];
  16336. /**
  16337. * The list of defines used in the shader
  16338. */
  16339. defines: string[];
  16340. }
  16341. /**
  16342. * 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.
  16343. *
  16344. * This returned material effects how the mesh will look based on the code in the shaders.
  16345. *
  16346. * @see http://doc.babylonjs.com/how_to/shader_material
  16347. */
  16348. export class ShaderMaterial extends Material {
  16349. private _shaderPath;
  16350. private _options;
  16351. private _textures;
  16352. private _textureArrays;
  16353. private _floats;
  16354. private _ints;
  16355. private _floatsArrays;
  16356. private _colors3;
  16357. private _colors3Arrays;
  16358. private _colors4;
  16359. private _vectors2;
  16360. private _vectors3;
  16361. private _vectors4;
  16362. private _matrices;
  16363. private _matrices3x3;
  16364. private _matrices2x2;
  16365. private _vectors2Arrays;
  16366. private _vectors3Arrays;
  16367. private _cachedWorldViewMatrix;
  16368. private _renderId;
  16369. /**
  16370. * Instantiate a new shader material.
  16371. * 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.
  16372. * This returned material effects how the mesh will look based on the code in the shaders.
  16373. * @see http://doc.babylonjs.com/how_to/shader_material
  16374. * @param name Define the name of the material in the scene
  16375. * @param scene Define the scene the material belongs to
  16376. * @param shaderPath Defines the route to the shader code in one of three ways:
  16377. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16378. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16379. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16380. * @param options Define the options used to create the shader
  16381. */
  16382. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16383. /**
  16384. * Gets the current class name of the material e.g. "ShaderMaterial"
  16385. * Mainly use in serialization.
  16386. * @returns the class name
  16387. */
  16388. getClassName(): string;
  16389. /**
  16390. * Specifies if the material will require alpha blending
  16391. * @returns a boolean specifying if alpha blending is needed
  16392. */
  16393. needAlphaBlending(): boolean;
  16394. /**
  16395. * Specifies if this material should be rendered in alpha test mode
  16396. * @returns a boolean specifying if an alpha test is needed.
  16397. */
  16398. needAlphaTesting(): boolean;
  16399. private _checkUniform;
  16400. /**
  16401. * Set a texture in the shader.
  16402. * @param name Define the name of the uniform samplers as defined in the shader
  16403. * @param texture Define the texture to bind to this sampler
  16404. * @return the material itself allowing "fluent" like uniform updates
  16405. */
  16406. setTexture(name: string, texture: Texture): ShaderMaterial;
  16407. /**
  16408. * Set a texture array in the shader.
  16409. * @param name Define the name of the uniform sampler array as defined in the shader
  16410. * @param textures Define the list of textures to bind to this sampler
  16411. * @return the material itself allowing "fluent" like uniform updates
  16412. */
  16413. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16414. /**
  16415. * Set a float in the shader.
  16416. * @param name Define the name of the uniform as defined in the shader
  16417. * @param value Define the value to give to the uniform
  16418. * @return the material itself allowing "fluent" like uniform updates
  16419. */
  16420. setFloat(name: string, value: number): ShaderMaterial;
  16421. /**
  16422. * Set a int in the shader.
  16423. * @param name Define the name of the uniform as defined in the shader
  16424. * @param value Define the value to give to the uniform
  16425. * @return the material itself allowing "fluent" like uniform updates
  16426. */
  16427. setInt(name: string, value: number): ShaderMaterial;
  16428. /**
  16429. * Set an array of floats in the shader.
  16430. * @param name Define the name of the uniform as defined in the shader
  16431. * @param value Define the value to give to the uniform
  16432. * @return the material itself allowing "fluent" like uniform updates
  16433. */
  16434. setFloats(name: string, value: number[]): ShaderMaterial;
  16435. /**
  16436. * Set a vec3 in the shader from a Color3.
  16437. * @param name Define the name of the uniform as defined in the shader
  16438. * @param value Define the value to give to the uniform
  16439. * @return the material itself allowing "fluent" like uniform updates
  16440. */
  16441. setColor3(name: string, value: Color3): ShaderMaterial;
  16442. /**
  16443. * Set a vec3 array in the shader from a Color3 array.
  16444. * @param name Define the name of the uniform as defined in the shader
  16445. * @param value Define the value to give to the uniform
  16446. * @return the material itself allowing "fluent" like uniform updates
  16447. */
  16448. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16449. /**
  16450. * Set a vec4 in the shader from a Color4.
  16451. * @param name Define the name of the uniform as defined in the shader
  16452. * @param value Define the value to give to the uniform
  16453. * @return the material itself allowing "fluent" like uniform updates
  16454. */
  16455. setColor4(name: string, value: Color4): ShaderMaterial;
  16456. /**
  16457. * Set a vec2 in the shader from a Vector2.
  16458. * @param name Define the name of the uniform as defined in the shader
  16459. * @param value Define the value to give to the uniform
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setVector2(name: string, value: Vector2): ShaderMaterial;
  16463. /**
  16464. * Set a vec3 in the shader from a Vector3.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setVector3(name: string, value: Vector3): ShaderMaterial;
  16470. /**
  16471. * Set a vec4 in the shader from a Vector4.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the material itself allowing "fluent" like uniform updates
  16475. */
  16476. setVector4(name: string, value: Vector4): ShaderMaterial;
  16477. /**
  16478. * Set a mat4 in the shader from a Matrix.
  16479. * @param name Define the name of the uniform as defined in the shader
  16480. * @param value Define the value to give to the uniform
  16481. * @return the material itself allowing "fluent" like uniform updates
  16482. */
  16483. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16484. /**
  16485. * Set a mat3 in the shader from a Float32Array.
  16486. * @param name Define the name of the uniform as defined in the shader
  16487. * @param value Define the value to give to the uniform
  16488. * @return the material itself allowing "fluent" like uniform updates
  16489. */
  16490. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16491. /**
  16492. * Set a mat2 in the shader from a Float32Array.
  16493. * @param name Define the name of the uniform as defined in the shader
  16494. * @param value Define the value to give to the uniform
  16495. * @return the material itself allowing "fluent" like uniform updates
  16496. */
  16497. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16498. /**
  16499. * Set a vec2 array in the shader from a number array.
  16500. * @param name Define the name of the uniform as defined in the shader
  16501. * @param value Define the value to give to the uniform
  16502. * @return the material itself allowing "fluent" like uniform updates
  16503. */
  16504. setArray2(name: string, value: number[]): ShaderMaterial;
  16505. /**
  16506. * Set a vec3 array in the shader from a number array.
  16507. * @param name Define the name of the uniform as defined in the shader
  16508. * @param value Define the value to give to the uniform
  16509. * @return the material itself allowing "fluent" like uniform updates
  16510. */
  16511. setArray3(name: string, value: number[]): ShaderMaterial;
  16512. private _checkCache;
  16513. /**
  16514. * Checks if the material is ready to render the requested mesh
  16515. * @param mesh Define the mesh to render
  16516. * @param useInstances Define whether or not the material is used with instances
  16517. * @returns true if ready, otherwise false
  16518. */
  16519. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16520. /**
  16521. * Binds the world matrix to the material
  16522. * @param world defines the world transformation matrix
  16523. */
  16524. bindOnlyWorldMatrix(world: Matrix): void;
  16525. /**
  16526. * Binds the material to the mesh
  16527. * @param world defines the world transformation matrix
  16528. * @param mesh defines the mesh to bind the material to
  16529. */
  16530. bind(world: Matrix, mesh?: Mesh): void;
  16531. /**
  16532. * Gets the active textures from the material
  16533. * @returns an array of textures
  16534. */
  16535. getActiveTextures(): BaseTexture[];
  16536. /**
  16537. * Specifies if the material uses a texture
  16538. * @param texture defines the texture to check against the material
  16539. * @returns a boolean specifying if the material uses the texture
  16540. */
  16541. hasTexture(texture: BaseTexture): boolean;
  16542. /**
  16543. * Makes a duplicate of the material, and gives it a new name
  16544. * @param name defines the new name for the duplicated material
  16545. * @returns the cloned material
  16546. */
  16547. clone(name: string): ShaderMaterial;
  16548. /**
  16549. * Disposes the material
  16550. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16551. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16552. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16553. */
  16554. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16555. /**
  16556. * Serializes this material in a JSON representation
  16557. * @returns the serialized material object
  16558. */
  16559. serialize(): any;
  16560. /**
  16561. * Creates a shader material from parsed shader material data
  16562. * @param source defines the JSON represnetation of the material
  16563. * @param scene defines the hosting scene
  16564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16565. * @returns a new material
  16566. */
  16567. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16568. }
  16569. }
  16570. declare module BABYLON {
  16571. /** @hidden */
  16572. export var colorPixelShader: {
  16573. name: string;
  16574. shader: string;
  16575. };
  16576. }
  16577. declare module BABYLON {
  16578. /** @hidden */
  16579. export var colorVertexShader: {
  16580. name: string;
  16581. shader: string;
  16582. };
  16583. }
  16584. declare module BABYLON {
  16585. /**
  16586. * Line mesh
  16587. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16588. */
  16589. export class LinesMesh extends Mesh {
  16590. /**
  16591. * If vertex color should be applied to the mesh
  16592. */
  16593. useVertexColor?: boolean | undefined;
  16594. /**
  16595. * If vertex alpha should be applied to the mesh
  16596. */
  16597. useVertexAlpha?: boolean | undefined;
  16598. /**
  16599. * Color of the line (Default: White)
  16600. */
  16601. color: Color3;
  16602. /**
  16603. * Alpha of the line (Default: 1)
  16604. */
  16605. alpha: number;
  16606. /**
  16607. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16608. * This margin is expressed in world space coordinates, so its value may vary.
  16609. * Default value is 0.1
  16610. */
  16611. intersectionThreshold: number;
  16612. private _colorShader;
  16613. /**
  16614. * Creates a new LinesMesh
  16615. * @param name defines the name
  16616. * @param scene defines the hosting scene
  16617. * @param parent defines the parent mesh if any
  16618. * @param source defines the optional source LinesMesh used to clone data from
  16619. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16620. * When false, achieved by calling a clone(), also passing False.
  16621. * This will make creation of children, recursive.
  16622. * @param useVertexColor defines if this LinesMesh supports vertex color
  16623. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16624. */
  16625. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16626. /**
  16627. * If vertex color should be applied to the mesh
  16628. */
  16629. useVertexColor?: boolean | undefined,
  16630. /**
  16631. * If vertex alpha should be applied to the mesh
  16632. */
  16633. useVertexAlpha?: boolean | undefined);
  16634. /**
  16635. * Returns the string "LineMesh"
  16636. */
  16637. getClassName(): string;
  16638. /**
  16639. * @hidden
  16640. */
  16641. /**
  16642. * @hidden
  16643. */
  16644. material: Material;
  16645. /**
  16646. * @hidden
  16647. */
  16648. readonly checkCollisions: boolean;
  16649. /** @hidden */
  16650. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16651. /** @hidden */
  16652. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16653. /**
  16654. * Disposes of the line mesh
  16655. * @param doNotRecurse If children should be disposed
  16656. */
  16657. dispose(doNotRecurse?: boolean): void;
  16658. /**
  16659. * Returns a new LineMesh object cloned from the current one.
  16660. */
  16661. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16662. /**
  16663. * Creates a new InstancedLinesMesh object from the mesh model.
  16664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16665. * @param name defines the name of the new instance
  16666. * @returns a new InstancedLinesMesh
  16667. */
  16668. createInstance(name: string): InstancedLinesMesh;
  16669. }
  16670. /**
  16671. * Creates an instance based on a source LinesMesh
  16672. */
  16673. export class InstancedLinesMesh extends InstancedMesh {
  16674. /**
  16675. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16676. * This margin is expressed in world space coordinates, so its value may vary.
  16677. * Initilized with the intersectionThreshold value of the source LinesMesh
  16678. */
  16679. intersectionThreshold: number;
  16680. constructor(name: string, source: LinesMesh);
  16681. /**
  16682. * Returns the string "InstancedLinesMesh".
  16683. */
  16684. getClassName(): string;
  16685. }
  16686. }
  16687. declare module BABYLON {
  16688. /** @hidden */
  16689. export var linePixelShader: {
  16690. name: string;
  16691. shader: string;
  16692. };
  16693. }
  16694. declare module BABYLON {
  16695. /** @hidden */
  16696. export var lineVertexShader: {
  16697. name: string;
  16698. shader: string;
  16699. };
  16700. }
  16701. declare module BABYLON {
  16702. interface AbstractMesh {
  16703. /**
  16704. * Disables the mesh edge rendering mode
  16705. * @returns the currentAbstractMesh
  16706. */
  16707. disableEdgesRendering(): AbstractMesh;
  16708. /**
  16709. * Enables the edge rendering mode on the mesh.
  16710. * This mode makes the mesh edges visible
  16711. * @param epsilon defines the maximal distance between two angles to detect a face
  16712. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16713. * @returns the currentAbstractMesh
  16714. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16715. */
  16716. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16717. /**
  16718. * Gets the edgesRenderer associated with the mesh
  16719. */
  16720. edgesRenderer: Nullable<EdgesRenderer>;
  16721. }
  16722. interface LinesMesh {
  16723. /**
  16724. * Enables the edge rendering mode on the mesh.
  16725. * This mode makes the mesh edges visible
  16726. * @param epsilon defines the maximal distance between two angles to detect a face
  16727. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16728. * @returns the currentAbstractMesh
  16729. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16730. */
  16731. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16732. }
  16733. interface InstancedLinesMesh {
  16734. /**
  16735. * Enables the edge rendering mode on the mesh.
  16736. * This mode makes the mesh edges visible
  16737. * @param epsilon defines the maximal distance between two angles to detect a face
  16738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16739. * @returns the current InstancedLinesMesh
  16740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16741. */
  16742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16743. }
  16744. /**
  16745. * Defines the minimum contract an Edges renderer should follow.
  16746. */
  16747. export interface IEdgesRenderer extends IDisposable {
  16748. /**
  16749. * Gets or sets a boolean indicating if the edgesRenderer is active
  16750. */
  16751. isEnabled: boolean;
  16752. /**
  16753. * Renders the edges of the attached mesh,
  16754. */
  16755. render(): void;
  16756. /**
  16757. * Checks wether or not the edges renderer is ready to render.
  16758. * @return true if ready, otherwise false.
  16759. */
  16760. isReady(): boolean;
  16761. }
  16762. /**
  16763. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16764. */
  16765. export class EdgesRenderer implements IEdgesRenderer {
  16766. /**
  16767. * Define the size of the edges with an orthographic camera
  16768. */
  16769. edgesWidthScalerForOrthographic: number;
  16770. /**
  16771. * Define the size of the edges with a perspective camera
  16772. */
  16773. edgesWidthScalerForPerspective: number;
  16774. protected _source: AbstractMesh;
  16775. protected _linesPositions: number[];
  16776. protected _linesNormals: number[];
  16777. protected _linesIndices: number[];
  16778. protected _epsilon: number;
  16779. protected _indicesCount: number;
  16780. protected _lineShader: ShaderMaterial;
  16781. protected _ib: WebGLBuffer;
  16782. protected _buffers: {
  16783. [key: string]: Nullable<VertexBuffer>;
  16784. };
  16785. protected _checkVerticesInsteadOfIndices: boolean;
  16786. private _meshRebuildObserver;
  16787. private _meshDisposeObserver;
  16788. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16789. isEnabled: boolean;
  16790. /**
  16791. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16792. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16793. * @param source Mesh used to create edges
  16794. * @param epsilon sum of angles in adjacency to check for edge
  16795. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16796. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16797. */
  16798. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16799. protected _prepareRessources(): void;
  16800. /** @hidden */
  16801. _rebuild(): void;
  16802. /**
  16803. * Releases the required resources for the edges renderer
  16804. */
  16805. dispose(): void;
  16806. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16807. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16808. /**
  16809. * Checks if the pair of p0 and p1 is en edge
  16810. * @param faceIndex
  16811. * @param edge
  16812. * @param faceNormals
  16813. * @param p0
  16814. * @param p1
  16815. * @private
  16816. */
  16817. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16818. /**
  16819. * push line into the position, normal and index buffer
  16820. * @protected
  16821. */
  16822. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16823. /**
  16824. * Generates lines edges from adjacencjes
  16825. * @private
  16826. */
  16827. _generateEdgesLines(): void;
  16828. /**
  16829. * Checks wether or not the edges renderer is ready to render.
  16830. * @return true if ready, otherwise false.
  16831. */
  16832. isReady(): boolean;
  16833. /**
  16834. * Renders the edges of the attached mesh,
  16835. */
  16836. render(): void;
  16837. }
  16838. /**
  16839. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16840. */
  16841. export class LineEdgesRenderer extends EdgesRenderer {
  16842. /**
  16843. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16844. * @param source LineMesh used to generate edges
  16845. * @param epsilon not important (specified angle for edge detection)
  16846. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16847. */
  16848. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16849. /**
  16850. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16851. */
  16852. _generateEdgesLines(): void;
  16853. }
  16854. }
  16855. declare module BABYLON {
  16856. /**
  16857. * This represents the object necessary to create a rendering group.
  16858. * This is exclusively used and created by the rendering manager.
  16859. * To modify the behavior, you use the available helpers in your scene or meshes.
  16860. * @hidden
  16861. */
  16862. export class RenderingGroup {
  16863. index: number;
  16864. private _scene;
  16865. private _opaqueSubMeshes;
  16866. private _transparentSubMeshes;
  16867. private _alphaTestSubMeshes;
  16868. private _depthOnlySubMeshes;
  16869. private _particleSystems;
  16870. private _spriteManagers;
  16871. private _opaqueSortCompareFn;
  16872. private _alphaTestSortCompareFn;
  16873. private _transparentSortCompareFn;
  16874. private _renderOpaque;
  16875. private _renderAlphaTest;
  16876. private _renderTransparent;
  16877. private _edgesRenderers;
  16878. onBeforeTransparentRendering: () => void;
  16879. /**
  16880. * Set the opaque sort comparison function.
  16881. * If null the sub meshes will be render in the order they were created
  16882. */
  16883. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16884. /**
  16885. * Set the alpha test sort comparison function.
  16886. * If null the sub meshes will be render in the order they were created
  16887. */
  16888. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16889. /**
  16890. * Set the transparent sort comparison function.
  16891. * If null the sub meshes will be render in the order they were created
  16892. */
  16893. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16894. /**
  16895. * Creates a new rendering group.
  16896. * @param index The rendering group index
  16897. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16898. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16899. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16900. */
  16901. 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>);
  16902. /**
  16903. * Render all the sub meshes contained in the group.
  16904. * @param customRenderFunction Used to override the default render behaviour of the group.
  16905. * @returns true if rendered some submeshes.
  16906. */
  16907. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16908. /**
  16909. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16910. * @param subMeshes The submeshes to render
  16911. */
  16912. private renderOpaqueSorted;
  16913. /**
  16914. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16915. * @param subMeshes The submeshes to render
  16916. */
  16917. private renderAlphaTestSorted;
  16918. /**
  16919. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16920. * @param subMeshes The submeshes to render
  16921. */
  16922. private renderTransparentSorted;
  16923. /**
  16924. * Renders the submeshes in a specified order.
  16925. * @param subMeshes The submeshes to sort before render
  16926. * @param sortCompareFn The comparison function use to sort
  16927. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16928. * @param transparent Specifies to activate blending if true
  16929. */
  16930. private static renderSorted;
  16931. /**
  16932. * Renders the submeshes in the order they were dispatched (no sort applied).
  16933. * @param subMeshes The submeshes to render
  16934. */
  16935. private static renderUnsorted;
  16936. /**
  16937. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16938. * are rendered back to front if in the same alpha index.
  16939. *
  16940. * @param a The first submesh
  16941. * @param b The second submesh
  16942. * @returns The result of the comparison
  16943. */
  16944. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16945. /**
  16946. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16947. * are rendered back to front.
  16948. *
  16949. * @param a The first submesh
  16950. * @param b The second submesh
  16951. * @returns The result of the comparison
  16952. */
  16953. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16954. /**
  16955. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16956. * are rendered front to back (prevent overdraw).
  16957. *
  16958. * @param a The first submesh
  16959. * @param b The second submesh
  16960. * @returns The result of the comparison
  16961. */
  16962. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16963. /**
  16964. * Resets the different lists of submeshes to prepare a new frame.
  16965. */
  16966. prepare(): void;
  16967. dispose(): void;
  16968. /**
  16969. * Inserts the submesh in its correct queue depending on its material.
  16970. * @param subMesh The submesh to dispatch
  16971. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16972. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16973. */
  16974. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16975. dispatchSprites(spriteManager: ISpriteManager): void;
  16976. dispatchParticles(particleSystem: IParticleSystem): void;
  16977. private _renderParticles;
  16978. private _renderSprites;
  16979. }
  16980. }
  16981. declare module BABYLON {
  16982. /**
  16983. * Interface describing the different options available in the rendering manager
  16984. * regarding Auto Clear between groups.
  16985. */
  16986. export interface IRenderingManagerAutoClearSetup {
  16987. /**
  16988. * Defines whether or not autoclear is enable.
  16989. */
  16990. autoClear: boolean;
  16991. /**
  16992. * Defines whether or not to autoclear the depth buffer.
  16993. */
  16994. depth: boolean;
  16995. /**
  16996. * Defines whether or not to autoclear the stencil buffer.
  16997. */
  16998. stencil: boolean;
  16999. }
  17000. /**
  17001. * This class is used by the onRenderingGroupObservable
  17002. */
  17003. export class RenderingGroupInfo {
  17004. /**
  17005. * The Scene that being rendered
  17006. */
  17007. scene: Scene;
  17008. /**
  17009. * The camera currently used for the rendering pass
  17010. */
  17011. camera: Nullable<Camera>;
  17012. /**
  17013. * The ID of the renderingGroup being processed
  17014. */
  17015. renderingGroupId: number;
  17016. }
  17017. /**
  17018. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17019. * It is enable to manage the different groups as well as the different necessary sort functions.
  17020. * This should not be used directly aside of the few static configurations
  17021. */
  17022. export class RenderingManager {
  17023. /**
  17024. * The max id used for rendering groups (not included)
  17025. */
  17026. static MAX_RENDERINGGROUPS: number;
  17027. /**
  17028. * The min id used for rendering groups (included)
  17029. */
  17030. static MIN_RENDERINGGROUPS: number;
  17031. /**
  17032. * Used to globally prevent autoclearing scenes.
  17033. */
  17034. static AUTOCLEAR: boolean;
  17035. /**
  17036. * @hidden
  17037. */
  17038. _useSceneAutoClearSetup: boolean;
  17039. private _scene;
  17040. private _renderingGroups;
  17041. private _depthStencilBufferAlreadyCleaned;
  17042. private _autoClearDepthStencil;
  17043. private _customOpaqueSortCompareFn;
  17044. private _customAlphaTestSortCompareFn;
  17045. private _customTransparentSortCompareFn;
  17046. private _renderingGroupInfo;
  17047. /**
  17048. * Instantiates a new rendering group for a particular scene
  17049. * @param scene Defines the scene the groups belongs to
  17050. */
  17051. constructor(scene: Scene);
  17052. private _clearDepthStencilBuffer;
  17053. /**
  17054. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17055. * @hidden
  17056. */
  17057. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17058. /**
  17059. * Resets the different information of the group to prepare a new frame
  17060. * @hidden
  17061. */
  17062. reset(): void;
  17063. /**
  17064. * Dispose and release the group and its associated resources.
  17065. * @hidden
  17066. */
  17067. dispose(): void;
  17068. /**
  17069. * Clear the info related to rendering groups preventing retention points during dispose.
  17070. */
  17071. freeRenderingGroups(): void;
  17072. private _prepareRenderingGroup;
  17073. /**
  17074. * Add a sprite manager to the rendering manager in order to render it this frame.
  17075. * @param spriteManager Define the sprite manager to render
  17076. */
  17077. dispatchSprites(spriteManager: ISpriteManager): void;
  17078. /**
  17079. * Add a particle system to the rendering manager in order to render it this frame.
  17080. * @param particleSystem Define the particle system to render
  17081. */
  17082. dispatchParticles(particleSystem: IParticleSystem): void;
  17083. /**
  17084. * Add a submesh to the manager in order to render it this frame
  17085. * @param subMesh The submesh to dispatch
  17086. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17087. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17088. */
  17089. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17090. /**
  17091. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17092. * This allowed control for front to back rendering or reversly depending of the special needs.
  17093. *
  17094. * @param renderingGroupId The rendering group id corresponding to its index
  17095. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17096. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17097. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17098. */
  17099. 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;
  17100. /**
  17101. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17102. *
  17103. * @param renderingGroupId The rendering group id corresponding to its index
  17104. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17105. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17106. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17107. */
  17108. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17109. /**
  17110. * Gets the current auto clear configuration for one rendering group of the rendering
  17111. * manager.
  17112. * @param index the rendering group index to get the information for
  17113. * @returns The auto clear setup for the requested rendering group
  17114. */
  17115. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17116. }
  17117. }
  17118. declare module BABYLON {
  17119. /**
  17120. * This Helps creating a texture that will be created from a camera in your scene.
  17121. * It is basically a dynamic texture that could be used to create special effects for instance.
  17122. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17123. */
  17124. export class RenderTargetTexture extends Texture {
  17125. isCube: boolean;
  17126. /**
  17127. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17128. */
  17129. static readonly REFRESHRATE_RENDER_ONCE: number;
  17130. /**
  17131. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17132. */
  17133. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17134. /**
  17135. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17136. * the central point of your effect and can save a lot of performances.
  17137. */
  17138. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17139. /**
  17140. * Use this predicate to dynamically define the list of mesh you want to render.
  17141. * If set, the renderList property will be overwritten.
  17142. */
  17143. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17144. private _renderList;
  17145. /**
  17146. * Use this list to define the list of mesh you want to render.
  17147. */
  17148. renderList: Nullable<Array<AbstractMesh>>;
  17149. private _hookArray;
  17150. /**
  17151. * Define if particles should be rendered in your texture.
  17152. */
  17153. renderParticles: boolean;
  17154. /**
  17155. * Define if sprites should be rendered in your texture.
  17156. */
  17157. renderSprites: boolean;
  17158. /**
  17159. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17160. */
  17161. coordinatesMode: number;
  17162. /**
  17163. * Define the camera used to render the texture.
  17164. */
  17165. activeCamera: Nullable<Camera>;
  17166. /**
  17167. * Override the render function of the texture with your own one.
  17168. */
  17169. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17170. /**
  17171. * Define if camera post processes should be use while rendering the texture.
  17172. */
  17173. useCameraPostProcesses: boolean;
  17174. /**
  17175. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17176. */
  17177. ignoreCameraViewport: boolean;
  17178. private _postProcessManager;
  17179. private _postProcesses;
  17180. private _resizeObserver;
  17181. /**
  17182. * An event triggered when the texture is unbind.
  17183. */
  17184. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17185. /**
  17186. * An event triggered when the texture is unbind.
  17187. */
  17188. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17189. private _onAfterUnbindObserver;
  17190. /**
  17191. * Set a after unbind callback in the texture.
  17192. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17193. */
  17194. onAfterUnbind: () => void;
  17195. /**
  17196. * An event triggered before rendering the texture
  17197. */
  17198. onBeforeRenderObservable: Observable<number>;
  17199. private _onBeforeRenderObserver;
  17200. /**
  17201. * Set a before render callback in the texture.
  17202. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17203. */
  17204. onBeforeRender: (faceIndex: number) => void;
  17205. /**
  17206. * An event triggered after rendering the texture
  17207. */
  17208. onAfterRenderObservable: Observable<number>;
  17209. private _onAfterRenderObserver;
  17210. /**
  17211. * Set a after render callback in the texture.
  17212. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17213. */
  17214. onAfterRender: (faceIndex: number) => void;
  17215. /**
  17216. * An event triggered after the texture clear
  17217. */
  17218. onClearObservable: Observable<Engine>;
  17219. private _onClearObserver;
  17220. /**
  17221. * Set a clear callback in the texture.
  17222. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17223. */
  17224. onClear: (Engine: Engine) => void;
  17225. /**
  17226. * Define the clear color of the Render Target if it should be different from the scene.
  17227. */
  17228. clearColor: Color4;
  17229. protected _size: number | {
  17230. width: number;
  17231. height: number;
  17232. };
  17233. protected _initialSizeParameter: number | {
  17234. width: number;
  17235. height: number;
  17236. } | {
  17237. ratio: number;
  17238. };
  17239. protected _sizeRatio: Nullable<number>;
  17240. /** @hidden */
  17241. _generateMipMaps: boolean;
  17242. protected _renderingManager: RenderingManager;
  17243. /** @hidden */
  17244. _waitingRenderList: string[];
  17245. protected _doNotChangeAspectRatio: boolean;
  17246. protected _currentRefreshId: number;
  17247. protected _refreshRate: number;
  17248. protected _textureMatrix: Matrix;
  17249. protected _samples: number;
  17250. protected _renderTargetOptions: RenderTargetCreationOptions;
  17251. /**
  17252. * Gets render target creation options that were used.
  17253. */
  17254. readonly renderTargetOptions: RenderTargetCreationOptions;
  17255. protected _engine: Engine;
  17256. protected _onRatioRescale(): void;
  17257. /**
  17258. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17259. * It must define where the camera used to render the texture is set
  17260. */
  17261. boundingBoxPosition: Vector3;
  17262. private _boundingBoxSize;
  17263. /**
  17264. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17265. * When defined, the cubemap will switch to local mode
  17266. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17267. * @example https://www.babylonjs-playground.com/#RNASML
  17268. */
  17269. boundingBoxSize: Vector3;
  17270. /**
  17271. * In case the RTT has been created with a depth texture, get the associated
  17272. * depth texture.
  17273. * Otherwise, return null.
  17274. */
  17275. depthStencilTexture: Nullable<InternalTexture>;
  17276. /**
  17277. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17278. * or used a shadow, depth texture...
  17279. * @param name The friendly name of the texture
  17280. * @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)
  17281. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17282. * @param generateMipMaps True if mip maps need to be generated after render.
  17283. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17284. * @param type The type of the buffer in the RTT (int, half float, float...)
  17285. * @param isCube True if a cube texture needs to be created
  17286. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17287. * @param generateDepthBuffer True to generate a depth buffer
  17288. * @param generateStencilBuffer True to generate a stencil buffer
  17289. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17290. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17291. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17292. */
  17293. constructor(name: string, size: number | {
  17294. width: number;
  17295. height: number;
  17296. } | {
  17297. ratio: number;
  17298. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17299. /**
  17300. * Creates a depth stencil texture.
  17301. * This is only available in WebGL 2 or with the depth texture extension available.
  17302. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17303. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17304. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17305. */
  17306. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17307. private _processSizeParameter;
  17308. /**
  17309. * Define the number of samples to use in case of MSAA.
  17310. * It defaults to one meaning no MSAA has been enabled.
  17311. */
  17312. samples: number;
  17313. /**
  17314. * Resets the refresh counter of the texture and start bak from scratch.
  17315. * Could be useful to regenerate the texture if it is setup to render only once.
  17316. */
  17317. resetRefreshCounter(): void;
  17318. /**
  17319. * Define the refresh rate of the texture or the rendering frequency.
  17320. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17321. */
  17322. refreshRate: number;
  17323. /**
  17324. * Adds a post process to the render target rendering passes.
  17325. * @param postProcess define the post process to add
  17326. */
  17327. addPostProcess(postProcess: PostProcess): void;
  17328. /**
  17329. * Clear all the post processes attached to the render target
  17330. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17331. */
  17332. clearPostProcesses(dispose?: boolean): void;
  17333. /**
  17334. * Remove one of the post process from the list of attached post processes to the texture
  17335. * @param postProcess define the post process to remove from the list
  17336. */
  17337. removePostProcess(postProcess: PostProcess): void;
  17338. /** @hidden */
  17339. _shouldRender(): boolean;
  17340. /**
  17341. * Gets the actual render size of the texture.
  17342. * @returns the width of the render size
  17343. */
  17344. getRenderSize(): number;
  17345. /**
  17346. * Gets the actual render width of the texture.
  17347. * @returns the width of the render size
  17348. */
  17349. getRenderWidth(): number;
  17350. /**
  17351. * Gets the actual render height of the texture.
  17352. * @returns the height of the render size
  17353. */
  17354. getRenderHeight(): number;
  17355. /**
  17356. * Get if the texture can be rescaled or not.
  17357. */
  17358. readonly canRescale: boolean;
  17359. /**
  17360. * Resize the texture using a ratio.
  17361. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17362. */
  17363. scale(ratio: number): void;
  17364. /**
  17365. * Get the texture reflection matrix used to rotate/transform the reflection.
  17366. * @returns the reflection matrix
  17367. */
  17368. getReflectionTextureMatrix(): Matrix;
  17369. /**
  17370. * Resize the texture to a new desired size.
  17371. * Be carrefull as it will recreate all the data in the new texture.
  17372. * @param size Define the new size. It can be:
  17373. * - a number for squared texture,
  17374. * - an object containing { width: number, height: number }
  17375. * - or an object containing a ratio { ratio: number }
  17376. */
  17377. resize(size: number | {
  17378. width: number;
  17379. height: number;
  17380. } | {
  17381. ratio: number;
  17382. }): void;
  17383. /**
  17384. * Renders all the objects from the render list into the texture.
  17385. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17386. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17387. */
  17388. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17389. private _bestReflectionRenderTargetDimension;
  17390. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17391. private renderToTarget;
  17392. /**
  17393. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17394. * This allowed control for front to back rendering or reversly depending of the special needs.
  17395. *
  17396. * @param renderingGroupId The rendering group id corresponding to its index
  17397. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17398. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17399. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17400. */
  17401. 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;
  17402. /**
  17403. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17404. *
  17405. * @param renderingGroupId The rendering group id corresponding to its index
  17406. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17407. */
  17408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17409. /**
  17410. * Clones the texture.
  17411. * @returns the cloned texture
  17412. */
  17413. clone(): RenderTargetTexture;
  17414. /**
  17415. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17416. * @returns The JSON representation of the texture
  17417. */
  17418. serialize(): any;
  17419. /**
  17420. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17421. */
  17422. disposeFramebufferObjects(): void;
  17423. /**
  17424. * Dispose the texture and release its associated resources.
  17425. */
  17426. dispose(): void;
  17427. /** @hidden */
  17428. _rebuild(): void;
  17429. /**
  17430. * Clear the info related to rendering groups preventing retention point in material dispose.
  17431. */
  17432. freeRenderingGroups(): void;
  17433. }
  17434. }
  17435. declare module BABYLON {
  17436. /**
  17437. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17438. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17439. * You can then easily use it as a reflectionTexture on a flat surface.
  17440. * In case the surface is not a plane, please consider relying on reflection probes.
  17441. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17442. */
  17443. export class MirrorTexture extends RenderTargetTexture {
  17444. private scene;
  17445. /**
  17446. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17447. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  17448. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17449. */
  17450. mirrorPlane: Plane;
  17451. /**
  17452. * Define the blur ratio used to blur the reflection if needed.
  17453. */
  17454. blurRatio: number;
  17455. /**
  17456. * Define the adaptive blur kernel used to blur the reflection if needed.
  17457. * This will autocompute the closest best match for the `blurKernel`
  17458. */
  17459. adaptiveBlurKernel: number;
  17460. /**
  17461. * Define the blur kernel used to blur the reflection if needed.
  17462. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17463. */
  17464. blurKernel: number;
  17465. /**
  17466. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17467. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17468. */
  17469. blurKernelX: number;
  17470. /**
  17471. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17472. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17473. */
  17474. blurKernelY: number;
  17475. private _autoComputeBlurKernel;
  17476. protected _onRatioRescale(): void;
  17477. private _updateGammaSpace;
  17478. private _imageProcessingConfigChangeObserver;
  17479. private _transformMatrix;
  17480. private _mirrorMatrix;
  17481. private _savedViewMatrix;
  17482. private _blurX;
  17483. private _blurY;
  17484. private _adaptiveBlurKernel;
  17485. private _blurKernelX;
  17486. private _blurKernelY;
  17487. private _blurRatio;
  17488. /**
  17489. * Instantiates a Mirror Texture.
  17490. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17491. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17492. * You can then easily use it as a reflectionTexture on a flat surface.
  17493. * In case the surface is not a plane, please consider relying on reflection probes.
  17494. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17495. * @param name
  17496. * @param size
  17497. * @param scene
  17498. * @param generateMipMaps
  17499. * @param type
  17500. * @param samplingMode
  17501. * @param generateDepthBuffer
  17502. */
  17503. constructor(name: string, size: number | {
  17504. width: number;
  17505. height: number;
  17506. } | {
  17507. ratio: number;
  17508. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17509. private _preparePostProcesses;
  17510. /**
  17511. * Clone the mirror texture.
  17512. * @returns the cloned texture
  17513. */
  17514. clone(): MirrorTexture;
  17515. /**
  17516. * Serialize the texture to a JSON representation you could use in Parse later on
  17517. * @returns the serialized JSON representation
  17518. */
  17519. serialize(): any;
  17520. /**
  17521. * Dispose the texture and release its associated resources.
  17522. */
  17523. dispose(): void;
  17524. }
  17525. }
  17526. declare module BABYLON {
  17527. /**
  17528. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17529. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17530. */
  17531. export class Texture extends BaseTexture {
  17532. /** @hidden */
  17533. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17534. /** @hidden */
  17535. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17536. /** @hidden */
  17537. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17538. /** nearest is mag = nearest and min = nearest and mip = linear */
  17539. static readonly NEAREST_SAMPLINGMODE: number;
  17540. /** nearest is mag = nearest and min = nearest and mip = linear */
  17541. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17542. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17543. static readonly BILINEAR_SAMPLINGMODE: number;
  17544. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17545. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17546. /** Trilinear is mag = linear and min = linear and mip = linear */
  17547. static readonly TRILINEAR_SAMPLINGMODE: number;
  17548. /** Trilinear is mag = linear and min = linear and mip = linear */
  17549. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17550. /** mag = nearest and min = nearest and mip = nearest */
  17551. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17552. /** mag = nearest and min = linear and mip = nearest */
  17553. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17554. /** mag = nearest and min = linear and mip = linear */
  17555. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17556. /** mag = nearest and min = linear and mip = none */
  17557. static readonly NEAREST_LINEAR: number;
  17558. /** mag = nearest and min = nearest and mip = none */
  17559. static readonly NEAREST_NEAREST: number;
  17560. /** mag = linear and min = nearest and mip = nearest */
  17561. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17562. /** mag = linear and min = nearest and mip = linear */
  17563. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17564. /** mag = linear and min = linear and mip = none */
  17565. static readonly LINEAR_LINEAR: number;
  17566. /** mag = linear and min = nearest and mip = none */
  17567. static readonly LINEAR_NEAREST: number;
  17568. /** Explicit coordinates mode */
  17569. static readonly EXPLICIT_MODE: number;
  17570. /** Spherical coordinates mode */
  17571. static readonly SPHERICAL_MODE: number;
  17572. /** Planar coordinates mode */
  17573. static readonly PLANAR_MODE: number;
  17574. /** Cubic coordinates mode */
  17575. static readonly CUBIC_MODE: number;
  17576. /** Projection coordinates mode */
  17577. static readonly PROJECTION_MODE: number;
  17578. /** Inverse Cubic coordinates mode */
  17579. static readonly SKYBOX_MODE: number;
  17580. /** Inverse Cubic coordinates mode */
  17581. static readonly INVCUBIC_MODE: number;
  17582. /** Equirectangular coordinates mode */
  17583. static readonly EQUIRECTANGULAR_MODE: number;
  17584. /** Equirectangular Fixed coordinates mode */
  17585. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17586. /** Equirectangular Fixed Mirrored coordinates mode */
  17587. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17588. /** Texture is not repeating outside of 0..1 UVs */
  17589. static readonly CLAMP_ADDRESSMODE: number;
  17590. /** Texture is repeating outside of 0..1 UVs */
  17591. static readonly WRAP_ADDRESSMODE: number;
  17592. /** Texture is repeating and mirrored */
  17593. static readonly MIRROR_ADDRESSMODE: number;
  17594. /**
  17595. * 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
  17596. */
  17597. static UseSerializedUrlIfAny: boolean;
  17598. /**
  17599. * Define the url of the texture.
  17600. */
  17601. url: Nullable<string>;
  17602. /**
  17603. * Define an offset on the texture to offset the u coordinates of the UVs
  17604. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17605. */
  17606. uOffset: number;
  17607. /**
  17608. * Define an offset on the texture to offset the v coordinates of the UVs
  17609. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17610. */
  17611. vOffset: number;
  17612. /**
  17613. * Define an offset on the texture to scale the u coordinates of the UVs
  17614. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17615. */
  17616. uScale: number;
  17617. /**
  17618. * Define an offset on the texture to scale the v coordinates of the UVs
  17619. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17620. */
  17621. vScale: number;
  17622. /**
  17623. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17624. * @see http://doc.babylonjs.com/how_to/more_materials
  17625. */
  17626. uAng: number;
  17627. /**
  17628. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17629. * @see http://doc.babylonjs.com/how_to/more_materials
  17630. */
  17631. vAng: number;
  17632. /**
  17633. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17634. * @see http://doc.babylonjs.com/how_to/more_materials
  17635. */
  17636. wAng: number;
  17637. /**
  17638. * Defines the center of rotation (U)
  17639. */
  17640. uRotationCenter: number;
  17641. /**
  17642. * Defines the center of rotation (V)
  17643. */
  17644. vRotationCenter: number;
  17645. /**
  17646. * Defines the center of rotation (W)
  17647. */
  17648. wRotationCenter: number;
  17649. /**
  17650. * Are mip maps generated for this texture or not.
  17651. */
  17652. readonly noMipmap: boolean;
  17653. private _noMipmap;
  17654. /** @hidden */
  17655. _invertY: boolean;
  17656. private _rowGenerationMatrix;
  17657. private _cachedTextureMatrix;
  17658. private _projectionModeMatrix;
  17659. private _t0;
  17660. private _t1;
  17661. private _t2;
  17662. private _cachedUOffset;
  17663. private _cachedVOffset;
  17664. private _cachedUScale;
  17665. private _cachedVScale;
  17666. private _cachedUAng;
  17667. private _cachedVAng;
  17668. private _cachedWAng;
  17669. private _cachedProjectionMatrixId;
  17670. private _cachedCoordinatesMode;
  17671. /** @hidden */
  17672. protected _initialSamplingMode: number;
  17673. /** @hidden */
  17674. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17675. private _deleteBuffer;
  17676. protected _format: Nullable<number>;
  17677. private _delayedOnLoad;
  17678. private _delayedOnError;
  17679. /**
  17680. * Observable triggered once the texture has been loaded.
  17681. */
  17682. onLoadObservable: Observable<Texture>;
  17683. protected _isBlocking: boolean;
  17684. /**
  17685. * Is the texture preventing material to render while loading.
  17686. * If false, a default texture will be used instead of the loading one during the preparation step.
  17687. */
  17688. isBlocking: boolean;
  17689. /**
  17690. * Get the current sampling mode associated with the texture.
  17691. */
  17692. readonly samplingMode: number;
  17693. /**
  17694. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17695. */
  17696. readonly invertY: boolean;
  17697. /**
  17698. * Instantiates a new texture.
  17699. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17700. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17701. * @param url define the url of the picture to load as a texture
  17702. * @param scene define the scene the texture will belong to
  17703. * @param noMipmap define if the texture will require mip maps or not
  17704. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17705. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17706. * @param onLoad define a callback triggered when the texture has been loaded
  17707. * @param onError define a callback triggered when an error occurred during the loading session
  17708. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17709. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17710. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17711. */
  17712. 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);
  17713. /**
  17714. * Update the url (and optional buffer) of this texture if url was null during construction.
  17715. * @param url the url of the texture
  17716. * @param buffer the buffer of the texture (defaults to null)
  17717. * @param onLoad callback called when the texture is loaded (defaults to null)
  17718. */
  17719. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17720. /**
  17721. * Finish the loading sequence of a texture flagged as delayed load.
  17722. * @hidden
  17723. */
  17724. delayLoad(): void;
  17725. private _prepareRowForTextureGeneration;
  17726. /**
  17727. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17728. * @returns the transform matrix of the texture.
  17729. */
  17730. getTextureMatrix(): Matrix;
  17731. /**
  17732. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17733. * @returns The reflection texture transform
  17734. */
  17735. getReflectionTextureMatrix(): Matrix;
  17736. /**
  17737. * Clones the texture.
  17738. * @returns the cloned texture
  17739. */
  17740. clone(): Texture;
  17741. /**
  17742. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17743. * @returns The JSON representation of the texture
  17744. */
  17745. serialize(): any;
  17746. /**
  17747. * Get the current class name of the texture useful for serialization or dynamic coding.
  17748. * @returns "Texture"
  17749. */
  17750. getClassName(): string;
  17751. /**
  17752. * Dispose the texture and release its associated resources.
  17753. */
  17754. dispose(): void;
  17755. /**
  17756. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17757. * @param parsedTexture Define the JSON representation of the texture
  17758. * @param scene Define the scene the parsed texture should be instantiated in
  17759. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17760. * @returns The parsed texture if successful
  17761. */
  17762. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17763. /**
  17764. * Creates a texture from its base 64 representation.
  17765. * @param data Define the base64 payload without the data: prefix
  17766. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17767. * @param scene Define the scene the texture should belong to
  17768. * @param noMipmap Forces the texture to not create mip map information if true
  17769. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17770. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17771. * @param onLoad define a callback triggered when the texture has been loaded
  17772. * @param onError define a callback triggered when an error occurred during the loading session
  17773. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17774. * @returns the created texture
  17775. */
  17776. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17777. /**
  17778. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17779. * @param data Define the base64 payload without the data: prefix
  17780. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17781. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17782. * @param scene Define the scene the texture should belong to
  17783. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17784. * @param noMipmap Forces the texture to not create mip map information if true
  17785. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17786. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17787. * @param onLoad define a callback triggered when the texture has been loaded
  17788. * @param onError define a callback triggered when an error occurred during the loading session
  17789. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17790. * @returns the created texture
  17791. */
  17792. 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;
  17793. }
  17794. }
  17795. declare module BABYLON {
  17796. /**
  17797. * Raw texture can help creating a texture directly from an array of data.
  17798. * This can be super useful if you either get the data from an uncompressed source or
  17799. * if you wish to create your texture pixel by pixel.
  17800. */
  17801. export class RawTexture extends Texture {
  17802. /**
  17803. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17804. */
  17805. format: number;
  17806. private _engine;
  17807. /**
  17808. * Instantiates a new RawTexture.
  17809. * Raw texture can help creating a texture directly from an array of data.
  17810. * This can be super useful if you either get the data from an uncompressed source or
  17811. * if you wish to create your texture pixel by pixel.
  17812. * @param data define the array of data to use to create the texture
  17813. * @param width define the width of the texture
  17814. * @param height define the height of the texture
  17815. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17816. * @param scene define the scene the texture belongs to
  17817. * @param generateMipMaps define whether mip maps should be generated or not
  17818. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17819. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17820. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17821. */
  17822. constructor(data: ArrayBufferView, width: number, height: number,
  17823. /**
  17824. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17825. */
  17826. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17827. /**
  17828. * Updates the texture underlying data.
  17829. * @param data Define the new data of the texture
  17830. */
  17831. update(data: ArrayBufferView): void;
  17832. /**
  17833. * Creates a luminance texture from some data.
  17834. * @param data Define the texture data
  17835. * @param width Define the width of the texture
  17836. * @param height Define the height of the texture
  17837. * @param scene Define the scene the texture belongs to
  17838. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17841. * @returns the luminance texture
  17842. */
  17843. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17844. /**
  17845. * Creates a luminance alpha texture from some data.
  17846. * @param data Define the texture data
  17847. * @param width Define the width of the texture
  17848. * @param height Define the height of the texture
  17849. * @param scene Define the scene the texture belongs to
  17850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17853. * @returns the luminance alpha texture
  17854. */
  17855. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17856. /**
  17857. * Creates an alpha texture from some data.
  17858. * @param data Define the texture data
  17859. * @param width Define the width of the texture
  17860. * @param height Define the height of the texture
  17861. * @param scene Define the scene the texture belongs to
  17862. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17863. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17864. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17865. * @returns the alpha texture
  17866. */
  17867. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17868. /**
  17869. * Creates a RGB texture from some data.
  17870. * @param data Define the texture data
  17871. * @param width Define the width of the texture
  17872. * @param height Define the height of the texture
  17873. * @param scene Define the scene the texture belongs to
  17874. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17877. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17878. * @returns the RGB alpha texture
  17879. */
  17880. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17881. /**
  17882. * Creates a RGBA texture from some data.
  17883. * @param data Define the texture data
  17884. * @param width Define the width of the texture
  17885. * @param height Define the height of the texture
  17886. * @param scene Define the scene the texture belongs to
  17887. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17888. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17889. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17890. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17891. * @returns the RGBA texture
  17892. */
  17893. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17894. /**
  17895. * Creates a R texture from some data.
  17896. * @param data Define the texture data
  17897. * @param width Define the width of the texture
  17898. * @param height Define the height of the texture
  17899. * @param scene Define the scene the texture belongs to
  17900. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17901. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17902. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17903. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17904. * @returns the R texture
  17905. */
  17906. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17907. }
  17908. }
  17909. declare module BABYLON {
  17910. /**
  17911. * Defines a runtime animation
  17912. */
  17913. export class RuntimeAnimation {
  17914. private _events;
  17915. /**
  17916. * The current frame of the runtime animation
  17917. */
  17918. private _currentFrame;
  17919. /**
  17920. * The animation used by the runtime animation
  17921. */
  17922. private _animation;
  17923. /**
  17924. * The target of the runtime animation
  17925. */
  17926. private _target;
  17927. /**
  17928. * The initiating animatable
  17929. */
  17930. private _host;
  17931. /**
  17932. * The original value of the runtime animation
  17933. */
  17934. private _originalValue;
  17935. /**
  17936. * The original blend value of the runtime animation
  17937. */
  17938. private _originalBlendValue;
  17939. /**
  17940. * The offsets cache of the runtime animation
  17941. */
  17942. private _offsetsCache;
  17943. /**
  17944. * The high limits cache of the runtime animation
  17945. */
  17946. private _highLimitsCache;
  17947. /**
  17948. * Specifies if the runtime animation has been stopped
  17949. */
  17950. private _stopped;
  17951. /**
  17952. * The blending factor of the runtime animation
  17953. */
  17954. private _blendingFactor;
  17955. /**
  17956. * The BabylonJS scene
  17957. */
  17958. private _scene;
  17959. /**
  17960. * The current value of the runtime animation
  17961. */
  17962. private _currentValue;
  17963. /** @hidden */
  17964. _workValue: any;
  17965. /**
  17966. * The active target of the runtime animation
  17967. */
  17968. private _activeTarget;
  17969. /**
  17970. * The target path of the runtime animation
  17971. */
  17972. private _targetPath;
  17973. /**
  17974. * The weight of the runtime animation
  17975. */
  17976. private _weight;
  17977. /**
  17978. * The ratio offset of the runtime animation
  17979. */
  17980. private _ratioOffset;
  17981. /**
  17982. * The previous delay of the runtime animation
  17983. */
  17984. private _previousDelay;
  17985. /**
  17986. * The previous ratio of the runtime animation
  17987. */
  17988. private _previousRatio;
  17989. /**
  17990. * Gets the current frame of the runtime animation
  17991. */
  17992. readonly currentFrame: number;
  17993. /**
  17994. * Gets the weight of the runtime animation
  17995. */
  17996. readonly weight: number;
  17997. /**
  17998. * Gets the current value of the runtime animation
  17999. */
  18000. readonly currentValue: any;
  18001. /**
  18002. * Gets the target path of the runtime animation
  18003. */
  18004. readonly targetPath: string;
  18005. /**
  18006. * Gets the actual target of the runtime animation
  18007. */
  18008. readonly target: any;
  18009. /**
  18010. * Create a new RuntimeAnimation object
  18011. * @param target defines the target of the animation
  18012. * @param animation defines the source animation object
  18013. * @param scene defines the hosting scene
  18014. * @param host defines the initiating Animatable
  18015. */
  18016. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18017. /**
  18018. * Gets the animation from the runtime animation
  18019. */
  18020. readonly animation: Animation;
  18021. /**
  18022. * Resets the runtime animation to the beginning
  18023. * @param restoreOriginal defines whether to restore the target property to the original value
  18024. */
  18025. reset(restoreOriginal?: boolean): void;
  18026. /**
  18027. * Specifies if the runtime animation is stopped
  18028. * @returns Boolean specifying if the runtime animation is stopped
  18029. */
  18030. isStopped(): boolean;
  18031. /**
  18032. * Disposes of the runtime animation
  18033. */
  18034. dispose(): void;
  18035. /**
  18036. * Interpolates the animation from the current frame
  18037. * @param currentFrame The frame to interpolate the animation to
  18038. * @param repeatCount The number of times that the animation should loop
  18039. * @param loopMode The type of looping mode to use
  18040. * @param offsetValue Animation offset value
  18041. * @param highLimitValue The high limit value
  18042. * @returns The interpolated value
  18043. */
  18044. private _interpolate;
  18045. /**
  18046. * Apply the interpolated value to the target
  18047. * @param currentValue defines the value computed by the animation
  18048. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18049. */
  18050. setValue(currentValue: any, weight?: number): void;
  18051. private _setValue;
  18052. /**
  18053. * Gets the loop pmode of the runtime animation
  18054. * @returns Loop Mode
  18055. */
  18056. private _getCorrectLoopMode;
  18057. /**
  18058. * Move the current animation to a given frame
  18059. * @param frame defines the frame to move to
  18060. */
  18061. goToFrame(frame: number): void;
  18062. /**
  18063. * @hidden Internal use only
  18064. */
  18065. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18066. /**
  18067. * Execute the current animation
  18068. * @param delay defines the delay to add to the current frame
  18069. * @param from defines the lower bound of the animation range
  18070. * @param to defines the upper bound of the animation range
  18071. * @param loop defines if the current animation must loop
  18072. * @param speedRatio defines the current speed ratio
  18073. * @param weight defines the weight of the animation (default is -1 so no weight)
  18074. * @param onLoop optional callback called when animation loops
  18075. * @returns a boolean indicating if the animation is running
  18076. */
  18077. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18078. }
  18079. }
  18080. declare module BABYLON {
  18081. /**
  18082. * Class used to store an actual running animation
  18083. */
  18084. export class Animatable {
  18085. /** defines the target object */
  18086. target: any;
  18087. /** defines the starting frame number (default is 0) */
  18088. fromFrame: number;
  18089. /** defines the ending frame number (default is 100) */
  18090. toFrame: number;
  18091. /** defines if the animation must loop (default is false) */
  18092. loopAnimation: boolean;
  18093. /** defines a callback to call when animation ends if it is not looping */
  18094. onAnimationEnd?: (() => void) | null | undefined;
  18095. /** defines a callback to call when animation loops */
  18096. onAnimationLoop?: (() => void) | null | undefined;
  18097. private _localDelayOffset;
  18098. private _pausedDelay;
  18099. private _runtimeAnimations;
  18100. private _paused;
  18101. private _scene;
  18102. private _speedRatio;
  18103. private _weight;
  18104. private _syncRoot;
  18105. /**
  18106. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18107. * This will only apply for non looping animation (default is true)
  18108. */
  18109. disposeOnEnd: boolean;
  18110. /**
  18111. * Gets a boolean indicating if the animation has started
  18112. */
  18113. animationStarted: boolean;
  18114. /**
  18115. * Observer raised when the animation ends
  18116. */
  18117. onAnimationEndObservable: Observable<Animatable>;
  18118. /**
  18119. * Observer raised when the animation loops
  18120. */
  18121. onAnimationLoopObservable: Observable<Animatable>;
  18122. /**
  18123. * Gets the root Animatable used to synchronize and normalize animations
  18124. */
  18125. readonly syncRoot: Animatable;
  18126. /**
  18127. * Gets the current frame of the first RuntimeAnimation
  18128. * Used to synchronize Animatables
  18129. */
  18130. readonly masterFrame: number;
  18131. /**
  18132. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18133. */
  18134. weight: number;
  18135. /**
  18136. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18137. */
  18138. speedRatio: number;
  18139. /**
  18140. * Creates a new Animatable
  18141. * @param scene defines the hosting scene
  18142. * @param target defines the target object
  18143. * @param fromFrame defines the starting frame number (default is 0)
  18144. * @param toFrame defines the ending frame number (default is 100)
  18145. * @param loopAnimation defines if the animation must loop (default is false)
  18146. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18147. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18148. * @param animations defines a group of animation to add to the new Animatable
  18149. * @param onAnimationLoop defines a callback to call when animation loops
  18150. */
  18151. constructor(scene: Scene,
  18152. /** defines the target object */
  18153. target: any,
  18154. /** defines the starting frame number (default is 0) */
  18155. fromFrame?: number,
  18156. /** defines the ending frame number (default is 100) */
  18157. toFrame?: number,
  18158. /** defines if the animation must loop (default is false) */
  18159. loopAnimation?: boolean, speedRatio?: number,
  18160. /** defines a callback to call when animation ends if it is not looping */
  18161. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18162. /** defines a callback to call when animation loops */
  18163. onAnimationLoop?: (() => void) | null | undefined);
  18164. /**
  18165. * Synchronize and normalize current Animatable with a source Animatable
  18166. * This is useful when using animation weights and when animations are not of the same length
  18167. * @param root defines the root Animatable to synchronize with
  18168. * @returns the current Animatable
  18169. */
  18170. syncWith(root: Animatable): Animatable;
  18171. /**
  18172. * Gets the list of runtime animations
  18173. * @returns an array of RuntimeAnimation
  18174. */
  18175. getAnimations(): RuntimeAnimation[];
  18176. /**
  18177. * Adds more animations to the current animatable
  18178. * @param target defines the target of the animations
  18179. * @param animations defines the new animations to add
  18180. */
  18181. appendAnimations(target: any, animations: Animation[]): void;
  18182. /**
  18183. * Gets the source animation for a specific property
  18184. * @param property defines the propertyu to look for
  18185. * @returns null or the source animation for the given property
  18186. */
  18187. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18188. /**
  18189. * Gets the runtime animation for a specific property
  18190. * @param property defines the propertyu to look for
  18191. * @returns null or the runtime animation for the given property
  18192. */
  18193. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18194. /**
  18195. * Resets the animatable to its original state
  18196. */
  18197. reset(): void;
  18198. /**
  18199. * Allows the animatable to blend with current running animations
  18200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18201. * @param blendingSpeed defines the blending speed to use
  18202. */
  18203. enableBlending(blendingSpeed: number): void;
  18204. /**
  18205. * Disable animation blending
  18206. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18207. */
  18208. disableBlending(): void;
  18209. /**
  18210. * Jump directly to a given frame
  18211. * @param frame defines the frame to jump to
  18212. */
  18213. goToFrame(frame: number): void;
  18214. /**
  18215. * Pause the animation
  18216. */
  18217. pause(): void;
  18218. /**
  18219. * Restart the animation
  18220. */
  18221. restart(): void;
  18222. private _raiseOnAnimationEnd;
  18223. /**
  18224. * Stop and delete the current animation
  18225. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18226. * @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)
  18227. */
  18228. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18229. /**
  18230. * Wait asynchronously for the animation to end
  18231. * @returns a promise which will be fullfilled when the animation ends
  18232. */
  18233. waitAsync(): Promise<Animatable>;
  18234. /** @hidden */
  18235. _animate(delay: number): boolean;
  18236. }
  18237. interface Scene {
  18238. /** @hidden */
  18239. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18240. /** @hidden */
  18241. _processLateAnimationBindingsForMatrices(holder: {
  18242. totalWeight: number;
  18243. animations: RuntimeAnimation[];
  18244. originalValue: Matrix;
  18245. }): any;
  18246. /** @hidden */
  18247. _processLateAnimationBindingsForQuaternions(holder: {
  18248. totalWeight: number;
  18249. animations: RuntimeAnimation[];
  18250. originalValue: Quaternion;
  18251. }, refQuaternion: Quaternion): Quaternion;
  18252. /** @hidden */
  18253. _processLateAnimationBindings(): void;
  18254. /**
  18255. * Will start the animation sequence of a given target
  18256. * @param target defines the target
  18257. * @param from defines from which frame should animation start
  18258. * @param to defines until which frame should animation run.
  18259. * @param weight defines the weight to apply to the animation (1.0 by default)
  18260. * @param loop defines if the animation loops
  18261. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18262. * @param onAnimationEnd defines the function to be executed when the animation ends
  18263. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18264. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18265. * @param onAnimationLoop defines the callback to call when an animation loops
  18266. * @returns the animatable object created for this animation
  18267. */
  18268. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18269. /**
  18270. * Will start the animation sequence of a given target
  18271. * @param target defines the target
  18272. * @param from defines from which frame should animation start
  18273. * @param to defines until which frame should animation run.
  18274. * @param loop defines if the animation loops
  18275. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18276. * @param onAnimationEnd defines the function to be executed when the animation ends
  18277. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18278. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18279. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18280. * @param onAnimationLoop defines the callback to call when an animation loops
  18281. * @returns the animatable object created for this animation
  18282. */
  18283. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18284. /**
  18285. * Will start the animation sequence of a given target and its hierarchy
  18286. * @param target defines the target
  18287. * @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.
  18288. * @param from defines from which frame should animation start
  18289. * @param to defines until which frame should animation run.
  18290. * @param loop defines if the animation loops
  18291. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18292. * @param onAnimationEnd defines the function to be executed when the animation ends
  18293. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18294. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18295. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18296. * @param onAnimationLoop defines the callback to call when an animation loops
  18297. * @returns the list of created animatables
  18298. */
  18299. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  18300. /**
  18301. * Begin a new animation on a given node
  18302. * @param target defines the target where the animation will take place
  18303. * @param animations defines the list of animations to start
  18304. * @param from defines the initial value
  18305. * @param to defines the final value
  18306. * @param loop defines if you want animation to loop (off by default)
  18307. * @param speedRatio defines the speed ratio to apply to all animations
  18308. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18309. * @param onAnimationLoop defines the callback to call when an animation loops
  18310. * @returns the list of created animatables
  18311. */
  18312. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18313. /**
  18314. * Begin a new animation on a given node and its hierarchy
  18315. * @param target defines the root node where the animation will take place
  18316. * @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.
  18317. * @param animations defines the list of animations to start
  18318. * @param from defines the initial value
  18319. * @param to defines the final value
  18320. * @param loop defines if you want animation to loop (off by default)
  18321. * @param speedRatio defines the speed ratio to apply to all animations
  18322. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18323. * @param onAnimationLoop defines the callback to call when an animation loops
  18324. * @returns the list of animatables created for all nodes
  18325. */
  18326. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18327. /**
  18328. * Gets the animatable associated with a specific target
  18329. * @param target defines the target of the animatable
  18330. * @returns the required animatable if found
  18331. */
  18332. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18333. /**
  18334. * Gets all animatables associated with a given target
  18335. * @param target defines the target to look animatables for
  18336. * @returns an array of Animatables
  18337. */
  18338. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18339. /**
  18340. * Will stop the animation of the given target
  18341. * @param target - the target
  18342. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18343. * @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)
  18344. */
  18345. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18346. /**
  18347. * Stops and removes all animations that have been applied to the scene
  18348. */
  18349. stopAllAnimations(): void;
  18350. }
  18351. interface Bone {
  18352. /**
  18353. * Copy an animation range from another bone
  18354. * @param source defines the source bone
  18355. * @param rangeName defines the range name to copy
  18356. * @param frameOffset defines the frame offset
  18357. * @param rescaleAsRequired defines if rescaling must be applied if required
  18358. * @param skelDimensionsRatio defines the scaling ratio
  18359. * @returns true if operation was successful
  18360. */
  18361. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18362. }
  18363. }
  18364. declare module BABYLON {
  18365. /**
  18366. * Class used to handle skinning animations
  18367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18368. */
  18369. export class Skeleton implements IAnimatable {
  18370. /** defines the skeleton name */
  18371. name: string;
  18372. /** defines the skeleton Id */
  18373. id: string;
  18374. /**
  18375. * Defines the list of child bones
  18376. */
  18377. bones: Bone[];
  18378. /**
  18379. * Defines an estimate of the dimension of the skeleton at rest
  18380. */
  18381. dimensionsAtRest: Vector3;
  18382. /**
  18383. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18384. */
  18385. needInitialSkinMatrix: boolean;
  18386. /**
  18387. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18388. */
  18389. overrideMesh: Nullable<AbstractMesh>;
  18390. /**
  18391. * Gets the list of animations attached to this skeleton
  18392. */
  18393. animations: Array<Animation>;
  18394. private _scene;
  18395. private _isDirty;
  18396. private _transformMatrices;
  18397. private _transformMatrixTexture;
  18398. private _meshesWithPoseMatrix;
  18399. private _animatables;
  18400. private _identity;
  18401. private _synchronizedWithMesh;
  18402. private _ranges;
  18403. private _lastAbsoluteTransformsUpdateId;
  18404. private _canUseTextureForBones;
  18405. /** @hidden */
  18406. _numBonesWithLinkedTransformNode: number;
  18407. /**
  18408. * Specifies if the skeleton should be serialized
  18409. */
  18410. doNotSerialize: boolean;
  18411. /**
  18412. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18413. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18414. */
  18415. useTextureToStoreBoneMatrices: boolean;
  18416. private _animationPropertiesOverride;
  18417. /**
  18418. * Gets or sets the animation properties override
  18419. */
  18420. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18421. /**
  18422. * An observable triggered before computing the skeleton's matrices
  18423. */
  18424. onBeforeComputeObservable: Observable<Skeleton>;
  18425. /**
  18426. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18427. */
  18428. readonly isUsingTextureForMatrices: boolean;
  18429. /**
  18430. * Creates a new skeleton
  18431. * @param name defines the skeleton name
  18432. * @param id defines the skeleton Id
  18433. * @param scene defines the hosting scene
  18434. */
  18435. constructor(
  18436. /** defines the skeleton name */
  18437. name: string,
  18438. /** defines the skeleton Id */
  18439. id: string, scene: Scene);
  18440. /**
  18441. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18442. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18443. * @returns a Float32Array containing matrices data
  18444. */
  18445. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18446. /**
  18447. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18448. * @returns a raw texture containing the data
  18449. */
  18450. getTransformMatrixTexture(): Nullable<RawTexture>;
  18451. /**
  18452. * Gets the current hosting scene
  18453. * @returns a scene object
  18454. */
  18455. getScene(): Scene;
  18456. /**
  18457. * Gets a string representing the current skeleton data
  18458. * @param fullDetails defines a boolean indicating if we want a verbose version
  18459. * @returns a string representing the current skeleton data
  18460. */
  18461. toString(fullDetails?: boolean): string;
  18462. /**
  18463. * Get bone's index searching by name
  18464. * @param name defines bone's name to search for
  18465. * @return the indice of the bone. Returns -1 if not found
  18466. */
  18467. getBoneIndexByName(name: string): number;
  18468. /**
  18469. * Creater a new animation range
  18470. * @param name defines the name of the range
  18471. * @param from defines the start key
  18472. * @param to defines the end key
  18473. */
  18474. createAnimationRange(name: string, from: number, to: number): void;
  18475. /**
  18476. * Delete a specific animation range
  18477. * @param name defines the name of the range
  18478. * @param deleteFrames defines if frames must be removed as well
  18479. */
  18480. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18481. /**
  18482. * Gets a specific animation range
  18483. * @param name defines the name of the range to look for
  18484. * @returns the requested animation range or null if not found
  18485. */
  18486. getAnimationRange(name: string): Nullable<AnimationRange>;
  18487. /**
  18488. * Gets the list of all animation ranges defined on this skeleton
  18489. * @returns an array
  18490. */
  18491. getAnimationRanges(): Nullable<AnimationRange>[];
  18492. /**
  18493. * Copy animation range from a source skeleton.
  18494. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18495. * @param source defines the source skeleton
  18496. * @param name defines the name of the range to copy
  18497. * @param rescaleAsRequired defines if rescaling must be applied if required
  18498. * @returns true if operation was successful
  18499. */
  18500. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18501. /**
  18502. * Forces the skeleton to go to rest pose
  18503. */
  18504. returnToRest(): void;
  18505. private _getHighestAnimationFrame;
  18506. /**
  18507. * Begin a specific animation range
  18508. * @param name defines the name of the range to start
  18509. * @param loop defines if looping must be turned on (false by default)
  18510. * @param speedRatio defines the speed ratio to apply (1 by default)
  18511. * @param onAnimationEnd defines a callback which will be called when animation will end
  18512. * @returns a new animatable
  18513. */
  18514. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18515. /** @hidden */
  18516. _markAsDirty(): void;
  18517. /** @hidden */
  18518. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18519. /** @hidden */
  18520. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18521. private _computeTransformMatrices;
  18522. /**
  18523. * Build all resources required to render a skeleton
  18524. */
  18525. prepare(): void;
  18526. /**
  18527. * Gets the list of animatables currently running for this skeleton
  18528. * @returns an array of animatables
  18529. */
  18530. getAnimatables(): IAnimatable[];
  18531. /**
  18532. * Clone the current skeleton
  18533. * @param name defines the name of the new skeleton
  18534. * @param id defines the id of the enw skeleton
  18535. * @returns the new skeleton
  18536. */
  18537. clone(name: string, id: string): Skeleton;
  18538. /**
  18539. * Enable animation blending for this skeleton
  18540. * @param blendingSpeed defines the blending speed to apply
  18541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18542. */
  18543. enableBlending(blendingSpeed?: number): void;
  18544. /**
  18545. * Releases all resources associated with the current skeleton
  18546. */
  18547. dispose(): void;
  18548. /**
  18549. * Serialize the skeleton in a JSON object
  18550. * @returns a JSON object
  18551. */
  18552. serialize(): any;
  18553. /**
  18554. * Creates a new skeleton from serialized data
  18555. * @param parsedSkeleton defines the serialized data
  18556. * @param scene defines the hosting scene
  18557. * @returns a new skeleton
  18558. */
  18559. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18560. /**
  18561. * Compute all node absolute transforms
  18562. * @param forceUpdate defines if computation must be done even if cache is up to date
  18563. */
  18564. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18565. /**
  18566. * Gets the root pose matrix
  18567. * @returns a matrix
  18568. */
  18569. getPoseMatrix(): Nullable<Matrix>;
  18570. /**
  18571. * Sorts bones per internal index
  18572. */
  18573. sortBones(): void;
  18574. private _sortBones;
  18575. }
  18576. }
  18577. declare module BABYLON {
  18578. /**
  18579. * Defines a target to use with MorphTargetManager
  18580. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18581. */
  18582. export class MorphTarget implements IAnimatable {
  18583. /** defines the name of the target */
  18584. name: string;
  18585. /**
  18586. * Gets or sets the list of animations
  18587. */
  18588. animations: Animation[];
  18589. private _scene;
  18590. private _positions;
  18591. private _normals;
  18592. private _tangents;
  18593. private _influence;
  18594. /**
  18595. * Observable raised when the influence changes
  18596. */
  18597. onInfluenceChanged: Observable<boolean>;
  18598. /** @hidden */
  18599. _onDataLayoutChanged: Observable<void>;
  18600. /**
  18601. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18602. */
  18603. influence: number;
  18604. /**
  18605. * Gets or sets the id of the morph Target
  18606. */
  18607. id: string;
  18608. private _animationPropertiesOverride;
  18609. /**
  18610. * Gets or sets the animation properties override
  18611. */
  18612. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18613. /**
  18614. * Creates a new MorphTarget
  18615. * @param name defines the name of the target
  18616. * @param influence defines the influence to use
  18617. * @param scene defines the scene the morphtarget belongs to
  18618. */
  18619. constructor(
  18620. /** defines the name of the target */
  18621. name: string, influence?: number, scene?: Nullable<Scene>);
  18622. /**
  18623. * Gets a boolean defining if the target contains position data
  18624. */
  18625. readonly hasPositions: boolean;
  18626. /**
  18627. * Gets a boolean defining if the target contains normal data
  18628. */
  18629. readonly hasNormals: boolean;
  18630. /**
  18631. * Gets a boolean defining if the target contains tangent data
  18632. */
  18633. readonly hasTangents: boolean;
  18634. /**
  18635. * Affects position data to this target
  18636. * @param data defines the position data to use
  18637. */
  18638. setPositions(data: Nullable<FloatArray>): void;
  18639. /**
  18640. * Gets the position data stored in this target
  18641. * @returns a FloatArray containing the position data (or null if not present)
  18642. */
  18643. getPositions(): Nullable<FloatArray>;
  18644. /**
  18645. * Affects normal data to this target
  18646. * @param data defines the normal data to use
  18647. */
  18648. setNormals(data: Nullable<FloatArray>): void;
  18649. /**
  18650. * Gets the normal data stored in this target
  18651. * @returns a FloatArray containing the normal data (or null if not present)
  18652. */
  18653. getNormals(): Nullable<FloatArray>;
  18654. /**
  18655. * Affects tangent data to this target
  18656. * @param data defines the tangent data to use
  18657. */
  18658. setTangents(data: Nullable<FloatArray>): void;
  18659. /**
  18660. * Gets the tangent data stored in this target
  18661. * @returns a FloatArray containing the tangent data (or null if not present)
  18662. */
  18663. getTangents(): Nullable<FloatArray>;
  18664. /**
  18665. * Serializes the current target into a Serialization object
  18666. * @returns the serialized object
  18667. */
  18668. serialize(): any;
  18669. /**
  18670. * Returns the string "MorphTarget"
  18671. * @returns "MorphTarget"
  18672. */
  18673. getClassName(): string;
  18674. /**
  18675. * Creates a new target from serialized data
  18676. * @param serializationObject defines the serialized data to use
  18677. * @returns a new MorphTarget
  18678. */
  18679. static Parse(serializationObject: any): MorphTarget;
  18680. /**
  18681. * Creates a MorphTarget from mesh data
  18682. * @param mesh defines the source mesh
  18683. * @param name defines the name to use for the new target
  18684. * @param influence defines the influence to attach to the target
  18685. * @returns a new MorphTarget
  18686. */
  18687. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18688. }
  18689. }
  18690. declare module BABYLON {
  18691. /**
  18692. * This class is used to deform meshes using morphing between different targets
  18693. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18694. */
  18695. export class MorphTargetManager {
  18696. private _targets;
  18697. private _targetInfluenceChangedObservers;
  18698. private _targetDataLayoutChangedObservers;
  18699. private _activeTargets;
  18700. private _scene;
  18701. private _influences;
  18702. private _supportsNormals;
  18703. private _supportsTangents;
  18704. private _vertexCount;
  18705. private _uniqueId;
  18706. private _tempInfluences;
  18707. /**
  18708. * Creates a new MorphTargetManager
  18709. * @param scene defines the current scene
  18710. */
  18711. constructor(scene?: Nullable<Scene>);
  18712. /**
  18713. * Gets the unique ID of this manager
  18714. */
  18715. readonly uniqueId: number;
  18716. /**
  18717. * Gets the number of vertices handled by this manager
  18718. */
  18719. readonly vertexCount: number;
  18720. /**
  18721. * Gets a boolean indicating if this manager supports morphing of normals
  18722. */
  18723. readonly supportsNormals: boolean;
  18724. /**
  18725. * Gets a boolean indicating if this manager supports morphing of tangents
  18726. */
  18727. readonly supportsTangents: boolean;
  18728. /**
  18729. * Gets the number of targets stored in this manager
  18730. */
  18731. readonly numTargets: number;
  18732. /**
  18733. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18734. */
  18735. readonly numInfluencers: number;
  18736. /**
  18737. * Gets the list of influences (one per target)
  18738. */
  18739. readonly influences: Float32Array;
  18740. /**
  18741. * Gets the active target at specified index. An active target is a target with an influence > 0
  18742. * @param index defines the index to check
  18743. * @returns the requested target
  18744. */
  18745. getActiveTarget(index: number): MorphTarget;
  18746. /**
  18747. * Gets the target at specified index
  18748. * @param index defines the index to check
  18749. * @returns the requested target
  18750. */
  18751. getTarget(index: number): MorphTarget;
  18752. /**
  18753. * Add a new target to this manager
  18754. * @param target defines the target to add
  18755. */
  18756. addTarget(target: MorphTarget): void;
  18757. /**
  18758. * Removes a target from the manager
  18759. * @param target defines the target to remove
  18760. */
  18761. removeTarget(target: MorphTarget): void;
  18762. /**
  18763. * Serializes the current manager into a Serialization object
  18764. * @returns the serialized object
  18765. */
  18766. serialize(): any;
  18767. private _syncActiveTargets;
  18768. /**
  18769. * Syncrhonize the targets with all the meshes using this morph target manager
  18770. */
  18771. synchronize(): void;
  18772. /**
  18773. * Creates a new MorphTargetManager from serialized data
  18774. * @param serializationObject defines the serialized data
  18775. * @param scene defines the hosting scene
  18776. * @returns the new MorphTargetManager
  18777. */
  18778. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18779. }
  18780. }
  18781. declare module BABYLON {
  18782. /**
  18783. * Mesh representing the gorund
  18784. */
  18785. export class GroundMesh extends Mesh {
  18786. /** If octree should be generated */
  18787. generateOctree: boolean;
  18788. private _heightQuads;
  18789. /** @hidden */
  18790. _subdivisionsX: number;
  18791. /** @hidden */
  18792. _subdivisionsY: number;
  18793. /** @hidden */
  18794. _width: number;
  18795. /** @hidden */
  18796. _height: number;
  18797. /** @hidden */
  18798. _minX: number;
  18799. /** @hidden */
  18800. _maxX: number;
  18801. /** @hidden */
  18802. _minZ: number;
  18803. /** @hidden */
  18804. _maxZ: number;
  18805. constructor(name: string, scene: Scene);
  18806. /**
  18807. * "GroundMesh"
  18808. * @returns "GroundMesh"
  18809. */
  18810. getClassName(): string;
  18811. /**
  18812. * The minimum of x and y subdivisions
  18813. */
  18814. readonly subdivisions: number;
  18815. /**
  18816. * X subdivisions
  18817. */
  18818. readonly subdivisionsX: number;
  18819. /**
  18820. * Y subdivisions
  18821. */
  18822. readonly subdivisionsY: number;
  18823. /**
  18824. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18825. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18826. * @param chunksCount the number of subdivisions for x and y
  18827. * @param octreeBlocksSize (Default: 32)
  18828. */
  18829. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18830. /**
  18831. * Returns a height (y) value in the Worl system :
  18832. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18833. * @param x x coordinate
  18834. * @param z z coordinate
  18835. * @returns the ground y position if (x, z) are outside the ground surface.
  18836. */
  18837. getHeightAtCoordinates(x: number, z: number): number;
  18838. /**
  18839. * Returns a normalized vector (Vector3) orthogonal to the ground
  18840. * at the ground coordinates (x, z) expressed in the World system.
  18841. * @param x x coordinate
  18842. * @param z z coordinate
  18843. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18844. */
  18845. getNormalAtCoordinates(x: number, z: number): Vector3;
  18846. /**
  18847. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18848. * at the ground coordinates (x, z) expressed in the World system.
  18849. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18850. * @param x x coordinate
  18851. * @param z z coordinate
  18852. * @param ref vector to store the result
  18853. * @returns the GroundMesh.
  18854. */
  18855. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18856. /**
  18857. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18858. * if the ground has been updated.
  18859. * This can be used in the render loop.
  18860. * @returns the GroundMesh.
  18861. */
  18862. updateCoordinateHeights(): GroundMesh;
  18863. private _getFacetAt;
  18864. private _initHeightQuads;
  18865. private _computeHeightQuads;
  18866. /**
  18867. * Serializes this ground mesh
  18868. * @param serializationObject object to write serialization to
  18869. */
  18870. serialize(serializationObject: any): void;
  18871. /**
  18872. * Parses a serialized ground mesh
  18873. * @param parsedMesh the serialized mesh
  18874. * @param scene the scene to create the ground mesh in
  18875. * @returns the created ground mesh
  18876. */
  18877. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Interface for Physics-Joint data
  18883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18884. */
  18885. export interface PhysicsJointData {
  18886. /**
  18887. * The main pivot of the joint
  18888. */
  18889. mainPivot?: Vector3;
  18890. /**
  18891. * The connected pivot of the joint
  18892. */
  18893. connectedPivot?: Vector3;
  18894. /**
  18895. * The main axis of the joint
  18896. */
  18897. mainAxis?: Vector3;
  18898. /**
  18899. * The connected axis of the joint
  18900. */
  18901. connectedAxis?: Vector3;
  18902. /**
  18903. * The collision of the joint
  18904. */
  18905. collision?: boolean;
  18906. /**
  18907. * Native Oimo/Cannon/Energy data
  18908. */
  18909. nativeParams?: any;
  18910. }
  18911. /**
  18912. * This is a holder class for the physics joint created by the physics plugin
  18913. * It holds a set of functions to control the underlying joint
  18914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18915. */
  18916. export class PhysicsJoint {
  18917. /**
  18918. * The type of the physics joint
  18919. */
  18920. type: number;
  18921. /**
  18922. * The data for the physics joint
  18923. */
  18924. jointData: PhysicsJointData;
  18925. private _physicsJoint;
  18926. protected _physicsPlugin: IPhysicsEnginePlugin;
  18927. /**
  18928. * Initializes the physics joint
  18929. * @param type The type of the physics joint
  18930. * @param jointData The data for the physics joint
  18931. */
  18932. constructor(
  18933. /**
  18934. * The type of the physics joint
  18935. */
  18936. type: number,
  18937. /**
  18938. * The data for the physics joint
  18939. */
  18940. jointData: PhysicsJointData);
  18941. /**
  18942. * Gets the physics joint
  18943. */
  18944. /**
  18945. * Sets the physics joint
  18946. */
  18947. physicsJoint: any;
  18948. /**
  18949. * Sets the physics plugin
  18950. */
  18951. physicsPlugin: IPhysicsEnginePlugin;
  18952. /**
  18953. * Execute a function that is physics-plugin specific.
  18954. * @param {Function} func the function that will be executed.
  18955. * It accepts two parameters: the physics world and the physics joint
  18956. */
  18957. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18958. /**
  18959. * Distance-Joint type
  18960. */
  18961. static DistanceJoint: number;
  18962. /**
  18963. * Hinge-Joint type
  18964. */
  18965. static HingeJoint: number;
  18966. /**
  18967. * Ball-and-Socket joint type
  18968. */
  18969. static BallAndSocketJoint: number;
  18970. /**
  18971. * Wheel-Joint type
  18972. */
  18973. static WheelJoint: number;
  18974. /**
  18975. * Slider-Joint type
  18976. */
  18977. static SliderJoint: number;
  18978. /**
  18979. * Prismatic-Joint type
  18980. */
  18981. static PrismaticJoint: number;
  18982. /**
  18983. * Universal-Joint type
  18984. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18985. */
  18986. static UniversalJoint: number;
  18987. /**
  18988. * Hinge-Joint 2 type
  18989. */
  18990. static Hinge2Joint: number;
  18991. /**
  18992. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18993. */
  18994. static PointToPointJoint: number;
  18995. /**
  18996. * Spring-Joint type
  18997. */
  18998. static SpringJoint: number;
  18999. /**
  19000. * Lock-Joint type
  19001. */
  19002. static LockJoint: number;
  19003. }
  19004. /**
  19005. * A class representing a physics distance joint
  19006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19007. */
  19008. export class DistanceJoint extends PhysicsJoint {
  19009. /**
  19010. *
  19011. * @param jointData The data for the Distance-Joint
  19012. */
  19013. constructor(jointData: DistanceJointData);
  19014. /**
  19015. * Update the predefined distance.
  19016. * @param maxDistance The maximum preferred distance
  19017. * @param minDistance The minimum preferred distance
  19018. */
  19019. updateDistance(maxDistance: number, minDistance?: number): void;
  19020. }
  19021. /**
  19022. * Represents a Motor-Enabled Joint
  19023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19024. */
  19025. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19026. /**
  19027. * Initializes the Motor-Enabled Joint
  19028. * @param type The type of the joint
  19029. * @param jointData The physica joint data for the joint
  19030. */
  19031. constructor(type: number, jointData: PhysicsJointData);
  19032. /**
  19033. * Set the motor values.
  19034. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19035. * @param force the force to apply
  19036. * @param maxForce max force for this motor.
  19037. */
  19038. setMotor(force?: number, maxForce?: number): void;
  19039. /**
  19040. * Set the motor's limits.
  19041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19042. * @param upperLimit The upper limit of the motor
  19043. * @param lowerLimit The lower limit of the motor
  19044. */
  19045. setLimit(upperLimit: number, lowerLimit?: number): void;
  19046. }
  19047. /**
  19048. * This class represents a single physics Hinge-Joint
  19049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19050. */
  19051. export class HingeJoint extends MotorEnabledJoint {
  19052. /**
  19053. * Initializes the Hinge-Joint
  19054. * @param jointData The joint data for the Hinge-Joint
  19055. */
  19056. constructor(jointData: PhysicsJointData);
  19057. /**
  19058. * Set the motor values.
  19059. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19060. * @param {number} force the force to apply
  19061. * @param {number} maxForce max force for this motor.
  19062. */
  19063. setMotor(force?: number, maxForce?: number): void;
  19064. /**
  19065. * Set the motor's limits.
  19066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19067. * @param upperLimit The upper limit of the motor
  19068. * @param lowerLimit The lower limit of the motor
  19069. */
  19070. setLimit(upperLimit: number, lowerLimit?: number): void;
  19071. }
  19072. /**
  19073. * This class represents a dual hinge physics joint (same as wheel joint)
  19074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19075. */
  19076. export class Hinge2Joint extends MotorEnabledJoint {
  19077. /**
  19078. * Initializes the Hinge2-Joint
  19079. * @param jointData The joint data for the Hinge2-Joint
  19080. */
  19081. constructor(jointData: PhysicsJointData);
  19082. /**
  19083. * Set the motor values.
  19084. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19085. * @param {number} targetSpeed the speed the motor is to reach
  19086. * @param {number} maxForce max force for this motor.
  19087. * @param {motorIndex} the motor's index, 0 or 1.
  19088. */
  19089. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19090. /**
  19091. * Set the motor limits.
  19092. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19093. * @param {number} upperLimit the upper limit
  19094. * @param {number} lowerLimit lower limit
  19095. * @param {motorIndex} the motor's index, 0 or 1.
  19096. */
  19097. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19098. }
  19099. /**
  19100. * Interface for a motor enabled joint
  19101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19102. */
  19103. export interface IMotorEnabledJoint {
  19104. /**
  19105. * Physics joint
  19106. */
  19107. physicsJoint: any;
  19108. /**
  19109. * Sets the motor of the motor-enabled joint
  19110. * @param force The force of the motor
  19111. * @param maxForce The maximum force of the motor
  19112. * @param motorIndex The index of the motor
  19113. */
  19114. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19115. /**
  19116. * Sets the limit of the motor
  19117. * @param upperLimit The upper limit of the motor
  19118. * @param lowerLimit The lower limit of the motor
  19119. * @param motorIndex The index of the motor
  19120. */
  19121. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19122. }
  19123. /**
  19124. * Joint data for a Distance-Joint
  19125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19126. */
  19127. export interface DistanceJointData extends PhysicsJointData {
  19128. /**
  19129. * Max distance the 2 joint objects can be apart
  19130. */
  19131. maxDistance: number;
  19132. }
  19133. /**
  19134. * Joint data from a spring joint
  19135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19136. */
  19137. export interface SpringJointData extends PhysicsJointData {
  19138. /**
  19139. * Length of the spring
  19140. */
  19141. length: number;
  19142. /**
  19143. * Stiffness of the spring
  19144. */
  19145. stiffness: number;
  19146. /**
  19147. * Damping of the spring
  19148. */
  19149. damping: number;
  19150. /** this callback will be called when applying the force to the impostors. */
  19151. forceApplicationCallback: () => void;
  19152. }
  19153. }
  19154. declare module BABYLON {
  19155. /**
  19156. * Interface used to describe a physics joint
  19157. */
  19158. export interface PhysicsImpostorJoint {
  19159. /** Defines the main impostor to which the joint is linked */
  19160. mainImpostor: PhysicsImpostor;
  19161. /** Defines the impostor that is connected to the main impostor using this joint */
  19162. connectedImpostor: PhysicsImpostor;
  19163. /** Defines the joint itself */
  19164. joint: PhysicsJoint;
  19165. }
  19166. /** @hidden */
  19167. export interface IPhysicsEnginePlugin {
  19168. world: any;
  19169. name: string;
  19170. setGravity(gravity: Vector3): void;
  19171. setTimeStep(timeStep: number): void;
  19172. getTimeStep(): number;
  19173. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19174. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19175. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19176. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19177. removePhysicsBody(impostor: PhysicsImpostor): void;
  19178. generateJoint(joint: PhysicsImpostorJoint): void;
  19179. removeJoint(joint: PhysicsImpostorJoint): void;
  19180. isSupported(): boolean;
  19181. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19183. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19184. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19185. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19186. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19187. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19188. getBodyMass(impostor: PhysicsImpostor): number;
  19189. getBodyFriction(impostor: PhysicsImpostor): number;
  19190. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19191. getBodyRestitution(impostor: PhysicsImpostor): number;
  19192. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19193. sleepBody(impostor: PhysicsImpostor): void;
  19194. wakeUpBody(impostor: PhysicsImpostor): void;
  19195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19196. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19198. getRadius(impostor: PhysicsImpostor): number;
  19199. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19200. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19201. dispose(): void;
  19202. }
  19203. /**
  19204. * Interface used to define a physics engine
  19205. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19206. */
  19207. export interface IPhysicsEngine {
  19208. /**
  19209. * Gets the gravity vector used by the simulation
  19210. */
  19211. gravity: Vector3;
  19212. /**
  19213. * Sets the gravity vector used by the simulation
  19214. * @param gravity defines the gravity vector to use
  19215. */
  19216. setGravity(gravity: Vector3): void;
  19217. /**
  19218. * Set the time step of the physics engine.
  19219. * Default is 1/60.
  19220. * To slow it down, enter 1/600 for example.
  19221. * To speed it up, 1/30
  19222. * @param newTimeStep the new timestep to apply to this world.
  19223. */
  19224. setTimeStep(newTimeStep: number): void;
  19225. /**
  19226. * Get the time step of the physics engine.
  19227. * @returns the current time step
  19228. */
  19229. getTimeStep(): number;
  19230. /**
  19231. * Release all resources
  19232. */
  19233. dispose(): void;
  19234. /**
  19235. * Gets the name of the current physics plugin
  19236. * @returns the name of the plugin
  19237. */
  19238. getPhysicsPluginName(): string;
  19239. /**
  19240. * Adding a new impostor for the impostor tracking.
  19241. * This will be done by the impostor itself.
  19242. * @param impostor the impostor to add
  19243. */
  19244. addImpostor(impostor: PhysicsImpostor): void;
  19245. /**
  19246. * Remove an impostor from the engine.
  19247. * This impostor and its mesh will not longer be updated by the physics engine.
  19248. * @param impostor the impostor to remove
  19249. */
  19250. removeImpostor(impostor: PhysicsImpostor): void;
  19251. /**
  19252. * Add a joint to the physics engine
  19253. * @param mainImpostor defines the main impostor to which the joint is added.
  19254. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19255. * @param joint defines the joint that will connect both impostors.
  19256. */
  19257. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19258. /**
  19259. * Removes a joint from the simulation
  19260. * @param mainImpostor defines the impostor used with the joint
  19261. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19262. * @param joint defines the joint to remove
  19263. */
  19264. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19265. /**
  19266. * Gets the current plugin used to run the simulation
  19267. * @returns current plugin
  19268. */
  19269. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19270. /**
  19271. * Gets the list of physic impostors
  19272. * @returns an array of PhysicsImpostor
  19273. */
  19274. getImpostors(): Array<PhysicsImpostor>;
  19275. /**
  19276. * Gets the impostor for a physics enabled object
  19277. * @param object defines the object impersonated by the impostor
  19278. * @returns the PhysicsImpostor or null if not found
  19279. */
  19280. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19281. /**
  19282. * Gets the impostor for a physics body object
  19283. * @param body defines physics body used by the impostor
  19284. * @returns the PhysicsImpostor or null if not found
  19285. */
  19286. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19287. /**
  19288. * Called by the scene. No need to call it.
  19289. * @param delta defines the timespam between frames
  19290. */
  19291. _step(delta: number): void;
  19292. }
  19293. }
  19294. declare module BABYLON {
  19295. /**
  19296. * The interface for the physics imposter parameters
  19297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19298. */
  19299. export interface PhysicsImpostorParameters {
  19300. /**
  19301. * The mass of the physics imposter
  19302. */
  19303. mass: number;
  19304. /**
  19305. * The friction of the physics imposter
  19306. */
  19307. friction?: number;
  19308. /**
  19309. * The coefficient of restitution of the physics imposter
  19310. */
  19311. restitution?: number;
  19312. /**
  19313. * The native options of the physics imposter
  19314. */
  19315. nativeOptions?: any;
  19316. /**
  19317. * Specifies if the parent should be ignored
  19318. */
  19319. ignoreParent?: boolean;
  19320. /**
  19321. * Specifies if bi-directional transformations should be disabled
  19322. */
  19323. disableBidirectionalTransformation?: boolean;
  19324. }
  19325. /**
  19326. * Interface for a physics-enabled object
  19327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19328. */
  19329. export interface IPhysicsEnabledObject {
  19330. /**
  19331. * The position of the physics-enabled object
  19332. */
  19333. position: Vector3;
  19334. /**
  19335. * The rotation of the physics-enabled object
  19336. */
  19337. rotationQuaternion: Nullable<Quaternion>;
  19338. /**
  19339. * The scale of the physics-enabled object
  19340. */
  19341. scaling: Vector3;
  19342. /**
  19343. * The rotation of the physics-enabled object
  19344. */
  19345. rotation?: Vector3;
  19346. /**
  19347. * The parent of the physics-enabled object
  19348. */
  19349. parent?: any;
  19350. /**
  19351. * The bounding info of the physics-enabled object
  19352. * @returns The bounding info of the physics-enabled object
  19353. */
  19354. getBoundingInfo(): BoundingInfo;
  19355. /**
  19356. * Computes the world matrix
  19357. * @param force Specifies if the world matrix should be computed by force
  19358. * @returns A world matrix
  19359. */
  19360. computeWorldMatrix(force: boolean): Matrix;
  19361. /**
  19362. * Gets the world matrix
  19363. * @returns A world matrix
  19364. */
  19365. getWorldMatrix?(): Matrix;
  19366. /**
  19367. * Gets the child meshes
  19368. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19369. * @returns An array of abstract meshes
  19370. */
  19371. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19372. /**
  19373. * Gets the vertex data
  19374. * @param kind The type of vertex data
  19375. * @returns A nullable array of numbers, or a float32 array
  19376. */
  19377. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19378. /**
  19379. * Gets the indices from the mesh
  19380. * @returns A nullable array of index arrays
  19381. */
  19382. getIndices?(): Nullable<IndicesArray>;
  19383. /**
  19384. * Gets the scene from the mesh
  19385. * @returns the indices array or null
  19386. */
  19387. getScene?(): Scene;
  19388. /**
  19389. * Gets the absolute position from the mesh
  19390. * @returns the absolute position
  19391. */
  19392. getAbsolutePosition(): Vector3;
  19393. /**
  19394. * Gets the absolute pivot point from the mesh
  19395. * @returns the absolute pivot point
  19396. */
  19397. getAbsolutePivotPoint(): Vector3;
  19398. /**
  19399. * Rotates the mesh
  19400. * @param axis The axis of rotation
  19401. * @param amount The amount of rotation
  19402. * @param space The space of the rotation
  19403. * @returns The rotation transform node
  19404. */
  19405. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19406. /**
  19407. * Translates the mesh
  19408. * @param axis The axis of translation
  19409. * @param distance The distance of translation
  19410. * @param space The space of the translation
  19411. * @returns The transform node
  19412. */
  19413. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19414. /**
  19415. * Sets the absolute position of the mesh
  19416. * @param absolutePosition The absolute position of the mesh
  19417. * @returns The transform node
  19418. */
  19419. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19420. /**
  19421. * Gets the class name of the mesh
  19422. * @returns The class name
  19423. */
  19424. getClassName(): string;
  19425. }
  19426. /**
  19427. * Represents a physics imposter
  19428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19429. */
  19430. export class PhysicsImpostor {
  19431. /**
  19432. * The physics-enabled object used as the physics imposter
  19433. */
  19434. object: IPhysicsEnabledObject;
  19435. /**
  19436. * The type of the physics imposter
  19437. */
  19438. type: number;
  19439. private _options;
  19440. private _scene?;
  19441. /**
  19442. * The default object size of the imposter
  19443. */
  19444. static DEFAULT_OBJECT_SIZE: Vector3;
  19445. /**
  19446. * The identity quaternion of the imposter
  19447. */
  19448. static IDENTITY_QUATERNION: Quaternion;
  19449. /** @hidden */
  19450. _pluginData: any;
  19451. private _physicsEngine;
  19452. private _physicsBody;
  19453. private _bodyUpdateRequired;
  19454. private _onBeforePhysicsStepCallbacks;
  19455. private _onAfterPhysicsStepCallbacks;
  19456. /** @hidden */
  19457. _onPhysicsCollideCallbacks: Array<{
  19458. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19459. otherImpostors: Array<PhysicsImpostor>;
  19460. }>;
  19461. private _deltaPosition;
  19462. private _deltaRotation;
  19463. private _deltaRotationConjugated;
  19464. private _parent;
  19465. private _isDisposed;
  19466. private static _tmpVecs;
  19467. private static _tmpQuat;
  19468. /**
  19469. * Specifies if the physics imposter is disposed
  19470. */
  19471. readonly isDisposed: boolean;
  19472. /**
  19473. * Gets the mass of the physics imposter
  19474. */
  19475. mass: number;
  19476. /**
  19477. * Gets the coefficient of friction
  19478. */
  19479. /**
  19480. * Sets the coefficient of friction
  19481. */
  19482. friction: number;
  19483. /**
  19484. * Gets the coefficient of restitution
  19485. */
  19486. /**
  19487. * Sets the coefficient of restitution
  19488. */
  19489. restitution: number;
  19490. /**
  19491. * The unique id of the physics imposter
  19492. * set by the physics engine when adding this impostor to the array
  19493. */
  19494. uniqueId: number;
  19495. private _joints;
  19496. /**
  19497. * Initializes the physics imposter
  19498. * @param object The physics-enabled object used as the physics imposter
  19499. * @param type The type of the physics imposter
  19500. * @param _options The options for the physics imposter
  19501. * @param _scene The Babylon scene
  19502. */
  19503. constructor(
  19504. /**
  19505. * The physics-enabled object used as the physics imposter
  19506. */
  19507. object: IPhysicsEnabledObject,
  19508. /**
  19509. * The type of the physics imposter
  19510. */
  19511. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19512. /**
  19513. * This function will completly initialize this impostor.
  19514. * It will create a new body - but only if this mesh has no parent.
  19515. * If it has, this impostor will not be used other than to define the impostor
  19516. * of the child mesh.
  19517. * @hidden
  19518. */
  19519. _init(): void;
  19520. private _getPhysicsParent;
  19521. /**
  19522. * Should a new body be generated.
  19523. * @returns boolean specifying if body initialization is required
  19524. */
  19525. isBodyInitRequired(): boolean;
  19526. /**
  19527. * Sets the updated scaling
  19528. * @param updated Specifies if the scaling is updated
  19529. */
  19530. setScalingUpdated(): void;
  19531. /**
  19532. * Force a regeneration of this or the parent's impostor's body.
  19533. * Use under cautious - This will remove all joints already implemented.
  19534. */
  19535. forceUpdate(): void;
  19536. /**
  19537. * Gets the body that holds this impostor. Either its own, or its parent.
  19538. */
  19539. /**
  19540. * Set the physics body. Used mainly by the physics engine/plugin
  19541. */
  19542. physicsBody: any;
  19543. /**
  19544. * Get the parent of the physics imposter
  19545. * @returns Physics imposter or null
  19546. */
  19547. /**
  19548. * Sets the parent of the physics imposter
  19549. */
  19550. parent: Nullable<PhysicsImpostor>;
  19551. /**
  19552. * Resets the update flags
  19553. */
  19554. resetUpdateFlags(): void;
  19555. /**
  19556. * Gets the object extend size
  19557. * @returns the object extend size
  19558. */
  19559. getObjectExtendSize(): Vector3;
  19560. /**
  19561. * Gets the object center
  19562. * @returns The object center
  19563. */
  19564. getObjectCenter(): Vector3;
  19565. /**
  19566. * Get a specific parametes from the options parameter
  19567. * @param paramName The object parameter name
  19568. * @returns The object parameter
  19569. */
  19570. getParam(paramName: string): any;
  19571. /**
  19572. * Sets a specific parameter in the options given to the physics plugin
  19573. * @param paramName The parameter name
  19574. * @param value The value of the parameter
  19575. */
  19576. setParam(paramName: string, value: number): void;
  19577. /**
  19578. * Specifically change the body's mass option. Won't recreate the physics body object
  19579. * @param mass The mass of the physics imposter
  19580. */
  19581. setMass(mass: number): void;
  19582. /**
  19583. * Gets the linear velocity
  19584. * @returns linear velocity or null
  19585. */
  19586. getLinearVelocity(): Nullable<Vector3>;
  19587. /**
  19588. * Sets the linear velocity
  19589. * @param velocity linear velocity or null
  19590. */
  19591. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19592. /**
  19593. * Gets the angular velocity
  19594. * @returns angular velocity or null
  19595. */
  19596. getAngularVelocity(): Nullable<Vector3>;
  19597. /**
  19598. * Sets the angular velocity
  19599. * @param velocity The velocity or null
  19600. */
  19601. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19602. /**
  19603. * Execute a function with the physics plugin native code
  19604. * Provide a function the will have two variables - the world object and the physics body object
  19605. * @param func The function to execute with the physics plugin native code
  19606. */
  19607. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19608. /**
  19609. * Register a function that will be executed before the physics world is stepping forward
  19610. * @param func The function to execute before the physics world is stepped forward
  19611. */
  19612. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19613. /**
  19614. * Unregister a function that will be executed before the physics world is stepping forward
  19615. * @param func The function to execute before the physics world is stepped forward
  19616. */
  19617. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19618. /**
  19619. * Register a function that will be executed after the physics step
  19620. * @param func The function to execute after physics step
  19621. */
  19622. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19623. /**
  19624. * Unregisters a function that will be executed after the physics step
  19625. * @param func The function to execute after physics step
  19626. */
  19627. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19628. /**
  19629. * register a function that will be executed when this impostor collides against a different body
  19630. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19631. * @param func Callback that is executed on collision
  19632. */
  19633. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19634. /**
  19635. * Unregisters the physics imposter on contact
  19636. * @param collideAgainst The physics object to collide against
  19637. * @param func Callback to execute on collision
  19638. */
  19639. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19640. private _tmpQuat;
  19641. private _tmpQuat2;
  19642. /**
  19643. * Get the parent rotation
  19644. * @returns The parent rotation
  19645. */
  19646. getParentsRotation(): Quaternion;
  19647. /**
  19648. * this function is executed by the physics engine.
  19649. */
  19650. beforeStep: () => void;
  19651. /**
  19652. * this function is executed by the physics engine
  19653. */
  19654. afterStep: () => void;
  19655. /**
  19656. * Legacy collision detection event support
  19657. */
  19658. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19659. /**
  19660. * event and body object due to cannon's event-based architecture.
  19661. */
  19662. onCollide: (e: {
  19663. body: any;
  19664. }) => void;
  19665. /**
  19666. * Apply a force
  19667. * @param force The force to apply
  19668. * @param contactPoint The contact point for the force
  19669. * @returns The physics imposter
  19670. */
  19671. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19672. /**
  19673. * Apply an impulse
  19674. * @param force The impulse force
  19675. * @param contactPoint The contact point for the impulse force
  19676. * @returns The physics imposter
  19677. */
  19678. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19679. /**
  19680. * A help function to create a joint
  19681. * @param otherImpostor A physics imposter used to create a joint
  19682. * @param jointType The type of joint
  19683. * @param jointData The data for the joint
  19684. * @returns The physics imposter
  19685. */
  19686. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19687. /**
  19688. * Add a joint to this impostor with a different impostor
  19689. * @param otherImpostor A physics imposter used to add a joint
  19690. * @param joint The joint to add
  19691. * @returns The physics imposter
  19692. */
  19693. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19694. /**
  19695. * Will keep this body still, in a sleep mode.
  19696. * @returns the physics imposter
  19697. */
  19698. sleep(): PhysicsImpostor;
  19699. /**
  19700. * Wake the body up.
  19701. * @returns The physics imposter
  19702. */
  19703. wakeUp(): PhysicsImpostor;
  19704. /**
  19705. * Clones the physics imposter
  19706. * @param newObject The physics imposter clones to this physics-enabled object
  19707. * @returns A nullable physics imposter
  19708. */
  19709. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19710. /**
  19711. * Disposes the physics imposter
  19712. */
  19713. dispose(): void;
  19714. /**
  19715. * Sets the delta position
  19716. * @param position The delta position amount
  19717. */
  19718. setDeltaPosition(position: Vector3): void;
  19719. /**
  19720. * Sets the delta rotation
  19721. * @param rotation The delta rotation amount
  19722. */
  19723. setDeltaRotation(rotation: Quaternion): void;
  19724. /**
  19725. * Gets the box size of the physics imposter and stores the result in the input parameter
  19726. * @param result Stores the box size
  19727. * @returns The physics imposter
  19728. */
  19729. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19730. /**
  19731. * Gets the radius of the physics imposter
  19732. * @returns Radius of the physics imposter
  19733. */
  19734. getRadius(): number;
  19735. /**
  19736. * Sync a bone with this impostor
  19737. * @param bone The bone to sync to the impostor.
  19738. * @param boneMesh The mesh that the bone is influencing.
  19739. * @param jointPivot The pivot of the joint / bone in local space.
  19740. * @param distToJoint Optional distance from the impostor to the joint.
  19741. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19742. */
  19743. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19744. /**
  19745. * Sync impostor to a bone
  19746. * @param bone The bone that the impostor will be synced to.
  19747. * @param boneMesh The mesh that the bone is influencing.
  19748. * @param jointPivot The pivot of the joint / bone in local space.
  19749. * @param distToJoint Optional distance from the impostor to the joint.
  19750. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19751. * @param boneAxis Optional vector3 axis the bone is aligned with
  19752. */
  19753. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19754. /**
  19755. * No-Imposter type
  19756. */
  19757. static NoImpostor: number;
  19758. /**
  19759. * Sphere-Imposter type
  19760. */
  19761. static SphereImpostor: number;
  19762. /**
  19763. * Box-Imposter type
  19764. */
  19765. static BoxImpostor: number;
  19766. /**
  19767. * Plane-Imposter type
  19768. */
  19769. static PlaneImpostor: number;
  19770. /**
  19771. * Mesh-imposter type
  19772. */
  19773. static MeshImpostor: number;
  19774. /**
  19775. * Cylinder-Imposter type
  19776. */
  19777. static CylinderImpostor: number;
  19778. /**
  19779. * Particle-Imposter type
  19780. */
  19781. static ParticleImpostor: number;
  19782. /**
  19783. * Heightmap-Imposter type
  19784. */
  19785. static HeightmapImpostor: number;
  19786. }
  19787. }
  19788. declare module BABYLON {
  19789. /**
  19790. * Class used to represent a specific level of detail of a mesh
  19791. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19792. */
  19793. export class MeshLODLevel {
  19794. /** Defines the distance where this level should star being displayed */
  19795. distance: number;
  19796. /** Defines the mesh to use to render this level */
  19797. mesh: Nullable<Mesh>;
  19798. /**
  19799. * Creates a new LOD level
  19800. * @param distance defines the distance where this level should star being displayed
  19801. * @param mesh defines the mesh to use to render this level
  19802. */
  19803. constructor(
  19804. /** Defines the distance where this level should star being displayed */
  19805. distance: number,
  19806. /** Defines the mesh to use to render this level */
  19807. mesh: Nullable<Mesh>);
  19808. }
  19809. /**
  19810. * @hidden
  19811. **/
  19812. export class _CreationDataStorage {
  19813. closePath?: boolean;
  19814. closeArray?: boolean;
  19815. idx: number[];
  19816. dashSize: number;
  19817. gapSize: number;
  19818. path3D: Path3D;
  19819. pathArray: Vector3[][];
  19820. arc: number;
  19821. radius: number;
  19822. cap: number;
  19823. tessellation: number;
  19824. }
  19825. /**
  19826. * @hidden
  19827. **/
  19828. class _InstanceDataStorage {
  19829. visibleInstances: any;
  19830. renderIdForInstances: number[];
  19831. batchCache: _InstancesBatch;
  19832. instancesBufferSize: number;
  19833. instancesBuffer: Nullable<Buffer>;
  19834. instancesData: Float32Array;
  19835. overridenInstanceCount: number;
  19836. }
  19837. /**
  19838. * @hidden
  19839. **/
  19840. export class _InstancesBatch {
  19841. mustReturn: boolean;
  19842. visibleInstances: Nullable<InstancedMesh[]>[];
  19843. renderSelf: boolean[];
  19844. }
  19845. /**
  19846. * Class used to represent renderable models
  19847. */
  19848. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19849. /**
  19850. * Mesh side orientation : usually the external or front surface
  19851. */
  19852. static readonly FRONTSIDE: number;
  19853. /**
  19854. * Mesh side orientation : usually the internal or back surface
  19855. */
  19856. static readonly BACKSIDE: number;
  19857. /**
  19858. * Mesh side orientation : both internal and external or front and back surfaces
  19859. */
  19860. static readonly DOUBLESIDE: number;
  19861. /**
  19862. * Mesh side orientation : by default, `FRONTSIDE`
  19863. */
  19864. static readonly DEFAULTSIDE: number;
  19865. /**
  19866. * Mesh cap setting : no cap
  19867. */
  19868. static readonly NO_CAP: number;
  19869. /**
  19870. * Mesh cap setting : one cap at the beginning of the mesh
  19871. */
  19872. static readonly CAP_START: number;
  19873. /**
  19874. * Mesh cap setting : one cap at the end of the mesh
  19875. */
  19876. static readonly CAP_END: number;
  19877. /**
  19878. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19879. */
  19880. static readonly CAP_ALL: number;
  19881. /**
  19882. * Gets the default side orientation.
  19883. * @param orientation the orientation to value to attempt to get
  19884. * @returns the default orientation
  19885. * @hidden
  19886. */
  19887. static _GetDefaultSideOrientation(orientation?: number): number;
  19888. private _onBeforeRenderObservable;
  19889. private _onBeforeBindObservable;
  19890. private _onAfterRenderObservable;
  19891. private _onBeforeDrawObservable;
  19892. /**
  19893. * An event triggered before rendering the mesh
  19894. */
  19895. readonly onBeforeRenderObservable: Observable<Mesh>;
  19896. /**
  19897. * An event triggered before binding the mesh
  19898. */
  19899. readonly onBeforeBindObservable: Observable<Mesh>;
  19900. /**
  19901. * An event triggered after rendering the mesh
  19902. */
  19903. readonly onAfterRenderObservable: Observable<Mesh>;
  19904. /**
  19905. * An event triggered before drawing the mesh
  19906. */
  19907. readonly onBeforeDrawObservable: Observable<Mesh>;
  19908. private _onBeforeDrawObserver;
  19909. /**
  19910. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19911. */
  19912. onBeforeDraw: () => void;
  19913. /**
  19914. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19915. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19916. */
  19917. delayLoadState: number;
  19918. /**
  19919. * Gets the list of instances created from this mesh
  19920. * it is not supposed to be modified manually.
  19921. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19922. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19923. */
  19924. instances: InstancedMesh[];
  19925. /**
  19926. * Gets the file containing delay loading data for this mesh
  19927. */
  19928. delayLoadingFile: string;
  19929. /** @hidden */
  19930. _binaryInfo: any;
  19931. private _LODLevels;
  19932. /**
  19933. * User defined function used to change how LOD level selection is done
  19934. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19935. */
  19936. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19937. private _morphTargetManager;
  19938. /**
  19939. * Gets or sets the morph target manager
  19940. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19941. */
  19942. morphTargetManager: Nullable<MorphTargetManager>;
  19943. /** @hidden */
  19944. _creationDataStorage: Nullable<_CreationDataStorage>;
  19945. /** @hidden */
  19946. _geometry: Nullable<Geometry>;
  19947. /** @hidden */
  19948. _delayInfo: Array<string>;
  19949. /** @hidden */
  19950. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19951. /** @hidden */
  19952. _instanceDataStorage: _InstanceDataStorage;
  19953. private _effectiveMaterial;
  19954. /** @hidden */
  19955. _shouldGenerateFlatShading: boolean;
  19956. private _preActivateId;
  19957. /** @hidden */
  19958. _originalBuilderSideOrientation: number;
  19959. /**
  19960. * Use this property to change the original side orientation defined at construction time
  19961. */
  19962. overrideMaterialSideOrientation: Nullable<number>;
  19963. private _areNormalsFrozen;
  19964. private _sourcePositions;
  19965. private _sourceNormals;
  19966. private _source;
  19967. private meshMap;
  19968. /**
  19969. * Gets the source mesh (the one used to clone this one from)
  19970. */
  19971. readonly source: Nullable<Mesh>;
  19972. /**
  19973. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19974. */
  19975. isUnIndexed: boolean;
  19976. /**
  19977. * @constructor
  19978. * @param name The value used by scene.getMeshByName() to do a lookup.
  19979. * @param scene The scene to add this mesh to.
  19980. * @param parent The parent of this mesh, if it has one
  19981. * @param source An optional Mesh from which geometry is shared, cloned.
  19982. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19983. * When false, achieved by calling a clone(), also passing False.
  19984. * This will make creation of children, recursive.
  19985. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19986. */
  19987. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19988. /**
  19989. * Gets the class name
  19990. * @returns the string "Mesh".
  19991. */
  19992. getClassName(): string;
  19993. /** @hidden */
  19994. readonly _isMesh: boolean;
  19995. /**
  19996. * Returns a description of this mesh
  19997. * @param fullDetails define if full details about this mesh must be used
  19998. * @returns a descriptive string representing this mesh
  19999. */
  20000. toString(fullDetails?: boolean): string;
  20001. /** @hidden */
  20002. _unBindEffect(): void;
  20003. /**
  20004. * Gets a boolean indicating if this mesh has LOD
  20005. */
  20006. readonly hasLODLevels: boolean;
  20007. /**
  20008. * Gets the list of MeshLODLevel associated with the current mesh
  20009. * @returns an array of MeshLODLevel
  20010. */
  20011. getLODLevels(): MeshLODLevel[];
  20012. private _sortLODLevels;
  20013. /**
  20014. * Add a mesh as LOD level triggered at the given distance.
  20015. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20016. * @param distance The distance from the center of the object to show this level
  20017. * @param mesh The mesh to be added as LOD level (can be null)
  20018. * @return This mesh (for chaining)
  20019. */
  20020. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20021. /**
  20022. * Returns the LOD level mesh at the passed distance or null if not found.
  20023. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20024. * @param distance The distance from the center of the object to show this level
  20025. * @returns a Mesh or `null`
  20026. */
  20027. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20028. /**
  20029. * Remove a mesh from the LOD array
  20030. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20031. * @param mesh defines the mesh to be removed
  20032. * @return This mesh (for chaining)
  20033. */
  20034. removeLODLevel(mesh: Mesh): Mesh;
  20035. /**
  20036. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20037. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20038. * @param camera defines the camera to use to compute distance
  20039. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20040. * @return This mesh (for chaining)
  20041. */
  20042. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20043. /**
  20044. * Gets the mesh internal Geometry object
  20045. */
  20046. readonly geometry: Nullable<Geometry>;
  20047. /**
  20048. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20049. * @returns the total number of vertices
  20050. */
  20051. getTotalVertices(): number;
  20052. /**
  20053. * Returns the content of an associated vertex buffer
  20054. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20055. * - VertexBuffer.PositionKind
  20056. * - VertexBuffer.UVKind
  20057. * - VertexBuffer.UV2Kind
  20058. * - VertexBuffer.UV3Kind
  20059. * - VertexBuffer.UV4Kind
  20060. * - VertexBuffer.UV5Kind
  20061. * - VertexBuffer.UV6Kind
  20062. * - VertexBuffer.ColorKind
  20063. * - VertexBuffer.MatricesIndicesKind
  20064. * - VertexBuffer.MatricesIndicesExtraKind
  20065. * - VertexBuffer.MatricesWeightsKind
  20066. * - VertexBuffer.MatricesWeightsExtraKind
  20067. * @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
  20068. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20069. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20070. */
  20071. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20072. /**
  20073. * Returns the mesh VertexBuffer object from the requested `kind`
  20074. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20075. * - VertexBuffer.PositionKind
  20076. * - VertexBuffer.UVKind
  20077. * - VertexBuffer.UV2Kind
  20078. * - VertexBuffer.UV3Kind
  20079. * - VertexBuffer.UV4Kind
  20080. * - VertexBuffer.UV5Kind
  20081. * - VertexBuffer.UV6Kind
  20082. * - VertexBuffer.ColorKind
  20083. * - VertexBuffer.MatricesIndicesKind
  20084. * - VertexBuffer.MatricesIndicesExtraKind
  20085. * - VertexBuffer.MatricesWeightsKind
  20086. * - VertexBuffer.MatricesWeightsExtraKind
  20087. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20088. */
  20089. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20090. /**
  20091. * Tests if a specific vertex buffer is associated with this mesh
  20092. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20093. * - VertexBuffer.PositionKind
  20094. * - VertexBuffer.UVKind
  20095. * - VertexBuffer.UV2Kind
  20096. * - VertexBuffer.UV3Kind
  20097. * - VertexBuffer.UV4Kind
  20098. * - VertexBuffer.UV5Kind
  20099. * - VertexBuffer.UV6Kind
  20100. * - VertexBuffer.ColorKind
  20101. * - VertexBuffer.MatricesIndicesKind
  20102. * - VertexBuffer.MatricesIndicesExtraKind
  20103. * - VertexBuffer.MatricesWeightsKind
  20104. * - VertexBuffer.MatricesWeightsExtraKind
  20105. * @returns a boolean
  20106. */
  20107. isVerticesDataPresent(kind: string): boolean;
  20108. /**
  20109. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20110. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20111. * - VertexBuffer.PositionKind
  20112. * - VertexBuffer.UVKind
  20113. * - VertexBuffer.UV2Kind
  20114. * - VertexBuffer.UV3Kind
  20115. * - VertexBuffer.UV4Kind
  20116. * - VertexBuffer.UV5Kind
  20117. * - VertexBuffer.UV6Kind
  20118. * - VertexBuffer.ColorKind
  20119. * - VertexBuffer.MatricesIndicesKind
  20120. * - VertexBuffer.MatricesIndicesExtraKind
  20121. * - VertexBuffer.MatricesWeightsKind
  20122. * - VertexBuffer.MatricesWeightsExtraKind
  20123. * @returns a boolean
  20124. */
  20125. isVertexBufferUpdatable(kind: string): boolean;
  20126. /**
  20127. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20128. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20129. * - VertexBuffer.PositionKind
  20130. * - VertexBuffer.UVKind
  20131. * - VertexBuffer.UV2Kind
  20132. * - VertexBuffer.UV3Kind
  20133. * - VertexBuffer.UV4Kind
  20134. * - VertexBuffer.UV5Kind
  20135. * - VertexBuffer.UV6Kind
  20136. * - VertexBuffer.ColorKind
  20137. * - VertexBuffer.MatricesIndicesKind
  20138. * - VertexBuffer.MatricesIndicesExtraKind
  20139. * - VertexBuffer.MatricesWeightsKind
  20140. * - VertexBuffer.MatricesWeightsExtraKind
  20141. * @returns an array of strings
  20142. */
  20143. getVerticesDataKinds(): string[];
  20144. /**
  20145. * Returns a positive integer : the total number of indices in this mesh geometry.
  20146. * @returns the numner of indices or zero if the mesh has no geometry.
  20147. */
  20148. getTotalIndices(): number;
  20149. /**
  20150. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20151. * @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.
  20152. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20153. * @returns the indices array or an empty array if the mesh has no geometry
  20154. */
  20155. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20156. readonly isBlocked: boolean;
  20157. /**
  20158. * Determine if the current mesh is ready to be rendered
  20159. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20160. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20161. * @returns true if all associated assets are ready (material, textures, shaders)
  20162. */
  20163. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20164. /**
  20165. * 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.
  20166. */
  20167. readonly areNormalsFrozen: boolean;
  20168. /**
  20169. * 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.
  20170. * @returns the current mesh
  20171. */
  20172. freezeNormals(): Mesh;
  20173. /**
  20174. * 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
  20175. * @returns the current mesh
  20176. */
  20177. unfreezeNormals(): Mesh;
  20178. /**
  20179. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20180. */
  20181. overridenInstanceCount: number;
  20182. /** @hidden */
  20183. _preActivate(): Mesh;
  20184. /** @hidden */
  20185. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20186. /** @hidden */
  20187. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20188. /**
  20189. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20190. * This means the mesh underlying bounding box and sphere are recomputed.
  20191. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20192. * @returns the current mesh
  20193. */
  20194. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20195. /** @hidden */
  20196. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20197. /**
  20198. * This function will subdivide the mesh into multiple submeshes
  20199. * @param count defines the expected number of submeshes
  20200. */
  20201. subdivide(count: number): void;
  20202. /**
  20203. * Copy a FloatArray into a specific associated vertex buffer
  20204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20205. * - VertexBuffer.PositionKind
  20206. * - VertexBuffer.UVKind
  20207. * - VertexBuffer.UV2Kind
  20208. * - VertexBuffer.UV3Kind
  20209. * - VertexBuffer.UV4Kind
  20210. * - VertexBuffer.UV5Kind
  20211. * - VertexBuffer.UV6Kind
  20212. * - VertexBuffer.ColorKind
  20213. * - VertexBuffer.MatricesIndicesKind
  20214. * - VertexBuffer.MatricesIndicesExtraKind
  20215. * - VertexBuffer.MatricesWeightsKind
  20216. * - VertexBuffer.MatricesWeightsExtraKind
  20217. * @param data defines the data source
  20218. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20219. * @param stride defines the data stride size (can be null)
  20220. * @returns the current mesh
  20221. */
  20222. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20223. /**
  20224. * Flags an associated vertex buffer as updatable
  20225. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20226. * - VertexBuffer.PositionKind
  20227. * - VertexBuffer.UVKind
  20228. * - VertexBuffer.UV2Kind
  20229. * - VertexBuffer.UV3Kind
  20230. * - VertexBuffer.UV4Kind
  20231. * - VertexBuffer.UV5Kind
  20232. * - VertexBuffer.UV6Kind
  20233. * - VertexBuffer.ColorKind
  20234. * - VertexBuffer.MatricesIndicesKind
  20235. * - VertexBuffer.MatricesIndicesExtraKind
  20236. * - VertexBuffer.MatricesWeightsKind
  20237. * - VertexBuffer.MatricesWeightsExtraKind
  20238. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20239. */
  20240. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20241. /**
  20242. * Sets the mesh global Vertex Buffer
  20243. * @param buffer defines the buffer to use
  20244. * @returns the current mesh
  20245. */
  20246. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20247. /**
  20248. * Update a specific associated vertex buffer
  20249. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20250. * - VertexBuffer.PositionKind
  20251. * - VertexBuffer.UVKind
  20252. * - VertexBuffer.UV2Kind
  20253. * - VertexBuffer.UV3Kind
  20254. * - VertexBuffer.UV4Kind
  20255. * - VertexBuffer.UV5Kind
  20256. * - VertexBuffer.UV6Kind
  20257. * - VertexBuffer.ColorKind
  20258. * - VertexBuffer.MatricesIndicesKind
  20259. * - VertexBuffer.MatricesIndicesExtraKind
  20260. * - VertexBuffer.MatricesWeightsKind
  20261. * - VertexBuffer.MatricesWeightsExtraKind
  20262. * @param data defines the data source
  20263. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20264. * @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)
  20265. * @returns the current mesh
  20266. */
  20267. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20268. /**
  20269. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20270. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20271. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20272. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20273. * @returns the current mesh
  20274. */
  20275. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20276. /**
  20277. * Creates a un-shared specific occurence of the geometry for the mesh.
  20278. * @returns the current mesh
  20279. */
  20280. makeGeometryUnique(): Mesh;
  20281. /**
  20282. * Set the index buffer of this mesh
  20283. * @param indices defines the source data
  20284. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20285. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20286. * @returns the current mesh
  20287. */
  20288. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20289. /**
  20290. * Update the current index buffer
  20291. * @param indices defines the source data
  20292. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20293. * @returns the current mesh
  20294. */
  20295. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20296. /**
  20297. * Invert the geometry to move from a right handed system to a left handed one.
  20298. * @returns the current mesh
  20299. */
  20300. toLeftHanded(): Mesh;
  20301. /** @hidden */
  20302. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20303. /** @hidden */
  20304. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20305. /**
  20306. * Registers for this mesh a javascript function called just before the rendering process
  20307. * @param func defines the function to call before rendering this mesh
  20308. * @returns the current mesh
  20309. */
  20310. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20311. /**
  20312. * Disposes a previously registered javascript function called before the rendering
  20313. * @param func defines the function to remove
  20314. * @returns the current mesh
  20315. */
  20316. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20317. /**
  20318. * Registers for this mesh a javascript function called just after the rendering is complete
  20319. * @param func defines the function to call after rendering this mesh
  20320. * @returns the current mesh
  20321. */
  20322. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20323. /**
  20324. * Disposes a previously registered javascript function called after the rendering.
  20325. * @param func defines the function to remove
  20326. * @returns the current mesh
  20327. */
  20328. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20329. /** @hidden */
  20330. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20331. /** @hidden */
  20332. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20333. /** @hidden */
  20334. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20335. /**
  20336. * 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
  20337. * @param subMesh defines the subMesh to render
  20338. * @param enableAlphaMode defines if alpha mode can be changed
  20339. * @returns the current mesh
  20340. */
  20341. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20342. private _onBeforeDraw;
  20343. /**
  20344. * Renormalize the mesh and patch it up if there are no weights
  20345. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20346. * However in the case of zero weights then we set just a single influence to 1.
  20347. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20348. */
  20349. cleanMatrixWeights(): void;
  20350. private normalizeSkinFourWeights;
  20351. private normalizeSkinWeightsAndExtra;
  20352. /**
  20353. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20354. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20355. * the user know there was an issue with importing the mesh
  20356. * @returns a validation object with skinned, valid and report string
  20357. */
  20358. validateSkinning(): {
  20359. skinned: boolean;
  20360. valid: boolean;
  20361. report: string;
  20362. };
  20363. /** @hidden */
  20364. _checkDelayState(): Mesh;
  20365. private _queueLoad;
  20366. /**
  20367. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20368. * A mesh is in the frustum if its bounding box intersects the frustum
  20369. * @param frustumPlanes defines the frustum to test
  20370. * @returns true if the mesh is in the frustum planes
  20371. */
  20372. isInFrustum(frustumPlanes: Plane[]): boolean;
  20373. /**
  20374. * Sets the mesh material by the material or multiMaterial `id` property
  20375. * @param id is a string identifying the material or the multiMaterial
  20376. * @returns the current mesh
  20377. */
  20378. setMaterialByID(id: string): Mesh;
  20379. /**
  20380. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20381. * @returns an array of IAnimatable
  20382. */
  20383. getAnimatables(): IAnimatable[];
  20384. /**
  20385. * Modifies the mesh geometry according to the passed transformation matrix.
  20386. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20387. * The mesh normals are modified using the same transformation.
  20388. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20389. * @param transform defines the transform matrix to use
  20390. * @see http://doc.babylonjs.com/resources/baking_transformations
  20391. * @returns the current mesh
  20392. */
  20393. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20394. /**
  20395. * Modifies the mesh geometry according to its own current World Matrix.
  20396. * The mesh World Matrix is then reset.
  20397. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20398. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20399. * @see http://doc.babylonjs.com/resources/baking_transformations
  20400. * @returns the current mesh
  20401. */
  20402. bakeCurrentTransformIntoVertices(): Mesh;
  20403. /** @hidden */
  20404. readonly _positions: Nullable<Vector3[]>;
  20405. /** @hidden */
  20406. _resetPointsArrayCache(): Mesh;
  20407. /** @hidden */
  20408. _generatePointsArray(): boolean;
  20409. /**
  20410. * Returns a new Mesh object generated from the current mesh properties.
  20411. * This method must not get confused with createInstance()
  20412. * @param name is a string, the name given to the new mesh
  20413. * @param newParent can be any Node object (default `null`)
  20414. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20415. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20416. * @returns a new mesh
  20417. */
  20418. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20419. /**
  20420. * Releases resources associated with this mesh.
  20421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20423. */
  20424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20425. /**
  20426. * Modifies the mesh geometry according to a displacement map.
  20427. * 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.
  20428. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20429. * @param url is a string, the URL from the image file is to be downloaded.
  20430. * @param minHeight is the lower limit of the displacement.
  20431. * @param maxHeight is the upper limit of the displacement.
  20432. * @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.
  20433. * @param uvOffset is an optional vector2 used to offset UV.
  20434. * @param uvScale is an optional vector2 used to scale UV.
  20435. * @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.
  20436. * @returns the Mesh.
  20437. */
  20438. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20439. /**
  20440. * Modifies the mesh geometry according to a displacementMap buffer.
  20441. * 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.
  20442. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20443. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20444. * @param heightMapWidth is the width of the buffer image.
  20445. * @param heightMapHeight is the height of the buffer image.
  20446. * @param minHeight is the lower limit of the displacement.
  20447. * @param maxHeight is the upper limit of the displacement.
  20448. * @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.
  20449. * @param uvOffset is an optional vector2 used to offset UV.
  20450. * @param uvScale is an optional vector2 used to scale UV.
  20451. * @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.
  20452. * @returns the Mesh.
  20453. */
  20454. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20455. /**
  20456. * Modify the mesh to get a flat shading rendering.
  20457. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20458. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20459. * @returns current mesh
  20460. */
  20461. convertToFlatShadedMesh(): Mesh;
  20462. /**
  20463. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20464. * In other words, more vertices, no more indices and a single bigger VBO.
  20465. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20466. * @returns current mesh
  20467. */
  20468. convertToUnIndexedMesh(): Mesh;
  20469. /**
  20470. * Inverses facet orientations.
  20471. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20472. * @param flipNormals will also inverts the normals
  20473. * @returns current mesh
  20474. */
  20475. flipFaces(flipNormals?: boolean): Mesh;
  20476. /** @hidden */
  20477. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20478. /** @hidden */
  20479. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20480. /**
  20481. * Creates a new InstancedMesh object from the mesh model.
  20482. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20483. * @param name defines the name of the new instance
  20484. * @returns a new InstancedMesh
  20485. */
  20486. createInstance(name: string): InstancedMesh;
  20487. /**
  20488. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20489. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20490. * @returns the current mesh
  20491. */
  20492. synchronizeInstances(): Mesh;
  20493. /**
  20494. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20495. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20496. * This should be used together with the simplification to avoid disappearing triangles.
  20497. * @param successCallback an optional success callback to be called after the optimization finished.
  20498. * @returns the current mesh
  20499. */
  20500. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20501. /**
  20502. * Serialize current mesh
  20503. * @param serializationObject defines the object which will receive the serialization data
  20504. */
  20505. serialize(serializationObject: any): void;
  20506. /** @hidden */
  20507. _syncGeometryWithMorphTargetManager(): void;
  20508. /** @hidden */
  20509. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20510. /**
  20511. * Returns a new Mesh object parsed from the source provided.
  20512. * @param parsedMesh is the source
  20513. * @param scene defines the hosting scene
  20514. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20515. * @returns a new Mesh
  20516. */
  20517. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20518. /**
  20519. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20520. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20521. * @param name defines the name of the mesh to create
  20522. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20523. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20524. * @param closePath creates a seam between the first and the last points of each path of the path array
  20525. * @param offset is taken in account only if the `pathArray` is containing a single path
  20526. * @param scene defines the hosting scene
  20527. * @param updatable defines if the mesh must be flagged as updatable
  20528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20529. * @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)
  20530. * @returns a new Mesh
  20531. */
  20532. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20533. /**
  20534. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20535. * @param name defines the name of the mesh to create
  20536. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20537. * @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
  20538. * @param scene defines the hosting scene
  20539. * @param updatable defines if the mesh must be flagged as updatable
  20540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20541. * @returns a new Mesh
  20542. */
  20543. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20544. /**
  20545. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20546. * @param name defines the name of the mesh to create
  20547. * @param size sets the size (float) of each box side (default 1)
  20548. * @param scene defines the hosting scene
  20549. * @param updatable defines if the mesh must be flagged as updatable
  20550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20551. * @returns a new Mesh
  20552. */
  20553. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20554. /**
  20555. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20556. * @param name defines the name of the mesh to create
  20557. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20558. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20559. * @param scene defines the hosting scene
  20560. * @param updatable defines if the mesh must be flagged as updatable
  20561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20562. * @returns a new Mesh
  20563. */
  20564. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20565. /**
  20566. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20567. * @param name defines the name of the mesh to create
  20568. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20569. * @param diameterTop set the top cap diameter (floats, default 1)
  20570. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20571. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20572. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20573. * @param scene defines the hosting scene
  20574. * @param updatable defines if the mesh must be flagged as updatable
  20575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20576. * @returns a new Mesh
  20577. */
  20578. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20579. /**
  20580. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20581. * @param name defines the name of the mesh to create
  20582. * @param diameter sets the diameter size (float) of the torus (default 1)
  20583. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20584. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20585. * @param scene defines the hosting scene
  20586. * @param updatable defines if the mesh must be flagged as updatable
  20587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20588. * @returns a new Mesh
  20589. */
  20590. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20591. /**
  20592. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20593. * @param name defines the name of the mesh to create
  20594. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20595. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20596. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20597. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20598. * @param p the number of windings on X axis (positive integers, default 2)
  20599. * @param q the number of windings on Y axis (positive integers, default 3)
  20600. * @param scene defines the hosting scene
  20601. * @param updatable defines if the mesh must be flagged as updatable
  20602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20603. * @returns a new Mesh
  20604. */
  20605. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20606. /**
  20607. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20608. * @param name defines the name of the mesh to create
  20609. * @param points is an array successive Vector3
  20610. * @param scene defines the hosting scene
  20611. * @param updatable defines if the mesh must be flagged as updatable
  20612. * @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).
  20613. * @returns a new Mesh
  20614. */
  20615. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20616. /**
  20617. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20618. * @param name defines the name of the mesh to create
  20619. * @param points is an array successive Vector3
  20620. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20621. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20622. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20623. * @param scene defines the hosting scene
  20624. * @param updatable defines if the mesh must be flagged as updatable
  20625. * @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)
  20626. * @returns a new Mesh
  20627. */
  20628. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20629. /**
  20630. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20631. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20632. * 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.
  20633. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20634. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20635. * Remember you can only change the shape positions, not their number when updating a polygon.
  20636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20637. * @param name defines the name of the mesh to create
  20638. * @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
  20639. * @param scene defines the hosting scene
  20640. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20641. * @param updatable defines if the mesh must be flagged as updatable
  20642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20643. * @param earcutInjection can be used to inject your own earcut reference
  20644. * @returns a new Mesh
  20645. */
  20646. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20647. /**
  20648. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20649. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20650. * @param name defines the name of the mesh to create
  20651. * @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
  20652. * @param depth defines the height of extrusion
  20653. * @param scene defines the hosting scene
  20654. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20655. * @param updatable defines if the mesh must be flagged as updatable
  20656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20657. * @param earcutInjection can be used to inject your own earcut reference
  20658. * @returns a new Mesh
  20659. */
  20660. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20661. /**
  20662. * Creates an extruded shape mesh.
  20663. * 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
  20664. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20666. * @param name defines the name of the mesh to create
  20667. * @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
  20668. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20669. * @param scale is the value to scale the shape
  20670. * @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
  20671. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  20672. * @param scene defines the hosting scene
  20673. * @param updatable defines if the mesh must be flagged as updatable
  20674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20675. * @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)
  20676. * @returns a new Mesh
  20677. */
  20678. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20679. /**
  20680. * Creates an custom extruded shape mesh.
  20681. * The custom extrusion is a parametric shape.
  20682. * It has no predefined shape. Its final shape will depend on the input parameters.
  20683. * Please consider using the same method from the MeshBuilder class instead
  20684. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20685. * @param name defines the name of the mesh to create
  20686. * @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
  20687. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20688. * @param scaleFunction is a custom Javascript function called on each path point
  20689. * @param rotationFunction is a custom Javascript function called on each path point
  20690. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20691. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20692. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  20693. * @param scene defines the hosting scene
  20694. * @param updatable defines if the mesh must be flagged as updatable
  20695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20696. * @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)
  20697. * @returns a new Mesh
  20698. */
  20699. 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;
  20700. /**
  20701. * Creates lathe mesh.
  20702. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20703. * Please consider using the same method from the MeshBuilder class instead
  20704. * @param name defines the name of the mesh to create
  20705. * @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
  20706. * @param radius is the radius value of the lathe
  20707. * @param tessellation is the side number of the lathe.
  20708. * @param scene defines the hosting scene
  20709. * @param updatable defines if the mesh must be flagged as updatable
  20710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20711. * @returns a new Mesh
  20712. */
  20713. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20714. /**
  20715. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20716. * @param name defines the name of the mesh to create
  20717. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20718. * @param scene defines the hosting scene
  20719. * @param updatable defines if the mesh must be flagged as updatable
  20720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20721. * @returns a new Mesh
  20722. */
  20723. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20724. /**
  20725. * Creates a ground mesh.
  20726. * Please consider using the same method from the MeshBuilder class instead
  20727. * @param name defines the name of the mesh to create
  20728. * @param width set the width of the ground
  20729. * @param height set the height of the ground
  20730. * @param subdivisions sets the number of subdivisions per side
  20731. * @param scene defines the hosting scene
  20732. * @param updatable defines if the mesh must be flagged as updatable
  20733. * @returns a new Mesh
  20734. */
  20735. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20736. /**
  20737. * Creates a tiled ground mesh.
  20738. * Please consider using the same method from the MeshBuilder class instead
  20739. * @param name defines the name of the mesh to create
  20740. * @param xmin set the ground minimum X coordinate
  20741. * @param zmin set the ground minimum Y coordinate
  20742. * @param xmax set the ground maximum X coordinate
  20743. * @param zmax set the ground maximum Z coordinate
  20744. * @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
  20745. * @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
  20746. * @param scene defines the hosting scene
  20747. * @param updatable defines if the mesh must be flagged as updatable
  20748. * @returns a new Mesh
  20749. */
  20750. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20751. w: number;
  20752. h: number;
  20753. }, precision: {
  20754. w: number;
  20755. h: number;
  20756. }, scene: Scene, updatable?: boolean): Mesh;
  20757. /**
  20758. * Creates a ground mesh from a height map.
  20759. * Please consider using the same method from the MeshBuilder class instead
  20760. * @see http://doc.babylonjs.com/babylon101/height_map
  20761. * @param name defines the name of the mesh to create
  20762. * @param url sets the URL of the height map image resource
  20763. * @param width set the ground width size
  20764. * @param height set the ground height size
  20765. * @param subdivisions sets the number of subdivision per side
  20766. * @param minHeight is the minimum altitude on the ground
  20767. * @param maxHeight is the maximum altitude on the ground
  20768. * @param scene defines the hosting scene
  20769. * @param updatable defines if the mesh must be flagged as updatable
  20770. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20771. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20772. * @returns a new Mesh
  20773. */
  20774. 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;
  20775. /**
  20776. * Creates a tube mesh.
  20777. * The tube is a parametric shape.
  20778. * It has no predefined shape. Its final shape will depend on the input parameters.
  20779. * Please consider using the same method from the MeshBuilder class instead
  20780. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20781. * @param name defines the name of the mesh to create
  20782. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20783. * @param radius sets the tube radius size
  20784. * @param tessellation is the number of sides on the tubular surface
  20785. * @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
  20786. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  20787. * @param scene defines the hosting scene
  20788. * @param updatable defines if the mesh must be flagged as updatable
  20789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20790. * @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)
  20791. * @returns a new Mesh
  20792. */
  20793. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20794. (i: number, distance: number): number;
  20795. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20796. /**
  20797. * Creates a polyhedron mesh.
  20798. * Please consider using the same method from the MeshBuilder class instead.
  20799. * * 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
  20800. * * The parameter `size` (positive float, default 1) sets the polygon size
  20801. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20802. * * 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`
  20803. * * 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
  20804. * * 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)`)
  20805. * * 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
  20806. * * 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
  20807. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20808. * * 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
  20809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20810. * @param name defines the name of the mesh to create
  20811. * @param options defines the options used to create the mesh
  20812. * @param scene defines the hosting scene
  20813. * @returns a new Mesh
  20814. */
  20815. static CreatePolyhedron(name: string, options: {
  20816. type?: number;
  20817. size?: number;
  20818. sizeX?: number;
  20819. sizeY?: number;
  20820. sizeZ?: number;
  20821. custom?: any;
  20822. faceUV?: Vector4[];
  20823. faceColors?: Color4[];
  20824. updatable?: boolean;
  20825. sideOrientation?: number;
  20826. }, scene: Scene): Mesh;
  20827. /**
  20828. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20829. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20830. * * 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`)
  20831. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20832. * * 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
  20833. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20834. * * 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
  20835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20836. * @param name defines the name of the mesh
  20837. * @param options defines the options used to create the mesh
  20838. * @param scene defines the hosting scene
  20839. * @returns a new Mesh
  20840. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20841. */
  20842. static CreateIcoSphere(name: string, options: {
  20843. radius?: number;
  20844. flat?: boolean;
  20845. subdivisions?: number;
  20846. sideOrientation?: number;
  20847. updatable?: boolean;
  20848. }, scene: Scene): Mesh;
  20849. /**
  20850. * Creates a decal mesh.
  20851. * Please consider using the same method from the MeshBuilder class instead.
  20852. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20853. * @param name defines the name of the mesh
  20854. * @param sourceMesh defines the mesh receiving the decal
  20855. * @param position sets the position of the decal in world coordinates
  20856. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20857. * @param size sets the decal scaling
  20858. * @param angle sets the angle to rotate the decal
  20859. * @returns a new Mesh
  20860. */
  20861. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20862. /**
  20863. * Prepare internal position array for software CPU skinning
  20864. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20865. */
  20866. setPositionsForCPUSkinning(): Float32Array;
  20867. /**
  20868. * Prepare internal normal array for software CPU skinning
  20869. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20870. */
  20871. setNormalsForCPUSkinning(): Float32Array;
  20872. /**
  20873. * Updates the vertex buffer by applying transformation from the bones
  20874. * @param skeleton defines the skeleton to apply to current mesh
  20875. * @returns the current mesh
  20876. */
  20877. applySkeleton(skeleton: Skeleton): Mesh;
  20878. /**
  20879. * 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
  20880. * @param meshes defines the list of meshes to scan
  20881. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20882. */
  20883. static MinMax(meshes: AbstractMesh[]): {
  20884. min: Vector3;
  20885. max: Vector3;
  20886. };
  20887. /**
  20888. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20889. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20890. * @returns a vector3
  20891. */
  20892. static Center(meshesOrMinMaxVector: {
  20893. min: Vector3;
  20894. max: Vector3;
  20895. } | AbstractMesh[]): Vector3;
  20896. /**
  20897. * Merge the array of meshes into a single mesh for performance reasons.
  20898. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20899. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20900. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20901. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20902. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20903. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20904. * @returns a new mesh
  20905. */
  20906. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20907. /** @hidden */
  20908. addInstance(instance: InstancedMesh): void;
  20909. /** @hidden */
  20910. removeInstance(instance: InstancedMesh): void;
  20911. }
  20912. }
  20913. declare module BABYLON {
  20914. /**
  20915. * Base class for the main features of a material in Babylon.js
  20916. */
  20917. export class Material implements IAnimatable {
  20918. /**
  20919. * Returns the triangle fill mode
  20920. */
  20921. static readonly TriangleFillMode: number;
  20922. /**
  20923. * Returns the wireframe mode
  20924. */
  20925. static readonly WireFrameFillMode: number;
  20926. /**
  20927. * Returns the point fill mode
  20928. */
  20929. static readonly PointFillMode: number;
  20930. /**
  20931. * Returns the point list draw mode
  20932. */
  20933. static readonly PointListDrawMode: number;
  20934. /**
  20935. * Returns the line list draw mode
  20936. */
  20937. static readonly LineListDrawMode: number;
  20938. /**
  20939. * Returns the line loop draw mode
  20940. */
  20941. static readonly LineLoopDrawMode: number;
  20942. /**
  20943. * Returns the line strip draw mode
  20944. */
  20945. static readonly LineStripDrawMode: number;
  20946. /**
  20947. * Returns the triangle strip draw mode
  20948. */
  20949. static readonly TriangleStripDrawMode: number;
  20950. /**
  20951. * Returns the triangle fan draw mode
  20952. */
  20953. static readonly TriangleFanDrawMode: number;
  20954. /**
  20955. * Stores the clock-wise side orientation
  20956. */
  20957. static readonly ClockWiseSideOrientation: number;
  20958. /**
  20959. * Stores the counter clock-wise side orientation
  20960. */
  20961. static readonly CounterClockWiseSideOrientation: number;
  20962. /**
  20963. * The dirty texture flag value
  20964. */
  20965. static readonly TextureDirtyFlag: number;
  20966. /**
  20967. * The dirty light flag value
  20968. */
  20969. static readonly LightDirtyFlag: number;
  20970. /**
  20971. * The dirty fresnel flag value
  20972. */
  20973. static readonly FresnelDirtyFlag: number;
  20974. /**
  20975. * The dirty attribute flag value
  20976. */
  20977. static readonly AttributesDirtyFlag: number;
  20978. /**
  20979. * The dirty misc flag value
  20980. */
  20981. static readonly MiscDirtyFlag: number;
  20982. /**
  20983. * The all dirty flag value
  20984. */
  20985. static readonly AllDirtyFlag: number;
  20986. /**
  20987. * The ID of the material
  20988. */
  20989. id: string;
  20990. /**
  20991. * Gets or sets the unique id of the material
  20992. */
  20993. uniqueId: number;
  20994. /**
  20995. * The name of the material
  20996. */
  20997. name: string;
  20998. /**
  20999. * Gets or sets user defined metadata
  21000. */
  21001. metadata: any;
  21002. /**
  21003. * For internal use only. Please do not use.
  21004. */
  21005. reservedDataStore: any;
  21006. /**
  21007. * Specifies if the ready state should be checked on each call
  21008. */
  21009. checkReadyOnEveryCall: boolean;
  21010. /**
  21011. * Specifies if the ready state should be checked once
  21012. */
  21013. checkReadyOnlyOnce: boolean;
  21014. /**
  21015. * The state of the material
  21016. */
  21017. state: string;
  21018. /**
  21019. * The alpha value of the material
  21020. */
  21021. protected _alpha: number;
  21022. /**
  21023. * Sets the alpha value of the material
  21024. */
  21025. /**
  21026. * Gets the alpha value of the material
  21027. */
  21028. alpha: number;
  21029. /**
  21030. * Specifies if back face culling is enabled
  21031. */
  21032. protected _backFaceCulling: boolean;
  21033. /**
  21034. * Sets the back-face culling state
  21035. */
  21036. /**
  21037. * Gets the back-face culling state
  21038. */
  21039. backFaceCulling: boolean;
  21040. /**
  21041. * Stores the value for side orientation
  21042. */
  21043. sideOrientation: number;
  21044. /**
  21045. * Callback triggered when the material is compiled
  21046. */
  21047. onCompiled: (effect: Effect) => void;
  21048. /**
  21049. * Callback triggered when an error occurs
  21050. */
  21051. onError: (effect: Effect, errors: string) => void;
  21052. /**
  21053. * Callback triggered to get the render target textures
  21054. */
  21055. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21056. /**
  21057. * Gets a boolean indicating that current material needs to register RTT
  21058. */
  21059. readonly hasRenderTargetTextures: boolean;
  21060. /**
  21061. * Specifies if the material should be serialized
  21062. */
  21063. doNotSerialize: boolean;
  21064. /**
  21065. * @hidden
  21066. */
  21067. _storeEffectOnSubMeshes: boolean;
  21068. /**
  21069. * Stores the animations for the material
  21070. */
  21071. animations: Array<Animation>;
  21072. /**
  21073. * An event triggered when the material is disposed
  21074. */
  21075. onDisposeObservable: Observable<Material>;
  21076. /**
  21077. * An observer which watches for dispose events
  21078. */
  21079. private _onDisposeObserver;
  21080. private _onUnBindObservable;
  21081. /**
  21082. * Called during a dispose event
  21083. */
  21084. onDispose: () => void;
  21085. private _onBindObservable;
  21086. /**
  21087. * An event triggered when the material is bound
  21088. */
  21089. readonly onBindObservable: Observable<AbstractMesh>;
  21090. /**
  21091. * An observer which watches for bind events
  21092. */
  21093. private _onBindObserver;
  21094. /**
  21095. * Called during a bind event
  21096. */
  21097. onBind: (Mesh: AbstractMesh) => void;
  21098. /**
  21099. * An event triggered when the material is unbound
  21100. */
  21101. readonly onUnBindObservable: Observable<Material>;
  21102. /**
  21103. * Stores the value of the alpha mode
  21104. */
  21105. private _alphaMode;
  21106. /**
  21107. * Sets the value of the alpha mode.
  21108. *
  21109. * | Value | Type | Description |
  21110. * | --- | --- | --- |
  21111. * | 0 | ALPHA_DISABLE | |
  21112. * | 1 | ALPHA_ADD | |
  21113. * | 2 | ALPHA_COMBINE | |
  21114. * | 3 | ALPHA_SUBTRACT | |
  21115. * | 4 | ALPHA_MULTIPLY | |
  21116. * | 5 | ALPHA_MAXIMIZED | |
  21117. * | 6 | ALPHA_ONEONE | |
  21118. * | 7 | ALPHA_PREMULTIPLIED | |
  21119. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21120. * | 9 | ALPHA_INTERPOLATE | |
  21121. * | 10 | ALPHA_SCREENMODE | |
  21122. *
  21123. */
  21124. /**
  21125. * Gets the value of the alpha mode
  21126. */
  21127. alphaMode: number;
  21128. /**
  21129. * Stores the state of the need depth pre-pass value
  21130. */
  21131. private _needDepthPrePass;
  21132. /**
  21133. * Sets the need depth pre-pass value
  21134. */
  21135. /**
  21136. * Gets the depth pre-pass value
  21137. */
  21138. needDepthPrePass: boolean;
  21139. /**
  21140. * Specifies if depth writing should be disabled
  21141. */
  21142. disableDepthWrite: boolean;
  21143. /**
  21144. * Specifies if depth writing should be forced
  21145. */
  21146. forceDepthWrite: boolean;
  21147. /**
  21148. * Specifies if there should be a separate pass for culling
  21149. */
  21150. separateCullingPass: boolean;
  21151. /**
  21152. * Stores the state specifing if fog should be enabled
  21153. */
  21154. private _fogEnabled;
  21155. /**
  21156. * Sets the state for enabling fog
  21157. */
  21158. /**
  21159. * Gets the value of the fog enabled state
  21160. */
  21161. fogEnabled: boolean;
  21162. /**
  21163. * Stores the size of points
  21164. */
  21165. pointSize: number;
  21166. /**
  21167. * Stores the z offset value
  21168. */
  21169. zOffset: number;
  21170. /**
  21171. * Gets a value specifying if wireframe mode is enabled
  21172. */
  21173. /**
  21174. * Sets the state of wireframe mode
  21175. */
  21176. wireframe: boolean;
  21177. /**
  21178. * Gets the value specifying if point clouds are enabled
  21179. */
  21180. /**
  21181. * Sets the state of point cloud mode
  21182. */
  21183. pointsCloud: boolean;
  21184. /**
  21185. * Gets the material fill mode
  21186. */
  21187. /**
  21188. * Sets the material fill mode
  21189. */
  21190. fillMode: number;
  21191. /**
  21192. * @hidden
  21193. * Stores the effects for the material
  21194. */
  21195. _effect: Nullable<Effect>;
  21196. /**
  21197. * @hidden
  21198. * Specifies if the material was previously ready
  21199. */
  21200. _wasPreviouslyReady: boolean;
  21201. /**
  21202. * Specifies if uniform buffers should be used
  21203. */
  21204. private _useUBO;
  21205. /**
  21206. * Stores a reference to the scene
  21207. */
  21208. private _scene;
  21209. /**
  21210. * Stores the fill mode state
  21211. */
  21212. private _fillMode;
  21213. /**
  21214. * Specifies if the depth write state should be cached
  21215. */
  21216. private _cachedDepthWriteState;
  21217. /**
  21218. * Stores the uniform buffer
  21219. */
  21220. protected _uniformBuffer: UniformBuffer;
  21221. /** @hidden */
  21222. _indexInSceneMaterialArray: number;
  21223. /** @hidden */
  21224. meshMap: Nullable<{
  21225. [id: string]: AbstractMesh | undefined;
  21226. }>;
  21227. /**
  21228. * Creates a material instance
  21229. * @param name defines the name of the material
  21230. * @param scene defines the scene to reference
  21231. * @param doNotAdd specifies if the material should be added to the scene
  21232. */
  21233. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21234. /**
  21235. * Returns a string representation of the current material
  21236. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21237. * @returns a string with material information
  21238. */
  21239. toString(fullDetails?: boolean): string;
  21240. /**
  21241. * Gets the class name of the material
  21242. * @returns a string with the class name of the material
  21243. */
  21244. getClassName(): string;
  21245. /**
  21246. * Specifies if updates for the material been locked
  21247. */
  21248. readonly isFrozen: boolean;
  21249. /**
  21250. * Locks updates for the material
  21251. */
  21252. freeze(): void;
  21253. /**
  21254. * Unlocks updates for the material
  21255. */
  21256. unfreeze(): void;
  21257. /**
  21258. * Specifies if the material is ready to be used
  21259. * @param mesh defines the mesh to check
  21260. * @param useInstances specifies if instances should be used
  21261. * @returns a boolean indicating if the material is ready to be used
  21262. */
  21263. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21264. /**
  21265. * Specifies that the submesh is ready to be used
  21266. * @param mesh defines the mesh to check
  21267. * @param subMesh defines which submesh to check
  21268. * @param useInstances specifies that instances should be used
  21269. * @returns a boolean indicating that the submesh is ready or not
  21270. */
  21271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21272. /**
  21273. * Returns the material effect
  21274. * @returns the effect associated with the material
  21275. */
  21276. getEffect(): Nullable<Effect>;
  21277. /**
  21278. * Returns the current scene
  21279. * @returns a Scene
  21280. */
  21281. getScene(): Scene;
  21282. /**
  21283. * Specifies if the material will require alpha blending
  21284. * @returns a boolean specifying if alpha blending is needed
  21285. */
  21286. needAlphaBlending(): boolean;
  21287. /**
  21288. * Specifies if the mesh will require alpha blending
  21289. * @param mesh defines the mesh to check
  21290. * @returns a boolean specifying if alpha blending is needed for the mesh
  21291. */
  21292. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21293. /**
  21294. * Specifies if this material should be rendered in alpha test mode
  21295. * @returns a boolean specifying if an alpha test is needed.
  21296. */
  21297. needAlphaTesting(): boolean;
  21298. /**
  21299. * Gets the texture used for the alpha test
  21300. * @returns the texture to use for alpha testing
  21301. */
  21302. getAlphaTestTexture(): Nullable<BaseTexture>;
  21303. /**
  21304. * Marks the material to indicate that it needs to be re-calculated
  21305. */
  21306. markDirty(): void;
  21307. /** @hidden */
  21308. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21309. /**
  21310. * Binds the material to the mesh
  21311. * @param world defines the world transformation matrix
  21312. * @param mesh defines the mesh to bind the material to
  21313. */
  21314. bind(world: Matrix, mesh?: Mesh): void;
  21315. /**
  21316. * Binds the submesh to the material
  21317. * @param world defines the world transformation matrix
  21318. * @param mesh defines the mesh containing the submesh
  21319. * @param subMesh defines the submesh to bind the material to
  21320. */
  21321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21322. /**
  21323. * Binds the world matrix to the material
  21324. * @param world defines the world transformation matrix
  21325. */
  21326. bindOnlyWorldMatrix(world: Matrix): void;
  21327. /**
  21328. * Binds the scene's uniform buffer to the effect.
  21329. * @param effect defines the effect to bind to the scene uniform buffer
  21330. * @param sceneUbo defines the uniform buffer storing scene data
  21331. */
  21332. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21333. /**
  21334. * Binds the view matrix to the effect
  21335. * @param effect defines the effect to bind the view matrix to
  21336. */
  21337. bindView(effect: Effect): void;
  21338. /**
  21339. * Binds the view projection matrix to the effect
  21340. * @param effect defines the effect to bind the view projection matrix to
  21341. */
  21342. bindViewProjection(effect: Effect): void;
  21343. /**
  21344. * Specifies if material alpha testing should be turned on for the mesh
  21345. * @param mesh defines the mesh to check
  21346. */
  21347. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21348. /**
  21349. * Processes to execute after binding the material to a mesh
  21350. * @param mesh defines the rendered mesh
  21351. */
  21352. protected _afterBind(mesh?: Mesh): void;
  21353. /**
  21354. * Unbinds the material from the mesh
  21355. */
  21356. unbind(): void;
  21357. /**
  21358. * Gets the active textures from the material
  21359. * @returns an array of textures
  21360. */
  21361. getActiveTextures(): BaseTexture[];
  21362. /**
  21363. * Specifies if the material uses a texture
  21364. * @param texture defines the texture to check against the material
  21365. * @returns a boolean specifying if the material uses the texture
  21366. */
  21367. hasTexture(texture: BaseTexture): boolean;
  21368. /**
  21369. * Makes a duplicate of the material, and gives it a new name
  21370. * @param name defines the new name for the duplicated material
  21371. * @returns the cloned material
  21372. */
  21373. clone(name: string): Nullable<Material>;
  21374. /**
  21375. * Gets the meshes bound to the material
  21376. * @returns an array of meshes bound to the material
  21377. */
  21378. getBindedMeshes(): AbstractMesh[];
  21379. /**
  21380. * Force shader compilation
  21381. * @param mesh defines the mesh associated with this material
  21382. * @param onCompiled defines a function to execute once the material is compiled
  21383. * @param options defines the options to configure the compilation
  21384. */
  21385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21386. clipPlane: boolean;
  21387. }>): void;
  21388. /**
  21389. * Force shader compilation
  21390. * @param mesh defines the mesh that will use this material
  21391. * @param options defines additional options for compiling the shaders
  21392. * @returns a promise that resolves when the compilation completes
  21393. */
  21394. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21395. clipPlane: boolean;
  21396. }>): Promise<void>;
  21397. private static readonly _ImageProcessingDirtyCallBack;
  21398. private static readonly _TextureDirtyCallBack;
  21399. private static readonly _FresnelDirtyCallBack;
  21400. private static readonly _MiscDirtyCallBack;
  21401. private static readonly _LightsDirtyCallBack;
  21402. private static readonly _AttributeDirtyCallBack;
  21403. private static _FresnelAndMiscDirtyCallBack;
  21404. private static _TextureAndMiscDirtyCallBack;
  21405. private static readonly _DirtyCallbackArray;
  21406. private static readonly _RunDirtyCallBacks;
  21407. /**
  21408. * Marks a define in the material to indicate that it needs to be re-computed
  21409. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21410. */
  21411. markAsDirty(flag: number): void;
  21412. /**
  21413. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21414. * @param func defines a function which checks material defines against the submeshes
  21415. */
  21416. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21417. /**
  21418. * Indicates that image processing needs to be re-calculated for all submeshes
  21419. */
  21420. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21421. /**
  21422. * Indicates that textures need to be re-calculated for all submeshes
  21423. */
  21424. protected _markAllSubMeshesAsTexturesDirty(): void;
  21425. /**
  21426. * Indicates that fresnel needs to be re-calculated for all submeshes
  21427. */
  21428. protected _markAllSubMeshesAsFresnelDirty(): void;
  21429. /**
  21430. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21431. */
  21432. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21433. /**
  21434. * Indicates that lights need to be re-calculated for all submeshes
  21435. */
  21436. protected _markAllSubMeshesAsLightsDirty(): void;
  21437. /**
  21438. * Indicates that attributes need to be re-calculated for all submeshes
  21439. */
  21440. protected _markAllSubMeshesAsAttributesDirty(): void;
  21441. /**
  21442. * Indicates that misc needs to be re-calculated for all submeshes
  21443. */
  21444. protected _markAllSubMeshesAsMiscDirty(): void;
  21445. /**
  21446. * Indicates that textures and misc need to be re-calculated for all submeshes
  21447. */
  21448. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21449. /**
  21450. * Disposes the material
  21451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21453. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21454. */
  21455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21456. /** @hidden */
  21457. private releaseVertexArrayObject;
  21458. /**
  21459. * Serializes this material
  21460. * @returns the serialized material object
  21461. */
  21462. serialize(): any;
  21463. /**
  21464. * Creates a material from parsed material data
  21465. * @param parsedMaterial defines parsed material data
  21466. * @param scene defines the hosting scene
  21467. * @param rootUrl defines the root URL to use to load textures
  21468. * @returns a new material
  21469. */
  21470. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21471. }
  21472. }
  21473. declare module BABYLON {
  21474. /**
  21475. * Base class for submeshes
  21476. */
  21477. export class BaseSubMesh {
  21478. /** @hidden */
  21479. _materialDefines: Nullable<MaterialDefines>;
  21480. /** @hidden */
  21481. _materialEffect: Nullable<Effect>;
  21482. /**
  21483. * Gets associated effect
  21484. */
  21485. readonly effect: Nullable<Effect>;
  21486. /**
  21487. * Sets associated effect (effect used to render this submesh)
  21488. * @param effect defines the effect to associate with
  21489. * @param defines defines the set of defines used to compile this effect
  21490. */
  21491. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21492. }
  21493. /**
  21494. * Defines a subdivision inside a mesh
  21495. */
  21496. export class SubMesh extends BaseSubMesh implements ICullable {
  21497. /** the material index to use */
  21498. materialIndex: number;
  21499. /** vertex index start */
  21500. verticesStart: number;
  21501. /** vertices count */
  21502. verticesCount: number;
  21503. /** index start */
  21504. indexStart: number;
  21505. /** indices count */
  21506. indexCount: number;
  21507. /** @hidden */
  21508. _linesIndexCount: number;
  21509. private _mesh;
  21510. private _renderingMesh;
  21511. private _boundingInfo;
  21512. private _linesIndexBuffer;
  21513. /** @hidden */
  21514. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21515. /** @hidden */
  21516. _trianglePlanes: Plane[];
  21517. /** @hidden */
  21518. _lastColliderTransformMatrix: Matrix;
  21519. /** @hidden */
  21520. _renderId: number;
  21521. /** @hidden */
  21522. _alphaIndex: number;
  21523. /** @hidden */
  21524. _distanceToCamera: number;
  21525. /** @hidden */
  21526. _id: number;
  21527. private _currentMaterial;
  21528. /**
  21529. * Add a new submesh to a mesh
  21530. * @param materialIndex defines the material index to use
  21531. * @param verticesStart defines vertex index start
  21532. * @param verticesCount defines vertices count
  21533. * @param indexStart defines index start
  21534. * @param indexCount defines indices count
  21535. * @param mesh defines the parent mesh
  21536. * @param renderingMesh defines an optional rendering mesh
  21537. * @param createBoundingBox defines if bounding box should be created for this submesh
  21538. * @returns the new submesh
  21539. */
  21540. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21541. /**
  21542. * Creates a new submesh
  21543. * @param materialIndex defines the material index to use
  21544. * @param verticesStart defines vertex index start
  21545. * @param verticesCount defines vertices count
  21546. * @param indexStart defines index start
  21547. * @param indexCount defines indices count
  21548. * @param mesh defines the parent mesh
  21549. * @param renderingMesh defines an optional rendering mesh
  21550. * @param createBoundingBox defines if bounding box should be created for this submesh
  21551. */
  21552. constructor(
  21553. /** the material index to use */
  21554. materialIndex: number,
  21555. /** vertex index start */
  21556. verticesStart: number,
  21557. /** vertices count */
  21558. verticesCount: number,
  21559. /** index start */
  21560. indexStart: number,
  21561. /** indices count */
  21562. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21563. /**
  21564. * Returns true if this submesh covers the entire parent mesh
  21565. * @ignorenaming
  21566. */
  21567. readonly IsGlobal: boolean;
  21568. /**
  21569. * Returns the submesh BoudingInfo object
  21570. * @returns current bounding info (or mesh's one if the submesh is global)
  21571. */
  21572. getBoundingInfo(): BoundingInfo;
  21573. /**
  21574. * Sets the submesh BoundingInfo
  21575. * @param boundingInfo defines the new bounding info to use
  21576. * @returns the SubMesh
  21577. */
  21578. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21579. /**
  21580. * Returns the mesh of the current submesh
  21581. * @return the parent mesh
  21582. */
  21583. getMesh(): AbstractMesh;
  21584. /**
  21585. * Returns the rendering mesh of the submesh
  21586. * @returns the rendering mesh (could be different from parent mesh)
  21587. */
  21588. getRenderingMesh(): Mesh;
  21589. /**
  21590. * Returns the submesh material
  21591. * @returns null or the current material
  21592. */
  21593. getMaterial(): Nullable<Material>;
  21594. /**
  21595. * Sets a new updated BoundingInfo object to the submesh
  21596. * @returns the SubMesh
  21597. */
  21598. refreshBoundingInfo(): SubMesh;
  21599. /** @hidden */
  21600. _checkCollision(collider: Collider): boolean;
  21601. /**
  21602. * Updates the submesh BoundingInfo
  21603. * @param world defines the world matrix to use to update the bounding info
  21604. * @returns the submesh
  21605. */
  21606. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21607. /**
  21608. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21609. * @param frustumPlanes defines the frustum planes
  21610. * @returns true if the submesh is intersecting with the frustum
  21611. */
  21612. isInFrustum(frustumPlanes: Plane[]): boolean;
  21613. /**
  21614. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21615. * @param frustumPlanes defines the frustum planes
  21616. * @returns true if the submesh is inside the frustum
  21617. */
  21618. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21619. /**
  21620. * Renders the submesh
  21621. * @param enableAlphaMode defines if alpha needs to be used
  21622. * @returns the submesh
  21623. */
  21624. render(enableAlphaMode: boolean): SubMesh;
  21625. /**
  21626. * @hidden
  21627. */
  21628. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21629. /**
  21630. * Checks if the submesh intersects with a ray
  21631. * @param ray defines the ray to test
  21632. * @returns true is the passed ray intersects the submesh bounding box
  21633. */
  21634. canIntersects(ray: Ray): boolean;
  21635. /**
  21636. * Intersects current submesh with a ray
  21637. * @param ray defines the ray to test
  21638. * @param positions defines mesh's positions array
  21639. * @param indices defines mesh's indices array
  21640. * @param fastCheck defines if only bounding info should be used
  21641. * @returns intersection info or null if no intersection
  21642. */
  21643. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21644. /** @hidden */
  21645. private _intersectLines;
  21646. /** @hidden */
  21647. private _intersectTriangles;
  21648. /** @hidden */
  21649. _rebuild(): void;
  21650. /**
  21651. * Creates a new submesh from the passed mesh
  21652. * @param newMesh defines the new hosting mesh
  21653. * @param newRenderingMesh defines an optional rendering mesh
  21654. * @returns the new submesh
  21655. */
  21656. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21657. /**
  21658. * Release associated resources
  21659. */
  21660. dispose(): void;
  21661. /**
  21662. * Gets the class name
  21663. * @returns the string "SubMesh".
  21664. */
  21665. getClassName(): string;
  21666. /**
  21667. * Creates a new submesh from indices data
  21668. * @param materialIndex the index of the main mesh material
  21669. * @param startIndex the index where to start the copy in the mesh indices array
  21670. * @param indexCount the number of indices to copy then from the startIndex
  21671. * @param mesh the main mesh to create the submesh from
  21672. * @param renderingMesh the optional rendering mesh
  21673. * @returns a new submesh
  21674. */
  21675. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21676. }
  21677. }
  21678. declare module BABYLON {
  21679. /**
  21680. * Class used to store geometry data (vertex buffers + index buffer)
  21681. */
  21682. export class Geometry implements IGetSetVerticesData {
  21683. /**
  21684. * Gets or sets the ID of the geometry
  21685. */
  21686. id: string;
  21687. /**
  21688. * Gets or sets the unique ID of the geometry
  21689. */
  21690. uniqueId: number;
  21691. /**
  21692. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21693. */
  21694. delayLoadState: number;
  21695. /**
  21696. * Gets the file containing the data to load when running in delay load state
  21697. */
  21698. delayLoadingFile: Nullable<string>;
  21699. /**
  21700. * Callback called when the geometry is updated
  21701. */
  21702. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21703. private _scene;
  21704. private _engine;
  21705. private _meshes;
  21706. private _totalVertices;
  21707. /** @hidden */
  21708. _indices: IndicesArray;
  21709. /** @hidden */
  21710. _vertexBuffers: {
  21711. [key: string]: VertexBuffer;
  21712. };
  21713. private _isDisposed;
  21714. private _extend;
  21715. private _boundingBias;
  21716. /** @hidden */
  21717. _delayInfo: Array<string>;
  21718. private _indexBuffer;
  21719. private _indexBufferIsUpdatable;
  21720. /** @hidden */
  21721. _boundingInfo: Nullable<BoundingInfo>;
  21722. /** @hidden */
  21723. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21724. /** @hidden */
  21725. _softwareSkinningFrameId: number;
  21726. private _vertexArrayObjects;
  21727. private _updatable;
  21728. /** @hidden */
  21729. _positions: Nullable<Vector3[]>;
  21730. /**
  21731. * 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
  21732. */
  21733. /**
  21734. * 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
  21735. */
  21736. boundingBias: Vector2;
  21737. /**
  21738. * Static function used to attach a new empty geometry to a mesh
  21739. * @param mesh defines the mesh to attach the geometry to
  21740. * @returns the new Geometry
  21741. */
  21742. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21743. /**
  21744. * Creates a new geometry
  21745. * @param id defines the unique ID
  21746. * @param scene defines the hosting scene
  21747. * @param vertexData defines the VertexData used to get geometry data
  21748. * @param updatable defines if geometry must be updatable (false by default)
  21749. * @param mesh defines the mesh that will be associated with the geometry
  21750. */
  21751. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21752. /**
  21753. * Gets the current extend of the geometry
  21754. */
  21755. readonly extend: {
  21756. minimum: Vector3;
  21757. maximum: Vector3;
  21758. };
  21759. /**
  21760. * Gets the hosting scene
  21761. * @returns the hosting Scene
  21762. */
  21763. getScene(): Scene;
  21764. /**
  21765. * Gets the hosting engine
  21766. * @returns the hosting Engine
  21767. */
  21768. getEngine(): Engine;
  21769. /**
  21770. * Defines if the geometry is ready to use
  21771. * @returns true if the geometry is ready to be used
  21772. */
  21773. isReady(): boolean;
  21774. /**
  21775. * Gets a value indicating that the geometry should not be serialized
  21776. */
  21777. readonly doNotSerialize: boolean;
  21778. /** @hidden */
  21779. _rebuild(): void;
  21780. /**
  21781. * Affects all geometry data in one call
  21782. * @param vertexData defines the geometry data
  21783. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21784. */
  21785. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21786. /**
  21787. * Set specific vertex data
  21788. * @param kind defines the data kind (Position, normal, etc...)
  21789. * @param data defines the vertex data to use
  21790. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21791. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21792. */
  21793. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21794. /**
  21795. * Removes a specific vertex data
  21796. * @param kind defines the data kind (Position, normal, etc...)
  21797. */
  21798. removeVerticesData(kind: string): void;
  21799. /**
  21800. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21801. * @param buffer defines the vertex buffer to use
  21802. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21803. */
  21804. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21805. /**
  21806. * Update a specific vertex buffer
  21807. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21808. * It will do nothing if the buffer is not updatable
  21809. * @param kind defines the data kind (Position, normal, etc...)
  21810. * @param data defines the data to use
  21811. * @param offset defines the offset in the target buffer where to store the data
  21812. * @param useBytes set to true if the offset is in bytes
  21813. */
  21814. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21815. /**
  21816. * Update a specific vertex buffer
  21817. * This function will create a new buffer if the current one is not updatable
  21818. * @param kind defines the data kind (Position, normal, etc...)
  21819. * @param data defines the data to use
  21820. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21821. */
  21822. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21823. private _updateBoundingInfo;
  21824. /** @hidden */
  21825. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21826. /**
  21827. * Gets total number of vertices
  21828. * @returns the total number of vertices
  21829. */
  21830. getTotalVertices(): number;
  21831. /**
  21832. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21833. * @param kind defines the data kind (Position, normal, etc...)
  21834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21836. * @returns a float array containing vertex data
  21837. */
  21838. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21839. /**
  21840. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21841. * @param kind defines the data kind (Position, normal, etc...)
  21842. * @returns true if the vertex buffer with the specified kind is updatable
  21843. */
  21844. isVertexBufferUpdatable(kind: string): boolean;
  21845. /**
  21846. * Gets a specific vertex buffer
  21847. * @param kind defines the data kind (Position, normal, etc...)
  21848. * @returns a VertexBuffer
  21849. */
  21850. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21851. /**
  21852. * Returns all vertex buffers
  21853. * @return an object holding all vertex buffers indexed by kind
  21854. */
  21855. getVertexBuffers(): Nullable<{
  21856. [key: string]: VertexBuffer;
  21857. }>;
  21858. /**
  21859. * Gets a boolean indicating if specific vertex buffer is present
  21860. * @param kind defines the data kind (Position, normal, etc...)
  21861. * @returns true if data is present
  21862. */
  21863. isVerticesDataPresent(kind: string): boolean;
  21864. /**
  21865. * Gets a list of all attached data kinds (Position, normal, etc...)
  21866. * @returns a list of string containing all kinds
  21867. */
  21868. getVerticesDataKinds(): string[];
  21869. /**
  21870. * Update index buffer
  21871. * @param indices defines the indices to store in the index buffer
  21872. * @param offset defines the offset in the target buffer where to store the data
  21873. */
  21874. updateIndices(indices: IndicesArray, offset?: number): void;
  21875. /**
  21876. * Creates a new index buffer
  21877. * @param indices defines the indices to store in the index buffer
  21878. * @param totalVertices defines the total number of vertices (could be null)
  21879. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21880. */
  21881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21882. /**
  21883. * Return the total number of indices
  21884. * @returns the total number of indices
  21885. */
  21886. getTotalIndices(): number;
  21887. /**
  21888. * Gets the index buffer array
  21889. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21890. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21891. * @returns the index buffer array
  21892. */
  21893. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21894. /**
  21895. * Gets the index buffer
  21896. * @return the index buffer
  21897. */
  21898. getIndexBuffer(): Nullable<WebGLBuffer>;
  21899. /** @hidden */
  21900. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21901. /**
  21902. * Release the associated resources for a specific mesh
  21903. * @param mesh defines the source mesh
  21904. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21905. */
  21906. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21907. /**
  21908. * Apply current geometry to a given mesh
  21909. * @param mesh defines the mesh to apply geometry to
  21910. */
  21911. applyToMesh(mesh: Mesh): void;
  21912. private _updateExtend;
  21913. private _applyToMesh;
  21914. private notifyUpdate;
  21915. /**
  21916. * Load the geometry if it was flagged as delay loaded
  21917. * @param scene defines the hosting scene
  21918. * @param onLoaded defines a callback called when the geometry is loaded
  21919. */
  21920. load(scene: Scene, onLoaded?: () => void): void;
  21921. private _queueLoad;
  21922. /**
  21923. * Invert the geometry to move from a right handed system to a left handed one.
  21924. */
  21925. toLeftHanded(): void;
  21926. /** @hidden */
  21927. _resetPointsArrayCache(): void;
  21928. /** @hidden */
  21929. _generatePointsArray(): boolean;
  21930. /**
  21931. * Gets a value indicating if the geometry is disposed
  21932. * @returns true if the geometry was disposed
  21933. */
  21934. isDisposed(): boolean;
  21935. private _disposeVertexArrayObjects;
  21936. /**
  21937. * Free all associated resources
  21938. */
  21939. dispose(): void;
  21940. /**
  21941. * Clone the current geometry into a new geometry
  21942. * @param id defines the unique ID of the new geometry
  21943. * @returns a new geometry object
  21944. */
  21945. copy(id: string): Geometry;
  21946. /**
  21947. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21948. * @return a JSON representation of the current geometry data (without the vertices data)
  21949. */
  21950. serialize(): any;
  21951. private toNumberArray;
  21952. /**
  21953. * Serialize all vertices data into a JSON oject
  21954. * @returns a JSON representation of the current geometry data
  21955. */
  21956. serializeVerticeData(): any;
  21957. /**
  21958. * Extracts a clone of a mesh geometry
  21959. * @param mesh defines the source mesh
  21960. * @param id defines the unique ID of the new geometry object
  21961. * @returns the new geometry object
  21962. */
  21963. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21964. /**
  21965. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21966. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21967. * Be aware Math.random() could cause collisions, but:
  21968. * "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"
  21969. * @returns a string containing a new GUID
  21970. */
  21971. static RandomId(): string;
  21972. /** @hidden */
  21973. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21974. private static _CleanMatricesWeights;
  21975. /**
  21976. * Create a new geometry from persisted data (Using .babylon file format)
  21977. * @param parsedVertexData defines the persisted data
  21978. * @param scene defines the hosting scene
  21979. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21980. * @returns the new geometry object
  21981. */
  21982. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21983. }
  21984. }
  21985. declare module BABYLON {
  21986. /**
  21987. * Define an interface for all classes that will get and set the data on vertices
  21988. */
  21989. export interface IGetSetVerticesData {
  21990. /**
  21991. * Gets a boolean indicating if specific vertex data is present
  21992. * @param kind defines the vertex data kind to use
  21993. * @returns true is data kind is present
  21994. */
  21995. isVerticesDataPresent(kind: string): boolean;
  21996. /**
  21997. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21998. * @param kind defines the data kind (Position, normal, etc...)
  21999. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22000. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22001. * @returns a float array containing vertex data
  22002. */
  22003. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22004. /**
  22005. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22006. * @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.
  22007. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22008. * @returns the indices array or an empty array if the mesh has no geometry
  22009. */
  22010. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22011. /**
  22012. * Set specific vertex data
  22013. * @param kind defines the data kind (Position, normal, etc...)
  22014. * @param data defines the vertex data to use
  22015. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22016. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22017. */
  22018. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22019. /**
  22020. * Update a specific associated vertex buffer
  22021. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22022. * - VertexBuffer.PositionKind
  22023. * - VertexBuffer.UVKind
  22024. * - VertexBuffer.UV2Kind
  22025. * - VertexBuffer.UV3Kind
  22026. * - VertexBuffer.UV4Kind
  22027. * - VertexBuffer.UV5Kind
  22028. * - VertexBuffer.UV6Kind
  22029. * - VertexBuffer.ColorKind
  22030. * - VertexBuffer.MatricesIndicesKind
  22031. * - VertexBuffer.MatricesIndicesExtraKind
  22032. * - VertexBuffer.MatricesWeightsKind
  22033. * - VertexBuffer.MatricesWeightsExtraKind
  22034. * @param data defines the data source
  22035. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22036. * @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)
  22037. */
  22038. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22039. /**
  22040. * Creates a new index buffer
  22041. * @param indices defines the indices to store in the index buffer
  22042. * @param totalVertices defines the total number of vertices (could be null)
  22043. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22044. */
  22045. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22046. }
  22047. /**
  22048. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22049. */
  22050. export class VertexData {
  22051. /**
  22052. * Mesh side orientation : usually the external or front surface
  22053. */
  22054. static readonly FRONTSIDE: number;
  22055. /**
  22056. * Mesh side orientation : usually the internal or back surface
  22057. */
  22058. static readonly BACKSIDE: number;
  22059. /**
  22060. * Mesh side orientation : both internal and external or front and back surfaces
  22061. */
  22062. static readonly DOUBLESIDE: number;
  22063. /**
  22064. * Mesh side orientation : by default, `FRONTSIDE`
  22065. */
  22066. static readonly DEFAULTSIDE: number;
  22067. /**
  22068. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22069. */
  22070. positions: Nullable<FloatArray>;
  22071. /**
  22072. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22073. */
  22074. normals: Nullable<FloatArray>;
  22075. /**
  22076. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22077. */
  22078. tangents: Nullable<FloatArray>;
  22079. /**
  22080. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22081. */
  22082. uvs: Nullable<FloatArray>;
  22083. /**
  22084. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22085. */
  22086. uvs2: Nullable<FloatArray>;
  22087. /**
  22088. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22089. */
  22090. uvs3: Nullable<FloatArray>;
  22091. /**
  22092. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22093. */
  22094. uvs4: Nullable<FloatArray>;
  22095. /**
  22096. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22097. */
  22098. uvs5: Nullable<FloatArray>;
  22099. /**
  22100. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22101. */
  22102. uvs6: Nullable<FloatArray>;
  22103. /**
  22104. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22105. */
  22106. colors: Nullable<FloatArray>;
  22107. /**
  22108. * 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).
  22109. */
  22110. matricesIndices: Nullable<FloatArray>;
  22111. /**
  22112. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22113. */
  22114. matricesWeights: Nullable<FloatArray>;
  22115. /**
  22116. * An array extending the number of possible indices
  22117. */
  22118. matricesIndicesExtra: Nullable<FloatArray>;
  22119. /**
  22120. * An array extending the number of possible weights when the number of indices is extended
  22121. */
  22122. matricesWeightsExtra: Nullable<FloatArray>;
  22123. /**
  22124. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22125. */
  22126. indices: Nullable<IndicesArray>;
  22127. /**
  22128. * Uses the passed data array to set the set the values for the specified kind of data
  22129. * @param data a linear array of floating numbers
  22130. * @param kind the type of data that is being set, eg positions, colors etc
  22131. */
  22132. set(data: FloatArray, kind: string): void;
  22133. /**
  22134. * Associates the vertexData to the passed Mesh.
  22135. * Sets it as updatable or not (default `false`)
  22136. * @param mesh the mesh the vertexData is applied to
  22137. * @param updatable when used and having the value true allows new data to update the vertexData
  22138. * @returns the VertexData
  22139. */
  22140. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22141. /**
  22142. * Associates the vertexData to the passed Geometry.
  22143. * Sets it as updatable or not (default `false`)
  22144. * @param geometry the geometry the vertexData is applied to
  22145. * @param updatable when used and having the value true allows new data to update the vertexData
  22146. * @returns VertexData
  22147. */
  22148. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22149. /**
  22150. * Updates the associated mesh
  22151. * @param mesh the mesh to be updated
  22152. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22153. * @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
  22154. * @returns VertexData
  22155. */
  22156. updateMesh(mesh: Mesh): VertexData;
  22157. /**
  22158. * Updates the associated geometry
  22159. * @param geometry the geometry to be updated
  22160. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22161. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22162. * @returns VertexData.
  22163. */
  22164. updateGeometry(geometry: Geometry): VertexData;
  22165. private _applyTo;
  22166. private _update;
  22167. /**
  22168. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22169. * @param matrix the transforming matrix
  22170. * @returns the VertexData
  22171. */
  22172. transform(matrix: Matrix): VertexData;
  22173. /**
  22174. * Merges the passed VertexData into the current one
  22175. * @param other the VertexData to be merged into the current one
  22176. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22177. * @returns the modified VertexData
  22178. */
  22179. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22180. private _mergeElement;
  22181. private _validate;
  22182. /**
  22183. * Serializes the VertexData
  22184. * @returns a serialized object
  22185. */
  22186. serialize(): any;
  22187. /**
  22188. * Extracts the vertexData from a mesh
  22189. * @param mesh the mesh from which to extract the VertexData
  22190. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22191. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22192. * @returns the object VertexData associated to the passed mesh
  22193. */
  22194. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22195. /**
  22196. * Extracts the vertexData from the geometry
  22197. * @param geometry the geometry from which to extract the VertexData
  22198. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22199. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22200. * @returns the object VertexData associated to the passed mesh
  22201. */
  22202. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22203. private static _ExtractFrom;
  22204. /**
  22205. * Creates the VertexData for a Ribbon
  22206. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22207. * * pathArray array of paths, each of which an array of successive Vector3
  22208. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22209. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22210. * * 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
  22211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22212. * * 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)
  22213. * * 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)
  22214. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22215. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22216. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22217. * @returns the VertexData of the ribbon
  22218. */
  22219. static CreateRibbon(options: {
  22220. pathArray: Vector3[][];
  22221. closeArray?: boolean;
  22222. closePath?: boolean;
  22223. offset?: number;
  22224. sideOrientation?: number;
  22225. frontUVs?: Vector4;
  22226. backUVs?: Vector4;
  22227. invertUV?: boolean;
  22228. uvs?: Vector2[];
  22229. colors?: Color4[];
  22230. }): VertexData;
  22231. /**
  22232. * Creates the VertexData for a box
  22233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22234. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22235. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22236. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22237. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22238. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22239. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22241. * * 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)
  22242. * * 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)
  22243. * @returns the VertexData of the box
  22244. */
  22245. static CreateBox(options: {
  22246. size?: number;
  22247. width?: number;
  22248. height?: number;
  22249. depth?: number;
  22250. faceUV?: Vector4[];
  22251. faceColors?: Color4[];
  22252. sideOrientation?: number;
  22253. frontUVs?: Vector4;
  22254. backUVs?: Vector4;
  22255. }): VertexData;
  22256. /**
  22257. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22258. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22259. * * segments sets the number of horizontal strips optional, default 32
  22260. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22261. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22262. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22263. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22264. * * 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
  22265. * * 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
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * @returns the VertexData of the ellipsoid
  22270. */
  22271. static CreateSphere(options: {
  22272. segments?: number;
  22273. diameter?: number;
  22274. diameterX?: number;
  22275. diameterY?: number;
  22276. diameterZ?: number;
  22277. arc?: number;
  22278. slice?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. }): VertexData;
  22283. /**
  22284. * Creates the VertexData for a cylinder, cone or prism
  22285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22286. * * height sets the height (y direction) of the cylinder, optional, default 2
  22287. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22288. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22289. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22290. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22291. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22292. * * 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
  22293. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22294. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22295. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22296. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * 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)
  22299. * * 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)
  22300. * @returns the VertexData of the cylinder, cone or prism
  22301. */
  22302. static CreateCylinder(options: {
  22303. height?: number;
  22304. diameterTop?: number;
  22305. diameterBottom?: number;
  22306. diameter?: number;
  22307. tessellation?: number;
  22308. subdivisions?: number;
  22309. arc?: number;
  22310. faceColors?: Color4[];
  22311. faceUV?: Vector4[];
  22312. hasRings?: boolean;
  22313. enclose?: boolean;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Creates the VertexData for a torus
  22320. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22321. * * diameter the diameter of the torus, optional default 1
  22322. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22323. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22325. * * 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)
  22326. * * 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)
  22327. * @returns the VertexData of the torus
  22328. */
  22329. static CreateTorus(options: {
  22330. diameter?: number;
  22331. thickness?: number;
  22332. tessellation?: number;
  22333. sideOrientation?: number;
  22334. frontUVs?: Vector4;
  22335. backUVs?: Vector4;
  22336. }): VertexData;
  22337. /**
  22338. * Creates the VertexData of the LineSystem
  22339. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22340. * - lines an array of lines, each line being an array of successive Vector3
  22341. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22342. * @returns the VertexData of the LineSystem
  22343. */
  22344. static CreateLineSystem(options: {
  22345. lines: Vector3[][];
  22346. colors?: Nullable<Color4[][]>;
  22347. }): VertexData;
  22348. /**
  22349. * Create the VertexData for a DashedLines
  22350. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22351. * - points an array successive Vector3
  22352. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22353. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22354. * - dashNb the intended total number of dashes, optional, default 200
  22355. * @returns the VertexData for the DashedLines
  22356. */
  22357. static CreateDashedLines(options: {
  22358. points: Vector3[];
  22359. dashSize?: number;
  22360. gapSize?: number;
  22361. dashNb?: number;
  22362. }): VertexData;
  22363. /**
  22364. * Creates the VertexData for a Ground
  22365. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22366. * - width the width (x direction) of the ground, optional, default 1
  22367. * - height the height (z direction) of the ground, optional, default 1
  22368. * - subdivisions the number of subdivisions per side, optional, default 1
  22369. * @returns the VertexData of the Ground
  22370. */
  22371. static CreateGround(options: {
  22372. width?: number;
  22373. height?: number;
  22374. subdivisions?: number;
  22375. subdivisionsX?: number;
  22376. subdivisionsY?: number;
  22377. }): VertexData;
  22378. /**
  22379. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22380. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22381. * * xmin the ground minimum X coordinate, optional, default -1
  22382. * * zmin the ground minimum Z coordinate, optional, default -1
  22383. * * xmax the ground maximum X coordinate, optional, default 1
  22384. * * zmax the ground maximum Z coordinate, optional, default 1
  22385. * * 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}
  22386. * * 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}
  22387. * @returns the VertexData of the TiledGround
  22388. */
  22389. static CreateTiledGround(options: {
  22390. xmin: number;
  22391. zmin: number;
  22392. xmax: number;
  22393. zmax: number;
  22394. subdivisions?: {
  22395. w: number;
  22396. h: number;
  22397. };
  22398. precision?: {
  22399. w: number;
  22400. h: number;
  22401. };
  22402. }): VertexData;
  22403. /**
  22404. * Creates the VertexData of the Ground designed from a heightmap
  22405. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22406. * * width the width (x direction) of the ground
  22407. * * height the height (z direction) of the ground
  22408. * * subdivisions the number of subdivisions per side
  22409. * * minHeight the minimum altitude on the ground, optional, default 0
  22410. * * maxHeight the maximum altitude on the ground, optional default 1
  22411. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22412. * * buffer the array holding the image color data
  22413. * * bufferWidth the width of image
  22414. * * bufferHeight the height of image
  22415. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22416. * @returns the VertexData of the Ground designed from a heightmap
  22417. */
  22418. static CreateGroundFromHeightMap(options: {
  22419. width: number;
  22420. height: number;
  22421. subdivisions: number;
  22422. minHeight: number;
  22423. maxHeight: number;
  22424. colorFilter: Color3;
  22425. buffer: Uint8Array;
  22426. bufferWidth: number;
  22427. bufferHeight: number;
  22428. alphaFilter: number;
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData for a Plane
  22432. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22433. * * size sets the width and height of the plane to the value of size, optional default 1
  22434. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22435. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22437. * * 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)
  22438. * * 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)
  22439. * @returns the VertexData of the box
  22440. */
  22441. static CreatePlane(options: {
  22442. size?: number;
  22443. width?: number;
  22444. height?: number;
  22445. sideOrientation?: number;
  22446. frontUVs?: Vector4;
  22447. backUVs?: Vector4;
  22448. }): VertexData;
  22449. /**
  22450. * Creates the VertexData of the Disc or regular Polygon
  22451. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22452. * * radius the radius of the disc, optional default 0.5
  22453. * * tessellation the number of polygon sides, optional, default 64
  22454. * * 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
  22455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22456. * * 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)
  22457. * * 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)
  22458. * @returns the VertexData of the box
  22459. */
  22460. static CreateDisc(options: {
  22461. radius?: number;
  22462. tessellation?: number;
  22463. arc?: number;
  22464. sideOrientation?: number;
  22465. frontUVs?: Vector4;
  22466. backUVs?: Vector4;
  22467. }): VertexData;
  22468. /**
  22469. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22470. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22471. * @param polygon a mesh built from polygonTriangulation.build()
  22472. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22473. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22474. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22475. * @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)
  22476. * @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)
  22477. * @returns the VertexData of the Polygon
  22478. */
  22479. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22480. /**
  22481. * Creates the VertexData of the IcoSphere
  22482. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22483. * * radius the radius of the IcoSphere, optional default 1
  22484. * * radiusX allows stretching in the x direction, optional, default radius
  22485. * * radiusY allows stretching in the y direction, optional, default radius
  22486. * * radiusZ allows stretching in the z direction, optional, default radius
  22487. * * flat when true creates a flat shaded mesh, optional, default true
  22488. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22490. * * 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)
  22491. * * 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)
  22492. * @returns the VertexData of the IcoSphere
  22493. */
  22494. static CreateIcoSphere(options: {
  22495. radius?: number;
  22496. radiusX?: number;
  22497. radiusY?: number;
  22498. radiusZ?: number;
  22499. flat?: boolean;
  22500. subdivisions?: number;
  22501. sideOrientation?: number;
  22502. frontUVs?: Vector4;
  22503. backUVs?: Vector4;
  22504. }): VertexData;
  22505. /**
  22506. * Creates the VertexData for a Polyhedron
  22507. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22508. * * type provided types are:
  22509. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22510. * * 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)
  22511. * * size the size of the IcoSphere, optional default 1
  22512. * * sizeX allows stretching in the x direction, optional, default size
  22513. * * sizeY allows stretching in the y direction, optional, default size
  22514. * * sizeZ allows stretching in the z direction, optional, default size
  22515. * * 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
  22516. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22517. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22518. * * flat when true creates a flat shaded mesh, optional, default true
  22519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22521. * * 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)
  22522. * * 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)
  22523. * @returns the VertexData of the Polyhedron
  22524. */
  22525. static CreatePolyhedron(options: {
  22526. type?: number;
  22527. size?: number;
  22528. sizeX?: number;
  22529. sizeY?: number;
  22530. sizeZ?: number;
  22531. custom?: any;
  22532. faceUV?: Vector4[];
  22533. faceColors?: Color4[];
  22534. flat?: boolean;
  22535. sideOrientation?: number;
  22536. frontUVs?: Vector4;
  22537. backUVs?: Vector4;
  22538. }): VertexData;
  22539. /**
  22540. * Creates the VertexData for a TorusKnot
  22541. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22542. * * radius the radius of the torus knot, optional, default 2
  22543. * * tube the thickness of the tube, optional, default 0.5
  22544. * * radialSegments the number of sides on each tube segments, optional, default 32
  22545. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22546. * * p the number of windings around the z axis, optional, default 2
  22547. * * q the number of windings around the x axis, optional, default 3
  22548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22549. * * 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)
  22550. * * 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)
  22551. * @returns the VertexData of the Torus Knot
  22552. */
  22553. static CreateTorusKnot(options: {
  22554. radius?: number;
  22555. tube?: number;
  22556. radialSegments?: number;
  22557. tubularSegments?: number;
  22558. p?: number;
  22559. q?: number;
  22560. sideOrientation?: number;
  22561. frontUVs?: Vector4;
  22562. backUVs?: Vector4;
  22563. }): VertexData;
  22564. /**
  22565. * Compute normals for given positions and indices
  22566. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22567. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22568. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22569. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22570. * * facetNormals : optional array of facet normals (vector3)
  22571. * * facetPositions : optional array of facet positions (vector3)
  22572. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22573. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22574. * * bInfo : optional bounding info, required for facetPartitioning computation
  22575. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22576. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22577. * * useRightHandedSystem: optional boolean to for right handed system computation
  22578. * * depthSort : optional boolean to enable the facet depth sort computation
  22579. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22580. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22581. */
  22582. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22583. facetNormals?: any;
  22584. facetPositions?: any;
  22585. facetPartitioning?: any;
  22586. ratio?: number;
  22587. bInfo?: any;
  22588. bbSize?: Vector3;
  22589. subDiv?: any;
  22590. useRightHandedSystem?: boolean;
  22591. depthSort?: boolean;
  22592. distanceTo?: Vector3;
  22593. depthSortedFacets?: any;
  22594. }): void;
  22595. /** @hidden */
  22596. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22597. /**
  22598. * Applies VertexData created from the imported parameters to the geometry
  22599. * @param parsedVertexData the parsed data from an imported file
  22600. * @param geometry the geometry to apply the VertexData to
  22601. */
  22602. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22603. }
  22604. }
  22605. declare module BABYLON {
  22606. /**
  22607. * Class containing static functions to help procedurally build meshes
  22608. */
  22609. export class DiscBuilder {
  22610. /**
  22611. * Creates a plane polygonal mesh. By default, this is a disc
  22612. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22613. * * 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
  22614. * * 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
  22615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22616. * * 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
  22617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22618. * @param name defines the name of the mesh
  22619. * @param options defines the options used to create the mesh
  22620. * @param scene defines the hosting scene
  22621. * @returns the plane polygonal mesh
  22622. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22623. */
  22624. static CreateDisc(name: string, options: {
  22625. radius?: number;
  22626. tessellation?: number;
  22627. arc?: number;
  22628. updatable?: boolean;
  22629. sideOrientation?: number;
  22630. frontUVs?: Vector4;
  22631. backUVs?: Vector4;
  22632. }, scene?: Nullable<Scene>): Mesh;
  22633. }
  22634. }
  22635. declare module BABYLON {
  22636. /**
  22637. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22638. *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.
  22639. * The SPS is also a particle system. It provides some methods to manage the particles.
  22640. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22641. *
  22642. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22643. */
  22644. export class SolidParticleSystem implements IDisposable {
  22645. /**
  22646. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22647. * Example : var p = SPS.particles[i];
  22648. */
  22649. particles: SolidParticle[];
  22650. /**
  22651. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22652. */
  22653. nbParticles: number;
  22654. /**
  22655. * If the particles must ever face the camera (default false). Useful for planar particles.
  22656. */
  22657. billboard: boolean;
  22658. /**
  22659. * Recompute normals when adding a shape
  22660. */
  22661. recomputeNormals: boolean;
  22662. /**
  22663. * This a counter ofr your own usage. It's not set by any SPS functions.
  22664. */
  22665. counter: number;
  22666. /**
  22667. * The SPS name. This name is also given to the underlying mesh.
  22668. */
  22669. name: string;
  22670. /**
  22671. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22672. */
  22673. mesh: Mesh;
  22674. /**
  22675. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22676. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22677. */
  22678. vars: any;
  22679. /**
  22680. * This array is populated when the SPS is set as 'pickable'.
  22681. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22682. * Each element of this array is an object `{idx: int, faceId: int}`.
  22683. * `idx` is the picked particle index in the `SPS.particles` array
  22684. * `faceId` is the picked face index counted within this particle.
  22685. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22686. */
  22687. pickedParticles: {
  22688. idx: number;
  22689. faceId: number;
  22690. }[];
  22691. /**
  22692. * This array is populated when `enableDepthSort` is set to true.
  22693. * Each element of this array is an instance of the class DepthSortedParticle.
  22694. */
  22695. depthSortedParticles: DepthSortedParticle[];
  22696. /**
  22697. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22698. * @hidden
  22699. */
  22700. _bSphereOnly: boolean;
  22701. /**
  22702. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22703. * @hidden
  22704. */
  22705. _bSphereRadiusFactor: number;
  22706. private _scene;
  22707. private _positions;
  22708. private _indices;
  22709. private _normals;
  22710. private _colors;
  22711. private _uvs;
  22712. private _indices32;
  22713. private _positions32;
  22714. private _normals32;
  22715. private _fixedNormal32;
  22716. private _colors32;
  22717. private _uvs32;
  22718. private _index;
  22719. private _updatable;
  22720. private _pickable;
  22721. private _isVisibilityBoxLocked;
  22722. private _alwaysVisible;
  22723. private _depthSort;
  22724. private _shapeCounter;
  22725. private _copy;
  22726. private _color;
  22727. private _computeParticleColor;
  22728. private _computeParticleTexture;
  22729. private _computeParticleRotation;
  22730. private _computeParticleVertex;
  22731. private _computeBoundingBox;
  22732. private _depthSortParticles;
  22733. private _camera;
  22734. private _mustUnrotateFixedNormals;
  22735. private _particlesIntersect;
  22736. private _needs32Bits;
  22737. /**
  22738. * Creates a SPS (Solid Particle System) object.
  22739. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22740. * @param scene (Scene) is the scene in which the SPS is added.
  22741. * @param options defines the options of the sps e.g.
  22742. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22743. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22744. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22745. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22746. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22747. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22748. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22749. */
  22750. constructor(name: string, scene: Scene, options?: {
  22751. updatable?: boolean;
  22752. isPickable?: boolean;
  22753. enableDepthSort?: boolean;
  22754. particleIntersection?: boolean;
  22755. boundingSphereOnly?: boolean;
  22756. bSphereRadiusFactor?: number;
  22757. });
  22758. /**
  22759. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22760. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22761. * @returns the created mesh
  22762. */
  22763. buildMesh(): Mesh;
  22764. /**
  22765. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22766. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22767. * Thus the particles generated from `digest()` have their property `position` set yet.
  22768. * @param mesh ( Mesh ) is the mesh to be digested
  22769. * @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
  22770. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22771. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22772. * @returns the current SPS
  22773. */
  22774. digest(mesh: Mesh, options?: {
  22775. facetNb?: number;
  22776. number?: number;
  22777. delta?: number;
  22778. }): SolidParticleSystem;
  22779. private _unrotateFixedNormals;
  22780. private _resetCopy;
  22781. private _meshBuilder;
  22782. private _posToShape;
  22783. private _uvsToShapeUV;
  22784. private _addParticle;
  22785. /**
  22786. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22787. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22788. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22789. * @param nb (positive integer) the number of particles to be created from this model
  22790. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22791. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22792. * @returns the number of shapes in the system
  22793. */
  22794. addShape(mesh: Mesh, nb: number, options?: {
  22795. positionFunction?: any;
  22796. vertexFunction?: any;
  22797. }): number;
  22798. private _rebuildParticle;
  22799. /**
  22800. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22801. * @returns the SPS.
  22802. */
  22803. rebuildMesh(): SolidParticleSystem;
  22804. /**
  22805. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22806. * This method calls `updateParticle()` for each particle of the SPS.
  22807. * For an animated SPS, it is usually called within the render loop.
  22808. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22809. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22810. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22811. * @returns the SPS.
  22812. */
  22813. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22814. /**
  22815. * Disposes the SPS.
  22816. */
  22817. dispose(): void;
  22818. /**
  22819. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22820. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22821. * @returns the SPS.
  22822. */
  22823. refreshVisibleSize(): SolidParticleSystem;
  22824. /**
  22825. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22826. * @param size the size (float) of the visibility box
  22827. * note : this doesn't lock the SPS mesh bounding box.
  22828. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22829. */
  22830. setVisibilityBox(size: number): void;
  22831. /**
  22832. * Gets whether the SPS as always visible or not
  22833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22834. */
  22835. /**
  22836. * Sets the SPS as always visible or not
  22837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22838. */
  22839. isAlwaysVisible: boolean;
  22840. /**
  22841. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22843. */
  22844. /**
  22845. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22847. */
  22848. isVisibilityBoxLocked: boolean;
  22849. /**
  22850. * Tells to `setParticles()` to compute the particle rotations or not.
  22851. * Default value : true. The SPS is faster when it's set to false.
  22852. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22853. */
  22854. /**
  22855. * Gets if `setParticles()` computes the particle rotations or not.
  22856. * Default value : true. The SPS is faster when it's set to false.
  22857. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22858. */
  22859. computeParticleRotation: boolean;
  22860. /**
  22861. * Tells to `setParticles()` to compute the particle colors or not.
  22862. * Default value : true. The SPS is faster when it's set to false.
  22863. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22864. */
  22865. /**
  22866. * Gets if `setParticles()` computes the particle colors or not.
  22867. * Default value : true. The SPS is faster when it's set to false.
  22868. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22869. */
  22870. computeParticleColor: boolean;
  22871. /**
  22872. * Gets if `setParticles()` computes the particle textures or not.
  22873. * Default value : true. The SPS is faster when it's set to false.
  22874. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22875. */
  22876. computeParticleTexture: boolean;
  22877. /**
  22878. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22879. * Default value : false. The SPS is faster when it's set to false.
  22880. * Note : the particle custom vertex positions aren't stored values.
  22881. */
  22882. /**
  22883. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22884. * Default value : false. The SPS is faster when it's set to false.
  22885. * Note : the particle custom vertex positions aren't stored values.
  22886. */
  22887. computeParticleVertex: boolean;
  22888. /**
  22889. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22890. */
  22891. /**
  22892. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22893. */
  22894. computeBoundingBox: boolean;
  22895. /**
  22896. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22897. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22898. * Default : `true`
  22899. */
  22900. /**
  22901. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22902. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22903. * Default : `true`
  22904. */
  22905. depthSortParticles: boolean;
  22906. /**
  22907. * This function does nothing. It may be overwritten to set all the particle first values.
  22908. * The SPS doesn't call this function, you may have to call it by your own.
  22909. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22910. */
  22911. initParticles(): void;
  22912. /**
  22913. * This function does nothing. It may be overwritten to recycle a particle.
  22914. * The SPS doesn't call this function, you may have to call it by your own.
  22915. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22916. * @param particle The particle to recycle
  22917. * @returns the recycled particle
  22918. */
  22919. recycleParticle(particle: SolidParticle): SolidParticle;
  22920. /**
  22921. * Updates a particle : this function should be overwritten by the user.
  22922. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22923. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22924. * @example : just set a particle position or velocity and recycle conditions
  22925. * @param particle The particle to update
  22926. * @returns the updated particle
  22927. */
  22928. updateParticle(particle: SolidParticle): SolidParticle;
  22929. /**
  22930. * Updates a vertex of a particle : it can be overwritten by the user.
  22931. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22932. * @param particle the current particle
  22933. * @param vertex the current index of the current particle
  22934. * @param pt the index of the current vertex in the particle shape
  22935. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22936. * @example : just set a vertex particle position
  22937. * @returns the updated vertex
  22938. */
  22939. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22940. /**
  22941. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22942. * This does nothing and may be overwritten by the user.
  22943. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22944. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22945. * @param update the boolean update value actually passed to setParticles()
  22946. */
  22947. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22948. /**
  22949. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22950. * This will be passed three parameters.
  22951. * This does nothing and may be overwritten by the user.
  22952. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22953. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22954. * @param update the boolean update value actually passed to setParticles()
  22955. */
  22956. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22957. }
  22958. }
  22959. declare module BABYLON {
  22960. /**
  22961. * Represents one particle of a solid particle system.
  22962. */
  22963. export class SolidParticle {
  22964. /**
  22965. * particle global index
  22966. */
  22967. idx: number;
  22968. /**
  22969. * The color of the particle
  22970. */
  22971. color: Nullable<Color4>;
  22972. /**
  22973. * The world space position of the particle.
  22974. */
  22975. position: Vector3;
  22976. /**
  22977. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22978. */
  22979. rotation: Vector3;
  22980. /**
  22981. * The world space rotation quaternion of the particle.
  22982. */
  22983. rotationQuaternion: Nullable<Quaternion>;
  22984. /**
  22985. * The scaling of the particle.
  22986. */
  22987. scaling: Vector3;
  22988. /**
  22989. * The uvs of the particle.
  22990. */
  22991. uvs: Vector4;
  22992. /**
  22993. * The current speed of the particle.
  22994. */
  22995. velocity: Vector3;
  22996. /**
  22997. * The pivot point in the particle local space.
  22998. */
  22999. pivot: Vector3;
  23000. /**
  23001. * Must the particle be translated from its pivot point in its local space ?
  23002. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23003. * Default : false
  23004. */
  23005. translateFromPivot: boolean;
  23006. /**
  23007. * Is the particle active or not ?
  23008. */
  23009. alive: boolean;
  23010. /**
  23011. * Is the particle visible or not ?
  23012. */
  23013. isVisible: boolean;
  23014. /**
  23015. * Index of this particle in the global "positions" array (Internal use)
  23016. * @hidden
  23017. */
  23018. _pos: number;
  23019. /**
  23020. * @hidden Index of this particle in the global "indices" array (Internal use)
  23021. */
  23022. _ind: number;
  23023. /**
  23024. * @hidden ModelShape of this particle (Internal use)
  23025. */
  23026. _model: ModelShape;
  23027. /**
  23028. * ModelShape id of this particle
  23029. */
  23030. shapeId: number;
  23031. /**
  23032. * Index of the particle in its shape id (Internal use)
  23033. */
  23034. idxInShape: number;
  23035. /**
  23036. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23037. */
  23038. _modelBoundingInfo: BoundingInfo;
  23039. /**
  23040. * @hidden Particle BoundingInfo object (Internal use)
  23041. */
  23042. _boundingInfo: BoundingInfo;
  23043. /**
  23044. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23045. */
  23046. _sps: SolidParticleSystem;
  23047. /**
  23048. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23049. */
  23050. _stillInvisible: boolean;
  23051. /**
  23052. * @hidden Last computed particle rotation matrix
  23053. */
  23054. _rotationMatrix: number[];
  23055. /**
  23056. * Parent particle Id, if any.
  23057. * Default null.
  23058. */
  23059. parentId: Nullable<number>;
  23060. /**
  23061. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23062. * The possible values are :
  23063. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23064. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23065. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23066. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23067. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23068. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23069. * */
  23070. cullingStrategy: number;
  23071. /**
  23072. * @hidden Internal global position in the SPS.
  23073. */
  23074. _globalPosition: Vector3;
  23075. /**
  23076. * Creates a Solid Particle object.
  23077. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23078. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23079. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23080. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23081. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23082. * @param shapeId (integer) is the model shape identifier in the SPS.
  23083. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23084. * @param sps defines the sps it is associated to
  23085. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23086. */
  23087. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23088. /**
  23089. * Legacy support, changed scale to scaling
  23090. */
  23091. /**
  23092. * Legacy support, changed scale to scaling
  23093. */
  23094. scale: Vector3;
  23095. /**
  23096. * Legacy support, changed quaternion to rotationQuaternion
  23097. */
  23098. /**
  23099. * Legacy support, changed quaternion to rotationQuaternion
  23100. */
  23101. quaternion: Nullable<Quaternion>;
  23102. /**
  23103. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23104. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23105. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23106. * @returns true if it intersects
  23107. */
  23108. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23109. /**
  23110. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23111. * A particle is in the frustum if its bounding box intersects the frustum
  23112. * @param frustumPlanes defines the frustum to test
  23113. * @returns true if the particle is in the frustum planes
  23114. */
  23115. isInFrustum(frustumPlanes: Plane[]): boolean;
  23116. /**
  23117. * get the rotation matrix of the particle
  23118. * @hidden
  23119. */
  23120. getRotationMatrix(m: Matrix): void;
  23121. }
  23122. /**
  23123. * Represents the shape of the model used by one particle of a solid particle system.
  23124. * SPS internal tool, don't use it manually.
  23125. */
  23126. export class ModelShape {
  23127. /**
  23128. * The shape id
  23129. * @hidden
  23130. */
  23131. shapeID: number;
  23132. /**
  23133. * flat array of model positions (internal use)
  23134. * @hidden
  23135. */
  23136. _shape: Vector3[];
  23137. /**
  23138. * flat array of model UVs (internal use)
  23139. * @hidden
  23140. */
  23141. _shapeUV: number[];
  23142. /**
  23143. * length of the shape in the model indices array (internal use)
  23144. * @hidden
  23145. */
  23146. _indicesLength: number;
  23147. /**
  23148. * Custom position function (internal use)
  23149. * @hidden
  23150. */
  23151. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23152. /**
  23153. * Custom vertex function (internal use)
  23154. * @hidden
  23155. */
  23156. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23157. /**
  23158. * 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.
  23159. * SPS internal tool, don't use it manually.
  23160. * @hidden
  23161. */
  23162. 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>);
  23163. }
  23164. /**
  23165. * Represents a Depth Sorted Particle in the solid particle system.
  23166. */
  23167. export class DepthSortedParticle {
  23168. /**
  23169. * Index of the particle in the "indices" array
  23170. */
  23171. ind: number;
  23172. /**
  23173. * Length of the particle shape in the "indices" array
  23174. */
  23175. indicesLength: number;
  23176. /**
  23177. * Squared distance from the particle to the camera
  23178. */
  23179. sqDistance: number;
  23180. }
  23181. }
  23182. declare module BABYLON {
  23183. /**
  23184. * Class used to store all common mesh properties
  23185. */
  23186. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23187. /** No occlusion */
  23188. static OCCLUSION_TYPE_NONE: number;
  23189. /** Occlusion set to optimisitic */
  23190. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23191. /** Occlusion set to strict */
  23192. static OCCLUSION_TYPE_STRICT: number;
  23193. /** Use an accurante occlusion algorithm */
  23194. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23195. /** Use a conservative occlusion algorithm */
  23196. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23197. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23198. * Test order :
  23199. * Is the bounding sphere outside the frustum ?
  23200. * If not, are the bounding box vertices outside the frustum ?
  23201. * It not, then the cullable object is in the frustum.
  23202. */
  23203. static readonly CULLINGSTRATEGY_STANDARD: number;
  23204. /** Culling strategy : Bounding Sphere Only.
  23205. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23206. * It's also less accurate than the standard because some not visible objects can still be selected.
  23207. * Test : is the bounding sphere outside the frustum ?
  23208. * If not, then the cullable object is in the frustum.
  23209. */
  23210. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23211. /** Culling strategy : Optimistic Inclusion.
  23212. * This in an inclusion test first, then the standard exclusion test.
  23213. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23214. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  23215. * Anyway, it's as accurate as the standard strategy.
  23216. * Test :
  23217. * Is the cullable object bounding sphere center in the frustum ?
  23218. * If not, apply the default culling strategy.
  23219. */
  23220. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23221. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23222. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23223. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23224. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  23225. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23226. * Test :
  23227. * Is the cullable object bounding sphere center in the frustum ?
  23228. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23229. */
  23230. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23231. /**
  23232. * No billboard
  23233. */
  23234. static readonly BILLBOARDMODE_NONE: number;
  23235. /** Billboard on X axis */
  23236. static readonly BILLBOARDMODE_X: number;
  23237. /** Billboard on Y axis */
  23238. static readonly BILLBOARDMODE_Y: number;
  23239. /** Billboard on Z axis */
  23240. static readonly BILLBOARDMODE_Z: number;
  23241. /** Billboard on all axes */
  23242. static readonly BILLBOARDMODE_ALL: number;
  23243. private _facetData;
  23244. /**
  23245. * The culling strategy to use to check whether the mesh must be rendered or not.
  23246. * This value can be changed at any time and will be used on the next render mesh selection.
  23247. * The possible values are :
  23248. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23249. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23250. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23251. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23252. * Please read each static variable documentation to get details about the culling process.
  23253. * */
  23254. cullingStrategy: number;
  23255. /**
  23256. * Gets the number of facets in the mesh
  23257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23258. */
  23259. readonly facetNb: number;
  23260. /**
  23261. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23263. */
  23264. partitioningSubdivisions: number;
  23265. /**
  23266. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23267. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23269. */
  23270. partitioningBBoxRatio: number;
  23271. /**
  23272. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23273. * Works only for updatable meshes.
  23274. * Doesn't work with multi-materials
  23275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23276. */
  23277. mustDepthSortFacets: boolean;
  23278. /**
  23279. * The location (Vector3) where the facet depth sort must be computed from.
  23280. * By default, the active camera position.
  23281. * Used only when facet depth sort is enabled
  23282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23283. */
  23284. facetDepthSortFrom: Vector3;
  23285. /**
  23286. * gets a boolean indicating if facetData is enabled
  23287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23288. */
  23289. readonly isFacetDataEnabled: boolean;
  23290. /** @hidden */
  23291. _updateNonUniformScalingState(value: boolean): boolean;
  23292. /**
  23293. * An event triggered when this mesh collides with another one
  23294. */
  23295. onCollideObservable: Observable<AbstractMesh>;
  23296. private _onCollideObserver;
  23297. /** Set a function to call when this mesh collides with another one */
  23298. onCollide: () => void;
  23299. /**
  23300. * An event triggered when the collision's position changes
  23301. */
  23302. onCollisionPositionChangeObservable: Observable<Vector3>;
  23303. private _onCollisionPositionChangeObserver;
  23304. /** Set a function to call when the collision's position changes */
  23305. onCollisionPositionChange: () => void;
  23306. /**
  23307. * An event triggered when material is changed
  23308. */
  23309. onMaterialChangedObservable: Observable<AbstractMesh>;
  23310. /**
  23311. * Gets or sets the orientation for POV movement & rotation
  23312. */
  23313. definedFacingForward: boolean;
  23314. /** @hidden */
  23315. _occlusionQuery: Nullable<WebGLQuery>;
  23316. private _visibility;
  23317. /**
  23318. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23319. */
  23320. /**
  23321. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23322. */
  23323. visibility: number;
  23324. /** Gets or sets the alpha index used to sort transparent meshes
  23325. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23326. */
  23327. alphaIndex: number;
  23328. /**
  23329. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23330. */
  23331. isVisible: boolean;
  23332. /**
  23333. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23334. */
  23335. isPickable: boolean;
  23336. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23337. showSubMeshesBoundingBox: boolean;
  23338. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23340. */
  23341. isBlocker: boolean;
  23342. /**
  23343. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23344. */
  23345. enablePointerMoveEvents: boolean;
  23346. /**
  23347. * Specifies the rendering group id for this mesh (0 by default)
  23348. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23349. */
  23350. renderingGroupId: number;
  23351. private _material;
  23352. /** Gets or sets current material */
  23353. material: Nullable<Material>;
  23354. private _receiveShadows;
  23355. /**
  23356. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23357. * @see http://doc.babylonjs.com/babylon101/shadows
  23358. */
  23359. receiveShadows: boolean;
  23360. /** Defines color to use when rendering outline */
  23361. outlineColor: Color3;
  23362. /** Define width to use when rendering outline */
  23363. outlineWidth: number;
  23364. /** Defines color to use when rendering overlay */
  23365. overlayColor: Color3;
  23366. /** Defines alpha to use when rendering overlay */
  23367. overlayAlpha: number;
  23368. private _hasVertexAlpha;
  23369. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23370. hasVertexAlpha: boolean;
  23371. private _useVertexColors;
  23372. /** 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) */
  23373. useVertexColors: boolean;
  23374. private _computeBonesUsingShaders;
  23375. /**
  23376. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23377. */
  23378. computeBonesUsingShaders: boolean;
  23379. private _numBoneInfluencers;
  23380. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23381. numBoneInfluencers: number;
  23382. private _applyFog;
  23383. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23384. applyFog: boolean;
  23385. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23386. useOctreeForRenderingSelection: boolean;
  23387. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23388. useOctreeForPicking: boolean;
  23389. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23390. useOctreeForCollisions: boolean;
  23391. private _layerMask;
  23392. /**
  23393. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23394. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23395. */
  23396. layerMask: number;
  23397. /**
  23398. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23399. */
  23400. alwaysSelectAsActiveMesh: boolean;
  23401. /**
  23402. * Gets or sets the current action manager
  23403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23404. */
  23405. actionManager: Nullable<AbstractActionManager>;
  23406. private _checkCollisions;
  23407. private _collisionMask;
  23408. private _collisionGroup;
  23409. /**
  23410. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23412. */
  23413. ellipsoid: Vector3;
  23414. /**
  23415. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23417. */
  23418. ellipsoidOffset: Vector3;
  23419. private _collider;
  23420. private _oldPositionForCollisions;
  23421. private _diffPositionForCollisions;
  23422. /**
  23423. * Gets or sets a collision mask used to mask collisions (default is -1).
  23424. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23425. */
  23426. collisionMask: number;
  23427. /**
  23428. * Gets or sets the current collision group mask (-1 by default).
  23429. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23430. */
  23431. collisionGroup: number;
  23432. /**
  23433. * Defines edge width used when edgesRenderer is enabled
  23434. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23435. */
  23436. edgesWidth: number;
  23437. /**
  23438. * Defines edge color used when edgesRenderer is enabled
  23439. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23440. */
  23441. edgesColor: Color4;
  23442. /** @hidden */
  23443. _edgesRenderer: Nullable<IEdgesRenderer>;
  23444. /** @hidden */
  23445. _masterMesh: Nullable<AbstractMesh>;
  23446. /** @hidden */
  23447. _boundingInfo: Nullable<BoundingInfo>;
  23448. /** @hidden */
  23449. _renderId: number;
  23450. /**
  23451. * Gets or sets the list of subMeshes
  23452. * @see http://doc.babylonjs.com/how_to/multi_materials
  23453. */
  23454. subMeshes: SubMesh[];
  23455. /** @hidden */
  23456. _intersectionsInProgress: AbstractMesh[];
  23457. /** @hidden */
  23458. _unIndexed: boolean;
  23459. /** @hidden */
  23460. _lightSources: Light[];
  23461. /** @hidden */
  23462. readonly _positions: Nullable<Vector3[]>;
  23463. /** @hidden */
  23464. _waitingActions: any;
  23465. /** @hidden */
  23466. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23467. private _skeleton;
  23468. /** @hidden */
  23469. _bonesTransformMatrices: Nullable<Float32Array>;
  23470. /**
  23471. * Gets or sets a skeleton to apply skining transformations
  23472. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23473. */
  23474. skeleton: Nullable<Skeleton>;
  23475. /**
  23476. * An event triggered when the mesh is rebuilt.
  23477. */
  23478. onRebuildObservable: Observable<AbstractMesh>;
  23479. /**
  23480. * Creates a new AbstractMesh
  23481. * @param name defines the name of the mesh
  23482. * @param scene defines the hosting scene
  23483. */
  23484. constructor(name: string, scene?: Nullable<Scene>);
  23485. /**
  23486. * Returns the string "AbstractMesh"
  23487. * @returns "AbstractMesh"
  23488. */
  23489. getClassName(): string;
  23490. /**
  23491. * Gets a string representation of the current mesh
  23492. * @param fullDetails defines a boolean indicating if full details must be included
  23493. * @returns a string representation of the current mesh
  23494. */
  23495. toString(fullDetails?: boolean): string;
  23496. /** @hidden */
  23497. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23498. /** @hidden */
  23499. _rebuild(): void;
  23500. /** @hidden */
  23501. _resyncLightSources(): void;
  23502. /** @hidden */
  23503. _resyncLighSource(light: Light): void;
  23504. /** @hidden */
  23505. _unBindEffect(): void;
  23506. /** @hidden */
  23507. _removeLightSource(light: Light): void;
  23508. private _markSubMeshesAsDirty;
  23509. /** @hidden */
  23510. _markSubMeshesAsLightDirty(): void;
  23511. /** @hidden */
  23512. _markSubMeshesAsAttributesDirty(): void;
  23513. /** @hidden */
  23514. _markSubMeshesAsMiscDirty(): void;
  23515. /**
  23516. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23517. */
  23518. scaling: Vector3;
  23519. /**
  23520. * Returns true if the mesh is blocked. Implemented by child classes
  23521. */
  23522. readonly isBlocked: boolean;
  23523. /**
  23524. * Returns the mesh itself by default. Implemented by child classes
  23525. * @param camera defines the camera to use to pick the right LOD level
  23526. * @returns the currentAbstractMesh
  23527. */
  23528. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23529. /**
  23530. * Returns 0 by default. Implemented by child classes
  23531. * @returns an integer
  23532. */
  23533. getTotalVertices(): number;
  23534. /**
  23535. * Returns a positive integer : the total number of indices in this mesh geometry.
  23536. * @returns the numner of indices or zero if the mesh has no geometry.
  23537. */
  23538. getTotalIndices(): number;
  23539. /**
  23540. * Returns null by default. Implemented by child classes
  23541. * @returns null
  23542. */
  23543. getIndices(): Nullable<IndicesArray>;
  23544. /**
  23545. * Returns the array of the requested vertex data kind. Implemented by child classes
  23546. * @param kind defines the vertex data kind to use
  23547. * @returns null
  23548. */
  23549. getVerticesData(kind: string): Nullable<FloatArray>;
  23550. /**
  23551. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23552. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23553. * Note that a new underlying VertexBuffer object is created each call.
  23554. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23555. * @param kind defines vertex data kind:
  23556. * * VertexBuffer.PositionKind
  23557. * * VertexBuffer.UVKind
  23558. * * VertexBuffer.UV2Kind
  23559. * * VertexBuffer.UV3Kind
  23560. * * VertexBuffer.UV4Kind
  23561. * * VertexBuffer.UV5Kind
  23562. * * VertexBuffer.UV6Kind
  23563. * * VertexBuffer.ColorKind
  23564. * * VertexBuffer.MatricesIndicesKind
  23565. * * VertexBuffer.MatricesIndicesExtraKind
  23566. * * VertexBuffer.MatricesWeightsKind
  23567. * * VertexBuffer.MatricesWeightsExtraKind
  23568. * @param data defines the data source
  23569. * @param updatable defines if the data must be flagged as updatable (or static)
  23570. * @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
  23571. * @returns the current mesh
  23572. */
  23573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23574. /**
  23575. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23576. * If the mesh has no geometry, it is simply returned as it is.
  23577. * @param kind defines vertex data kind:
  23578. * * VertexBuffer.PositionKind
  23579. * * VertexBuffer.UVKind
  23580. * * VertexBuffer.UV2Kind
  23581. * * VertexBuffer.UV3Kind
  23582. * * VertexBuffer.UV4Kind
  23583. * * VertexBuffer.UV5Kind
  23584. * * VertexBuffer.UV6Kind
  23585. * * VertexBuffer.ColorKind
  23586. * * VertexBuffer.MatricesIndicesKind
  23587. * * VertexBuffer.MatricesIndicesExtraKind
  23588. * * VertexBuffer.MatricesWeightsKind
  23589. * * VertexBuffer.MatricesWeightsExtraKind
  23590. * @param data defines the data source
  23591. * @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
  23592. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23593. * @returns the current mesh
  23594. */
  23595. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23596. /**
  23597. * Sets the mesh indices,
  23598. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23599. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23600. * @param totalVertices Defines the total number of vertices
  23601. * @returns the current mesh
  23602. */
  23603. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23604. /**
  23605. * Gets a boolean indicating if specific vertex data is present
  23606. * @param kind defines the vertex data kind to use
  23607. * @returns true is data kind is present
  23608. */
  23609. isVerticesDataPresent(kind: string): boolean;
  23610. /**
  23611. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23612. * @returns a BoundingInfo
  23613. */
  23614. getBoundingInfo(): BoundingInfo;
  23615. /**
  23616. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23617. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23618. * @returns the current mesh
  23619. */
  23620. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23621. /**
  23622. * Overwrite the current bounding info
  23623. * @param boundingInfo defines the new bounding info
  23624. * @returns the current mesh
  23625. */
  23626. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23627. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23628. readonly useBones: boolean;
  23629. /** @hidden */
  23630. _preActivate(): void;
  23631. /** @hidden */
  23632. _preActivateForIntermediateRendering(renderId: number): void;
  23633. /** @hidden */
  23634. _activate(renderId: number): void;
  23635. /**
  23636. * Gets the current world matrix
  23637. * @returns a Matrix
  23638. */
  23639. getWorldMatrix(): Matrix;
  23640. /** @hidden */
  23641. _getWorldMatrixDeterminant(): number;
  23642. /**
  23643. * Perform relative position change from the point of view of behind the front of the mesh.
  23644. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23645. * Supports definition of mesh facing forward or backward
  23646. * @param amountRight defines the distance on the right axis
  23647. * @param amountUp defines the distance on the up axis
  23648. * @param amountForward defines the distance on the forward axis
  23649. * @returns the current mesh
  23650. */
  23651. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23652. /**
  23653. * Calculate relative position change from the point of view of behind the front of the mesh.
  23654. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23655. * Supports definition of mesh facing forward or backward
  23656. * @param amountRight defines the distance on the right axis
  23657. * @param amountUp defines the distance on the up axis
  23658. * @param amountForward defines the distance on the forward axis
  23659. * @returns the new displacement vector
  23660. */
  23661. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23662. /**
  23663. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23664. * Supports definition of mesh facing forward or backward
  23665. * @param flipBack defines the flip
  23666. * @param twirlClockwise defines the twirl
  23667. * @param tiltRight defines the tilt
  23668. * @returns the current mesh
  23669. */
  23670. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23671. /**
  23672. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23673. * Supports definition of mesh facing forward or backward.
  23674. * @param flipBack defines the flip
  23675. * @param twirlClockwise defines the twirl
  23676. * @param tiltRight defines the tilt
  23677. * @returns the new rotation vector
  23678. */
  23679. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23680. /**
  23681. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23682. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23683. * @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
  23684. * @returns the new bounding vectors
  23685. */
  23686. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23687. min: Vector3;
  23688. max: Vector3;
  23689. };
  23690. /**
  23691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23692. * This means the mesh underlying bounding box and sphere are recomputed.
  23693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23694. * @returns the current mesh
  23695. */
  23696. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23697. /** @hidden */
  23698. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23699. /** @hidden */
  23700. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23701. /** @hidden */
  23702. _updateBoundingInfo(): AbstractMesh;
  23703. /** @hidden */
  23704. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23705. /** @hidden */
  23706. protected _afterComputeWorldMatrix(): void;
  23707. /**
  23708. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23709. * A mesh is in the frustum if its bounding box intersects the frustum
  23710. * @param frustumPlanes defines the frustum to test
  23711. * @returns true if the mesh is in the frustum planes
  23712. */
  23713. isInFrustum(frustumPlanes: Plane[]): boolean;
  23714. /**
  23715. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23716. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23717. * @param frustumPlanes defines the frustum to test
  23718. * @returns true if the mesh is completely in the frustum planes
  23719. */
  23720. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23721. /**
  23722. * True if the mesh intersects another mesh or a SolidParticle object
  23723. * @param mesh defines a target mesh or SolidParticle to test
  23724. * @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)
  23725. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23726. * @returns true if there is an intersection
  23727. */
  23728. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23729. /**
  23730. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23731. * @param point defines the point to test
  23732. * @returns true if there is an intersection
  23733. */
  23734. intersectsPoint(point: Vector3): boolean;
  23735. /**
  23736. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23737. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23738. */
  23739. checkCollisions: boolean;
  23740. /**
  23741. * Gets Collider object used to compute collisions (not physics)
  23742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23743. */
  23744. readonly collider: Collider;
  23745. /**
  23746. * Move the mesh using collision engine
  23747. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23748. * @param displacement defines the requested displacement vector
  23749. * @returns the current mesh
  23750. */
  23751. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23752. private _onCollisionPositionChange;
  23753. /** @hidden */
  23754. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23755. /** @hidden */
  23756. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23757. /** @hidden */
  23758. _checkCollision(collider: Collider): AbstractMesh;
  23759. /** @hidden */
  23760. _generatePointsArray(): boolean;
  23761. /**
  23762. * Checks if the passed Ray intersects with the mesh
  23763. * @param ray defines the ray to use
  23764. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23765. * @returns the picking info
  23766. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23767. */
  23768. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23769. /**
  23770. * Clones the current mesh
  23771. * @param name defines the mesh name
  23772. * @param newParent defines the new mesh parent
  23773. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23774. * @returns the new mesh
  23775. */
  23776. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23777. /**
  23778. * Disposes all the submeshes of the current meshnp
  23779. * @returns the current mesh
  23780. */
  23781. releaseSubMeshes(): AbstractMesh;
  23782. /**
  23783. * Releases resources associated with this abstract mesh.
  23784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23786. */
  23787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23788. /**
  23789. * Adds the passed mesh as a child to the current mesh
  23790. * @param mesh defines the child mesh
  23791. * @returns the current mesh
  23792. */
  23793. addChild(mesh: AbstractMesh): AbstractMesh;
  23794. /**
  23795. * Removes the passed mesh from the current mesh children list
  23796. * @param mesh defines the child mesh
  23797. * @returns the current mesh
  23798. */
  23799. removeChild(mesh: AbstractMesh): AbstractMesh;
  23800. /** @hidden */
  23801. private _initFacetData;
  23802. /**
  23803. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23804. * This method can be called within the render loop.
  23805. * 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
  23806. * @returns the current mesh
  23807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23808. */
  23809. updateFacetData(): AbstractMesh;
  23810. /**
  23811. * Returns the facetLocalNormals array.
  23812. * The normals are expressed in the mesh local spac
  23813. * @returns an array of Vector3
  23814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23815. */
  23816. getFacetLocalNormals(): Vector3[];
  23817. /**
  23818. * Returns the facetLocalPositions array.
  23819. * The facet positions are expressed in the mesh local space
  23820. * @returns an array of Vector3
  23821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23822. */
  23823. getFacetLocalPositions(): Vector3[];
  23824. /**
  23825. * Returns the facetLocalPartioning array
  23826. * @returns an array of array of numbers
  23827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23828. */
  23829. getFacetLocalPartitioning(): number[][];
  23830. /**
  23831. * Returns the i-th facet position in the world system.
  23832. * This method allocates a new Vector3 per call
  23833. * @param i defines the facet index
  23834. * @returns a new Vector3
  23835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23836. */
  23837. getFacetPosition(i: number): Vector3;
  23838. /**
  23839. * Sets the reference Vector3 with the i-th facet position in the world system
  23840. * @param i defines the facet index
  23841. * @param ref defines the target vector
  23842. * @returns the current mesh
  23843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23844. */
  23845. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23846. /**
  23847. * Returns the i-th facet normal in the world system.
  23848. * This method allocates a new Vector3 per call
  23849. * @param i defines the facet index
  23850. * @returns a new Vector3
  23851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23852. */
  23853. getFacetNormal(i: number): Vector3;
  23854. /**
  23855. * Sets the reference Vector3 with the i-th facet normal in the world system
  23856. * @param i defines the facet index
  23857. * @param ref defines the target vector
  23858. * @returns the current mesh
  23859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23860. */
  23861. getFacetNormalToRef(i: number, ref: Vector3): this;
  23862. /**
  23863. * 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)
  23864. * @param x defines x coordinate
  23865. * @param y defines y coordinate
  23866. * @param z defines z coordinate
  23867. * @returns the array of facet indexes
  23868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23869. */
  23870. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23871. /**
  23872. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23873. * @param projected sets as the (x,y,z) world projection on the facet
  23874. * @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
  23875. * @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
  23876. * @param x defines x coordinate
  23877. * @param y defines y coordinate
  23878. * @param z defines z coordinate
  23879. * @returns the face index if found (or null instead)
  23880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23881. */
  23882. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23883. /**
  23884. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23885. * @param projected sets as the (x,y,z) local projection on the facet
  23886. * @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
  23887. * @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
  23888. * @param x defines x coordinate
  23889. * @param y defines y coordinate
  23890. * @param z defines z coordinate
  23891. * @returns the face index if found (or null instead)
  23892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23893. */
  23894. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23895. /**
  23896. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23897. * @returns the parameters
  23898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23899. */
  23900. getFacetDataParameters(): any;
  23901. /**
  23902. * Disables the feature FacetData and frees the related memory
  23903. * @returns the current mesh
  23904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23905. */
  23906. disableFacetData(): AbstractMesh;
  23907. /**
  23908. * Updates the AbstractMesh indices array
  23909. * @param indices defines the data source
  23910. * @returns the current mesh
  23911. */
  23912. updateIndices(indices: IndicesArray): AbstractMesh;
  23913. /**
  23914. * Creates new normals data for the mesh
  23915. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23916. * @returns the current mesh
  23917. */
  23918. createNormals(updatable: boolean): AbstractMesh;
  23919. /**
  23920. * Align the mesh with a normal
  23921. * @param normal defines the normal to use
  23922. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23923. * @returns the current mesh
  23924. */
  23925. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23926. /** @hidden */
  23927. _checkOcclusionQuery(): boolean;
  23928. }
  23929. }
  23930. declare module BABYLON {
  23931. /**
  23932. * Interface used to define ActionEvent
  23933. */
  23934. export interface IActionEvent {
  23935. /** The mesh or sprite that triggered the action */
  23936. source: any;
  23937. /** The X mouse cursor position at the time of the event */
  23938. pointerX: number;
  23939. /** The Y mouse cursor position at the time of the event */
  23940. pointerY: number;
  23941. /** The mesh that is currently pointed at (can be null) */
  23942. meshUnderPointer: Nullable<AbstractMesh>;
  23943. /** the original (browser) event that triggered the ActionEvent */
  23944. sourceEvent?: any;
  23945. /** additional data for the event */
  23946. additionalData?: any;
  23947. }
  23948. /**
  23949. * ActionEvent is the event being sent when an action is triggered.
  23950. */
  23951. export class ActionEvent implements IActionEvent {
  23952. /** The mesh or sprite that triggered the action */
  23953. source: any;
  23954. /** The X mouse cursor position at the time of the event */
  23955. pointerX: number;
  23956. /** The Y mouse cursor position at the time of the event */
  23957. pointerY: number;
  23958. /** The mesh that is currently pointed at (can be null) */
  23959. meshUnderPointer: Nullable<AbstractMesh>;
  23960. /** the original (browser) event that triggered the ActionEvent */
  23961. sourceEvent?: any;
  23962. /** additional data for the event */
  23963. additionalData?: any;
  23964. /**
  23965. * Creates a new ActionEvent
  23966. * @param source The mesh or sprite that triggered the action
  23967. * @param pointerX The X mouse cursor position at the time of the event
  23968. * @param pointerY The Y mouse cursor position at the time of the event
  23969. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  23970. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  23971. * @param additionalData additional data for the event
  23972. */
  23973. constructor(
  23974. /** The mesh or sprite that triggered the action */
  23975. source: any,
  23976. /** The X mouse cursor position at the time of the event */
  23977. pointerX: number,
  23978. /** The Y mouse cursor position at the time of the event */
  23979. pointerY: number,
  23980. /** The mesh that is currently pointed at (can be null) */
  23981. meshUnderPointer: Nullable<AbstractMesh>,
  23982. /** the original (browser) event that triggered the ActionEvent */
  23983. sourceEvent?: any,
  23984. /** additional data for the event */
  23985. additionalData?: any);
  23986. /**
  23987. * Helper function to auto-create an ActionEvent from a source mesh.
  23988. * @param source The source mesh that triggered the event
  23989. * @param evt The original (browser) event
  23990. * @param additionalData additional data for the event
  23991. * @returns the new ActionEvent
  23992. */
  23993. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  23994. /**
  23995. * Helper function to auto-create an ActionEvent from a source sprite
  23996. * @param source The source sprite that triggered the event
  23997. * @param scene Scene associated with the sprite
  23998. * @param evt The original (browser) event
  23999. * @param additionalData additional data for the event
  24000. * @returns the new ActionEvent
  24001. */
  24002. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24003. /**
  24004. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24005. * @param scene the scene where the event occurred
  24006. * @param evt The original (browser) event
  24007. * @returns the new ActionEvent
  24008. */
  24009. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24010. /**
  24011. * Helper function to auto-create an ActionEvent from a primitive
  24012. * @param prim defines the target primitive
  24013. * @param pointerPos defines the pointer position
  24014. * @param evt The original (browser) event
  24015. * @param additionalData additional data for the event
  24016. * @returns the new ActionEvent
  24017. */
  24018. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24019. }
  24020. }
  24021. declare module BABYLON {
  24022. /**
  24023. * Abstract class used to decouple action Manager from scene and meshes.
  24024. * Do not instantiate.
  24025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24026. */
  24027. export abstract class AbstractActionManager implements IDisposable {
  24028. /** Gets the list of active triggers */
  24029. static Triggers: {
  24030. [key: string]: number;
  24031. };
  24032. /** Gets the cursor to use when hovering items */
  24033. hoverCursor: string;
  24034. /** Gets the list of actions */
  24035. actions: IAction[];
  24036. /**
  24037. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24038. */
  24039. isRecursive: boolean;
  24040. /**
  24041. * Releases all associated resources
  24042. */
  24043. abstract dispose(): void;
  24044. /**
  24045. * Does this action manager has pointer triggers
  24046. */
  24047. abstract readonly hasPointerTriggers: boolean;
  24048. /**
  24049. * Does this action manager has pick triggers
  24050. */
  24051. abstract readonly hasPickTriggers: boolean;
  24052. /**
  24053. * Process a specific trigger
  24054. * @param trigger defines the trigger to process
  24055. * @param evt defines the event details to be processed
  24056. */
  24057. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24058. /**
  24059. * Does this action manager handles actions of any of the given triggers
  24060. * @param triggers defines the triggers to be tested
  24061. * @return a boolean indicating whether one (or more) of the triggers is handled
  24062. */
  24063. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24064. /**
  24065. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24066. * speed.
  24067. * @param triggerA defines the trigger to be tested
  24068. * @param triggerB defines the trigger to be tested
  24069. * @return a boolean indicating whether one (or more) of the triggers is handled
  24070. */
  24071. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24072. /**
  24073. * Does this action manager handles actions of a given trigger
  24074. * @param trigger defines the trigger to be tested
  24075. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24076. * @return whether the trigger is handled
  24077. */
  24078. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24079. /**
  24080. * Serialize this manager to a JSON object
  24081. * @param name defines the property name to store this manager
  24082. * @returns a JSON representation of this manager
  24083. */
  24084. abstract serialize(name: string): any;
  24085. /**
  24086. * Does exist one action manager with at least one trigger
  24087. **/
  24088. static readonly HasTriggers: boolean;
  24089. /**
  24090. * Does exist one action manager with at least one pick trigger
  24091. **/
  24092. static readonly HasPickTriggers: boolean;
  24093. /**
  24094. * Does exist one action manager that handles actions of a given trigger
  24095. * @param trigger defines the trigger to be tested
  24096. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24097. **/
  24098. static HasSpecificTrigger(trigger: number): boolean;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Defines how a node can be built from a string name.
  24104. */
  24105. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24106. /**
  24107. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24108. */
  24109. export class Node implements IBehaviorAware<Node> {
  24110. /** @hidden */
  24111. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24112. private static _NodeConstructors;
  24113. /**
  24114. * Add a new node constructor
  24115. * @param type defines the type name of the node to construct
  24116. * @param constructorFunc defines the constructor function
  24117. */
  24118. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24119. /**
  24120. * Returns a node constructor based on type name
  24121. * @param type defines the type name
  24122. * @param name defines the new node name
  24123. * @param scene defines the hosting scene
  24124. * @param options defines optional options to transmit to constructors
  24125. * @returns the new constructor or null
  24126. */
  24127. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24128. /**
  24129. * Gets or sets the name of the node
  24130. */
  24131. name: string;
  24132. /**
  24133. * Gets or sets the id of the node
  24134. */
  24135. id: string;
  24136. /**
  24137. * Gets or sets the unique id of the node
  24138. */
  24139. uniqueId: number;
  24140. /**
  24141. * Gets or sets a string used to store user defined state for the node
  24142. */
  24143. state: string;
  24144. /**
  24145. * Gets or sets an object used to store user defined information for the node
  24146. */
  24147. metadata: any;
  24148. /**
  24149. * For internal use only. Please do not use.
  24150. */
  24151. reservedDataStore: any;
  24152. /**
  24153. * Gets or sets a boolean used to define if the node must be serialized
  24154. */
  24155. doNotSerialize: boolean;
  24156. /** @hidden */
  24157. _isDisposed: boolean;
  24158. /**
  24159. * Gets a list of Animations associated with the node
  24160. */
  24161. animations: Animation[];
  24162. protected _ranges: {
  24163. [name: string]: Nullable<AnimationRange>;
  24164. };
  24165. /**
  24166. * Callback raised when the node is ready to be used
  24167. */
  24168. onReady: (node: Node) => void;
  24169. private _isEnabled;
  24170. private _isParentEnabled;
  24171. private _isReady;
  24172. /** @hidden */
  24173. _currentRenderId: number;
  24174. private _parentRenderId;
  24175. protected _childRenderId: number;
  24176. /** @hidden */
  24177. _waitingParentId: Nullable<string>;
  24178. /** @hidden */
  24179. _scene: Scene;
  24180. /** @hidden */
  24181. _cache: any;
  24182. private _parentNode;
  24183. private _children;
  24184. /** @hidden */
  24185. _worldMatrix: Matrix;
  24186. /** @hidden */
  24187. _worldMatrixDeterminant: number;
  24188. /** @hidden */
  24189. private _sceneRootNodesIndex;
  24190. /**
  24191. * Gets a boolean indicating if the node has been disposed
  24192. * @returns true if the node was disposed
  24193. */
  24194. isDisposed(): boolean;
  24195. /**
  24196. * Gets or sets the parent of the node
  24197. */
  24198. parent: Nullable<Node>;
  24199. private addToSceneRootNodes;
  24200. private removeFromSceneRootNodes;
  24201. private _animationPropertiesOverride;
  24202. /**
  24203. * Gets or sets the animation properties override
  24204. */
  24205. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24206. /**
  24207. * Gets a string idenfifying the name of the class
  24208. * @returns "Node" string
  24209. */
  24210. getClassName(): string;
  24211. /** @hidden */
  24212. readonly _isNode: boolean;
  24213. /**
  24214. * An event triggered when the mesh is disposed
  24215. */
  24216. onDisposeObservable: Observable<Node>;
  24217. private _onDisposeObserver;
  24218. /**
  24219. * Sets a callback that will be raised when the node will be disposed
  24220. */
  24221. onDispose: () => void;
  24222. /**
  24223. * Creates a new Node
  24224. * @param name the name and id to be given to this node
  24225. * @param scene the scene this node will be added to
  24226. * @param addToRootNodes the node will be added to scene.rootNodes
  24227. */
  24228. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24229. /**
  24230. * Gets the scene of the node
  24231. * @returns a scene
  24232. */
  24233. getScene(): Scene;
  24234. /**
  24235. * Gets the engine of the node
  24236. * @returns a Engine
  24237. */
  24238. getEngine(): Engine;
  24239. private _behaviors;
  24240. /**
  24241. * Attach a behavior to the node
  24242. * @see http://doc.babylonjs.com/features/behaviour
  24243. * @param behavior defines the behavior to attach
  24244. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24245. * @returns the current Node
  24246. */
  24247. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24248. /**
  24249. * Remove an attached behavior
  24250. * @see http://doc.babylonjs.com/features/behaviour
  24251. * @param behavior defines the behavior to attach
  24252. * @returns the current Node
  24253. */
  24254. removeBehavior(behavior: Behavior<Node>): Node;
  24255. /**
  24256. * Gets the list of attached behaviors
  24257. * @see http://doc.babylonjs.com/features/behaviour
  24258. */
  24259. readonly behaviors: Behavior<Node>[];
  24260. /**
  24261. * Gets an attached behavior by name
  24262. * @param name defines the name of the behavior to look for
  24263. * @see http://doc.babylonjs.com/features/behaviour
  24264. * @returns null if behavior was not found else the requested behavior
  24265. */
  24266. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24267. /**
  24268. * Returns the latest update of the World matrix
  24269. * @returns a Matrix
  24270. */
  24271. getWorldMatrix(): Matrix;
  24272. /** @hidden */
  24273. _getWorldMatrixDeterminant(): number;
  24274. /**
  24275. * Returns directly the latest state of the mesh World matrix.
  24276. * A Matrix is returned.
  24277. */
  24278. readonly worldMatrixFromCache: Matrix;
  24279. /** @hidden */
  24280. _initCache(): void;
  24281. /** @hidden */
  24282. updateCache(force?: boolean): void;
  24283. /** @hidden */
  24284. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24285. /** @hidden */
  24286. _updateCache(ignoreParentClass?: boolean): void;
  24287. /** @hidden */
  24288. _isSynchronized(): boolean;
  24289. /** @hidden */
  24290. _markSyncedWithParent(): void;
  24291. /** @hidden */
  24292. isSynchronizedWithParent(): boolean;
  24293. /** @hidden */
  24294. isSynchronized(): boolean;
  24295. /**
  24296. * Is this node ready to be used/rendered
  24297. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24298. * @return true if the node is ready
  24299. */
  24300. isReady(completeCheck?: boolean): boolean;
  24301. /**
  24302. * Is this node enabled?
  24303. * 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
  24304. * @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
  24305. * @return whether this node (and its parent) is enabled
  24306. */
  24307. isEnabled(checkAncestors?: boolean): boolean;
  24308. /** @hidden */
  24309. protected _syncParentEnabledState(): void;
  24310. /**
  24311. * Set the enabled state of this node
  24312. * @param value defines the new enabled state
  24313. */
  24314. setEnabled(value: boolean): void;
  24315. /**
  24316. * Is this node a descendant of the given node?
  24317. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24318. * @param ancestor defines the parent node to inspect
  24319. * @returns a boolean indicating if this node is a descendant of the given node
  24320. */
  24321. isDescendantOf(ancestor: Node): boolean;
  24322. /** @hidden */
  24323. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24324. /**
  24325. * Will return all nodes that have this node as ascendant
  24326. * @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
  24327. * @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
  24328. * @return all children nodes of all types
  24329. */
  24330. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24331. /**
  24332. * Get all child-meshes of this node
  24333. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24334. * @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
  24335. * @returns an array of AbstractMesh
  24336. */
  24337. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24338. /**
  24339. * Get all direct children of this node
  24340. * @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
  24341. * @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)
  24342. * @returns an array of Node
  24343. */
  24344. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24345. /** @hidden */
  24346. _setReady(state: boolean): void;
  24347. /**
  24348. * Get an animation by name
  24349. * @param name defines the name of the animation to look for
  24350. * @returns null if not found else the requested animation
  24351. */
  24352. getAnimationByName(name: string): Nullable<Animation>;
  24353. /**
  24354. * Creates an animation range for this node
  24355. * @param name defines the name of the range
  24356. * @param from defines the starting key
  24357. * @param to defines the end key
  24358. */
  24359. createAnimationRange(name: string, from: number, to: number): void;
  24360. /**
  24361. * Delete a specific animation range
  24362. * @param name defines the name of the range to delete
  24363. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24364. */
  24365. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24366. /**
  24367. * Get an animation range by name
  24368. * @param name defines the name of the animation range to look for
  24369. * @returns null if not found else the requested animation range
  24370. */
  24371. getAnimationRange(name: string): Nullable<AnimationRange>;
  24372. /**
  24373. * Will start the animation sequence
  24374. * @param name defines the range frames for animation sequence
  24375. * @param loop defines if the animation should loop (false by default)
  24376. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24377. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24378. * @returns the object created for this animation. If range does not exist, it will return null
  24379. */
  24380. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24381. /**
  24382. * Serialize animation ranges into a JSON compatible object
  24383. * @returns serialization object
  24384. */
  24385. serializeAnimationRanges(): any;
  24386. /**
  24387. * Computes the world matrix of the node
  24388. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24389. * @returns the world matrix
  24390. */
  24391. computeWorldMatrix(force?: boolean): Matrix;
  24392. /**
  24393. * Releases resources associated with this node.
  24394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24396. */
  24397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24398. /**
  24399. * Parse animation range data from a serialization object and store them into a given node
  24400. * @param node defines where to store the animation ranges
  24401. * @param parsedNode defines the serialization object to read data from
  24402. * @param scene defines the hosting scene
  24403. */
  24404. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24405. }
  24406. }
  24407. declare module BABYLON {
  24408. /**
  24409. * Class used to store any kind of animation
  24410. */
  24411. export class Animation {
  24412. /**Name of the animation */
  24413. name: string;
  24414. /**Property to animate */
  24415. targetProperty: string;
  24416. /**The frames per second of the animation */
  24417. framePerSecond: number;
  24418. /**The data type of the animation */
  24419. dataType: number;
  24420. /**The loop mode of the animation */
  24421. loopMode?: number | undefined;
  24422. /**Specifies if blending should be enabled */
  24423. enableBlending?: boolean | undefined;
  24424. /**
  24425. * Use matrix interpolation instead of using direct key value when animating matrices
  24426. */
  24427. static AllowMatricesInterpolation: boolean;
  24428. /**
  24429. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24430. */
  24431. static AllowMatrixDecomposeForInterpolation: boolean;
  24432. /**
  24433. * Stores the key frames of the animation
  24434. */
  24435. private _keys;
  24436. /**
  24437. * Stores the easing function of the animation
  24438. */
  24439. private _easingFunction;
  24440. /**
  24441. * @hidden Internal use only
  24442. */
  24443. _runtimeAnimations: RuntimeAnimation[];
  24444. /**
  24445. * The set of event that will be linked to this animation
  24446. */
  24447. private _events;
  24448. /**
  24449. * Stores an array of target property paths
  24450. */
  24451. targetPropertyPath: string[];
  24452. /**
  24453. * Stores the blending speed of the animation
  24454. */
  24455. blendingSpeed: number;
  24456. /**
  24457. * Stores the animation ranges for the animation
  24458. */
  24459. private _ranges;
  24460. /**
  24461. * @hidden Internal use
  24462. */
  24463. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24464. /**
  24465. * Sets up an animation
  24466. * @param property The property to animate
  24467. * @param animationType The animation type to apply
  24468. * @param framePerSecond The frames per second of the animation
  24469. * @param easingFunction The easing function used in the animation
  24470. * @returns The created animation
  24471. */
  24472. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24473. /**
  24474. * Create and start an animation on a node
  24475. * @param name defines the name of the global animation that will be run on all nodes
  24476. * @param node defines the root node where the animation will take place
  24477. * @param targetProperty defines property to animate
  24478. * @param framePerSecond defines the number of frame per second yo use
  24479. * @param totalFrame defines the number of frames in total
  24480. * @param from defines the initial value
  24481. * @param to defines the final value
  24482. * @param loopMode defines which loop mode you want to use (off by default)
  24483. * @param easingFunction defines the easing function to use (linear by default)
  24484. * @param onAnimationEnd defines the callback to call when animation end
  24485. * @returns the animatable created for this animation
  24486. */
  24487. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24488. /**
  24489. * Create and start an animation on a node and its descendants
  24490. * @param name defines the name of the global animation that will be run on all nodes
  24491. * @param node defines the root node where the animation will take place
  24492. * @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
  24493. * @param targetProperty defines property to animate
  24494. * @param framePerSecond defines the number of frame per second to use
  24495. * @param totalFrame defines the number of frames in total
  24496. * @param from defines the initial value
  24497. * @param to defines the final value
  24498. * @param loopMode defines which loop mode you want to use (off by default)
  24499. * @param easingFunction defines the easing function to use (linear by default)
  24500. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24501. * @returns the list of animatables created for all nodes
  24502. * @example https://www.babylonjs-playground.com/#MH0VLI
  24503. */
  24504. 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[]>;
  24505. /**
  24506. * Creates a new animation, merges it with the existing animations and starts it
  24507. * @param name Name of the animation
  24508. * @param node Node which contains the scene that begins the animations
  24509. * @param targetProperty Specifies which property to animate
  24510. * @param framePerSecond The frames per second of the animation
  24511. * @param totalFrame The total number of frames
  24512. * @param from The frame at the beginning of the animation
  24513. * @param to The frame at the end of the animation
  24514. * @param loopMode Specifies the loop mode of the animation
  24515. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24516. * @param onAnimationEnd Callback to run once the animation is complete
  24517. * @returns Nullable animation
  24518. */
  24519. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24520. /**
  24521. * Transition property of an host to the target Value
  24522. * @param property The property to transition
  24523. * @param targetValue The target Value of the property
  24524. * @param host The object where the property to animate belongs
  24525. * @param scene Scene used to run the animation
  24526. * @param frameRate Framerate (in frame/s) to use
  24527. * @param transition The transition type we want to use
  24528. * @param duration The duration of the animation, in milliseconds
  24529. * @param onAnimationEnd Callback trigger at the end of the animation
  24530. * @returns Nullable animation
  24531. */
  24532. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24533. /**
  24534. * Return the array of runtime animations currently using this animation
  24535. */
  24536. readonly runtimeAnimations: RuntimeAnimation[];
  24537. /**
  24538. * Specifies if any of the runtime animations are currently running
  24539. */
  24540. readonly hasRunningRuntimeAnimations: boolean;
  24541. /**
  24542. * Initializes the animation
  24543. * @param name Name of the animation
  24544. * @param targetProperty Property to animate
  24545. * @param framePerSecond The frames per second of the animation
  24546. * @param dataType The data type of the animation
  24547. * @param loopMode The loop mode of the animation
  24548. * @param enableBlending Specifies if blending should be enabled
  24549. */
  24550. constructor(
  24551. /**Name of the animation */
  24552. name: string,
  24553. /**Property to animate */
  24554. targetProperty: string,
  24555. /**The frames per second of the animation */
  24556. framePerSecond: number,
  24557. /**The data type of the animation */
  24558. dataType: number,
  24559. /**The loop mode of the animation */
  24560. loopMode?: number | undefined,
  24561. /**Specifies if blending should be enabled */
  24562. enableBlending?: boolean | undefined);
  24563. /**
  24564. * Converts the animation to a string
  24565. * @param fullDetails support for multiple levels of logging within scene loading
  24566. * @returns String form of the animation
  24567. */
  24568. toString(fullDetails?: boolean): string;
  24569. /**
  24570. * Add an event to this animation
  24571. * @param event Event to add
  24572. */
  24573. addEvent(event: AnimationEvent): void;
  24574. /**
  24575. * Remove all events found at the given frame
  24576. * @param frame The frame to remove events from
  24577. */
  24578. removeEvents(frame: number): void;
  24579. /**
  24580. * Retrieves all the events from the animation
  24581. * @returns Events from the animation
  24582. */
  24583. getEvents(): AnimationEvent[];
  24584. /**
  24585. * Creates an animation range
  24586. * @param name Name of the animation range
  24587. * @param from Starting frame of the animation range
  24588. * @param to Ending frame of the animation
  24589. */
  24590. createRange(name: string, from: number, to: number): void;
  24591. /**
  24592. * Deletes an animation range by name
  24593. * @param name Name of the animation range to delete
  24594. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24595. */
  24596. deleteRange(name: string, deleteFrames?: boolean): void;
  24597. /**
  24598. * Gets the animation range by name, or null if not defined
  24599. * @param name Name of the animation range
  24600. * @returns Nullable animation range
  24601. */
  24602. getRange(name: string): Nullable<AnimationRange>;
  24603. /**
  24604. * Gets the key frames from the animation
  24605. * @returns The key frames of the animation
  24606. */
  24607. getKeys(): Array<IAnimationKey>;
  24608. /**
  24609. * Gets the highest frame rate of the animation
  24610. * @returns Highest frame rate of the animation
  24611. */
  24612. getHighestFrame(): number;
  24613. /**
  24614. * Gets the easing function of the animation
  24615. * @returns Easing function of the animation
  24616. */
  24617. getEasingFunction(): IEasingFunction;
  24618. /**
  24619. * Sets the easing function of the animation
  24620. * @param easingFunction A custom mathematical formula for animation
  24621. */
  24622. setEasingFunction(easingFunction: EasingFunction): void;
  24623. /**
  24624. * Interpolates a scalar linearly
  24625. * @param startValue Start value of the animation curve
  24626. * @param endValue End value of the animation curve
  24627. * @param gradient Scalar amount to interpolate
  24628. * @returns Interpolated scalar value
  24629. */
  24630. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24631. /**
  24632. * Interpolates a scalar cubically
  24633. * @param startValue Start value of the animation curve
  24634. * @param outTangent End tangent of the animation
  24635. * @param endValue End value of the animation curve
  24636. * @param inTangent Start tangent of the animation curve
  24637. * @param gradient Scalar amount to interpolate
  24638. * @returns Interpolated scalar value
  24639. */
  24640. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24641. /**
  24642. * Interpolates a quaternion using a spherical linear interpolation
  24643. * @param startValue Start value of the animation curve
  24644. * @param endValue End value of the animation curve
  24645. * @param gradient Scalar amount to interpolate
  24646. * @returns Interpolated quaternion value
  24647. */
  24648. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24649. /**
  24650. * Interpolates a quaternion cubically
  24651. * @param startValue Start value of the animation curve
  24652. * @param outTangent End tangent of the animation curve
  24653. * @param endValue End value of the animation curve
  24654. * @param inTangent Start tangent of the animation curve
  24655. * @param gradient Scalar amount to interpolate
  24656. * @returns Interpolated quaternion value
  24657. */
  24658. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24659. /**
  24660. * Interpolates a Vector3 linearl
  24661. * @param startValue Start value of the animation curve
  24662. * @param endValue End value of the animation curve
  24663. * @param gradient Scalar amount to interpolate
  24664. * @returns Interpolated scalar value
  24665. */
  24666. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24667. /**
  24668. * Interpolates a Vector3 cubically
  24669. * @param startValue Start value of the animation curve
  24670. * @param outTangent End tangent of the animation
  24671. * @param endValue End value of the animation curve
  24672. * @param inTangent Start tangent of the animation curve
  24673. * @param gradient Scalar amount to interpolate
  24674. * @returns InterpolatedVector3 value
  24675. */
  24676. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24677. /**
  24678. * Interpolates a Vector2 linearly
  24679. * @param startValue Start value of the animation curve
  24680. * @param endValue End value of the animation curve
  24681. * @param gradient Scalar amount to interpolate
  24682. * @returns Interpolated Vector2 value
  24683. */
  24684. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24685. /**
  24686. * Interpolates a Vector2 cubically
  24687. * @param startValue Start value of the animation curve
  24688. * @param outTangent End tangent of the animation
  24689. * @param endValue End value of the animation curve
  24690. * @param inTangent Start tangent of the animation curve
  24691. * @param gradient Scalar amount to interpolate
  24692. * @returns Interpolated Vector2 value
  24693. */
  24694. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24695. /**
  24696. * Interpolates a size linearly
  24697. * @param startValue Start value of the animation curve
  24698. * @param endValue End value of the animation curve
  24699. * @param gradient Scalar amount to interpolate
  24700. * @returns Interpolated Size value
  24701. */
  24702. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24703. /**
  24704. * Interpolates a Color3 linearly
  24705. * @param startValue Start value of the animation curve
  24706. * @param endValue End value of the animation curve
  24707. * @param gradient Scalar amount to interpolate
  24708. * @returns Interpolated Color3 value
  24709. */
  24710. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24711. /**
  24712. * @hidden Internal use only
  24713. */
  24714. _getKeyValue(value: any): any;
  24715. /**
  24716. * @hidden Internal use only
  24717. */
  24718. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24719. /**
  24720. * Defines the function to use to interpolate matrices
  24721. * @param startValue defines the start matrix
  24722. * @param endValue defines the end matrix
  24723. * @param gradient defines the gradient between both matrices
  24724. * @param result defines an optional target matrix where to store the interpolation
  24725. * @returns the interpolated matrix
  24726. */
  24727. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24728. /**
  24729. * Makes a copy of the animation
  24730. * @returns Cloned animation
  24731. */
  24732. clone(): Animation;
  24733. /**
  24734. * Sets the key frames of the animation
  24735. * @param values The animation key frames to set
  24736. */
  24737. setKeys(values: Array<IAnimationKey>): void;
  24738. /**
  24739. * Serializes the animation to an object
  24740. * @returns Serialized object
  24741. */
  24742. serialize(): any;
  24743. /**
  24744. * Float animation type
  24745. */
  24746. private static _ANIMATIONTYPE_FLOAT;
  24747. /**
  24748. * Vector3 animation type
  24749. */
  24750. private static _ANIMATIONTYPE_VECTOR3;
  24751. /**
  24752. * Quaternion animation type
  24753. */
  24754. private static _ANIMATIONTYPE_QUATERNION;
  24755. /**
  24756. * Matrix animation type
  24757. */
  24758. private static _ANIMATIONTYPE_MATRIX;
  24759. /**
  24760. * Color3 animation type
  24761. */
  24762. private static _ANIMATIONTYPE_COLOR3;
  24763. /**
  24764. * Vector2 animation type
  24765. */
  24766. private static _ANIMATIONTYPE_VECTOR2;
  24767. /**
  24768. * Size animation type
  24769. */
  24770. private static _ANIMATIONTYPE_SIZE;
  24771. /**
  24772. * Relative Loop Mode
  24773. */
  24774. private static _ANIMATIONLOOPMODE_RELATIVE;
  24775. /**
  24776. * Cycle Loop Mode
  24777. */
  24778. private static _ANIMATIONLOOPMODE_CYCLE;
  24779. /**
  24780. * Constant Loop Mode
  24781. */
  24782. private static _ANIMATIONLOOPMODE_CONSTANT;
  24783. /**
  24784. * Get the float animation type
  24785. */
  24786. static readonly ANIMATIONTYPE_FLOAT: number;
  24787. /**
  24788. * Get the Vector3 animation type
  24789. */
  24790. static readonly ANIMATIONTYPE_VECTOR3: number;
  24791. /**
  24792. * Get the Vector2 animation type
  24793. */
  24794. static readonly ANIMATIONTYPE_VECTOR2: number;
  24795. /**
  24796. * Get the Size animation type
  24797. */
  24798. static readonly ANIMATIONTYPE_SIZE: number;
  24799. /**
  24800. * Get the Quaternion animation type
  24801. */
  24802. static readonly ANIMATIONTYPE_QUATERNION: number;
  24803. /**
  24804. * Get the Matrix animation type
  24805. */
  24806. static readonly ANIMATIONTYPE_MATRIX: number;
  24807. /**
  24808. * Get the Color3 animation type
  24809. */
  24810. static readonly ANIMATIONTYPE_COLOR3: number;
  24811. /**
  24812. * Get the Relative Loop Mode
  24813. */
  24814. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24815. /**
  24816. * Get the Cycle Loop Mode
  24817. */
  24818. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24819. /**
  24820. * Get the Constant Loop Mode
  24821. */
  24822. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24823. /** @hidden */
  24824. static _UniversalLerp(left: any, right: any, amount: number): any;
  24825. /**
  24826. * Parses an animation object and creates an animation
  24827. * @param parsedAnimation Parsed animation object
  24828. * @returns Animation object
  24829. */
  24830. static Parse(parsedAnimation: any): Animation;
  24831. /**
  24832. * Appends the serialized animations from the source animations
  24833. * @param source Source containing the animations
  24834. * @param destination Target to store the animations
  24835. */
  24836. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24837. }
  24838. }
  24839. declare module BABYLON {
  24840. /**
  24841. * Base class of all the textures in babylon.
  24842. * It groups all the common properties the materials, post process, lights... might need
  24843. * in order to make a correct use of the texture.
  24844. */
  24845. export class BaseTexture implements IAnimatable {
  24846. /**
  24847. * Default anisotropic filtering level for the application.
  24848. * It is set to 4 as a good tradeoff between perf and quality.
  24849. */
  24850. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24851. /**
  24852. * Gets or sets the unique id of the texture
  24853. */
  24854. uniqueId: number;
  24855. /**
  24856. * Define the name of the texture.
  24857. */
  24858. name: string;
  24859. /**
  24860. * Gets or sets an object used to store user defined information.
  24861. */
  24862. metadata: any;
  24863. /**
  24864. * For internal use only. Please do not use.
  24865. */
  24866. reservedDataStore: any;
  24867. private _hasAlpha;
  24868. /**
  24869. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24870. */
  24871. hasAlpha: boolean;
  24872. /**
  24873. * Defines if the alpha value should be determined via the rgb values.
  24874. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24875. */
  24876. getAlphaFromRGB: boolean;
  24877. /**
  24878. * Intensity or strength of the texture.
  24879. * It is commonly used by materials to fine tune the intensity of the texture
  24880. */
  24881. level: number;
  24882. /**
  24883. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24884. * This is part of the texture as textures usually maps to one uv set.
  24885. */
  24886. coordinatesIndex: number;
  24887. private _coordinatesMode;
  24888. /**
  24889. * How a texture is mapped.
  24890. *
  24891. * | Value | Type | Description |
  24892. * | ----- | ----------------------------------- | ----------- |
  24893. * | 0 | EXPLICIT_MODE | |
  24894. * | 1 | SPHERICAL_MODE | |
  24895. * | 2 | PLANAR_MODE | |
  24896. * | 3 | CUBIC_MODE | |
  24897. * | 4 | PROJECTION_MODE | |
  24898. * | 5 | SKYBOX_MODE | |
  24899. * | 6 | INVCUBIC_MODE | |
  24900. * | 7 | EQUIRECTANGULAR_MODE | |
  24901. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24902. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24903. */
  24904. coordinatesMode: number;
  24905. /**
  24906. * | Value | Type | Description |
  24907. * | ----- | ------------------ | ----------- |
  24908. * | 0 | CLAMP_ADDRESSMODE | |
  24909. * | 1 | WRAP_ADDRESSMODE | |
  24910. * | 2 | MIRROR_ADDRESSMODE | |
  24911. */
  24912. wrapU: number;
  24913. /**
  24914. * | Value | Type | Description |
  24915. * | ----- | ------------------ | ----------- |
  24916. * | 0 | CLAMP_ADDRESSMODE | |
  24917. * | 1 | WRAP_ADDRESSMODE | |
  24918. * | 2 | MIRROR_ADDRESSMODE | |
  24919. */
  24920. wrapV: number;
  24921. /**
  24922. * | Value | Type | Description |
  24923. * | ----- | ------------------ | ----------- |
  24924. * | 0 | CLAMP_ADDRESSMODE | |
  24925. * | 1 | WRAP_ADDRESSMODE | |
  24926. * | 2 | MIRROR_ADDRESSMODE | |
  24927. */
  24928. wrapR: number;
  24929. /**
  24930. * With compliant hardware and browser (supporting anisotropic filtering)
  24931. * this defines the level of anisotropic filtering in the texture.
  24932. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24933. */
  24934. anisotropicFilteringLevel: number;
  24935. /**
  24936. * Define if the texture is a cube texture or if false a 2d texture.
  24937. */
  24938. isCube: boolean;
  24939. /**
  24940. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24941. */
  24942. is3D: boolean;
  24943. /**
  24944. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24945. * HDR texture are usually stored in linear space.
  24946. * This only impacts the PBR and Background materials
  24947. */
  24948. gammaSpace: boolean;
  24949. /**
  24950. * Gets whether or not the texture contains RGBD data.
  24951. */
  24952. readonly isRGBD: boolean;
  24953. /**
  24954. * Is Z inverted in the texture (useful in a cube texture).
  24955. */
  24956. invertZ: boolean;
  24957. /**
  24958. * Are mip maps generated for this texture or not.
  24959. */
  24960. readonly noMipmap: boolean;
  24961. /**
  24962. * @hidden
  24963. */
  24964. lodLevelInAlpha: boolean;
  24965. /**
  24966. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24967. */
  24968. lodGenerationOffset: number;
  24969. /**
  24970. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24971. */
  24972. lodGenerationScale: number;
  24973. /**
  24974. * Define if the texture is a render target.
  24975. */
  24976. isRenderTarget: boolean;
  24977. /**
  24978. * Define the unique id of the texture in the scene.
  24979. */
  24980. readonly uid: string;
  24981. /**
  24982. * Return a string representation of the texture.
  24983. * @returns the texture as a string
  24984. */
  24985. toString(): string;
  24986. /**
  24987. * Get the class name of the texture.
  24988. * @returns "BaseTexture"
  24989. */
  24990. getClassName(): string;
  24991. /**
  24992. * Define the list of animation attached to the texture.
  24993. */
  24994. animations: Animation[];
  24995. /**
  24996. * An event triggered when the texture is disposed.
  24997. */
  24998. onDisposeObservable: Observable<BaseTexture>;
  24999. private _onDisposeObserver;
  25000. /**
  25001. * Callback triggered when the texture has been disposed.
  25002. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25003. */
  25004. onDispose: () => void;
  25005. /**
  25006. * Define the current state of the loading sequence when in delayed load mode.
  25007. */
  25008. delayLoadState: number;
  25009. private _scene;
  25010. /** @hidden */
  25011. _texture: Nullable<InternalTexture>;
  25012. private _uid;
  25013. /**
  25014. * Define if the texture is preventinga material to render or not.
  25015. * If not and the texture is not ready, the engine will use a default black texture instead.
  25016. */
  25017. readonly isBlocking: boolean;
  25018. /**
  25019. * Instantiates a new BaseTexture.
  25020. * Base class of all the textures in babylon.
  25021. * It groups all the common properties the materials, post process, lights... might need
  25022. * in order to make a correct use of the texture.
  25023. * @param scene Define the scene the texture blongs to
  25024. */
  25025. constructor(scene: Nullable<Scene>);
  25026. /**
  25027. * Get the scene the texture belongs to.
  25028. * @returns the scene or null if undefined
  25029. */
  25030. getScene(): Nullable<Scene>;
  25031. /**
  25032. * Get the texture transform matrix used to offset tile the texture for istance.
  25033. * @returns the transformation matrix
  25034. */
  25035. getTextureMatrix(): Matrix;
  25036. /**
  25037. * Get the texture reflection matrix used to rotate/transform the reflection.
  25038. * @returns the reflection matrix
  25039. */
  25040. getReflectionTextureMatrix(): Matrix;
  25041. /**
  25042. * Get the underlying lower level texture from Babylon.
  25043. * @returns the insternal texture
  25044. */
  25045. getInternalTexture(): Nullable<InternalTexture>;
  25046. /**
  25047. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25048. * @returns true if ready or not blocking
  25049. */
  25050. isReadyOrNotBlocking(): boolean;
  25051. /**
  25052. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25053. * @returns true if fully ready
  25054. */
  25055. isReady(): boolean;
  25056. private _cachedSize;
  25057. /**
  25058. * Get the size of the texture.
  25059. * @returns the texture size.
  25060. */
  25061. getSize(): ISize;
  25062. /**
  25063. * Get the base size of the texture.
  25064. * It can be different from the size if the texture has been resized for POT for instance
  25065. * @returns the base size
  25066. */
  25067. getBaseSize(): ISize;
  25068. /**
  25069. * Update the sampling mode of the texture.
  25070. * Default is Trilinear mode.
  25071. *
  25072. * | Value | Type | Description |
  25073. * | ----- | ------------------ | ----------- |
  25074. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25075. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25076. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25077. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25078. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25079. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25080. * | 7 | NEAREST_LINEAR | |
  25081. * | 8 | NEAREST_NEAREST | |
  25082. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25083. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25084. * | 11 | LINEAR_LINEAR | |
  25085. * | 12 | LINEAR_NEAREST | |
  25086. *
  25087. * > _mag_: magnification filter (close to the viewer)
  25088. * > _min_: minification filter (far from the viewer)
  25089. * > _mip_: filter used between mip map levels
  25090. *@param samplingMode Define the new sampling mode of the texture
  25091. */
  25092. updateSamplingMode(samplingMode: number): void;
  25093. /**
  25094. * Scales the texture if is `canRescale()`
  25095. * @param ratio the resize factor we want to use to rescale
  25096. */
  25097. scale(ratio: number): void;
  25098. /**
  25099. * Get if the texture can rescale.
  25100. */
  25101. readonly canRescale: boolean;
  25102. /** @hidden */
  25103. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25104. /** @hidden */
  25105. _rebuild(): void;
  25106. /**
  25107. * Triggers the load sequence in delayed load mode.
  25108. */
  25109. delayLoad(): void;
  25110. /**
  25111. * Clones the texture.
  25112. * @returns the cloned texture
  25113. */
  25114. clone(): Nullable<BaseTexture>;
  25115. /**
  25116. * Get the texture underlying type (INT, FLOAT...)
  25117. */
  25118. readonly textureType: number;
  25119. /**
  25120. * Get the texture underlying format (RGB, RGBA...)
  25121. */
  25122. readonly textureFormat: number;
  25123. /**
  25124. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25125. * This will returns an RGBA array buffer containing either in values (0-255) or
  25126. * float values (0-1) depending of the underlying buffer type.
  25127. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25128. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25129. * @param buffer defines a user defined buffer to fill with data (can be null)
  25130. * @returns The Array buffer containing the pixels data.
  25131. */
  25132. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25133. /**
  25134. * Release and destroy the underlying lower level texture aka internalTexture.
  25135. */
  25136. releaseInternalTexture(): void;
  25137. /**
  25138. * Get the polynomial representation of the texture data.
  25139. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25140. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25141. */
  25142. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25143. /** @hidden */
  25144. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25145. /** @hidden */
  25146. readonly _lodTextureMid: Nullable<BaseTexture>;
  25147. /** @hidden */
  25148. readonly _lodTextureLow: Nullable<BaseTexture>;
  25149. /**
  25150. * Dispose the texture and release its associated resources.
  25151. */
  25152. dispose(): void;
  25153. /**
  25154. * Serialize the texture into a JSON representation that can be parsed later on.
  25155. * @returns the JSON representation of the texture
  25156. */
  25157. serialize(): any;
  25158. /**
  25159. * Helper function to be called back once a list of texture contains only ready textures.
  25160. * @param textures Define the list of textures to wait for
  25161. * @param callback Define the callback triggered once the entire list will be ready
  25162. */
  25163. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25164. }
  25165. }
  25166. declare module BABYLON {
  25167. /**
  25168. * Uniform buffer objects.
  25169. *
  25170. * Handles blocks of uniform on the GPU.
  25171. *
  25172. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25173. *
  25174. * For more information, please refer to :
  25175. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25176. */
  25177. export class UniformBuffer {
  25178. private _engine;
  25179. private _buffer;
  25180. private _data;
  25181. private _bufferData;
  25182. private _dynamic?;
  25183. private _uniformLocations;
  25184. private _uniformSizes;
  25185. private _uniformLocationPointer;
  25186. private _needSync;
  25187. private _noUBO;
  25188. private _currentEffect;
  25189. private static _MAX_UNIFORM_SIZE;
  25190. private static _tempBuffer;
  25191. /**
  25192. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25193. * This is dynamic to allow compat with webgl 1 and 2.
  25194. * You will need to pass the name of the uniform as well as the value.
  25195. */
  25196. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25197. /**
  25198. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25199. * This is dynamic to allow compat with webgl 1 and 2.
  25200. * You will need to pass the name of the uniform as well as the value.
  25201. */
  25202. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25203. /**
  25204. * Lambda to Update a single float in a uniform buffer.
  25205. * This is dynamic to allow compat with webgl 1 and 2.
  25206. * You will need to pass the name of the uniform as well as the value.
  25207. */
  25208. updateFloat: (name: string, x: number) => void;
  25209. /**
  25210. * Lambda to Update a vec2 of float in a uniform buffer.
  25211. * This is dynamic to allow compat with webgl 1 and 2.
  25212. * You will need to pass the name of the uniform as well as the value.
  25213. */
  25214. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25215. /**
  25216. * Lambda to Update a vec3 of float in a uniform buffer.
  25217. * This is dynamic to allow compat with webgl 1 and 2.
  25218. * You will need to pass the name of the uniform as well as the value.
  25219. */
  25220. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25221. /**
  25222. * Lambda to Update a vec4 of float in a uniform buffer.
  25223. * This is dynamic to allow compat with webgl 1 and 2.
  25224. * You will need to pass the name of the uniform as well as the value.
  25225. */
  25226. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25227. /**
  25228. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25229. * This is dynamic to allow compat with webgl 1 and 2.
  25230. * You will need to pass the name of the uniform as well as the value.
  25231. */
  25232. updateMatrix: (name: string, mat: Matrix) => void;
  25233. /**
  25234. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25235. * This is dynamic to allow compat with webgl 1 and 2.
  25236. * You will need to pass the name of the uniform as well as the value.
  25237. */
  25238. updateVector3: (name: string, vector: Vector3) => void;
  25239. /**
  25240. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25241. * This is dynamic to allow compat with webgl 1 and 2.
  25242. * You will need to pass the name of the uniform as well as the value.
  25243. */
  25244. updateVector4: (name: string, vector: Vector4) => void;
  25245. /**
  25246. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25247. * This is dynamic to allow compat with webgl 1 and 2.
  25248. * You will need to pass the name of the uniform as well as the value.
  25249. */
  25250. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25251. /**
  25252. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25253. * This is dynamic to allow compat with webgl 1 and 2.
  25254. * You will need to pass the name of the uniform as well as the value.
  25255. */
  25256. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25257. /**
  25258. * Instantiates a new Uniform buffer objects.
  25259. *
  25260. * Handles blocks of uniform on the GPU.
  25261. *
  25262. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25263. *
  25264. * For more information, please refer to :
  25265. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25266. * @param engine Define the engine the buffer is associated with
  25267. * @param data Define the data contained in the buffer
  25268. * @param dynamic Define if the buffer is updatable
  25269. */
  25270. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25271. /**
  25272. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25273. * or just falling back on setUniformXXX calls.
  25274. */
  25275. readonly useUbo: boolean;
  25276. /**
  25277. * Indicates if the WebGL underlying uniform buffer is in sync
  25278. * with the javascript cache data.
  25279. */
  25280. readonly isSync: boolean;
  25281. /**
  25282. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25283. * Also, a dynamic UniformBuffer will disable cache verification and always
  25284. * update the underlying WebGL uniform buffer to the GPU.
  25285. * @returns if Dynamic, otherwise false
  25286. */
  25287. isDynamic(): boolean;
  25288. /**
  25289. * The data cache on JS side.
  25290. * @returns the underlying data as a float array
  25291. */
  25292. getData(): Float32Array;
  25293. /**
  25294. * The underlying WebGL Uniform buffer.
  25295. * @returns the webgl buffer
  25296. */
  25297. getBuffer(): Nullable<WebGLBuffer>;
  25298. /**
  25299. * std140 layout specifies how to align data within an UBO structure.
  25300. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25301. * for specs.
  25302. */
  25303. private _fillAlignment;
  25304. /**
  25305. * Adds an uniform in the buffer.
  25306. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25307. * for the layout to be correct !
  25308. * @param name Name of the uniform, as used in the uniform block in the shader.
  25309. * @param size Data size, or data directly.
  25310. */
  25311. addUniform(name: string, size: number | number[]): void;
  25312. /**
  25313. * Adds a Matrix 4x4 to the uniform buffer.
  25314. * @param name Name of the uniform, as used in the uniform block in the shader.
  25315. * @param mat A 4x4 matrix.
  25316. */
  25317. addMatrix(name: string, mat: Matrix): void;
  25318. /**
  25319. * Adds a vec2 to the uniform buffer.
  25320. * @param name Name of the uniform, as used in the uniform block in the shader.
  25321. * @param x Define the x component value of the vec2
  25322. * @param y Define the y component value of the vec2
  25323. */
  25324. addFloat2(name: string, x: number, y: number): void;
  25325. /**
  25326. * Adds a vec3 to the uniform buffer.
  25327. * @param name Name of the uniform, as used in the uniform block in the shader.
  25328. * @param x Define the x component value of the vec3
  25329. * @param y Define the y component value of the vec3
  25330. * @param z Define the z component value of the vec3
  25331. */
  25332. addFloat3(name: string, x: number, y: number, z: number): void;
  25333. /**
  25334. * Adds a vec3 to the uniform buffer.
  25335. * @param name Name of the uniform, as used in the uniform block in the shader.
  25336. * @param color Define the vec3 from a Color
  25337. */
  25338. addColor3(name: string, color: Color3): void;
  25339. /**
  25340. * Adds a vec4 to the uniform buffer.
  25341. * @param name Name of the uniform, as used in the uniform block in the shader.
  25342. * @param color Define the rgb components from a Color
  25343. * @param alpha Define the a component of the vec4
  25344. */
  25345. addColor4(name: string, color: Color3, alpha: number): void;
  25346. /**
  25347. * Adds a vec3 to the uniform buffer.
  25348. * @param name Name of the uniform, as used in the uniform block in the shader.
  25349. * @param vector Define the vec3 components from a Vector
  25350. */
  25351. addVector3(name: string, vector: Vector3): void;
  25352. /**
  25353. * Adds a Matrix 3x3 to the uniform buffer.
  25354. * @param name Name of the uniform, as used in the uniform block in the shader.
  25355. */
  25356. addMatrix3x3(name: string): void;
  25357. /**
  25358. * Adds a Matrix 2x2 to the uniform buffer.
  25359. * @param name Name of the uniform, as used in the uniform block in the shader.
  25360. */
  25361. addMatrix2x2(name: string): void;
  25362. /**
  25363. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25364. */
  25365. create(): void;
  25366. /** @hidden */
  25367. _rebuild(): void;
  25368. /**
  25369. * Updates the WebGL Uniform Buffer on the GPU.
  25370. * If the `dynamic` flag is set to true, no cache comparison is done.
  25371. * Otherwise, the buffer will be updated only if the cache differs.
  25372. */
  25373. update(): void;
  25374. /**
  25375. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25376. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25377. * @param data Define the flattened data
  25378. * @param size Define the size of the data.
  25379. */
  25380. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25381. private _updateMatrix3x3ForUniform;
  25382. private _updateMatrix3x3ForEffect;
  25383. private _updateMatrix2x2ForEffect;
  25384. private _updateMatrix2x2ForUniform;
  25385. private _updateFloatForEffect;
  25386. private _updateFloatForUniform;
  25387. private _updateFloat2ForEffect;
  25388. private _updateFloat2ForUniform;
  25389. private _updateFloat3ForEffect;
  25390. private _updateFloat3ForUniform;
  25391. private _updateFloat4ForEffect;
  25392. private _updateFloat4ForUniform;
  25393. private _updateMatrixForEffect;
  25394. private _updateMatrixForUniform;
  25395. private _updateVector3ForEffect;
  25396. private _updateVector3ForUniform;
  25397. private _updateVector4ForEffect;
  25398. private _updateVector4ForUniform;
  25399. private _updateColor3ForEffect;
  25400. private _updateColor3ForUniform;
  25401. private _updateColor4ForEffect;
  25402. private _updateColor4ForUniform;
  25403. /**
  25404. * Sets a sampler uniform on the effect.
  25405. * @param name Define the name of the sampler.
  25406. * @param texture Define the texture to set in the sampler
  25407. */
  25408. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25409. /**
  25410. * Directly updates the value of the uniform in the cache AND on the GPU.
  25411. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25412. * @param data Define the flattened data
  25413. */
  25414. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25415. /**
  25416. * Binds this uniform buffer to an effect.
  25417. * @param effect Define the effect to bind the buffer to
  25418. * @param name Name of the uniform block in the shader.
  25419. */
  25420. bindToEffect(effect: Effect, name: string): void;
  25421. /**
  25422. * Disposes the uniform buffer.
  25423. */
  25424. dispose(): void;
  25425. }
  25426. }
  25427. declare module BABYLON {
  25428. /**
  25429. * This represents the required contract to create a new type of texture loader.
  25430. */
  25431. export interface IInternalTextureLoader {
  25432. /**
  25433. * Defines wether the loader supports cascade loading the different faces.
  25434. */
  25435. supportCascades: boolean;
  25436. /**
  25437. * This returns if the loader support the current file information.
  25438. * @param extension defines the file extension of the file being loaded
  25439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25440. * @param fallback defines the fallback internal texture if any
  25441. * @param isBase64 defines whether the texture is encoded as a base64
  25442. * @param isBuffer defines whether the texture data are stored as a buffer
  25443. * @returns true if the loader can load the specified file
  25444. */
  25445. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25446. /**
  25447. * Transform the url before loading if required.
  25448. * @param rootUrl the url of the texture
  25449. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25450. * @returns the transformed texture
  25451. */
  25452. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25453. /**
  25454. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25455. * @param rootUrl the url of the texture
  25456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25457. * @returns the fallback texture
  25458. */
  25459. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25460. /**
  25461. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25462. * @param data contains the texture data
  25463. * @param texture defines the BabylonJS internal texture
  25464. * @param createPolynomials will be true if polynomials have been requested
  25465. * @param onLoad defines the callback to trigger once the texture is ready
  25466. * @param onError defines the callback to trigger in case of error
  25467. */
  25468. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25469. /**
  25470. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25471. * @param data contains the texture data
  25472. * @param texture defines the BabylonJS internal texture
  25473. * @param callback defines the method to call once ready to upload
  25474. */
  25475. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25476. }
  25477. }
  25478. declare module BABYLON {
  25479. /**
  25480. * Creation options of the multi render target texture.
  25481. */
  25482. export interface IMultiRenderTargetOptions {
  25483. /**
  25484. * Define if the texture needs to create mip maps after render.
  25485. */
  25486. generateMipMaps?: boolean;
  25487. /**
  25488. * Define the types of all the draw buffers we want to create
  25489. */
  25490. types?: number[];
  25491. /**
  25492. * Define the sampling modes of all the draw buffers we want to create
  25493. */
  25494. samplingModes?: number[];
  25495. /**
  25496. * Define if a depth buffer is required
  25497. */
  25498. generateDepthBuffer?: boolean;
  25499. /**
  25500. * Define if a stencil buffer is required
  25501. */
  25502. generateStencilBuffer?: boolean;
  25503. /**
  25504. * Define if a depth texture is required instead of a depth buffer
  25505. */
  25506. generateDepthTexture?: boolean;
  25507. /**
  25508. * Define the number of desired draw buffers
  25509. */
  25510. textureCount?: number;
  25511. /**
  25512. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25513. */
  25514. doNotChangeAspectRatio?: boolean;
  25515. /**
  25516. * Define the default type of the buffers we are creating
  25517. */
  25518. defaultType?: number;
  25519. }
  25520. /**
  25521. * A multi render target, like a render target provides the ability to render to a texture.
  25522. * Unlike the render target, it can render to several draw buffers in one draw.
  25523. * This is specially interesting in deferred rendering or for any effects requiring more than
  25524. * just one color from a single pass.
  25525. */
  25526. export class MultiRenderTarget extends RenderTargetTexture {
  25527. private _internalTextures;
  25528. private _textures;
  25529. private _multiRenderTargetOptions;
  25530. /**
  25531. * Get if draw buffers are currently supported by the used hardware and browser.
  25532. */
  25533. readonly isSupported: boolean;
  25534. /**
  25535. * Get the list of textures generated by the multi render target.
  25536. */
  25537. readonly textures: Texture[];
  25538. /**
  25539. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25540. */
  25541. readonly depthTexture: Texture;
  25542. /**
  25543. * Set the wrapping mode on U of all the textures we are rendering to.
  25544. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25545. */
  25546. wrapU: number;
  25547. /**
  25548. * Set the wrapping mode on V of all the textures we are rendering to.
  25549. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25550. */
  25551. wrapV: number;
  25552. /**
  25553. * Instantiate a new multi render target texture.
  25554. * A multi render target, like a render target provides the ability to render to a texture.
  25555. * Unlike the render target, it can render to several draw buffers in one draw.
  25556. * This is specially interesting in deferred rendering or for any effects requiring more than
  25557. * just one color from a single pass.
  25558. * @param name Define the name of the texture
  25559. * @param size Define the size of the buffers to render to
  25560. * @param count Define the number of target we are rendering into
  25561. * @param scene Define the scene the texture belongs to
  25562. * @param options Define the options used to create the multi render target
  25563. */
  25564. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25565. /** @hidden */
  25566. _rebuild(): void;
  25567. private _createInternalTextures;
  25568. private _createTextures;
  25569. /**
  25570. * Define the number of samples used if MSAA is enabled.
  25571. */
  25572. samples: number;
  25573. /**
  25574. * Resize all the textures in the multi render target.
  25575. * Be carrefull as it will recreate all the data in the new texture.
  25576. * @param size Define the new size
  25577. */
  25578. resize(size: any): void;
  25579. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25580. /**
  25581. * Dispose the render targets and their associated resources
  25582. */
  25583. dispose(): void;
  25584. /**
  25585. * Release all the underlying texture used as draw buffers.
  25586. */
  25587. releaseInternalTextures(): void;
  25588. }
  25589. }
  25590. declare module BABYLON {
  25591. /**
  25592. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25594. */
  25595. export class Analyser {
  25596. /**
  25597. * Gets or sets the smoothing
  25598. * @ignorenaming
  25599. */
  25600. SMOOTHING: number;
  25601. /**
  25602. * Gets or sets the FFT table size
  25603. * @ignorenaming
  25604. */
  25605. FFT_SIZE: number;
  25606. /**
  25607. * Gets or sets the bar graph amplitude
  25608. * @ignorenaming
  25609. */
  25610. BARGRAPHAMPLITUDE: number;
  25611. /**
  25612. * Gets or sets the position of the debug canvas
  25613. * @ignorenaming
  25614. */
  25615. DEBUGCANVASPOS: {
  25616. x: number;
  25617. y: number;
  25618. };
  25619. /**
  25620. * Gets or sets the debug canvas size
  25621. * @ignorenaming
  25622. */
  25623. DEBUGCANVASSIZE: {
  25624. width: number;
  25625. height: number;
  25626. };
  25627. private _byteFreqs;
  25628. private _byteTime;
  25629. private _floatFreqs;
  25630. private _webAudioAnalyser;
  25631. private _debugCanvas;
  25632. private _debugCanvasContext;
  25633. private _scene;
  25634. private _registerFunc;
  25635. private _audioEngine;
  25636. /**
  25637. * Creates a new analyser
  25638. * @param scene defines hosting scene
  25639. */
  25640. constructor(scene: Scene);
  25641. /**
  25642. * Get the number of data values you will have to play with for the visualization
  25643. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25644. * @returns a number
  25645. */
  25646. getFrequencyBinCount(): number;
  25647. /**
  25648. * Gets the current frequency data as a byte array
  25649. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25650. * @returns a Uint8Array
  25651. */
  25652. getByteFrequencyData(): Uint8Array;
  25653. /**
  25654. * Gets the current waveform as a byte array
  25655. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25656. * @returns a Uint8Array
  25657. */
  25658. getByteTimeDomainData(): Uint8Array;
  25659. /**
  25660. * Gets the current frequency data as a float array
  25661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25662. * @returns a Float32Array
  25663. */
  25664. getFloatFrequencyData(): Float32Array;
  25665. /**
  25666. * Renders the debug canvas
  25667. */
  25668. drawDebugCanvas(): void;
  25669. /**
  25670. * Stops rendering the debug canvas and removes it
  25671. */
  25672. stopDebugCanvas(): void;
  25673. /**
  25674. * Connects two audio nodes
  25675. * @param inputAudioNode defines first node to connect
  25676. * @param outputAudioNode defines second node to connect
  25677. */
  25678. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25679. /**
  25680. * Releases all associated resources
  25681. */
  25682. dispose(): void;
  25683. }
  25684. }
  25685. declare module BABYLON {
  25686. /**
  25687. * This represents an audio engine and it is responsible
  25688. * to play, synchronize and analyse sounds throughout the application.
  25689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25690. */
  25691. export interface IAudioEngine extends IDisposable {
  25692. /**
  25693. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25694. */
  25695. readonly canUseWebAudio: boolean;
  25696. /**
  25697. * Gets the current AudioContext if available.
  25698. */
  25699. readonly audioContext: Nullable<AudioContext>;
  25700. /**
  25701. * The master gain node defines the global audio volume of your audio engine.
  25702. */
  25703. readonly masterGain: GainNode;
  25704. /**
  25705. * Gets whether or not mp3 are supported by your browser.
  25706. */
  25707. readonly isMP3supported: boolean;
  25708. /**
  25709. * Gets whether or not ogg are supported by your browser.
  25710. */
  25711. readonly isOGGsupported: boolean;
  25712. /**
  25713. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25714. * @ignoreNaming
  25715. */
  25716. WarnedWebAudioUnsupported: boolean;
  25717. /**
  25718. * Defines if the audio engine relies on a custom unlocked button.
  25719. * In this case, the embedded button will not be displayed.
  25720. */
  25721. useCustomUnlockedButton: boolean;
  25722. /**
  25723. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25724. */
  25725. readonly unlocked: boolean;
  25726. /**
  25727. * Event raised when audio has been unlocked on the browser.
  25728. */
  25729. onAudioUnlockedObservable: Observable<AudioEngine>;
  25730. /**
  25731. * Event raised when audio has been locked on the browser.
  25732. */
  25733. onAudioLockedObservable: Observable<AudioEngine>;
  25734. /**
  25735. * Flags the audio engine in Locked state.
  25736. * This happens due to new browser policies preventing audio to autoplay.
  25737. */
  25738. lock(): void;
  25739. /**
  25740. * Unlocks the audio engine once a user action has been done on the dom.
  25741. * This is helpful to resume play once browser policies have been satisfied.
  25742. */
  25743. unlock(): void;
  25744. }
  25745. /**
  25746. * This represents the default audio engine used in babylon.
  25747. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25749. */
  25750. export class AudioEngine implements IAudioEngine {
  25751. private _audioContext;
  25752. private _audioContextInitialized;
  25753. private _muteButton;
  25754. private _hostElement;
  25755. /**
  25756. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25757. */
  25758. canUseWebAudio: boolean;
  25759. /**
  25760. * The master gain node defines the global audio volume of your audio engine.
  25761. */
  25762. masterGain: GainNode;
  25763. /**
  25764. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25765. * @ignoreNaming
  25766. */
  25767. WarnedWebAudioUnsupported: boolean;
  25768. /**
  25769. * Gets whether or not mp3 are supported by your browser.
  25770. */
  25771. isMP3supported: boolean;
  25772. /**
  25773. * Gets whether or not ogg are supported by your browser.
  25774. */
  25775. isOGGsupported: boolean;
  25776. /**
  25777. * Gets whether audio has been unlocked on the device.
  25778. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25779. * a user interaction has happened.
  25780. */
  25781. unlocked: boolean;
  25782. /**
  25783. * Defines if the audio engine relies on a custom unlocked button.
  25784. * In this case, the embedded button will not be displayed.
  25785. */
  25786. useCustomUnlockedButton: boolean;
  25787. /**
  25788. * Event raised when audio has been unlocked on the browser.
  25789. */
  25790. onAudioUnlockedObservable: Observable<AudioEngine>;
  25791. /**
  25792. * Event raised when audio has been locked on the browser.
  25793. */
  25794. onAudioLockedObservable: Observable<AudioEngine>;
  25795. /**
  25796. * Gets the current AudioContext if available.
  25797. */
  25798. readonly audioContext: Nullable<AudioContext>;
  25799. private _connectedAnalyser;
  25800. /**
  25801. * Instantiates a new audio engine.
  25802. *
  25803. * There should be only one per page as some browsers restrict the number
  25804. * of audio contexts you can create.
  25805. * @param hostElement defines the host element where to display the mute icon if necessary
  25806. */
  25807. constructor(hostElement?: Nullable<HTMLElement>);
  25808. /**
  25809. * Flags the audio engine in Locked state.
  25810. * This happens due to new browser policies preventing audio to autoplay.
  25811. */
  25812. lock(): void;
  25813. /**
  25814. * Unlocks the audio engine once a user action has been done on the dom.
  25815. * This is helpful to resume play once browser policies have been satisfied.
  25816. */
  25817. unlock(): void;
  25818. private _resumeAudioContext;
  25819. private _initializeAudioContext;
  25820. private _tryToRun;
  25821. private _triggerRunningState;
  25822. private _triggerSuspendedState;
  25823. private _displayMuteButton;
  25824. private _moveButtonToTopLeft;
  25825. private _onResize;
  25826. private _hideMuteButton;
  25827. /**
  25828. * Destroy and release the resources associated with the audio ccontext.
  25829. */
  25830. dispose(): void;
  25831. /**
  25832. * Gets the global volume sets on the master gain.
  25833. * @returns the global volume if set or -1 otherwise
  25834. */
  25835. getGlobalVolume(): number;
  25836. /**
  25837. * Sets the global volume of your experience (sets on the master gain).
  25838. * @param newVolume Defines the new global volume of the application
  25839. */
  25840. setGlobalVolume(newVolume: number): void;
  25841. /**
  25842. * Connect the audio engine to an audio analyser allowing some amazing
  25843. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25845. * @param analyser The analyser to connect to the engine
  25846. */
  25847. connectToAnalyser(analyser: Analyser): void;
  25848. }
  25849. }
  25850. declare module BABYLON {
  25851. /**
  25852. * Interface used to present a loading screen while loading a scene
  25853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25854. */
  25855. export interface ILoadingScreen {
  25856. /**
  25857. * Function called to display the loading screen
  25858. */
  25859. displayLoadingUI: () => void;
  25860. /**
  25861. * Function called to hide the loading screen
  25862. */
  25863. hideLoadingUI: () => void;
  25864. /**
  25865. * Gets or sets the color to use for the background
  25866. */
  25867. loadingUIBackgroundColor: string;
  25868. /**
  25869. * Gets or sets the text to display while loading
  25870. */
  25871. loadingUIText: string;
  25872. }
  25873. /**
  25874. * Class used for the default loading screen
  25875. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25876. */
  25877. export class DefaultLoadingScreen implements ILoadingScreen {
  25878. private _renderingCanvas;
  25879. private _loadingText;
  25880. private _loadingDivBackgroundColor;
  25881. private _loadingDiv;
  25882. private _loadingTextDiv;
  25883. /**
  25884. * Creates a new default loading screen
  25885. * @param _renderingCanvas defines the canvas used to render the scene
  25886. * @param _loadingText defines the default text to display
  25887. * @param _loadingDivBackgroundColor defines the default background color
  25888. */
  25889. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25890. /**
  25891. * Function called to display the loading screen
  25892. */
  25893. displayLoadingUI(): void;
  25894. /**
  25895. * Function called to hide the loading screen
  25896. */
  25897. hideLoadingUI(): void;
  25898. /**
  25899. * Gets or sets the text to display while loading
  25900. */
  25901. loadingUIText: string;
  25902. /**
  25903. * Gets or sets the color to use for the background
  25904. */
  25905. loadingUIBackgroundColor: string;
  25906. private _resizeLoadingUI;
  25907. }
  25908. }
  25909. declare module BABYLON {
  25910. /**
  25911. * Settings for finer control over video usage
  25912. */
  25913. export interface VideoTextureSettings {
  25914. /**
  25915. * Applies `autoplay` to video, if specified
  25916. */
  25917. autoPlay?: boolean;
  25918. /**
  25919. * Applies `loop` to video, if specified
  25920. */
  25921. loop?: boolean;
  25922. /**
  25923. * Automatically updates internal texture from video at every frame in the render loop
  25924. */
  25925. autoUpdateTexture: boolean;
  25926. /**
  25927. * Image src displayed during the video loading or until the user interacts with the video.
  25928. */
  25929. poster?: string;
  25930. }
  25931. /**
  25932. * If you want to display a video in your scene, this is the special texture for that.
  25933. * This special texture works similar to other textures, with the exception of a few parameters.
  25934. * @see https://doc.babylonjs.com/how_to/video_texture
  25935. */
  25936. export class VideoTexture extends Texture {
  25937. /**
  25938. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25939. */
  25940. readonly autoUpdateTexture: boolean;
  25941. /**
  25942. * The video instance used by the texture internally
  25943. */
  25944. readonly video: HTMLVideoElement;
  25945. private _onUserActionRequestedObservable;
  25946. /**
  25947. * Event triggerd when a dom action is required by the user to play the video.
  25948. * This happens due to recent changes in browser policies preventing video to auto start.
  25949. */
  25950. readonly onUserActionRequestedObservable: Observable<Texture>;
  25951. private _generateMipMaps;
  25952. private _engine;
  25953. private _stillImageCaptured;
  25954. private _displayingPosterTexture;
  25955. private _settings;
  25956. private _createInternalTextureOnEvent;
  25957. /**
  25958. * Creates a video texture.
  25959. * If you want to display a video in your scene, this is the special texture for that.
  25960. * This special texture works similar to other textures, with the exception of a few parameters.
  25961. * @see https://doc.babylonjs.com/how_to/video_texture
  25962. * @param name optional name, will detect from video source, if not defined
  25963. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25964. * @param scene is obviously the current scene.
  25965. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25966. * @param invertY is false by default but can be used to invert video on Y axis
  25967. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25968. * @param settings allows finer control over video usage
  25969. */
  25970. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25971. private _getName;
  25972. private _getVideo;
  25973. private _createInternalTexture;
  25974. private reset;
  25975. /**
  25976. * @hidden Internal method to initiate `update`.
  25977. */
  25978. _rebuild(): void;
  25979. /**
  25980. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25981. */
  25982. update(): void;
  25983. /**
  25984. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25985. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25986. */
  25987. updateTexture(isVisible: boolean): void;
  25988. protected _updateInternalTexture: () => void;
  25989. /**
  25990. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25991. * @param url New url.
  25992. */
  25993. updateURL(url: string): void;
  25994. /**
  25995. * Dispose the texture and release its associated resources.
  25996. */
  25997. dispose(): void;
  25998. /**
  25999. * Creates a video texture straight from a stream.
  26000. * @param scene Define the scene the texture should be created in
  26001. * @param stream Define the stream the texture should be created from
  26002. * @returns The created video texture as a promise
  26003. */
  26004. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26005. /**
  26006. * Creates a video texture straight from your WebCam video feed.
  26007. * @param scene Define the scene the texture should be created in
  26008. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26009. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26010. * @returns The created video texture as a promise
  26011. */
  26012. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26013. minWidth: number;
  26014. maxWidth: number;
  26015. minHeight: number;
  26016. maxHeight: number;
  26017. deviceId: string;
  26018. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26019. /**
  26020. * Creates a video texture straight from your WebCam video feed.
  26021. * @param scene Define the scene the texture should be created in
  26022. * @param onReady Define a callback to triggered once the texture will be ready
  26023. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26024. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26025. */
  26026. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26027. minWidth: number;
  26028. maxWidth: number;
  26029. minHeight: number;
  26030. maxHeight: number;
  26031. deviceId: string;
  26032. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26033. }
  26034. }
  26035. declare module BABYLON {
  26036. /**
  26037. * Interface for attribute information associated with buffer instanciation
  26038. */
  26039. export class InstancingAttributeInfo {
  26040. /**
  26041. * Index/offset of the attribute in the vertex shader
  26042. */
  26043. index: number;
  26044. /**
  26045. * size of the attribute, 1, 2, 3 or 4
  26046. */
  26047. attributeSize: number;
  26048. /**
  26049. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26050. * default is FLOAT
  26051. */
  26052. attribyteType: number;
  26053. /**
  26054. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26055. */
  26056. normalized: boolean;
  26057. /**
  26058. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26059. */
  26060. offset: number;
  26061. /**
  26062. * Name of the GLSL attribute, for debugging purpose only
  26063. */
  26064. attributeName: string;
  26065. }
  26066. /**
  26067. * Define options used to create a depth texture
  26068. */
  26069. export class DepthTextureCreationOptions {
  26070. /** Specifies whether or not a stencil should be allocated in the texture */
  26071. generateStencil?: boolean;
  26072. /** Specifies whether or not bilinear filtering is enable on the texture */
  26073. bilinearFiltering?: boolean;
  26074. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26075. comparisonFunction?: number;
  26076. /** Specifies if the created texture is a cube texture */
  26077. isCube?: boolean;
  26078. }
  26079. /**
  26080. * Class used to describe the capabilities of the engine relatively to the current browser
  26081. */
  26082. export class EngineCapabilities {
  26083. /** Maximum textures units per fragment shader */
  26084. maxTexturesImageUnits: number;
  26085. /** Maximum texture units per vertex shader */
  26086. maxVertexTextureImageUnits: number;
  26087. /** Maximum textures units in the entire pipeline */
  26088. maxCombinedTexturesImageUnits: number;
  26089. /** Maximum texture size */
  26090. maxTextureSize: number;
  26091. /** Maximum cube texture size */
  26092. maxCubemapTextureSize: number;
  26093. /** Maximum render texture size */
  26094. maxRenderTextureSize: number;
  26095. /** Maximum number of vertex attributes */
  26096. maxVertexAttribs: number;
  26097. /** Maximum number of varyings */
  26098. maxVaryingVectors: number;
  26099. /** Maximum number of uniforms per vertex shader */
  26100. maxVertexUniformVectors: number;
  26101. /** Maximum number of uniforms per fragment shader */
  26102. maxFragmentUniformVectors: number;
  26103. /** Defines if standard derivates (dx/dy) are supported */
  26104. standardDerivatives: boolean;
  26105. /** Defines if s3tc texture compression is supported */
  26106. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26107. /** Defines if pvrtc texture compression is supported */
  26108. pvrtc: any;
  26109. /** Defines if etc1 texture compression is supported */
  26110. etc1: any;
  26111. /** Defines if etc2 texture compression is supported */
  26112. etc2: any;
  26113. /** Defines if astc texture compression is supported */
  26114. astc: any;
  26115. /** Defines if float textures are supported */
  26116. textureFloat: boolean;
  26117. /** Defines if vertex array objects are supported */
  26118. vertexArrayObject: boolean;
  26119. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26120. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26121. /** Gets the maximum level of anisotropy supported */
  26122. maxAnisotropy: number;
  26123. /** Defines if instancing is supported */
  26124. instancedArrays: boolean;
  26125. /** Defines if 32 bits indices are supported */
  26126. uintIndices: boolean;
  26127. /** Defines if high precision shaders are supported */
  26128. highPrecisionShaderSupported: boolean;
  26129. /** Defines if depth reading in the fragment shader is supported */
  26130. fragmentDepthSupported: boolean;
  26131. /** Defines if float texture linear filtering is supported*/
  26132. textureFloatLinearFiltering: boolean;
  26133. /** Defines if rendering to float textures is supported */
  26134. textureFloatRender: boolean;
  26135. /** Defines if half float textures are supported*/
  26136. textureHalfFloat: boolean;
  26137. /** Defines if half float texture linear filtering is supported*/
  26138. textureHalfFloatLinearFiltering: boolean;
  26139. /** Defines if rendering to half float textures is supported */
  26140. textureHalfFloatRender: boolean;
  26141. /** Defines if textureLOD shader command is supported */
  26142. textureLOD: boolean;
  26143. /** Defines if draw buffers extension is supported */
  26144. drawBuffersExtension: boolean;
  26145. /** Defines if depth textures are supported */
  26146. depthTextureExtension: boolean;
  26147. /** Defines if float color buffer are supported */
  26148. colorBufferFloat: boolean;
  26149. /** Gets disjoint timer query extension (null if not supported) */
  26150. timerQuery: EXT_disjoint_timer_query;
  26151. /** Defines if timestamp can be used with timer query */
  26152. canUseTimestampForTimerQuery: boolean;
  26153. /** Function used to let the system compiles shaders in background */
  26154. parallelShaderCompile: {
  26155. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26156. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26157. COMPLETION_STATUS_KHR: number;
  26158. };
  26159. }
  26160. /** Interface defining initialization parameters for Engine class */
  26161. export interface EngineOptions extends WebGLContextAttributes {
  26162. /**
  26163. * Defines if the engine should no exceed a specified device ratio
  26164. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26165. */
  26166. limitDeviceRatio?: number;
  26167. /**
  26168. * Defines if webvr should be enabled automatically
  26169. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26170. */
  26171. autoEnableWebVR?: boolean;
  26172. /**
  26173. * Defines if webgl2 should be turned off even if supported
  26174. * @see http://doc.babylonjs.com/features/webgl2
  26175. */
  26176. disableWebGL2Support?: boolean;
  26177. /**
  26178. * Defines if webaudio should be initialized as well
  26179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26180. */
  26181. audioEngine?: boolean;
  26182. /**
  26183. * Defines if animations should run using a deterministic lock step
  26184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26185. */
  26186. deterministicLockstep?: boolean;
  26187. /** Defines the maximum steps to use with deterministic lock step mode */
  26188. lockstepMaxSteps?: number;
  26189. /**
  26190. * Defines that engine should ignore context lost events
  26191. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26192. */
  26193. doNotHandleContextLost?: boolean;
  26194. /**
  26195. * Defines that engine should ignore modifying touch action attribute and style
  26196. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26197. */
  26198. doNotHandleTouchAction?: boolean;
  26199. }
  26200. /**
  26201. * Defines the interface used by display changed events
  26202. */
  26203. export interface IDisplayChangedEventArgs {
  26204. /** Gets the vrDisplay object (if any) */
  26205. vrDisplay: Nullable<any>;
  26206. /** Gets a boolean indicating if webVR is supported */
  26207. vrSupported: boolean;
  26208. }
  26209. /**
  26210. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26211. */
  26212. export class Engine {
  26213. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26214. static ExceptionList: ({
  26215. key: string;
  26216. capture: string;
  26217. captureConstraint: number;
  26218. targets: string[];
  26219. } | {
  26220. key: string;
  26221. capture: null;
  26222. captureConstraint: null;
  26223. targets: string[];
  26224. })[];
  26225. /** Gets the list of created engines */
  26226. static readonly Instances: Engine[];
  26227. /**
  26228. * Gets the latest created engine
  26229. */
  26230. static readonly LastCreatedEngine: Nullable<Engine>;
  26231. /**
  26232. * Gets the latest created scene
  26233. */
  26234. static readonly LastCreatedScene: Nullable<Scene>;
  26235. /**
  26236. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26237. * @param flag defines which part of the materials must be marked as dirty
  26238. * @param predicate defines a predicate used to filter which materials should be affected
  26239. */
  26240. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26241. /**
  26242. * Hidden
  26243. */
  26244. static _TextureLoaders: IInternalTextureLoader[];
  26245. /** Defines that alpha blending is disabled */
  26246. static readonly ALPHA_DISABLE: number;
  26247. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26248. static readonly ALPHA_ADD: number;
  26249. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26250. static readonly ALPHA_COMBINE: number;
  26251. /** Defines that alpha blending to DEST - SRC * DEST */
  26252. static readonly ALPHA_SUBTRACT: number;
  26253. /** Defines that alpha blending to SRC * DEST */
  26254. static readonly ALPHA_MULTIPLY: number;
  26255. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26256. static readonly ALPHA_MAXIMIZED: number;
  26257. /** Defines that alpha blending to SRC + DEST */
  26258. static readonly ALPHA_ONEONE: number;
  26259. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26260. static readonly ALPHA_PREMULTIPLIED: number;
  26261. /**
  26262. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26263. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26264. */
  26265. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26266. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26267. static readonly ALPHA_INTERPOLATE: number;
  26268. /**
  26269. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26270. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26271. */
  26272. static readonly ALPHA_SCREENMODE: number;
  26273. /** Defines that the ressource is not delayed*/
  26274. static readonly DELAYLOADSTATE_NONE: number;
  26275. /** Defines that the ressource was successfully delay loaded */
  26276. static readonly DELAYLOADSTATE_LOADED: number;
  26277. /** Defines that the ressource is currently delay loading */
  26278. static readonly DELAYLOADSTATE_LOADING: number;
  26279. /** Defines that the ressource is delayed and has not started loading */
  26280. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26281. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26282. static readonly NEVER: number;
  26283. /** 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 */
  26284. static readonly ALWAYS: number;
  26285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26286. static readonly LESS: number;
  26287. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26288. static readonly EQUAL: number;
  26289. /** 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 */
  26290. static readonly LEQUAL: number;
  26291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26292. static readonly GREATER: number;
  26293. /** 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 */
  26294. static readonly GEQUAL: number;
  26295. /** 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 */
  26296. static readonly NOTEQUAL: number;
  26297. /** Passed to stencilOperation to specify that stencil value must be kept */
  26298. static readonly KEEP: number;
  26299. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26300. static readonly REPLACE: number;
  26301. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26302. static readonly INCR: number;
  26303. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26304. static readonly DECR: number;
  26305. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26306. static readonly INVERT: number;
  26307. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26308. static readonly INCR_WRAP: number;
  26309. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26310. static readonly DECR_WRAP: number;
  26311. /** Texture is not repeating outside of 0..1 UVs */
  26312. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26313. /** Texture is repeating outside of 0..1 UVs */
  26314. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26315. /** Texture is repeating and mirrored */
  26316. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26317. /** ALPHA */
  26318. static readonly TEXTUREFORMAT_ALPHA: number;
  26319. /** LUMINANCE */
  26320. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26321. /** LUMINANCE_ALPHA */
  26322. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26323. /** RGB */
  26324. static readonly TEXTUREFORMAT_RGB: number;
  26325. /** RGBA */
  26326. static readonly TEXTUREFORMAT_RGBA: number;
  26327. /** RED */
  26328. static readonly TEXTUREFORMAT_RED: number;
  26329. /** RED (2nd reference) */
  26330. static readonly TEXTUREFORMAT_R: number;
  26331. /** RG */
  26332. static readonly TEXTUREFORMAT_RG: number;
  26333. /** RED_INTEGER */
  26334. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26335. /** RED_INTEGER (2nd reference) */
  26336. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26337. /** RG_INTEGER */
  26338. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26339. /** RGB_INTEGER */
  26340. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26341. /** RGBA_INTEGER */
  26342. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26343. /** UNSIGNED_BYTE */
  26344. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26345. /** UNSIGNED_BYTE (2nd reference) */
  26346. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26347. /** FLOAT */
  26348. static readonly TEXTURETYPE_FLOAT: number;
  26349. /** HALF_FLOAT */
  26350. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26351. /** BYTE */
  26352. static readonly TEXTURETYPE_BYTE: number;
  26353. /** SHORT */
  26354. static readonly TEXTURETYPE_SHORT: number;
  26355. /** UNSIGNED_SHORT */
  26356. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26357. /** INT */
  26358. static readonly TEXTURETYPE_INT: number;
  26359. /** UNSIGNED_INT */
  26360. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26361. /** UNSIGNED_SHORT_4_4_4_4 */
  26362. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26363. /** UNSIGNED_SHORT_5_5_5_1 */
  26364. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26365. /** UNSIGNED_SHORT_5_6_5 */
  26366. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26367. /** UNSIGNED_INT_2_10_10_10_REV */
  26368. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26369. /** UNSIGNED_INT_24_8 */
  26370. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26371. /** UNSIGNED_INT_10F_11F_11F_REV */
  26372. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26373. /** UNSIGNED_INT_5_9_9_9_REV */
  26374. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26375. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26376. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26377. /** nearest is mag = nearest and min = nearest and mip = linear */
  26378. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26379. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26380. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26381. /** Trilinear is mag = linear and min = linear and mip = linear */
  26382. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26383. /** nearest is mag = nearest and min = nearest and mip = linear */
  26384. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26385. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26386. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26387. /** Trilinear is mag = linear and min = linear and mip = linear */
  26388. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26389. /** mag = nearest and min = nearest and mip = nearest */
  26390. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26391. /** mag = nearest and min = linear and mip = nearest */
  26392. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26393. /** mag = nearest and min = linear and mip = linear */
  26394. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26395. /** mag = nearest and min = linear and mip = none */
  26396. static readonly TEXTURE_NEAREST_LINEAR: number;
  26397. /** mag = nearest and min = nearest and mip = none */
  26398. static readonly TEXTURE_NEAREST_NEAREST: number;
  26399. /** mag = linear and min = nearest and mip = nearest */
  26400. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26401. /** mag = linear and min = nearest and mip = linear */
  26402. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26403. /** mag = linear and min = linear and mip = none */
  26404. static readonly TEXTURE_LINEAR_LINEAR: number;
  26405. /** mag = linear and min = nearest and mip = none */
  26406. static readonly TEXTURE_LINEAR_NEAREST: number;
  26407. /** Explicit coordinates mode */
  26408. static readonly TEXTURE_EXPLICIT_MODE: number;
  26409. /** Spherical coordinates mode */
  26410. static readonly TEXTURE_SPHERICAL_MODE: number;
  26411. /** Planar coordinates mode */
  26412. static readonly TEXTURE_PLANAR_MODE: number;
  26413. /** Cubic coordinates mode */
  26414. static readonly TEXTURE_CUBIC_MODE: number;
  26415. /** Projection coordinates mode */
  26416. static readonly TEXTURE_PROJECTION_MODE: number;
  26417. /** Skybox coordinates mode */
  26418. static readonly TEXTURE_SKYBOX_MODE: number;
  26419. /** Inverse Cubic coordinates mode */
  26420. static readonly TEXTURE_INVCUBIC_MODE: number;
  26421. /** Equirectangular coordinates mode */
  26422. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26423. /** Equirectangular Fixed coordinates mode */
  26424. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26425. /** Equirectangular Fixed Mirrored coordinates mode */
  26426. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26427. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26428. static readonly SCALEMODE_FLOOR: number;
  26429. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26430. static readonly SCALEMODE_NEAREST: number;
  26431. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26432. static readonly SCALEMODE_CEILING: number;
  26433. /**
  26434. * Returns the current version of the framework
  26435. */
  26436. static readonly Version: string;
  26437. /**
  26438. * Returns a string describing the current engine
  26439. */
  26440. readonly description: string;
  26441. /**
  26442. * Gets or sets the epsilon value used by collision engine
  26443. */
  26444. static CollisionsEpsilon: number;
  26445. /**
  26446. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26447. */
  26448. static ShadersRepository: string;
  26449. /**
  26450. * Method called to create the default loading screen.
  26451. * This can be overriden in your own app.
  26452. * @param canvas The rendering canvas element
  26453. * @returns The loading screen
  26454. */
  26455. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26456. /**
  26457. * Method called to create the default rescale post process on each engine.
  26458. */
  26459. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26460. /**
  26461. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26462. */
  26463. forcePOTTextures: boolean;
  26464. /**
  26465. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26466. */
  26467. isFullscreen: boolean;
  26468. /**
  26469. * Gets a boolean indicating if the pointer is currently locked
  26470. */
  26471. isPointerLock: boolean;
  26472. /**
  26473. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26474. */
  26475. cullBackFaces: boolean;
  26476. /**
  26477. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26478. */
  26479. renderEvenInBackground: boolean;
  26480. /**
  26481. * Gets or sets a boolean indicating that cache can be kept between frames
  26482. */
  26483. preventCacheWipeBetweenFrames: boolean;
  26484. /**
  26485. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26486. **/
  26487. enableOfflineSupport: boolean;
  26488. /**
  26489. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  26490. **/
  26491. disableManifestCheck: boolean;
  26492. /**
  26493. * Gets the list of created scenes
  26494. */
  26495. scenes: Scene[];
  26496. /**
  26497. * Event raised when a new scene is created
  26498. */
  26499. onNewSceneAddedObservable: Observable<Scene>;
  26500. /**
  26501. * Gets the list of created postprocesses
  26502. */
  26503. postProcesses: PostProcess[];
  26504. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26505. validateShaderPrograms: boolean;
  26506. /**
  26507. * Observable event triggered each time the rendering canvas is resized
  26508. */
  26509. onResizeObservable: Observable<Engine>;
  26510. /**
  26511. * Observable event triggered each time the canvas loses focus
  26512. */
  26513. onCanvasBlurObservable: Observable<Engine>;
  26514. /**
  26515. * Observable event triggered each time the canvas gains focus
  26516. */
  26517. onCanvasFocusObservable: Observable<Engine>;
  26518. /**
  26519. * Observable event triggered each time the canvas receives pointerout event
  26520. */
  26521. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26522. /**
  26523. * Observable event triggered before each texture is initialized
  26524. */
  26525. onBeforeTextureInitObservable: Observable<Texture>;
  26526. private _vrDisplay;
  26527. private _vrSupported;
  26528. private _oldSize;
  26529. private _oldHardwareScaleFactor;
  26530. private _vrExclusivePointerMode;
  26531. private _webVRInitPromise;
  26532. /**
  26533. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26534. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26535. */
  26536. readonly isInVRExclusivePointerMode: boolean;
  26537. /**
  26538. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26539. */
  26540. disableUniformBuffers: boolean;
  26541. /** @hidden */
  26542. _uniformBuffers: UniformBuffer[];
  26543. /**
  26544. * Gets a boolean indicating that the engine supports uniform buffers
  26545. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26546. */
  26547. readonly supportsUniformBuffers: boolean;
  26548. /**
  26549. * Observable raised when the engine begins a new frame
  26550. */
  26551. onBeginFrameObservable: Observable<Engine>;
  26552. /**
  26553. * If set, will be used to request the next animation frame for the render loop
  26554. */
  26555. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26556. /**
  26557. * Observable raised when the engine ends the current frame
  26558. */
  26559. onEndFrameObservable: Observable<Engine>;
  26560. /**
  26561. * Observable raised when the engine is about to compile a shader
  26562. */
  26563. onBeforeShaderCompilationObservable: Observable<Engine>;
  26564. /**
  26565. * Observable raised when the engine has jsut compiled a shader
  26566. */
  26567. onAfterShaderCompilationObservable: Observable<Engine>;
  26568. /** @hidden */
  26569. _gl: WebGLRenderingContext;
  26570. private _renderingCanvas;
  26571. private _windowIsBackground;
  26572. private _webGLVersion;
  26573. /**
  26574. * Gets a boolean indicating that only power of 2 textures are supported
  26575. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26576. */
  26577. readonly needPOTTextures: boolean;
  26578. /** @hidden */
  26579. _badOS: boolean;
  26580. /** @hidden */
  26581. _badDesktopOS: boolean;
  26582. /**
  26583. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26584. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26585. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26586. */
  26587. disableTextureBindingOptimization: boolean;
  26588. /**
  26589. * Gets the audio engine
  26590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26591. * @ignorenaming
  26592. */
  26593. static audioEngine: IAudioEngine;
  26594. /**
  26595. * Default AudioEngine factory responsible of creating the Audio Engine.
  26596. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26597. */
  26598. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26599. /**
  26600. * Default offline support factory responsible of creating a tool used to store data locally.
  26601. * By default, this will create a Database object if the workload has been embedded.
  26602. */
  26603. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26604. private _onFocus;
  26605. private _onBlur;
  26606. private _onCanvasPointerOut;
  26607. private _onCanvasBlur;
  26608. private _onCanvasFocus;
  26609. private _onFullscreenChange;
  26610. private _onPointerLockChange;
  26611. private _onVRDisplayPointerRestricted;
  26612. private _onVRDisplayPointerUnrestricted;
  26613. private _onVrDisplayConnect;
  26614. private _onVrDisplayDisconnect;
  26615. private _onVrDisplayPresentChange;
  26616. /**
  26617. * Observable signaled when VR display mode changes
  26618. */
  26619. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26620. /**
  26621. * Observable signaled when VR request present is complete
  26622. */
  26623. onVRRequestPresentComplete: Observable<boolean>;
  26624. /**
  26625. * Observable signaled when VR request present starts
  26626. */
  26627. onVRRequestPresentStart: Observable<Engine>;
  26628. private _hardwareScalingLevel;
  26629. /** @hidden */
  26630. protected _caps: EngineCapabilities;
  26631. private _pointerLockRequested;
  26632. private _isStencilEnable;
  26633. private _colorWrite;
  26634. private _loadingScreen;
  26635. /** @hidden */
  26636. _drawCalls: PerfCounter;
  26637. /** @hidden */
  26638. _textureCollisions: PerfCounter;
  26639. private _glVersion;
  26640. private _glRenderer;
  26641. private _glVendor;
  26642. private _videoTextureSupported;
  26643. private _renderingQueueLaunched;
  26644. private _activeRenderLoops;
  26645. private _deterministicLockstep;
  26646. private _lockstepMaxSteps;
  26647. /**
  26648. * Observable signaled when a context lost event is raised
  26649. */
  26650. onContextLostObservable: Observable<Engine>;
  26651. /**
  26652. * Observable signaled when a context restored event is raised
  26653. */
  26654. onContextRestoredObservable: Observable<Engine>;
  26655. private _onContextLost;
  26656. private _onContextRestored;
  26657. private _contextWasLost;
  26658. private _doNotHandleContextLost;
  26659. /**
  26660. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26662. */
  26663. doNotHandleContextLost: boolean;
  26664. private _performanceMonitor;
  26665. private _fps;
  26666. private _deltaTime;
  26667. /**
  26668. * Turn this value on if you want to pause FPS computation when in background
  26669. */
  26670. disablePerformanceMonitorInBackground: boolean;
  26671. /**
  26672. * Gets the performance monitor attached to this engine
  26673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26674. */
  26675. readonly performanceMonitor: PerformanceMonitor;
  26676. /** @hidden */
  26677. protected _depthCullingState: _DepthCullingState;
  26678. /** @hidden */
  26679. protected _stencilState: _StencilState;
  26680. /** @hidden */
  26681. protected _alphaState: _AlphaState;
  26682. /** @hidden */
  26683. protected _alphaMode: number;
  26684. protected _internalTexturesCache: InternalTexture[];
  26685. /** @hidden */
  26686. protected _activeChannel: number;
  26687. private _currentTextureChannel;
  26688. /** @hidden */
  26689. protected _boundTexturesCache: {
  26690. [key: string]: Nullable<InternalTexture>;
  26691. };
  26692. /** @hidden */
  26693. protected _currentEffect: Nullable<Effect>;
  26694. /** @hidden */
  26695. protected _currentProgram: Nullable<WebGLProgram>;
  26696. private _compiledEffects;
  26697. private _vertexAttribArraysEnabled;
  26698. /** @hidden */
  26699. protected _cachedViewport: Nullable<Viewport>;
  26700. private _cachedVertexArrayObject;
  26701. /** @hidden */
  26702. protected _cachedVertexBuffers: any;
  26703. /** @hidden */
  26704. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26705. /** @hidden */
  26706. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26707. /** @hidden */
  26708. protected _currentRenderTarget: Nullable<InternalTexture>;
  26709. private _uintIndicesCurrentlySet;
  26710. private _currentBoundBuffer;
  26711. /** @hidden */
  26712. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26713. private _currentBufferPointers;
  26714. private _currentInstanceLocations;
  26715. private _currentInstanceBuffers;
  26716. private _textureUnits;
  26717. private _firstBoundInternalTextureTracker;
  26718. private _lastBoundInternalTextureTracker;
  26719. private _workingCanvas;
  26720. private _workingContext;
  26721. private _rescalePostProcess;
  26722. private _dummyFramebuffer;
  26723. private _externalData;
  26724. private _bindedRenderFunction;
  26725. private _vaoRecordInProgress;
  26726. private _mustWipeVertexAttributes;
  26727. private _emptyTexture;
  26728. private _emptyCubeTexture;
  26729. private _emptyTexture3D;
  26730. /** @hidden */
  26731. _frameHandler: number;
  26732. private _nextFreeTextureSlots;
  26733. private _maxSimultaneousTextures;
  26734. private _activeRequests;
  26735. private _texturesSupported;
  26736. private _textureFormatInUse;
  26737. /**
  26738. * Gets the list of texture formats supported
  26739. */
  26740. readonly texturesSupported: Array<string>;
  26741. /**
  26742. * Gets the list of texture formats in use
  26743. */
  26744. readonly textureFormatInUse: Nullable<string>;
  26745. /**
  26746. * Gets the current viewport
  26747. */
  26748. readonly currentViewport: Nullable<Viewport>;
  26749. /**
  26750. * Gets the default empty texture
  26751. */
  26752. readonly emptyTexture: InternalTexture;
  26753. /**
  26754. * Gets the default empty 3D texture
  26755. */
  26756. readonly emptyTexture3D: InternalTexture;
  26757. /**
  26758. * Gets the default empty cube texture
  26759. */
  26760. readonly emptyCubeTexture: InternalTexture;
  26761. /**
  26762. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26763. */
  26764. readonly premultipliedAlpha: boolean;
  26765. /**
  26766. * Creates a new engine
  26767. * @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
  26768. * @param antialias defines enable antialiasing (default: false)
  26769. * @param options defines further options to be sent to the getContext() function
  26770. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26771. */
  26772. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26773. private _disableTouchAction;
  26774. private _rebuildInternalTextures;
  26775. private _rebuildEffects;
  26776. /**
  26777. * Gets a boolean indicating if all created effects are ready
  26778. * @returns true if all effects are ready
  26779. */
  26780. areAllEffectsReady(): boolean;
  26781. private _rebuildBuffers;
  26782. private _initGLContext;
  26783. /**
  26784. * Gets version of the current webGL context
  26785. */
  26786. readonly webGLVersion: number;
  26787. /**
  26788. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26789. */
  26790. readonly isStencilEnable: boolean;
  26791. private _prepareWorkingCanvas;
  26792. /**
  26793. * Reset the texture cache to empty state
  26794. */
  26795. resetTextureCache(): void;
  26796. /**
  26797. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26798. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26799. * @returns true if engine is in deterministic lock step mode
  26800. */
  26801. isDeterministicLockStep(): boolean;
  26802. /**
  26803. * Gets the max steps when engine is running in deterministic lock step
  26804. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26805. * @returns the max steps
  26806. */
  26807. getLockstepMaxSteps(): number;
  26808. /**
  26809. * Gets an object containing information about the current webGL context
  26810. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26811. */
  26812. getGlInfo(): {
  26813. vendor: string;
  26814. renderer: string;
  26815. version: string;
  26816. };
  26817. /**
  26818. * Gets current aspect ratio
  26819. * @param camera defines the camera to use to get the aspect ratio
  26820. * @param useScreen defines if screen size must be used (or the current render target if any)
  26821. * @returns a number defining the aspect ratio
  26822. */
  26823. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26824. /**
  26825. * Gets current screen aspect ratio
  26826. * @returns a number defining the aspect ratio
  26827. */
  26828. getScreenAspectRatio(): number;
  26829. /**
  26830. * Gets the current render width
  26831. * @param useScreen defines if screen size must be used (or the current render target if any)
  26832. * @returns a number defining the current render width
  26833. */
  26834. getRenderWidth(useScreen?: boolean): number;
  26835. /**
  26836. * Gets the current render height
  26837. * @param useScreen defines if screen size must be used (or the current render target if any)
  26838. * @returns a number defining the current render height
  26839. */
  26840. getRenderHeight(useScreen?: boolean): number;
  26841. /**
  26842. * Gets the HTML canvas attached with the current webGL context
  26843. * @returns a HTML canvas
  26844. */
  26845. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26846. /**
  26847. * Gets the client rect of the HTML canvas attached with the current webGL context
  26848. * @returns a client rectanglee
  26849. */
  26850. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26851. /**
  26852. * Defines the hardware scaling level.
  26853. * By default the hardware scaling level is computed from the window device ratio.
  26854. * 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.
  26855. * @param level defines the level to use
  26856. */
  26857. setHardwareScalingLevel(level: number): void;
  26858. /**
  26859. * Gets the current hardware scaling level.
  26860. * By default the hardware scaling level is computed from the window device ratio.
  26861. * 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.
  26862. * @returns a number indicating the current hardware scaling level
  26863. */
  26864. getHardwareScalingLevel(): number;
  26865. /**
  26866. * Gets the list of loaded textures
  26867. * @returns an array containing all loaded textures
  26868. */
  26869. getLoadedTexturesCache(): InternalTexture[];
  26870. /**
  26871. * Gets the object containing all engine capabilities
  26872. * @returns the EngineCapabilities object
  26873. */
  26874. getCaps(): EngineCapabilities;
  26875. /**
  26876. * Gets the current depth function
  26877. * @returns a number defining the depth function
  26878. */
  26879. getDepthFunction(): Nullable<number>;
  26880. /**
  26881. * Sets the current depth function
  26882. * @param depthFunc defines the function to use
  26883. */
  26884. setDepthFunction(depthFunc: number): void;
  26885. /**
  26886. * Sets the current depth function to GREATER
  26887. */
  26888. setDepthFunctionToGreater(): void;
  26889. /**
  26890. * Sets the current depth function to GEQUAL
  26891. */
  26892. setDepthFunctionToGreaterOrEqual(): void;
  26893. /**
  26894. * Sets the current depth function to LESS
  26895. */
  26896. setDepthFunctionToLess(): void;
  26897. /**
  26898. * Sets the current depth function to LEQUAL
  26899. */
  26900. setDepthFunctionToLessOrEqual(): void;
  26901. /**
  26902. * Gets a boolean indicating if stencil buffer is enabled
  26903. * @returns the current stencil buffer state
  26904. */
  26905. getStencilBuffer(): boolean;
  26906. /**
  26907. * Enable or disable the stencil buffer
  26908. * @param enable defines if the stencil buffer must be enabled or disabled
  26909. */
  26910. setStencilBuffer(enable: boolean): void;
  26911. /**
  26912. * Gets the current stencil mask
  26913. * @returns a number defining the new stencil mask to use
  26914. */
  26915. getStencilMask(): number;
  26916. /**
  26917. * Sets the current stencil mask
  26918. * @param mask defines the new stencil mask to use
  26919. */
  26920. setStencilMask(mask: number): void;
  26921. /**
  26922. * Gets the current stencil function
  26923. * @returns a number defining the stencil function to use
  26924. */
  26925. getStencilFunction(): number;
  26926. /**
  26927. * Gets the current stencil reference value
  26928. * @returns a number defining the stencil reference value to use
  26929. */
  26930. getStencilFunctionReference(): number;
  26931. /**
  26932. * Gets the current stencil mask
  26933. * @returns a number defining the stencil mask to use
  26934. */
  26935. getStencilFunctionMask(): number;
  26936. /**
  26937. * Sets the current stencil function
  26938. * @param stencilFunc defines the new stencil function to use
  26939. */
  26940. setStencilFunction(stencilFunc: number): void;
  26941. /**
  26942. * Sets the current stencil reference
  26943. * @param reference defines the new stencil reference to use
  26944. */
  26945. setStencilFunctionReference(reference: number): void;
  26946. /**
  26947. * Sets the current stencil mask
  26948. * @param mask defines the new stencil mask to use
  26949. */
  26950. setStencilFunctionMask(mask: number): void;
  26951. /**
  26952. * Gets the current stencil operation when stencil fails
  26953. * @returns a number defining stencil operation to use when stencil fails
  26954. */
  26955. getStencilOperationFail(): number;
  26956. /**
  26957. * Gets the current stencil operation when depth fails
  26958. * @returns a number defining stencil operation to use when depth fails
  26959. */
  26960. getStencilOperationDepthFail(): number;
  26961. /**
  26962. * Gets the current stencil operation when stencil passes
  26963. * @returns a number defining stencil operation to use when stencil passes
  26964. */
  26965. getStencilOperationPass(): number;
  26966. /**
  26967. * Sets the stencil operation to use when stencil fails
  26968. * @param operation defines the stencil operation to use when stencil fails
  26969. */
  26970. setStencilOperationFail(operation: number): void;
  26971. /**
  26972. * Sets the stencil operation to use when depth fails
  26973. * @param operation defines the stencil operation to use when depth fails
  26974. */
  26975. setStencilOperationDepthFail(operation: number): void;
  26976. /**
  26977. * Sets the stencil operation to use when stencil passes
  26978. * @param operation defines the stencil operation to use when stencil passes
  26979. */
  26980. setStencilOperationPass(operation: number): void;
  26981. /**
  26982. * Sets a boolean indicating if the dithering state is enabled or disabled
  26983. * @param value defines the dithering state
  26984. */
  26985. setDitheringState(value: boolean): void;
  26986. /**
  26987. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26988. * @param value defines the rasterizer state
  26989. */
  26990. setRasterizerState(value: boolean): void;
  26991. /**
  26992. * stop executing a render loop function and remove it from the execution array
  26993. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26994. */
  26995. stopRenderLoop(renderFunction?: () => void): void;
  26996. /** @hidden */
  26997. _renderLoop(): void;
  26998. /**
  26999. * Register and execute a render loop. The engine can have more than one render function
  27000. * @param renderFunction defines the function to continuously execute
  27001. */
  27002. runRenderLoop(renderFunction: () => void): void;
  27003. /**
  27004. * Toggle full screen mode
  27005. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27006. */
  27007. switchFullscreen(requestPointerLock: boolean): void;
  27008. /**
  27009. * Enters full screen mode
  27010. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27011. */
  27012. enterFullscreen(requestPointerLock: boolean): void;
  27013. /**
  27014. * Exits full screen mode
  27015. */
  27016. exitFullscreen(): void;
  27017. /**
  27018. * Clear the current render buffer or the current render target (if any is set up)
  27019. * @param color defines the color to use
  27020. * @param backBuffer defines if the back buffer must be cleared
  27021. * @param depth defines if the depth buffer must be cleared
  27022. * @param stencil defines if the stencil buffer must be cleared
  27023. */
  27024. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27025. /**
  27026. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27027. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27028. * @param y defines the y-coordinate of the corner of the clear rectangle
  27029. * @param width defines the width of the clear rectangle
  27030. * @param height defines the height of the clear rectangle
  27031. * @param clearColor defines the clear color
  27032. */
  27033. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27034. /**
  27035. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27036. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27037. * @param y defines the y-coordinate of the corner of the clear rectangle
  27038. * @param width defines the width of the clear rectangle
  27039. * @param height defines the height of the clear rectangle
  27040. */
  27041. enableScissor(x: number, y: number, width: number, height: number): void;
  27042. /**
  27043. * Disable previously set scissor test rectangle
  27044. */
  27045. disableScissor(): void;
  27046. private _viewportCached;
  27047. /** @hidden */
  27048. _viewport(x: number, y: number, width: number, height: number): void;
  27049. /**
  27050. * Set the WebGL's viewport
  27051. * @param viewport defines the viewport element to be used
  27052. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27053. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27054. */
  27055. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27056. /**
  27057. * Directly set the WebGL Viewport
  27058. * @param x defines the x coordinate of the viewport (in screen space)
  27059. * @param y defines the y coordinate of the viewport (in screen space)
  27060. * @param width defines the width of the viewport (in screen space)
  27061. * @param height defines the height of the viewport (in screen space)
  27062. * @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
  27063. */
  27064. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27065. /**
  27066. * Begin a new frame
  27067. */
  27068. beginFrame(): void;
  27069. /**
  27070. * Enf the current frame
  27071. */
  27072. endFrame(): void;
  27073. /**
  27074. * Resize the view according to the canvas' size
  27075. */
  27076. resize(): void;
  27077. /**
  27078. * Force a specific size of the canvas
  27079. * @param width defines the new canvas' width
  27080. * @param height defines the new canvas' height
  27081. */
  27082. setSize(width: number, height: number): void;
  27083. /**
  27084. * Gets a boolean indicating if a webVR device was detected
  27085. * @returns true if a webVR device was detected
  27086. */
  27087. isVRDevicePresent(): boolean;
  27088. /**
  27089. * Gets the current webVR device
  27090. * @returns the current webVR device (or null)
  27091. */
  27092. getVRDevice(): any;
  27093. /**
  27094. * Initializes a webVR display and starts listening to display change events
  27095. * The onVRDisplayChangedObservable will be notified upon these changes
  27096. * @returns The onVRDisplayChangedObservable
  27097. */
  27098. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27099. /**
  27100. * Initializes a webVR display and starts listening to display change events
  27101. * The onVRDisplayChangedObservable will be notified upon these changes
  27102. * @returns A promise containing a VRDisplay and if vr is supported
  27103. */
  27104. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27105. /**
  27106. * Call this function to switch to webVR mode
  27107. * Will do nothing if webVR is not supported or if there is no webVR device
  27108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27109. */
  27110. enableVR(): void;
  27111. /**
  27112. * Call this function to leave webVR mode
  27113. * Will do nothing if webVR is not supported or if there is no webVR device
  27114. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27115. */
  27116. disableVR(): void;
  27117. private _onVRFullScreenTriggered;
  27118. private _getVRDisplaysAsync;
  27119. /**
  27120. * Binds the frame buffer to the specified texture.
  27121. * @param texture The texture to render to or null for the default canvas
  27122. * @param faceIndex The face of the texture to render to in case of cube texture
  27123. * @param requiredWidth The width of the target to render to
  27124. * @param requiredHeight The height of the target to render to
  27125. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27126. * @param depthStencilTexture The depth stencil texture to use to render
  27127. * @param lodLevel defines le lod level to bind to the frame buffer
  27128. */
  27129. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27130. private bindUnboundFramebuffer;
  27131. /**
  27132. * Unbind the current render target texture from the webGL context
  27133. * @param texture defines the render target texture to unbind
  27134. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27135. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27136. */
  27137. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27138. /**
  27139. * Unbind a list of render target textures from the webGL context
  27140. * This is used only when drawBuffer extension or webGL2 are active
  27141. * @param textures defines the render target textures to unbind
  27142. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27143. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27144. */
  27145. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27146. /**
  27147. * Force the mipmap generation for the given render target texture
  27148. * @param texture defines the render target texture to use
  27149. */
  27150. generateMipMapsForCubemap(texture: InternalTexture): void;
  27151. /**
  27152. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27153. */
  27154. flushFramebuffer(): void;
  27155. /**
  27156. * Unbind the current render target and bind the default framebuffer
  27157. */
  27158. restoreDefaultFramebuffer(): void;
  27159. /**
  27160. * Create an uniform buffer
  27161. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27162. * @param elements defines the content of the uniform buffer
  27163. * @returns the webGL uniform buffer
  27164. */
  27165. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27166. /**
  27167. * Create a dynamic uniform buffer
  27168. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27169. * @param elements defines the content of the uniform buffer
  27170. * @returns the webGL uniform buffer
  27171. */
  27172. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27173. /**
  27174. * Update an existing uniform buffer
  27175. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27176. * @param uniformBuffer defines the target uniform buffer
  27177. * @param elements defines the content to update
  27178. * @param offset defines the offset in the uniform buffer where update should start
  27179. * @param count defines the size of the data to update
  27180. */
  27181. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27182. private _resetVertexBufferBinding;
  27183. /**
  27184. * Creates a vertex buffer
  27185. * @param data the data for the vertex buffer
  27186. * @returns the new WebGL static buffer
  27187. */
  27188. createVertexBuffer(data: DataArray): WebGLBuffer;
  27189. /**
  27190. * Creates a dynamic vertex buffer
  27191. * @param data the data for the dynamic vertex buffer
  27192. * @returns the new WebGL dynamic buffer
  27193. */
  27194. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27195. /**
  27196. * Update a dynamic index buffer
  27197. * @param indexBuffer defines the target index buffer
  27198. * @param indices defines the data to update
  27199. * @param offset defines the offset in the target index buffer where update should start
  27200. */
  27201. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27202. /**
  27203. * Updates a dynamic vertex buffer.
  27204. * @param vertexBuffer the vertex buffer to update
  27205. * @param data the data used to update the vertex buffer
  27206. * @param byteOffset the byte offset of the data
  27207. * @param byteLength the byte length of the data
  27208. */
  27209. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27210. private _resetIndexBufferBinding;
  27211. /**
  27212. * Creates a new index buffer
  27213. * @param indices defines the content of the index buffer
  27214. * @param updatable defines if the index buffer must be updatable
  27215. * @returns a new webGL buffer
  27216. */
  27217. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27218. /**
  27219. * Bind a webGL buffer to the webGL context
  27220. * @param buffer defines the buffer to bind
  27221. */
  27222. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27223. /**
  27224. * Bind an uniform buffer to the current webGL context
  27225. * @param buffer defines the buffer to bind
  27226. */
  27227. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27228. /**
  27229. * Bind a buffer to the current webGL context at a given location
  27230. * @param buffer defines the buffer to bind
  27231. * @param location defines the index where to bind the buffer
  27232. */
  27233. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27234. /**
  27235. * Bind a specific block at a given index in a specific shader program
  27236. * @param shaderProgram defines the shader program
  27237. * @param blockName defines the block name
  27238. * @param index defines the index where to bind the block
  27239. */
  27240. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27241. private bindIndexBuffer;
  27242. private bindBuffer;
  27243. /**
  27244. * update the bound buffer with the given data
  27245. * @param data defines the data to update
  27246. */
  27247. updateArrayBuffer(data: Float32Array): void;
  27248. private _vertexAttribPointer;
  27249. private _bindIndexBufferWithCache;
  27250. private _bindVertexBuffersAttributes;
  27251. /**
  27252. * Records a vertex array object
  27253. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27254. * @param vertexBuffers defines the list of vertex buffers to store
  27255. * @param indexBuffer defines the index buffer to store
  27256. * @param effect defines the effect to store
  27257. * @returns the new vertex array object
  27258. */
  27259. recordVertexArrayObject(vertexBuffers: {
  27260. [key: string]: VertexBuffer;
  27261. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27262. /**
  27263. * Bind a specific vertex array object
  27264. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27265. * @param vertexArrayObject defines the vertex array object to bind
  27266. * @param indexBuffer defines the index buffer to bind
  27267. */
  27268. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27269. /**
  27270. * Bind webGl buffers directly to the webGL context
  27271. * @param vertexBuffer defines the vertex buffer to bind
  27272. * @param indexBuffer defines the index buffer to bind
  27273. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27274. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27275. * @param effect defines the effect associated with the vertex buffer
  27276. */
  27277. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27278. private _unbindVertexArrayObject;
  27279. /**
  27280. * Bind a list of vertex buffers to the webGL context
  27281. * @param vertexBuffers defines the list of vertex buffers to bind
  27282. * @param indexBuffer defines the index buffer to bind
  27283. * @param effect defines the effect associated with the vertex buffers
  27284. */
  27285. bindBuffers(vertexBuffers: {
  27286. [key: string]: Nullable<VertexBuffer>;
  27287. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27288. /**
  27289. * Unbind all instance attributes
  27290. */
  27291. unbindInstanceAttributes(): void;
  27292. /**
  27293. * Release and free the memory of a vertex array object
  27294. * @param vao defines the vertex array object to delete
  27295. */
  27296. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27297. /** @hidden */
  27298. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27299. /**
  27300. * Creates a webGL buffer to use with instanciation
  27301. * @param capacity defines the size of the buffer
  27302. * @returns the webGL buffer
  27303. */
  27304. createInstancesBuffer(capacity: number): WebGLBuffer;
  27305. /**
  27306. * Delete a webGL buffer used with instanciation
  27307. * @param buffer defines the webGL buffer to delete
  27308. */
  27309. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27310. /**
  27311. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27312. * @param instancesBuffer defines the webGL buffer to update and bind
  27313. * @param data defines the data to store in the buffer
  27314. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27315. */
  27316. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27317. /**
  27318. * Apply all cached states (depth, culling, stencil and alpha)
  27319. */
  27320. applyStates(): void;
  27321. /**
  27322. * Send a draw order
  27323. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27324. * @param indexStart defines the starting index
  27325. * @param indexCount defines the number of index to draw
  27326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27327. */
  27328. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27329. /**
  27330. * Draw a list of points
  27331. * @param verticesStart defines the index of first vertex to draw
  27332. * @param verticesCount defines the count of vertices to draw
  27333. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27334. */
  27335. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27336. /**
  27337. * Draw a list of unindexed primitives
  27338. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27339. * @param verticesStart defines the index of first vertex to draw
  27340. * @param verticesCount defines the count of vertices to draw
  27341. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27342. */
  27343. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27344. /**
  27345. * Draw a list of indexed primitives
  27346. * @param fillMode defines the primitive to use
  27347. * @param indexStart defines the starting index
  27348. * @param indexCount defines the number of index to draw
  27349. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27350. */
  27351. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27352. /**
  27353. * Draw a list of unindexed primitives
  27354. * @param fillMode defines the primitive to use
  27355. * @param verticesStart defines the index of first vertex to draw
  27356. * @param verticesCount defines the count of vertices to draw
  27357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27358. */
  27359. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27360. private _drawMode;
  27361. /** @hidden */
  27362. _releaseEffect(effect: Effect): void;
  27363. /** @hidden */
  27364. _deleteProgram(program: WebGLProgram): void;
  27365. /**
  27366. * Create a new effect (used to store vertex/fragment shaders)
  27367. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27368. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27369. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27370. * @param samplers defines an array of string used to represent textures
  27371. * @param defines defines the string containing the defines to use to compile the shaders
  27372. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27373. * @param onCompiled defines a function to call when the effect creation is successful
  27374. * @param onError defines a function to call when the effect creation has failed
  27375. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27376. * @returns the new Effect
  27377. */
  27378. 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;
  27379. private _compileShader;
  27380. private _compileRawShader;
  27381. /**
  27382. * Directly creates a webGL program
  27383. * @param vertexCode defines the vertex shader code to use
  27384. * @param fragmentCode defines the fragment shader code to use
  27385. * @param context defines the webGL context to use (if not set, the current one will be used)
  27386. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27387. * @returns the new webGL program
  27388. */
  27389. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27390. /**
  27391. * Creates a webGL program
  27392. * @param vertexCode defines the vertex shader code to use
  27393. * @param fragmentCode defines the fragment shader code to use
  27394. * @param defines defines the string containing the defines to use to compile the shaders
  27395. * @param context defines the webGL context to use (if not set, the current one will be used)
  27396. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27397. * @returns the new webGL program
  27398. */
  27399. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27400. private _createShaderProgram;
  27401. private _finalizeProgram;
  27402. /** @hidden */
  27403. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27404. /** @hidden */
  27405. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27406. /**
  27407. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27408. * @param shaderProgram defines the webGL program to use
  27409. * @param uniformsNames defines the list of uniform names
  27410. * @returns an array of webGL uniform locations
  27411. */
  27412. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27413. /**
  27414. * Gets the lsit of active attributes for a given webGL program
  27415. * @param shaderProgram defines the webGL program to use
  27416. * @param attributesNames defines the list of attribute names to get
  27417. * @returns an array of indices indicating the offset of each attribute
  27418. */
  27419. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27420. /**
  27421. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27422. * @param effect defines the effect to activate
  27423. */
  27424. enableEffect(effect: Nullable<Effect>): void;
  27425. /**
  27426. * Set the value of an uniform to an array of int32
  27427. * @param uniform defines the webGL uniform location where to store the value
  27428. * @param array defines the array of int32 to store
  27429. */
  27430. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27431. /**
  27432. * Set the value of an uniform to an array of int32 (stored as vec2)
  27433. * @param uniform defines the webGL uniform location where to store the value
  27434. * @param array defines the array of int32 to store
  27435. */
  27436. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27437. /**
  27438. * Set the value of an uniform to an array of int32 (stored as vec3)
  27439. * @param uniform defines the webGL uniform location where to store the value
  27440. * @param array defines the array of int32 to store
  27441. */
  27442. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27443. /**
  27444. * Set the value of an uniform to an array of int32 (stored as vec4)
  27445. * @param uniform defines the webGL uniform location where to store the value
  27446. * @param array defines the array of int32 to store
  27447. */
  27448. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27449. /**
  27450. * Set the value of an uniform to an array of float32
  27451. * @param uniform defines the webGL uniform location where to store the value
  27452. * @param array defines the array of float32 to store
  27453. */
  27454. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27455. /**
  27456. * Set the value of an uniform to an array of float32 (stored as vec2)
  27457. * @param uniform defines the webGL uniform location where to store the value
  27458. * @param array defines the array of float32 to store
  27459. */
  27460. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27461. /**
  27462. * Set the value of an uniform to an array of float32 (stored as vec3)
  27463. * @param uniform defines the webGL uniform location where to store the value
  27464. * @param array defines the array of float32 to store
  27465. */
  27466. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27467. /**
  27468. * Set the value of an uniform to an array of float32 (stored as vec4)
  27469. * @param uniform defines the webGL uniform location where to store the value
  27470. * @param array defines the array of float32 to store
  27471. */
  27472. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27473. /**
  27474. * Set the value of an uniform to an array of number
  27475. * @param uniform defines the webGL uniform location where to store the value
  27476. * @param array defines the array of number to store
  27477. */
  27478. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27479. /**
  27480. * Set the value of an uniform to an array of number (stored as vec2)
  27481. * @param uniform defines the webGL uniform location where to store the value
  27482. * @param array defines the array of number to store
  27483. */
  27484. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27485. /**
  27486. * Set the value of an uniform to an array of number (stored as vec3)
  27487. * @param uniform defines the webGL uniform location where to store the value
  27488. * @param array defines the array of number to store
  27489. */
  27490. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27491. /**
  27492. * Set the value of an uniform to an array of number (stored as vec4)
  27493. * @param uniform defines the webGL uniform location where to store the value
  27494. * @param array defines the array of number to store
  27495. */
  27496. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27497. /**
  27498. * Set the value of an uniform to an array of float32 (stored as matrices)
  27499. * @param uniform defines the webGL uniform location where to store the value
  27500. * @param matrices defines the array of float32 to store
  27501. */
  27502. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27503. /**
  27504. * Set the value of an uniform to a matrix
  27505. * @param uniform defines the webGL uniform location where to store the value
  27506. * @param matrix defines the matrix to store
  27507. */
  27508. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27509. /**
  27510. * Set the value of an uniform to a matrix (3x3)
  27511. * @param uniform defines the webGL uniform location where to store the value
  27512. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27513. */
  27514. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27515. /**
  27516. * Set the value of an uniform to a matrix (2x2)
  27517. * @param uniform defines the webGL uniform location where to store the value
  27518. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27519. */
  27520. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27521. /**
  27522. * Set the value of an uniform to a number (int)
  27523. * @param uniform defines the webGL uniform location where to store the value
  27524. * @param value defines the int number to store
  27525. */
  27526. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27527. /**
  27528. * Set the value of an uniform to a number (float)
  27529. * @param uniform defines the webGL uniform location where to store the value
  27530. * @param value defines the float number to store
  27531. */
  27532. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27533. /**
  27534. * Set the value of an uniform to a vec2
  27535. * @param uniform defines the webGL uniform location where to store the value
  27536. * @param x defines the 1st component of the value
  27537. * @param y defines the 2nd component of the value
  27538. */
  27539. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27540. /**
  27541. * Set the value of an uniform to a vec3
  27542. * @param uniform defines the webGL uniform location where to store the value
  27543. * @param x defines the 1st component of the value
  27544. * @param y defines the 2nd component of the value
  27545. * @param z defines the 3rd component of the value
  27546. */
  27547. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27548. /**
  27549. * Set the value of an uniform to a boolean
  27550. * @param uniform defines the webGL uniform location where to store the value
  27551. * @param bool defines the boolean to store
  27552. */
  27553. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27554. /**
  27555. * Set the value of an uniform to a vec4
  27556. * @param uniform defines the webGL uniform location where to store the value
  27557. * @param x defines the 1st component of the value
  27558. * @param y defines the 2nd component of the value
  27559. * @param z defines the 3rd component of the value
  27560. * @param w defines the 4th component of the value
  27561. */
  27562. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27563. /**
  27564. * Set the value of an uniform to a Color3
  27565. * @param uniform defines the webGL uniform location where to store the value
  27566. * @param color3 defines the color to store
  27567. */
  27568. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27569. /**
  27570. * Set the value of an uniform to a Color3 and an alpha value
  27571. * @param uniform defines the webGL uniform location where to store the value
  27572. * @param color3 defines the color to store
  27573. * @param alpha defines the alpha component to store
  27574. */
  27575. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27576. /**
  27577. * Sets a Color4 on a uniform variable
  27578. * @param uniform defines the uniform location
  27579. * @param color4 defines the value to be set
  27580. */
  27581. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27582. /**
  27583. * Set various states to the webGL context
  27584. * @param culling defines backface culling state
  27585. * @param zOffset defines the value to apply to zOffset (0 by default)
  27586. * @param force defines if states must be applied even if cache is up to date
  27587. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27588. */
  27589. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27590. /**
  27591. * Set the z offset to apply to current rendering
  27592. * @param value defines the offset to apply
  27593. */
  27594. setZOffset(value: number): void;
  27595. /**
  27596. * Gets the current value of the zOffset
  27597. * @returns the current zOffset state
  27598. */
  27599. getZOffset(): number;
  27600. /**
  27601. * Enable or disable depth buffering
  27602. * @param enable defines the state to set
  27603. */
  27604. setDepthBuffer(enable: boolean): void;
  27605. /**
  27606. * Gets a boolean indicating if depth writing is enabled
  27607. * @returns the current depth writing state
  27608. */
  27609. getDepthWrite(): boolean;
  27610. /**
  27611. * Enable or disable depth writing
  27612. * @param enable defines the state to set
  27613. */
  27614. setDepthWrite(enable: boolean): void;
  27615. /**
  27616. * Enable or disable color writing
  27617. * @param enable defines the state to set
  27618. */
  27619. setColorWrite(enable: boolean): void;
  27620. /**
  27621. * Gets a boolean indicating if color writing is enabled
  27622. * @returns the current color writing state
  27623. */
  27624. getColorWrite(): boolean;
  27625. /**
  27626. * Sets alpha constants used by some alpha blending modes
  27627. * @param r defines the red component
  27628. * @param g defines the green component
  27629. * @param b defines the blue component
  27630. * @param a defines the alpha component
  27631. */
  27632. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27633. /**
  27634. * Sets the current alpha mode
  27635. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27636. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27637. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27638. */
  27639. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27640. /**
  27641. * Gets the current alpha mode
  27642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27643. * @returns the current alpha mode
  27644. */
  27645. getAlphaMode(): number;
  27646. /**
  27647. * Clears the list of texture accessible through engine.
  27648. * This can help preventing texture load conflict due to name collision.
  27649. */
  27650. clearInternalTexturesCache(): void;
  27651. /**
  27652. * Force the entire cache to be cleared
  27653. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27654. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27655. */
  27656. wipeCaches(bruteForce?: boolean): void;
  27657. /**
  27658. * Set the compressed texture format to use, based on the formats you have, and the formats
  27659. * supported by the hardware / browser.
  27660. *
  27661. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27662. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27663. * to API arguments needed to compressed textures. This puts the burden on the container
  27664. * generator to house the arcane code for determining these for current & future formats.
  27665. *
  27666. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27667. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27668. *
  27669. * Note: The result of this call is not taken into account when a texture is base64.
  27670. *
  27671. * @param formatsAvailable defines the list of those format families you have created
  27672. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27673. *
  27674. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27675. * @returns The extension selected.
  27676. */
  27677. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27678. private _getSamplingParameters;
  27679. private _partialLoadImg;
  27680. private _cascadeLoadImgs;
  27681. /** @hidden */
  27682. _createTexture(): WebGLTexture;
  27683. /**
  27684. * Usually called from Texture.ts.
  27685. * Passed information to create a WebGLTexture
  27686. * @param urlArg defines a value which contains one of the following:
  27687. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27688. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27689. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27690. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27691. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  27692. * @param scene needed for loading to the correct scene
  27693. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27694. * @param onLoad optional callback to be called upon successful completion
  27695. * @param onError optional callback to be called upon failure
  27696. * @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
  27697. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27698. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27699. * @param forcedExtension defines the extension to use to pick the right loader
  27700. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27701. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27702. */
  27703. 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;
  27704. private _rescaleTexture;
  27705. /**
  27706. * Update a raw texture
  27707. * @param texture defines the texture to update
  27708. * @param data defines the data to store in the texture
  27709. * @param format defines the format of the data
  27710. * @param invertY defines if data must be stored with Y axis inverted
  27711. * @param compression defines the compression used (null by default)
  27712. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27713. */
  27714. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27715. /**
  27716. * Creates a raw texture
  27717. * @param data defines the data to store in the texture
  27718. * @param width defines the width of the texture
  27719. * @param height defines the height of the texture
  27720. * @param format defines the format of the data
  27721. * @param generateMipMaps defines if the engine should generate the mip levels
  27722. * @param invertY defines if data must be stored with Y axis inverted
  27723. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27724. * @param compression defines the compression used (null by default)
  27725. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27726. * @returns the raw texture inside an InternalTexture
  27727. */
  27728. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27729. private _unpackFlipYCached;
  27730. /**
  27731. * In case you are sharing the context with other applications, it might
  27732. * be interested to not cache the unpack flip y state to ensure a consistent
  27733. * value would be set.
  27734. */
  27735. enableUnpackFlipYCached: boolean;
  27736. /** @hidden */
  27737. _unpackFlipY(value: boolean): void;
  27738. /** @hidden */
  27739. _getUnpackAlignement(): number;
  27740. /**
  27741. * Creates a dynamic texture
  27742. * @param width defines the width of the texture
  27743. * @param height defines the height of the texture
  27744. * @param generateMipMaps defines if the engine should generate the mip levels
  27745. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27746. * @returns the dynamic texture inside an InternalTexture
  27747. */
  27748. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27749. /**
  27750. * Update the sampling mode of a given texture
  27751. * @param samplingMode defines the required sampling mode
  27752. * @param texture defines the texture to update
  27753. */
  27754. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27755. /**
  27756. * Update the content of a dynamic texture
  27757. * @param texture defines the texture to update
  27758. * @param canvas defines the canvas containing the source
  27759. * @param invertY defines if data must be stored with Y axis inverted
  27760. * @param premulAlpha defines if alpha is stored as premultiplied
  27761. * @param format defines the format of the data
  27762. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27763. */
  27764. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27765. /**
  27766. * Update a video texture
  27767. * @param texture defines the texture to update
  27768. * @param video defines the video element to use
  27769. * @param invertY defines if data must be stored with Y axis inverted
  27770. */
  27771. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27772. /**
  27773. * Updates a depth texture Comparison Mode and Function.
  27774. * If the comparison Function is equal to 0, the mode will be set to none.
  27775. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27776. * @param texture The texture to set the comparison function for
  27777. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27778. */
  27779. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27780. private _setupDepthStencilTexture;
  27781. /**
  27782. * Creates a depth stencil texture.
  27783. * This is only available in WebGL 2 or with the depth texture extension available.
  27784. * @param size The size of face edge in the texture.
  27785. * @param options The options defining the texture.
  27786. * @returns The texture
  27787. */
  27788. createDepthStencilTexture(size: number | {
  27789. width: number;
  27790. height: number;
  27791. }, options: DepthTextureCreationOptions): InternalTexture;
  27792. /**
  27793. * Creates a depth stencil texture.
  27794. * This is only available in WebGL 2 or with the depth texture extension available.
  27795. * @param size The size of face edge in the texture.
  27796. * @param options The options defining the texture.
  27797. * @returns The texture
  27798. */
  27799. private _createDepthStencilTexture;
  27800. /**
  27801. * Creates a depth stencil cube texture.
  27802. * This is only available in WebGL 2.
  27803. * @param size The size of face edge in the cube texture.
  27804. * @param options The options defining the cube texture.
  27805. * @returns The cube texture
  27806. */
  27807. private _createDepthStencilCubeTexture;
  27808. /**
  27809. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27810. * @param renderTarget The render target to set the frame buffer for
  27811. */
  27812. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27813. /**
  27814. * Creates a new render target texture
  27815. * @param size defines the size of the texture
  27816. * @param options defines the options used to create the texture
  27817. * @returns a new render target texture stored in an InternalTexture
  27818. */
  27819. createRenderTargetTexture(size: number | {
  27820. width: number;
  27821. height: number;
  27822. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27823. /**
  27824. * Create a multi render target texture
  27825. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27826. * @param size defines the size of the texture
  27827. * @param options defines the creation options
  27828. * @returns the cube texture as an InternalTexture
  27829. */
  27830. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27831. private _setupFramebufferDepthAttachments;
  27832. /**
  27833. * Updates the sample count of a render target texture
  27834. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27835. * @param texture defines the texture to update
  27836. * @param samples defines the sample count to set
  27837. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27838. */
  27839. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27840. /**
  27841. * Update the sample count for a given multiple render target texture
  27842. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27843. * @param textures defines the textures to update
  27844. * @param samples defines the sample count to set
  27845. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27846. */
  27847. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27848. /** @hidden */
  27849. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27850. /** @hidden */
  27851. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27852. /** @hidden */
  27853. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27854. /** @hidden */
  27855. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27856. /**
  27857. * Creates a new render target cube texture
  27858. * @param size defines the size of the texture
  27859. * @param options defines the options used to create the texture
  27860. * @returns a new render target cube texture stored in an InternalTexture
  27861. */
  27862. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27863. /**
  27864. * Creates a cube texture
  27865. * @param rootUrl defines the url where the files to load is located
  27866. * @param scene defines the current scene
  27867. * @param files defines the list of files to load (1 per face)
  27868. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27869. * @param onLoad defines an optional callback raised when the texture is loaded
  27870. * @param onError defines an optional callback raised if there is an issue to load the texture
  27871. * @param format defines the format of the data
  27872. * @param forcedExtension defines the extension to use to pick the right loader
  27873. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27874. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27875. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27876. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27877. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27878. * @returns the cube texture as an InternalTexture
  27879. */
  27880. 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;
  27881. /**
  27882. * @hidden
  27883. */
  27884. _setCubeMapTextureParams(loadMipmap: boolean): void;
  27885. /**
  27886. * Update a raw cube texture
  27887. * @param texture defines the texture to udpdate
  27888. * @param data defines the data to store
  27889. * @param format defines the data format
  27890. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27891. * @param invertY defines if data must be stored with Y axis inverted
  27892. * @param compression defines the compression used (null by default)
  27893. * @param level defines which level of the texture to update
  27894. */
  27895. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27896. /**
  27897. * Creates a new raw cube texture
  27898. * @param data defines the array of data to use to create each face
  27899. * @param size defines the size of the textures
  27900. * @param format defines the format of the data
  27901. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27902. * @param generateMipMaps defines if the engine should generate the mip levels
  27903. * @param invertY defines if data must be stored with Y axis inverted
  27904. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27905. * @param compression defines the compression used (null by default)
  27906. * @returns the cube texture as an InternalTexture
  27907. */
  27908. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27909. /**
  27910. * Creates a new raw cube texture from a specified url
  27911. * @param url defines the url where the data is located
  27912. * @param scene defines the current scene
  27913. * @param size defines the size of the textures
  27914. * @param format defines the format of the data
  27915. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27916. * @param noMipmap defines if the engine should avoid generating the mip levels
  27917. * @param callback defines a callback used to extract texture data from loaded data
  27918. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27919. * @param onLoad defines a callback called when texture is loaded
  27920. * @param onError defines a callback called if there is an error
  27921. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27922. * @param invertY defines if data must be stored with Y axis inverted
  27923. * @returns the cube texture as an InternalTexture
  27924. */
  27925. 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;
  27926. /**
  27927. * Update a raw 3D texture
  27928. * @param texture defines the texture to update
  27929. * @param data defines the data to store
  27930. * @param format defines the data format
  27931. * @param invertY defines if data must be stored with Y axis inverted
  27932. * @param compression defines the used compression (can be null)
  27933. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27934. */
  27935. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27936. /**
  27937. * Creates a new raw 3D texture
  27938. * @param data defines the data used to create the texture
  27939. * @param width defines the width of the texture
  27940. * @param height defines the height of the texture
  27941. * @param depth defines the depth of the texture
  27942. * @param format defines the format of the texture
  27943. * @param generateMipMaps defines if the engine must generate mip levels
  27944. * @param invertY defines if data must be stored with Y axis inverted
  27945. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27946. * @param compression defines the compressed used (can be null)
  27947. * @param textureType defines the compressed used (can be null)
  27948. * @returns a new raw 3D texture (stored in an InternalTexture)
  27949. */
  27950. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27951. private _prepareWebGLTextureContinuation;
  27952. private _prepareWebGLTexture;
  27953. private _convertRGBtoRGBATextureData;
  27954. /** @hidden */
  27955. _releaseFramebufferObjects(texture: InternalTexture): void;
  27956. /** @hidden */
  27957. _releaseTexture(texture: InternalTexture): void;
  27958. private setProgram;
  27959. private _boundUniforms;
  27960. /**
  27961. * Binds an effect to the webGL context
  27962. * @param effect defines the effect to bind
  27963. */
  27964. bindSamplers(effect: Effect): void;
  27965. private _moveBoundTextureOnTop;
  27966. private _getCorrectTextureChannel;
  27967. private _linkTrackers;
  27968. private _removeDesignatedSlot;
  27969. private _activateCurrentTexture;
  27970. /** @hidden */
  27971. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27972. /** @hidden */
  27973. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27974. /**
  27975. * Sets a texture to the webGL context from a postprocess
  27976. * @param channel defines the channel to use
  27977. * @param postProcess defines the source postprocess
  27978. */
  27979. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27980. /**
  27981. * Binds the output of the passed in post process to the texture channel specified
  27982. * @param channel The channel the texture should be bound to
  27983. * @param postProcess The post process which's output should be bound
  27984. */
  27985. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27986. /**
  27987. * Unbind all textures from the webGL context
  27988. */
  27989. unbindAllTextures(): void;
  27990. /**
  27991. * Sets a texture to the according uniform.
  27992. * @param channel The texture channel
  27993. * @param uniform The uniform to set
  27994. * @param texture The texture to apply
  27995. */
  27996. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27997. /**
  27998. * Sets a depth stencil texture from a render target to the according uniform.
  27999. * @param channel The texture channel
  28000. * @param uniform The uniform to set
  28001. * @param texture The render target texture containing the depth stencil texture to apply
  28002. */
  28003. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28004. private _bindSamplerUniformToChannel;
  28005. private _getTextureWrapMode;
  28006. private _setTexture;
  28007. /**
  28008. * Sets an array of texture to the webGL context
  28009. * @param channel defines the channel where the texture array must be set
  28010. * @param uniform defines the associated uniform location
  28011. * @param textures defines the array of textures to bind
  28012. */
  28013. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28014. /** @hidden */
  28015. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28016. private _setTextureParameterFloat;
  28017. private _setTextureParameterInteger;
  28018. /**
  28019. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28020. * @param x defines the x coordinate of the rectangle where pixels must be read
  28021. * @param y defines the y coordinate of the rectangle where pixels must be read
  28022. * @param width defines the width of the rectangle where pixels must be read
  28023. * @param height defines the height of the rectangle where pixels must be read
  28024. * @returns a Uint8Array containing RGBA colors
  28025. */
  28026. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28027. /**
  28028. * Add an externaly attached data from its key.
  28029. * This method call will fail and return false, if such key already exists.
  28030. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28031. * @param key the unique key that identifies the data
  28032. * @param data the data object to associate to the key for this Engine instance
  28033. * @return true if no such key were already present and the data was added successfully, false otherwise
  28034. */
  28035. addExternalData<T>(key: string, data: T): boolean;
  28036. /**
  28037. * Get an externaly attached data from its key
  28038. * @param key the unique key that identifies the data
  28039. * @return the associated data, if present (can be null), or undefined if not present
  28040. */
  28041. getExternalData<T>(key: string): T;
  28042. /**
  28043. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28044. * @param key the unique key that identifies the data
  28045. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28046. * @return the associated data, can be null if the factory returned null.
  28047. */
  28048. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28049. /**
  28050. * Remove an externaly attached data from the Engine instance
  28051. * @param key the unique key that identifies the data
  28052. * @return true if the data was successfully removed, false if it doesn't exist
  28053. */
  28054. removeExternalData(key: string): boolean;
  28055. /**
  28056. * Unbind all vertex attributes from the webGL context
  28057. */
  28058. unbindAllAttributes(): void;
  28059. /**
  28060. * 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
  28061. */
  28062. releaseEffects(): void;
  28063. /**
  28064. * Dispose and release all associated resources
  28065. */
  28066. dispose(): void;
  28067. /**
  28068. * Display the loading screen
  28069. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28070. */
  28071. displayLoadingUI(): void;
  28072. /**
  28073. * Hide the loading screen
  28074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28075. */
  28076. hideLoadingUI(): void;
  28077. /**
  28078. * Gets the current loading screen object
  28079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28080. */
  28081. /**
  28082. * Sets the current loading screen object
  28083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28084. */
  28085. loadingScreen: ILoadingScreen;
  28086. /**
  28087. * Sets the current loading screen text
  28088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28089. */
  28090. loadingUIText: string;
  28091. /**
  28092. * Sets the current loading screen background color
  28093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28094. */
  28095. loadingUIBackgroundColor: string;
  28096. /**
  28097. * Attach a new callback raised when context lost event is fired
  28098. * @param callback defines the callback to call
  28099. */
  28100. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28101. /**
  28102. * Attach a new callback raised when context restored event is fired
  28103. * @param callback defines the callback to call
  28104. */
  28105. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28106. /**
  28107. * Gets the source code of the vertex shader associated with a specific webGL program
  28108. * @param program defines the program to use
  28109. * @returns a string containing the source code of the vertex shader associated with the program
  28110. */
  28111. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28112. /**
  28113. * Gets the source code of the fragment shader associated with a specific webGL program
  28114. * @param program defines the program to use
  28115. * @returns a string containing the source code of the fragment shader associated with the program
  28116. */
  28117. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28118. /**
  28119. * Get the current error code of the webGL context
  28120. * @returns the error code
  28121. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28122. */
  28123. getError(): number;
  28124. /**
  28125. * Gets the current framerate
  28126. * @returns a number representing the framerate
  28127. */
  28128. getFps(): number;
  28129. /**
  28130. * Gets the time spent between current and previous frame
  28131. * @returns a number representing the delta time in ms
  28132. */
  28133. getDeltaTime(): number;
  28134. private _measureFps;
  28135. /** @hidden */
  28136. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28137. private _canRenderToFloatFramebuffer;
  28138. private _canRenderToHalfFloatFramebuffer;
  28139. private _canRenderToFramebuffer;
  28140. /** @hidden */
  28141. _getWebGLTextureType(type: number): number;
  28142. private _getInternalFormat;
  28143. /** @hidden */
  28144. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28145. /** @hidden */
  28146. _getRGBAMultiSampleBufferFormat(type: number): number;
  28147. /** @hidden */
  28148. _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;
  28149. /** @hidden */
  28150. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28151. private _partialLoadFile;
  28152. private _cascadeLoadFiles;
  28153. /**
  28154. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28155. * @returns true if the engine can be created
  28156. * @ignorenaming
  28157. */
  28158. static isSupported(): boolean;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. /**
  28163. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28164. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28165. */
  28166. export class EffectFallbacks {
  28167. private _defines;
  28168. private _currentRank;
  28169. private _maxRank;
  28170. private _mesh;
  28171. /**
  28172. * Removes the fallback from the bound mesh.
  28173. */
  28174. unBindMesh(): void;
  28175. /**
  28176. * Adds a fallback on the specified property.
  28177. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28178. * @param define The name of the define in the shader
  28179. */
  28180. addFallback(rank: number, define: string): void;
  28181. /**
  28182. * Sets the mesh to use CPU skinning when needing to fallback.
  28183. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28184. * @param mesh The mesh to use the fallbacks.
  28185. */
  28186. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28187. /**
  28188. * Checks to see if more fallbacks are still availible.
  28189. */
  28190. readonly isMoreFallbacks: boolean;
  28191. /**
  28192. * Removes the defines that shoould be removed when falling back.
  28193. * @param currentDefines defines the current define statements for the shader.
  28194. * @param effect defines the current effect we try to compile
  28195. * @returns The resulting defines with defines of the current rank removed.
  28196. */
  28197. reduce(currentDefines: string, effect: Effect): string;
  28198. }
  28199. /**
  28200. * Options to be used when creating an effect.
  28201. */
  28202. export class EffectCreationOptions {
  28203. /**
  28204. * Atrributes that will be used in the shader.
  28205. */
  28206. attributes: string[];
  28207. /**
  28208. * Uniform varible names that will be set in the shader.
  28209. */
  28210. uniformsNames: string[];
  28211. /**
  28212. * Uniform buffer varible names that will be set in the shader.
  28213. */
  28214. uniformBuffersNames: string[];
  28215. /**
  28216. * Sampler texture variable names that will be set in the shader.
  28217. */
  28218. samplers: string[];
  28219. /**
  28220. * Define statements that will be set in the shader.
  28221. */
  28222. defines: any;
  28223. /**
  28224. * Possible fallbacks for this effect to improve performance when needed.
  28225. */
  28226. fallbacks: Nullable<EffectFallbacks>;
  28227. /**
  28228. * Callback that will be called when the shader is compiled.
  28229. */
  28230. onCompiled: Nullable<(effect: Effect) => void>;
  28231. /**
  28232. * Callback that will be called if an error occurs during shader compilation.
  28233. */
  28234. onError: Nullable<(effect: Effect, errors: string) => void>;
  28235. /**
  28236. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28237. */
  28238. indexParameters: any;
  28239. /**
  28240. * Max number of lights that can be used in the shader.
  28241. */
  28242. maxSimultaneousLights: number;
  28243. /**
  28244. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28245. */
  28246. transformFeedbackVaryings: Nullable<string[]>;
  28247. }
  28248. /**
  28249. * Effect containing vertex and fragment shader that can be executed on an object.
  28250. */
  28251. export class Effect {
  28252. /**
  28253. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28254. */
  28255. static ShadersRepository: string;
  28256. /**
  28257. * Name of the effect.
  28258. */
  28259. name: any;
  28260. /**
  28261. * String container all the define statements that should be set on the shader.
  28262. */
  28263. defines: string;
  28264. /**
  28265. * Callback that will be called when the shader is compiled.
  28266. */
  28267. onCompiled: Nullable<(effect: Effect) => void>;
  28268. /**
  28269. * Callback that will be called if an error occurs during shader compilation.
  28270. */
  28271. onError: Nullable<(effect: Effect, errors: string) => void>;
  28272. /**
  28273. * Callback that will be called when effect is bound.
  28274. */
  28275. onBind: Nullable<(effect: Effect) => void>;
  28276. /**
  28277. * Unique ID of the effect.
  28278. */
  28279. uniqueId: number;
  28280. /**
  28281. * Observable that will be called when the shader is compiled.
  28282. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28283. */
  28284. onCompileObservable: Observable<Effect>;
  28285. /**
  28286. * Observable that will be called if an error occurs during shader compilation.
  28287. */
  28288. onErrorObservable: Observable<Effect>;
  28289. /** @hidden */
  28290. _onBindObservable: Nullable<Observable<Effect>>;
  28291. /**
  28292. * Observable that will be called when effect is bound.
  28293. */
  28294. readonly onBindObservable: Observable<Effect>;
  28295. /** @hidden */
  28296. _bonesComputationForcedToCPU: boolean;
  28297. private static _uniqueIdSeed;
  28298. private _engine;
  28299. private _uniformBuffersNames;
  28300. private _uniformsNames;
  28301. private _samplers;
  28302. private _isReady;
  28303. private _compilationError;
  28304. private _attributesNames;
  28305. private _attributes;
  28306. private _uniforms;
  28307. /**
  28308. * Key for the effect.
  28309. * @hidden
  28310. */
  28311. _key: string;
  28312. private _indexParameters;
  28313. private _fallbacks;
  28314. private _vertexSourceCode;
  28315. private _fragmentSourceCode;
  28316. private _vertexSourceCodeOverride;
  28317. private _fragmentSourceCodeOverride;
  28318. private _transformFeedbackVaryings;
  28319. /**
  28320. * Compiled shader to webGL program.
  28321. * @hidden
  28322. */
  28323. _program: WebGLProgram;
  28324. private _valueCache;
  28325. private static _baseCache;
  28326. /**
  28327. * Instantiates an effect.
  28328. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28329. * @param baseName Name of the effect.
  28330. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28331. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28332. * @param samplers List of sampler variables that will be passed to the shader.
  28333. * @param engine Engine to be used to render the effect
  28334. * @param defines Define statements to be added to the shader.
  28335. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28336. * @param onCompiled Callback that will be called when the shader is compiled.
  28337. * @param onError Callback that will be called if an error occurs during shader compilation.
  28338. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28339. */
  28340. 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);
  28341. /**
  28342. * Unique key for this effect
  28343. */
  28344. readonly key: string;
  28345. /**
  28346. * If the effect has been compiled and prepared.
  28347. * @returns if the effect is compiled and prepared.
  28348. */
  28349. isReady(): boolean;
  28350. /**
  28351. * The engine the effect was initialized with.
  28352. * @returns the engine.
  28353. */
  28354. getEngine(): Engine;
  28355. /**
  28356. * The compiled webGL program for the effect
  28357. * @returns the webGL program.
  28358. */
  28359. getProgram(): WebGLProgram;
  28360. /**
  28361. * The set of names of attribute variables for the shader.
  28362. * @returns An array of attribute names.
  28363. */
  28364. getAttributesNames(): string[];
  28365. /**
  28366. * Returns the attribute at the given index.
  28367. * @param index The index of the attribute.
  28368. * @returns The location of the attribute.
  28369. */
  28370. getAttributeLocation(index: number): number;
  28371. /**
  28372. * Returns the attribute based on the name of the variable.
  28373. * @param name of the attribute to look up.
  28374. * @returns the attribute location.
  28375. */
  28376. getAttributeLocationByName(name: string): number;
  28377. /**
  28378. * The number of attributes.
  28379. * @returns the numnber of attributes.
  28380. */
  28381. getAttributesCount(): number;
  28382. /**
  28383. * Gets the index of a uniform variable.
  28384. * @param uniformName of the uniform to look up.
  28385. * @returns the index.
  28386. */
  28387. getUniformIndex(uniformName: string): number;
  28388. /**
  28389. * Returns the attribute based on the name of the variable.
  28390. * @param uniformName of the uniform to look up.
  28391. * @returns the location of the uniform.
  28392. */
  28393. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28394. /**
  28395. * Returns an array of sampler variable names
  28396. * @returns The array of sampler variable neames.
  28397. */
  28398. getSamplers(): string[];
  28399. /**
  28400. * The error from the last compilation.
  28401. * @returns the error string.
  28402. */
  28403. getCompilationError(): string;
  28404. /**
  28405. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28406. * @param func The callback to be used.
  28407. */
  28408. executeWhenCompiled(func: (effect: Effect) => void): void;
  28409. private _checkIsReady;
  28410. /** @hidden */
  28411. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28412. /** @hidden */
  28413. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28414. /** @hidden */
  28415. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28416. private _processShaderConversion;
  28417. private _processIncludes;
  28418. private _processPrecision;
  28419. /**
  28420. * Recompiles the webGL program
  28421. * @param vertexSourceCode The source code for the vertex shader.
  28422. * @param fragmentSourceCode The source code for the fragment shader.
  28423. * @param onCompiled Callback called when completed.
  28424. * @param onError Callback called on error.
  28425. * @hidden
  28426. */
  28427. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28428. /**
  28429. * Gets the uniform locations of the the specified variable names
  28430. * @param names THe names of the variables to lookup.
  28431. * @returns Array of locations in the same order as variable names.
  28432. */
  28433. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28434. /**
  28435. * Prepares the effect
  28436. * @hidden
  28437. */
  28438. _prepareEffect(): void;
  28439. /**
  28440. * Checks if the effect is supported. (Must be called after compilation)
  28441. */
  28442. readonly isSupported: boolean;
  28443. /**
  28444. * Binds a texture to the engine to be used as output of the shader.
  28445. * @param channel Name of the output variable.
  28446. * @param texture Texture to bind.
  28447. * @hidden
  28448. */
  28449. _bindTexture(channel: string, texture: InternalTexture): void;
  28450. /**
  28451. * Sets a texture on the engine to be used in the shader.
  28452. * @param channel Name of the sampler variable.
  28453. * @param texture Texture to set.
  28454. */
  28455. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28456. /**
  28457. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28458. * @param channel Name of the sampler variable.
  28459. * @param texture Texture to set.
  28460. */
  28461. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28462. /**
  28463. * Sets an array of textures on the engine to be used in the shader.
  28464. * @param channel Name of the variable.
  28465. * @param textures Textures to set.
  28466. */
  28467. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28468. /**
  28469. * 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)
  28470. * @param channel Name of the sampler variable.
  28471. * @param postProcess Post process to get the input texture from.
  28472. */
  28473. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28474. /**
  28475. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28476. * 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)
  28477. * @param channel Name of the sampler variable.
  28478. * @param postProcess Post process to get the output texture from.
  28479. */
  28480. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28481. /** @hidden */
  28482. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28483. /** @hidden */
  28484. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28485. /** @hidden */
  28486. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28487. /** @hidden */
  28488. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28489. /**
  28490. * Binds a buffer to a uniform.
  28491. * @param buffer Buffer to bind.
  28492. * @param name Name of the uniform variable to bind to.
  28493. */
  28494. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28495. /**
  28496. * Binds block to a uniform.
  28497. * @param blockName Name of the block to bind.
  28498. * @param index Index to bind.
  28499. */
  28500. bindUniformBlock(blockName: string, index: number): void;
  28501. /**
  28502. * Sets an interger value on a uniform variable.
  28503. * @param uniformName Name of the variable.
  28504. * @param value Value to be set.
  28505. * @returns this effect.
  28506. */
  28507. setInt(uniformName: string, value: number): Effect;
  28508. /**
  28509. * Sets an int array on a uniform variable.
  28510. * @param uniformName Name of the variable.
  28511. * @param array array to be set.
  28512. * @returns this effect.
  28513. */
  28514. setIntArray(uniformName: string, array: Int32Array): Effect;
  28515. /**
  28516. * 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)
  28517. * @param uniformName Name of the variable.
  28518. * @param array array to be set.
  28519. * @returns this effect.
  28520. */
  28521. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28522. /**
  28523. * 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)
  28524. * @param uniformName Name of the variable.
  28525. * @param array array to be set.
  28526. * @returns this effect.
  28527. */
  28528. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28529. /**
  28530. * 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)
  28531. * @param uniformName Name of the variable.
  28532. * @param array array to be set.
  28533. * @returns this effect.
  28534. */
  28535. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28536. /**
  28537. * Sets an float array on a uniform variable.
  28538. * @param uniformName Name of the variable.
  28539. * @param array array to be set.
  28540. * @returns this effect.
  28541. */
  28542. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28543. /**
  28544. * 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)
  28545. * @param uniformName Name of the variable.
  28546. * @param array array to be set.
  28547. * @returns this effect.
  28548. */
  28549. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28550. /**
  28551. * 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)
  28552. * @param uniformName Name of the variable.
  28553. * @param array array to be set.
  28554. * @returns this effect.
  28555. */
  28556. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28557. /**
  28558. * 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)
  28559. * @param uniformName Name of the variable.
  28560. * @param array array to be set.
  28561. * @returns this effect.
  28562. */
  28563. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28564. /**
  28565. * Sets an array on a uniform variable.
  28566. * @param uniformName Name of the variable.
  28567. * @param array array to be set.
  28568. * @returns this effect.
  28569. */
  28570. setArray(uniformName: string, array: number[]): Effect;
  28571. /**
  28572. * 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)
  28573. * @param uniformName Name of the variable.
  28574. * @param array array to be set.
  28575. * @returns this effect.
  28576. */
  28577. setArray2(uniformName: string, array: number[]): Effect;
  28578. /**
  28579. * 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)
  28580. * @param uniformName Name of the variable.
  28581. * @param array array to be set.
  28582. * @returns this effect.
  28583. */
  28584. setArray3(uniformName: string, array: number[]): Effect;
  28585. /**
  28586. * 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)
  28587. * @param uniformName Name of the variable.
  28588. * @param array array to be set.
  28589. * @returns this effect.
  28590. */
  28591. setArray4(uniformName: string, array: number[]): Effect;
  28592. /**
  28593. * Sets matrices on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param matrices matrices to be set.
  28596. * @returns this effect.
  28597. */
  28598. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28599. /**
  28600. * Sets matrix on a uniform variable.
  28601. * @param uniformName Name of the variable.
  28602. * @param matrix matrix to be set.
  28603. * @returns this effect.
  28604. */
  28605. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28606. /**
  28607. * 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)
  28608. * @param uniformName Name of the variable.
  28609. * @param matrix matrix to be set.
  28610. * @returns this effect.
  28611. */
  28612. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28613. /**
  28614. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28615. * @param uniformName Name of the variable.
  28616. * @param matrix matrix to be set.
  28617. * @returns this effect.
  28618. */
  28619. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28620. /**
  28621. * Sets a float on a uniform variable.
  28622. * @param uniformName Name of the variable.
  28623. * @param value value to be set.
  28624. * @returns this effect.
  28625. */
  28626. setFloat(uniformName: string, value: number): Effect;
  28627. /**
  28628. * Sets a boolean on a uniform variable.
  28629. * @param uniformName Name of the variable.
  28630. * @param bool value to be set.
  28631. * @returns this effect.
  28632. */
  28633. setBool(uniformName: string, bool: boolean): Effect;
  28634. /**
  28635. * Sets a Vector2 on a uniform variable.
  28636. * @param uniformName Name of the variable.
  28637. * @param vector2 vector2 to be set.
  28638. * @returns this effect.
  28639. */
  28640. setVector2(uniformName: string, vector2: Vector2): Effect;
  28641. /**
  28642. * Sets a float2 on a uniform variable.
  28643. * @param uniformName Name of the variable.
  28644. * @param x First float in float2.
  28645. * @param y Second float in float2.
  28646. * @returns this effect.
  28647. */
  28648. setFloat2(uniformName: string, x: number, y: number): Effect;
  28649. /**
  28650. * Sets a Vector3 on a uniform variable.
  28651. * @param uniformName Name of the variable.
  28652. * @param vector3 Value to be set.
  28653. * @returns this effect.
  28654. */
  28655. setVector3(uniformName: string, vector3: Vector3): Effect;
  28656. /**
  28657. * Sets a float3 on a uniform variable.
  28658. * @param uniformName Name of the variable.
  28659. * @param x First float in float3.
  28660. * @param y Second float in float3.
  28661. * @param z Third float in float3.
  28662. * @returns this effect.
  28663. */
  28664. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28665. /**
  28666. * Sets a Vector4 on a uniform variable.
  28667. * @param uniformName Name of the variable.
  28668. * @param vector4 Value to be set.
  28669. * @returns this effect.
  28670. */
  28671. setVector4(uniformName: string, vector4: Vector4): Effect;
  28672. /**
  28673. * Sets a float4 on a uniform variable.
  28674. * @param uniformName Name of the variable.
  28675. * @param x First float in float4.
  28676. * @param y Second float in float4.
  28677. * @param z Third float in float4.
  28678. * @param w Fourth float in float4.
  28679. * @returns this effect.
  28680. */
  28681. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28682. /**
  28683. * Sets a Color3 on a uniform variable.
  28684. * @param uniformName Name of the variable.
  28685. * @param color3 Value to be set.
  28686. * @returns this effect.
  28687. */
  28688. setColor3(uniformName: string, color3: Color3): Effect;
  28689. /**
  28690. * Sets a Color4 on a uniform variable.
  28691. * @param uniformName Name of the variable.
  28692. * @param color3 Value to be set.
  28693. * @param alpha Alpha value to be set.
  28694. * @returns this effect.
  28695. */
  28696. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28697. /**
  28698. * Sets a Color4 on a uniform variable
  28699. * @param uniformName defines the name of the variable
  28700. * @param color4 defines the value to be set
  28701. * @returns this effect.
  28702. */
  28703. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28704. /**
  28705. * This function will add a new shader to the shader store
  28706. * @param name the name of the shader
  28707. * @param pixelShader optional pixel shader content
  28708. * @param vertexShader optional vertex shader content
  28709. */
  28710. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28711. /**
  28712. * Store of each shader (The can be looked up using effect.key)
  28713. */
  28714. static ShadersStore: {
  28715. [key: string]: string;
  28716. };
  28717. /**
  28718. * Store of each included file for a shader (The can be looked up using effect.key)
  28719. */
  28720. static IncludesShadersStore: {
  28721. [key: string]: string;
  28722. };
  28723. /**
  28724. * Resets the cache of effects.
  28725. */
  28726. static ResetCache(): void;
  28727. }
  28728. }
  28729. declare module BABYLON {
  28730. /**
  28731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28733. * 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;
  28734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28735. */
  28736. export class ColorCurves {
  28737. private _dirty;
  28738. private _tempColor;
  28739. private _globalCurve;
  28740. private _highlightsCurve;
  28741. private _midtonesCurve;
  28742. private _shadowsCurve;
  28743. private _positiveCurve;
  28744. private _negativeCurve;
  28745. private _globalHue;
  28746. private _globalDensity;
  28747. private _globalSaturation;
  28748. private _globalExposure;
  28749. /**
  28750. * Gets the global Hue value.
  28751. * 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).
  28752. */
  28753. /**
  28754. * Sets the global Hue value.
  28755. * 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).
  28756. */
  28757. globalHue: number;
  28758. /**
  28759. * Gets the global Density value.
  28760. * 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.
  28761. * Values less than zero provide a filter of opposite hue.
  28762. */
  28763. /**
  28764. * Sets the global Density value.
  28765. * 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.
  28766. * Values less than zero provide a filter of opposite hue.
  28767. */
  28768. globalDensity: number;
  28769. /**
  28770. * Gets the global Saturation value.
  28771. * 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.
  28772. */
  28773. /**
  28774. * Sets the global Saturation value.
  28775. * 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.
  28776. */
  28777. globalSaturation: number;
  28778. /**
  28779. * Gets the global Exposure value.
  28780. * 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.
  28781. */
  28782. /**
  28783. * Sets the global Exposure value.
  28784. * 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.
  28785. */
  28786. globalExposure: number;
  28787. private _highlightsHue;
  28788. private _highlightsDensity;
  28789. private _highlightsSaturation;
  28790. private _highlightsExposure;
  28791. /**
  28792. * Gets the highlights Hue value.
  28793. * 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).
  28794. */
  28795. /**
  28796. * Sets the highlights Hue value.
  28797. * 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).
  28798. */
  28799. highlightsHue: number;
  28800. /**
  28801. * Gets the highlights Density value.
  28802. * 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.
  28803. * Values less than zero provide a filter of opposite hue.
  28804. */
  28805. /**
  28806. * Sets the highlights Density value.
  28807. * 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.
  28808. * Values less than zero provide a filter of opposite hue.
  28809. */
  28810. highlightsDensity: number;
  28811. /**
  28812. * Gets the highlights Saturation value.
  28813. * 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.
  28814. */
  28815. /**
  28816. * Sets the highlights Saturation value.
  28817. * 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.
  28818. */
  28819. highlightsSaturation: number;
  28820. /**
  28821. * Gets the highlights Exposure value.
  28822. * 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.
  28823. */
  28824. /**
  28825. * Sets the highlights Exposure value.
  28826. * 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.
  28827. */
  28828. highlightsExposure: number;
  28829. private _midtonesHue;
  28830. private _midtonesDensity;
  28831. private _midtonesSaturation;
  28832. private _midtonesExposure;
  28833. /**
  28834. * Gets the midtones Hue value.
  28835. * 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).
  28836. */
  28837. /**
  28838. * Sets the midtones Hue value.
  28839. * 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).
  28840. */
  28841. midtonesHue: number;
  28842. /**
  28843. * Gets the midtones Density value.
  28844. * 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.
  28845. * Values less than zero provide a filter of opposite hue.
  28846. */
  28847. /**
  28848. * Sets the midtones Density value.
  28849. * 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.
  28850. * Values less than zero provide a filter of opposite hue.
  28851. */
  28852. midtonesDensity: number;
  28853. /**
  28854. * Gets the midtones Saturation value.
  28855. * 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.
  28856. */
  28857. /**
  28858. * Sets the midtones Saturation value.
  28859. * 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.
  28860. */
  28861. midtonesSaturation: number;
  28862. /**
  28863. * Gets the midtones Exposure value.
  28864. * 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.
  28865. */
  28866. /**
  28867. * Sets the midtones Exposure value.
  28868. * 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.
  28869. */
  28870. midtonesExposure: number;
  28871. private _shadowsHue;
  28872. private _shadowsDensity;
  28873. private _shadowsSaturation;
  28874. private _shadowsExposure;
  28875. /**
  28876. * Gets the shadows Hue value.
  28877. * 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).
  28878. */
  28879. /**
  28880. * Sets the shadows Hue value.
  28881. * 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).
  28882. */
  28883. shadowsHue: number;
  28884. /**
  28885. * Gets the shadows Density value.
  28886. * 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.
  28887. * Values less than zero provide a filter of opposite hue.
  28888. */
  28889. /**
  28890. * Sets the shadows Density value.
  28891. * 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.
  28892. * Values less than zero provide a filter of opposite hue.
  28893. */
  28894. shadowsDensity: number;
  28895. /**
  28896. * Gets the shadows Saturation value.
  28897. * 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.
  28898. */
  28899. /**
  28900. * Sets the shadows Saturation value.
  28901. * 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.
  28902. */
  28903. shadowsSaturation: number;
  28904. /**
  28905. * Gets the shadows Exposure value.
  28906. * 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.
  28907. */
  28908. /**
  28909. * Sets the shadows Exposure value.
  28910. * 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.
  28911. */
  28912. shadowsExposure: number;
  28913. /**
  28914. * Returns the class name
  28915. * @returns The class name
  28916. */
  28917. getClassName(): string;
  28918. /**
  28919. * Binds the color curves to the shader.
  28920. * @param colorCurves The color curve to bind
  28921. * @param effect The effect to bind to
  28922. * @param positiveUniform The positive uniform shader parameter
  28923. * @param neutralUniform The neutral uniform shader parameter
  28924. * @param negativeUniform The negative uniform shader parameter
  28925. */
  28926. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28927. /**
  28928. * Prepare the list of uniforms associated with the ColorCurves effects.
  28929. * @param uniformsList The list of uniforms used in the effect
  28930. */
  28931. static PrepareUniforms(uniformsList: string[]): void;
  28932. /**
  28933. * Returns color grading data based on a hue, density, saturation and exposure value.
  28934. * @param filterHue The hue of the color filter.
  28935. * @param filterDensity The density of the color filter.
  28936. * @param saturation The saturation.
  28937. * @param exposure The exposure.
  28938. * @param result The result data container.
  28939. */
  28940. private getColorGradingDataToRef;
  28941. /**
  28942. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28943. * @param value The input slider value in range [-100,100].
  28944. * @returns Adjusted value.
  28945. */
  28946. private static applyColorGradingSliderNonlinear;
  28947. /**
  28948. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28949. * @param hue The hue (H) input.
  28950. * @param saturation The saturation (S) input.
  28951. * @param brightness The brightness (B) input.
  28952. * @result An RGBA color represented as Vector4.
  28953. */
  28954. private static fromHSBToRef;
  28955. /**
  28956. * Returns a value clamped between min and max
  28957. * @param value The value to clamp
  28958. * @param min The minimum of value
  28959. * @param max The maximum of value
  28960. * @returns The clamped value.
  28961. */
  28962. private static clamp;
  28963. /**
  28964. * Clones the current color curve instance.
  28965. * @return The cloned curves
  28966. */
  28967. clone(): ColorCurves;
  28968. /**
  28969. * Serializes the current color curve instance to a json representation.
  28970. * @return a JSON representation
  28971. */
  28972. serialize(): any;
  28973. /**
  28974. * Parses the color curve from a json representation.
  28975. * @param source the JSON source to parse
  28976. * @return The parsed curves
  28977. */
  28978. static Parse(source: any): ColorCurves;
  28979. }
  28980. }
  28981. declare module BABYLON {
  28982. /**
  28983. * Interface to follow in your material defines to integrate easily the
  28984. * Image proccessing functions.
  28985. * @hidden
  28986. */
  28987. export interface IImageProcessingConfigurationDefines {
  28988. IMAGEPROCESSING: boolean;
  28989. VIGNETTE: boolean;
  28990. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28991. VIGNETTEBLENDMODEOPAQUE: boolean;
  28992. TONEMAPPING: boolean;
  28993. TONEMAPPING_ACES: boolean;
  28994. CONTRAST: boolean;
  28995. EXPOSURE: boolean;
  28996. COLORCURVES: boolean;
  28997. COLORGRADING: boolean;
  28998. COLORGRADING3D: boolean;
  28999. SAMPLER3DGREENDEPTH: boolean;
  29000. SAMPLER3DBGRMAP: boolean;
  29001. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29002. }
  29003. /**
  29004. * @hidden
  29005. */
  29006. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29007. IMAGEPROCESSING: boolean;
  29008. VIGNETTE: boolean;
  29009. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29010. VIGNETTEBLENDMODEOPAQUE: boolean;
  29011. TONEMAPPING: boolean;
  29012. TONEMAPPING_ACES: boolean;
  29013. CONTRAST: boolean;
  29014. COLORCURVES: boolean;
  29015. COLORGRADING: boolean;
  29016. COLORGRADING3D: boolean;
  29017. SAMPLER3DGREENDEPTH: boolean;
  29018. SAMPLER3DBGRMAP: boolean;
  29019. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29020. EXPOSURE: boolean;
  29021. constructor();
  29022. }
  29023. /**
  29024. * This groups together the common properties used for image processing either in direct forward pass
  29025. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29026. * or not.
  29027. */
  29028. export class ImageProcessingConfiguration {
  29029. /**
  29030. * Default tone mapping applied in BabylonJS.
  29031. */
  29032. static readonly TONEMAPPING_STANDARD: number;
  29033. /**
  29034. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29035. * to other engines rendering to increase portability.
  29036. */
  29037. static readonly TONEMAPPING_ACES: number;
  29038. /**
  29039. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29040. */
  29041. colorCurves: Nullable<ColorCurves>;
  29042. private _colorCurvesEnabled;
  29043. /**
  29044. * Gets wether the color curves effect is enabled.
  29045. */
  29046. /**
  29047. * Sets wether the color curves effect is enabled.
  29048. */
  29049. colorCurvesEnabled: boolean;
  29050. private _colorGradingTexture;
  29051. /**
  29052. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29053. */
  29054. /**
  29055. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29056. */
  29057. colorGradingTexture: Nullable<BaseTexture>;
  29058. private _colorGradingEnabled;
  29059. /**
  29060. * Gets wether the color grading effect is enabled.
  29061. */
  29062. /**
  29063. * Sets wether the color grading effect is enabled.
  29064. */
  29065. colorGradingEnabled: boolean;
  29066. private _colorGradingWithGreenDepth;
  29067. /**
  29068. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29069. */
  29070. /**
  29071. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29072. */
  29073. colorGradingWithGreenDepth: boolean;
  29074. private _colorGradingBGR;
  29075. /**
  29076. * Gets wether the color grading texture contains BGR values.
  29077. */
  29078. /**
  29079. * Sets wether the color grading texture contains BGR values.
  29080. */
  29081. colorGradingBGR: boolean;
  29082. /** @hidden */
  29083. _exposure: number;
  29084. /**
  29085. * Gets the Exposure used in the effect.
  29086. */
  29087. /**
  29088. * Sets the Exposure used in the effect.
  29089. */
  29090. exposure: number;
  29091. private _toneMappingEnabled;
  29092. /**
  29093. * Gets wether the tone mapping effect is enabled.
  29094. */
  29095. /**
  29096. * Sets wether the tone mapping effect is enabled.
  29097. */
  29098. toneMappingEnabled: boolean;
  29099. private _toneMappingType;
  29100. /**
  29101. * Gets the type of tone mapping effect.
  29102. */
  29103. /**
  29104. * Sets the type of tone mapping effect used in BabylonJS.
  29105. */
  29106. toneMappingType: number;
  29107. protected _contrast: number;
  29108. /**
  29109. * Gets the contrast used in the effect.
  29110. */
  29111. /**
  29112. * Sets the contrast used in the effect.
  29113. */
  29114. contrast: number;
  29115. /**
  29116. * Vignette stretch size.
  29117. */
  29118. vignetteStretch: number;
  29119. /**
  29120. * Vignette centre X Offset.
  29121. */
  29122. vignetteCentreX: number;
  29123. /**
  29124. * Vignette centre Y Offset.
  29125. */
  29126. vignetteCentreY: number;
  29127. /**
  29128. * Vignette weight or intensity of the vignette effect.
  29129. */
  29130. vignetteWeight: number;
  29131. /**
  29132. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29133. * if vignetteEnabled is set to true.
  29134. */
  29135. vignetteColor: Color4;
  29136. /**
  29137. * Camera field of view used by the Vignette effect.
  29138. */
  29139. vignetteCameraFov: number;
  29140. private _vignetteBlendMode;
  29141. /**
  29142. * Gets the vignette blend mode allowing different kind of effect.
  29143. */
  29144. /**
  29145. * Sets the vignette blend mode allowing different kind of effect.
  29146. */
  29147. vignetteBlendMode: number;
  29148. private _vignetteEnabled;
  29149. /**
  29150. * Gets wether the vignette effect is enabled.
  29151. */
  29152. /**
  29153. * Sets wether the vignette effect is enabled.
  29154. */
  29155. vignetteEnabled: boolean;
  29156. private _applyByPostProcess;
  29157. /**
  29158. * Gets wether the image processing is applied through a post process or not.
  29159. */
  29160. /**
  29161. * Sets wether the image processing is applied through a post process or not.
  29162. */
  29163. applyByPostProcess: boolean;
  29164. private _isEnabled;
  29165. /**
  29166. * Gets wether the image processing is enabled or not.
  29167. */
  29168. /**
  29169. * Sets wether the image processing is enabled or not.
  29170. */
  29171. isEnabled: boolean;
  29172. /**
  29173. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29174. */
  29175. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29176. /**
  29177. * Method called each time the image processing information changes requires to recompile the effect.
  29178. */
  29179. protected _updateParameters(): void;
  29180. /**
  29181. * Gets the current class name.
  29182. * @return "ImageProcessingConfiguration"
  29183. */
  29184. getClassName(): string;
  29185. /**
  29186. * Prepare the list of uniforms associated with the Image Processing effects.
  29187. * @param uniforms The list of uniforms used in the effect
  29188. * @param defines the list of defines currently in use
  29189. */
  29190. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29191. /**
  29192. * Prepare the list of samplers associated with the Image Processing effects.
  29193. * @param samplersList The list of uniforms used in the effect
  29194. * @param defines the list of defines currently in use
  29195. */
  29196. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29197. /**
  29198. * Prepare the list of defines associated to the shader.
  29199. * @param defines the list of defines to complete
  29200. * @param forPostProcess Define if we are currently in post process mode or not
  29201. */
  29202. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29203. /**
  29204. * Returns true if all the image processing information are ready.
  29205. * @returns True if ready, otherwise, false
  29206. */
  29207. isReady(): boolean;
  29208. /**
  29209. * Binds the image processing to the shader.
  29210. * @param effect The effect to bind to
  29211. * @param aspectRatio Define the current aspect ratio of the effect
  29212. */
  29213. bind(effect: Effect, aspectRatio?: number): void;
  29214. /**
  29215. * Clones the current image processing instance.
  29216. * @return The cloned image processing
  29217. */
  29218. clone(): ImageProcessingConfiguration;
  29219. /**
  29220. * Serializes the current image processing instance to a json representation.
  29221. * @return a JSON representation
  29222. */
  29223. serialize(): any;
  29224. /**
  29225. * Parses the image processing from a json representation.
  29226. * @param source the JSON source to parse
  29227. * @return The parsed image processing
  29228. */
  29229. static Parse(source: any): ImageProcessingConfiguration;
  29230. private static _VIGNETTEMODE_MULTIPLY;
  29231. private static _VIGNETTEMODE_OPAQUE;
  29232. /**
  29233. * Used to apply the vignette as a mix with the pixel color.
  29234. */
  29235. static readonly VIGNETTEMODE_MULTIPLY: number;
  29236. /**
  29237. * Used to apply the vignette as a replacement of the pixel color.
  29238. */
  29239. static readonly VIGNETTEMODE_OPAQUE: number;
  29240. }
  29241. }
  29242. declare module BABYLON {
  29243. /**
  29244. * This represents all the required information to add a fresnel effect on a material:
  29245. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29246. */
  29247. export class FresnelParameters {
  29248. private _isEnabled;
  29249. /**
  29250. * Define if the fresnel effect is enable or not.
  29251. */
  29252. isEnabled: boolean;
  29253. /**
  29254. * Define the color used on edges (grazing angle)
  29255. */
  29256. leftColor: Color3;
  29257. /**
  29258. * Define the color used on center
  29259. */
  29260. rightColor: Color3;
  29261. /**
  29262. * Define bias applied to computed fresnel term
  29263. */
  29264. bias: number;
  29265. /**
  29266. * Defined the power exponent applied to fresnel term
  29267. */
  29268. power: number;
  29269. /**
  29270. * Clones the current fresnel and its valuues
  29271. * @returns a clone fresnel configuration
  29272. */
  29273. clone(): FresnelParameters;
  29274. /**
  29275. * Serializes the current fresnel parameters to a JSON representation.
  29276. * @return the JSON serialization
  29277. */
  29278. serialize(): any;
  29279. /**
  29280. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29281. * @param parsedFresnelParameters Define the JSON representation
  29282. * @returns the parsed parameters
  29283. */
  29284. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29285. }
  29286. }
  29287. declare module BABYLON {
  29288. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29289. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29290. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29291. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29292. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29293. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29294. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29295. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29296. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29297. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29298. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29299. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29300. /**
  29301. * Decorator used to define property that can be serialized as reference to a camera
  29302. * @param sourceName defines the name of the property to decorate
  29303. */
  29304. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29305. /**
  29306. * Class used to help serialization objects
  29307. */
  29308. export class SerializationHelper {
  29309. /** hidden */
  29310. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29311. /** hidden */
  29312. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29313. /** hidden */
  29314. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29315. /** hidden */
  29316. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29317. /**
  29318. * Appends the serialized animations from the source animations
  29319. * @param source Source containing the animations
  29320. * @param destination Target to store the animations
  29321. */
  29322. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29323. /**
  29324. * Static function used to serialized a specific entity
  29325. * @param entity defines the entity to serialize
  29326. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29327. * @returns a JSON compatible object representing the serialization of the entity
  29328. */
  29329. static Serialize<T>(entity: T, serializationObject?: any): any;
  29330. /**
  29331. * Creates a new entity from a serialization data object
  29332. * @param creationFunction defines a function used to instanciated the new entity
  29333. * @param source defines the source serialization data
  29334. * @param scene defines the hosting scene
  29335. * @param rootUrl defines the root url for resources
  29336. * @returns a new entity
  29337. */
  29338. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29339. /**
  29340. * Clones an object
  29341. * @param creationFunction defines the function used to instanciate the new object
  29342. * @param source defines the source object
  29343. * @returns the cloned object
  29344. */
  29345. static Clone<T>(creationFunction: () => T, source: T): T;
  29346. /**
  29347. * Instanciates a new object based on a source one (some data will be shared between both object)
  29348. * @param creationFunction defines the function used to instanciate the new object
  29349. * @param source defines the source object
  29350. * @returns the new object
  29351. */
  29352. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29353. }
  29354. }
  29355. declare module BABYLON {
  29356. /**
  29357. * This is the base class of all the camera used in the application.
  29358. * @see http://doc.babylonjs.com/features/cameras
  29359. */
  29360. export class Camera extends Node {
  29361. /** @hidden */
  29362. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29363. /**
  29364. * This is the default projection mode used by the cameras.
  29365. * It helps recreating a feeling of perspective and better appreciate depth.
  29366. * This is the best way to simulate real life cameras.
  29367. */
  29368. static readonly PERSPECTIVE_CAMERA: number;
  29369. /**
  29370. * This helps creating camera with an orthographic mode.
  29371. * 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.
  29372. */
  29373. static readonly ORTHOGRAPHIC_CAMERA: number;
  29374. /**
  29375. * This is the default FOV mode for perspective cameras.
  29376. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29377. */
  29378. static readonly FOVMODE_VERTICAL_FIXED: number;
  29379. /**
  29380. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29381. */
  29382. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29383. /**
  29384. * This specifies ther is no need for a camera rig.
  29385. * Basically only one eye is rendered corresponding to the camera.
  29386. */
  29387. static readonly RIG_MODE_NONE: number;
  29388. /**
  29389. * Simulates a camera Rig with one blue eye and one red eye.
  29390. * This can be use with 3d blue and red glasses.
  29391. */
  29392. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29393. /**
  29394. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29395. */
  29396. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29397. /**
  29398. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29399. */
  29400. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29401. /**
  29402. * Defines that both eyes of the camera will be rendered over under each other.
  29403. */
  29404. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29405. /**
  29406. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29407. */
  29408. static readonly RIG_MODE_VR: number;
  29409. /**
  29410. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29411. */
  29412. static readonly RIG_MODE_WEBVR: number;
  29413. /**
  29414. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29415. */
  29416. static readonly RIG_MODE_CUSTOM: number;
  29417. /**
  29418. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29419. */
  29420. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29421. /**
  29422. * @hidden
  29423. * Might be removed once multiview will be a thing
  29424. */
  29425. static UseAlternateWebVRRendering: boolean;
  29426. /**
  29427. * Define the input manager associated with the camera.
  29428. */
  29429. inputs: CameraInputsManager<Camera>;
  29430. /** @hidden */
  29431. _position: Vector3;
  29432. /**
  29433. * Define the current local position of the camera in the scene
  29434. */
  29435. position: Vector3;
  29436. /**
  29437. * The vector the camera should consider as up.
  29438. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29439. */
  29440. upVector: Vector3;
  29441. /**
  29442. * Define the current limit on the left side for an orthographic camera
  29443. * In scene unit
  29444. */
  29445. orthoLeft: Nullable<number>;
  29446. /**
  29447. * Define the current limit on the right side for an orthographic camera
  29448. * In scene unit
  29449. */
  29450. orthoRight: Nullable<number>;
  29451. /**
  29452. * Define the current limit on the bottom side for an orthographic camera
  29453. * In scene unit
  29454. */
  29455. orthoBottom: Nullable<number>;
  29456. /**
  29457. * Define the current limit on the top side for an orthographic camera
  29458. * In scene unit
  29459. */
  29460. orthoTop: Nullable<number>;
  29461. /**
  29462. * Field Of View is set in Radians. (default is 0.8)
  29463. */
  29464. fov: number;
  29465. /**
  29466. * Define the minimum distance the camera can see from.
  29467. * This is important to note that the depth buffer are not infinite and the closer it starts
  29468. * the more your scene might encounter depth fighting issue.
  29469. */
  29470. minZ: number;
  29471. /**
  29472. * Define the maximum distance the camera can see to.
  29473. * This is important to note that the depth buffer are not infinite and the further it end
  29474. * the more your scene might encounter depth fighting issue.
  29475. */
  29476. maxZ: number;
  29477. /**
  29478. * Define the default inertia of the camera.
  29479. * This helps giving a smooth feeling to the camera movement.
  29480. */
  29481. inertia: number;
  29482. /**
  29483. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29484. */
  29485. mode: number;
  29486. /**
  29487. * Define wether the camera is intermediate.
  29488. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29489. */
  29490. isIntermediate: boolean;
  29491. /**
  29492. * Define the viewport of the camera.
  29493. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29494. */
  29495. viewport: Viewport;
  29496. /**
  29497. * Restricts the camera to viewing objects with the same layerMask.
  29498. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29499. */
  29500. layerMask: number;
  29501. /**
  29502. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29503. */
  29504. fovMode: number;
  29505. /**
  29506. * Rig mode of the camera.
  29507. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29508. * This is normally controlled byt the camera themselves as internal use.
  29509. */
  29510. cameraRigMode: number;
  29511. /**
  29512. * Defines the distance between both "eyes" in case of a RIG
  29513. */
  29514. interaxialDistance: number;
  29515. /**
  29516. * Defines if stereoscopic rendering is done side by side or over under.
  29517. */
  29518. isStereoscopicSideBySide: boolean;
  29519. /**
  29520. * 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
  29521. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29522. * else in the scene.
  29523. */
  29524. customRenderTargets: RenderTargetTexture[];
  29525. /**
  29526. * When set, the camera will render to this render target instead of the default canvas
  29527. */
  29528. outputRenderTarget: Nullable<RenderTargetTexture>;
  29529. /**
  29530. * Observable triggered when the camera view matrix has changed.
  29531. */
  29532. onViewMatrixChangedObservable: Observable<Camera>;
  29533. /**
  29534. * Observable triggered when the camera Projection matrix has changed.
  29535. */
  29536. onProjectionMatrixChangedObservable: Observable<Camera>;
  29537. /**
  29538. * Observable triggered when the inputs have been processed.
  29539. */
  29540. onAfterCheckInputsObservable: Observable<Camera>;
  29541. /**
  29542. * Observable triggered when reset has been called and applied to the camera.
  29543. */
  29544. onRestoreStateObservable: Observable<Camera>;
  29545. /** @hidden */
  29546. _cameraRigParams: any;
  29547. /** @hidden */
  29548. _rigCameras: Camera[];
  29549. /** @hidden */
  29550. _rigPostProcess: Nullable<PostProcess>;
  29551. protected _webvrViewMatrix: Matrix;
  29552. /** @hidden */
  29553. _skipRendering: boolean;
  29554. /** @hidden */
  29555. _alternateCamera: Camera;
  29556. /** @hidden */
  29557. _projectionMatrix: Matrix;
  29558. /** @hidden */
  29559. _postProcesses: Nullable<PostProcess>[];
  29560. /** @hidden */
  29561. _activeMeshes: SmartArray<AbstractMesh>;
  29562. protected _globalPosition: Vector3;
  29563. /** hidden */
  29564. _computedViewMatrix: Matrix;
  29565. private _doNotComputeProjectionMatrix;
  29566. private _transformMatrix;
  29567. private _frustumPlanes;
  29568. private _refreshFrustumPlanes;
  29569. private _storedFov;
  29570. private _stateStored;
  29571. /**
  29572. * Instantiates a new camera object.
  29573. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29574. * @see http://doc.babylonjs.com/features/cameras
  29575. * @param name Defines the name of the camera in the scene
  29576. * @param position Defines the position of the camera
  29577. * @param scene Defines the scene the camera belongs too
  29578. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29579. */
  29580. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29581. /**
  29582. * Store current camera state (fov, position, etc..)
  29583. * @returns the camera
  29584. */
  29585. storeState(): Camera;
  29586. /**
  29587. * Restores the camera state values if it has been stored. You must call storeState() first
  29588. */
  29589. protected _restoreStateValues(): boolean;
  29590. /**
  29591. * Restored camera state. You must call storeState() first.
  29592. * @returns true if restored and false otherwise
  29593. */
  29594. restoreState(): boolean;
  29595. /**
  29596. * Gets the class name of the camera.
  29597. * @returns the class name
  29598. */
  29599. getClassName(): string;
  29600. /** @hidden */
  29601. readonly _isCamera: boolean;
  29602. /**
  29603. * Gets a string representation of the camera useful for debug purpose.
  29604. * @param fullDetails Defines that a more verboe level of logging is required
  29605. * @returns the string representation
  29606. */
  29607. toString(fullDetails?: boolean): string;
  29608. /**
  29609. * Gets the current world space position of the camera.
  29610. */
  29611. readonly globalPosition: Vector3;
  29612. /**
  29613. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29614. * @returns the active meshe list
  29615. */
  29616. getActiveMeshes(): SmartArray<AbstractMesh>;
  29617. /**
  29618. * Check wether a mesh is part of the current active mesh list of the camera
  29619. * @param mesh Defines the mesh to check
  29620. * @returns true if active, false otherwise
  29621. */
  29622. isActiveMesh(mesh: Mesh): boolean;
  29623. /**
  29624. * Is this camera ready to be used/rendered
  29625. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29626. * @return true if the camera is ready
  29627. */
  29628. isReady(completeCheck?: boolean): boolean;
  29629. /** @hidden */
  29630. _initCache(): void;
  29631. /** @hidden */
  29632. _updateCache(ignoreParentClass?: boolean): void;
  29633. /** @hidden */
  29634. _isSynchronized(): boolean;
  29635. /** @hidden */
  29636. _isSynchronizedViewMatrix(): boolean;
  29637. /** @hidden */
  29638. _isSynchronizedProjectionMatrix(): boolean;
  29639. /**
  29640. * Attach the input controls to a specific dom element to get the input from.
  29641. * @param element Defines the element the controls should be listened from
  29642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29643. */
  29644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29645. /**
  29646. * Detach the current controls from the specified dom element.
  29647. * @param element Defines the element to stop listening the inputs from
  29648. */
  29649. detachControl(element: HTMLElement): void;
  29650. /**
  29651. * Update the camera state according to the different inputs gathered during the frame.
  29652. */
  29653. update(): void;
  29654. /** @hidden */
  29655. _checkInputs(): void;
  29656. /** @hidden */
  29657. readonly rigCameras: Camera[];
  29658. /**
  29659. * Gets the post process used by the rig cameras
  29660. */
  29661. readonly rigPostProcess: Nullable<PostProcess>;
  29662. /**
  29663. * Internal, gets the first post proces.
  29664. * @returns the first post process to be run on this camera.
  29665. */
  29666. _getFirstPostProcess(): Nullable<PostProcess>;
  29667. private _cascadePostProcessesToRigCams;
  29668. /**
  29669. * Attach a post process to the camera.
  29670. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29671. * @param postProcess The post process to attach to the camera
  29672. * @param insertAt The position of the post process in case several of them are in use in the scene
  29673. * @returns the position the post process has been inserted at
  29674. */
  29675. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29676. /**
  29677. * Detach a post process to the camera.
  29678. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29679. * @param postProcess The post process to detach from the camera
  29680. */
  29681. detachPostProcess(postProcess: PostProcess): void;
  29682. /**
  29683. * Gets the current world matrix of the camera
  29684. */
  29685. getWorldMatrix(): Matrix;
  29686. /** @hidden */
  29687. _getViewMatrix(): Matrix;
  29688. /**
  29689. * Gets the current view matrix of the camera.
  29690. * @param force forces the camera to recompute the matrix without looking at the cached state
  29691. * @returns the view matrix
  29692. */
  29693. getViewMatrix(force?: boolean): Matrix;
  29694. /**
  29695. * Freeze the projection matrix.
  29696. * It will prevent the cache check of the camera projection compute and can speed up perf
  29697. * if no parameter of the camera are meant to change
  29698. * @param projection Defines manually a projection if necessary
  29699. */
  29700. freezeProjectionMatrix(projection?: Matrix): void;
  29701. /**
  29702. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29703. */
  29704. unfreezeProjectionMatrix(): void;
  29705. /**
  29706. * Gets the current projection matrix of the camera.
  29707. * @param force forces the camera to recompute the matrix without looking at the cached state
  29708. * @returns the projection matrix
  29709. */
  29710. getProjectionMatrix(force?: boolean): Matrix;
  29711. /**
  29712. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29713. * @returns a Matrix
  29714. */
  29715. getTransformationMatrix(): Matrix;
  29716. private _updateFrustumPlanes;
  29717. /**
  29718. * Checks if a cullable object (mesh...) is in the camera frustum
  29719. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29720. * @param target The object to check
  29721. * @returns true if the object is in frustum otherwise false
  29722. */
  29723. isInFrustum(target: ICullable): boolean;
  29724. /**
  29725. * Checks if a cullable object (mesh...) is in the camera frustum
  29726. * Unlike isInFrustum this cheks the full bounding box
  29727. * @param target The object to check
  29728. * @returns true if the object is in frustum otherwise false
  29729. */
  29730. isCompletelyInFrustum(target: ICullable): boolean;
  29731. /**
  29732. * Gets a ray in the forward direction from the camera.
  29733. * @param length Defines the length of the ray to create
  29734. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29735. * @param origin Defines the start point of the ray which defaults to the camera position
  29736. * @returns the forward ray
  29737. */
  29738. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29739. /**
  29740. * Releases resources associated with this node.
  29741. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29742. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29743. */
  29744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29745. /**
  29746. * Gets the left camera of a rig setup in case of Rigged Camera
  29747. */
  29748. readonly leftCamera: Nullable<FreeCamera>;
  29749. /**
  29750. * Gets the right camera of a rig setup in case of Rigged Camera
  29751. */
  29752. readonly rightCamera: Nullable<FreeCamera>;
  29753. /**
  29754. * Gets the left camera target of a rig setup in case of Rigged Camera
  29755. * @returns the target position
  29756. */
  29757. getLeftTarget(): Nullable<Vector3>;
  29758. /**
  29759. * Gets the right camera target of a rig setup in case of Rigged Camera
  29760. * @returns the target position
  29761. */
  29762. getRightTarget(): Nullable<Vector3>;
  29763. /**
  29764. * @hidden
  29765. */
  29766. setCameraRigMode(mode: number, rigParams: any): void;
  29767. /** @hidden */
  29768. static _setStereoscopicRigMode(camera: Camera): void;
  29769. /** @hidden */
  29770. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29771. /** @hidden */
  29772. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29773. /** @hidden */
  29774. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29775. /** @hidden */
  29776. _getVRProjectionMatrix(): Matrix;
  29777. protected _updateCameraRotationMatrix(): void;
  29778. protected _updateWebVRCameraRotationMatrix(): void;
  29779. /**
  29780. * This function MUST be overwritten by the different WebVR cameras available.
  29781. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29782. * @hidden
  29783. */
  29784. _getWebVRProjectionMatrix(): Matrix;
  29785. /**
  29786. * This function MUST be overwritten by the different WebVR cameras available.
  29787. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29788. * @hidden
  29789. */
  29790. _getWebVRViewMatrix(): Matrix;
  29791. /** @hidden */
  29792. setCameraRigParameter(name: string, value: any): void;
  29793. /**
  29794. * needs to be overridden by children so sub has required properties to be copied
  29795. * @hidden
  29796. */
  29797. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29798. /**
  29799. * May need to be overridden by children
  29800. * @hidden
  29801. */
  29802. _updateRigCameras(): void;
  29803. /** @hidden */
  29804. _setupInputs(): void;
  29805. /**
  29806. * Serialiaze the camera setup to a json represention
  29807. * @returns the JSON representation
  29808. */
  29809. serialize(): any;
  29810. /**
  29811. * Clones the current camera.
  29812. * @param name The cloned camera name
  29813. * @returns the cloned camera
  29814. */
  29815. clone(name: string): Camera;
  29816. /**
  29817. * Gets the direction of the camera relative to a given local axis.
  29818. * @param localAxis Defines the reference axis to provide a relative direction.
  29819. * @return the direction
  29820. */
  29821. getDirection(localAxis: Vector3): Vector3;
  29822. /**
  29823. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29824. * @param localAxis Defines the reference axis to provide a relative direction.
  29825. * @param result Defines the vector to store the result in
  29826. */
  29827. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29828. /**
  29829. * Gets a camera constructor for a given camera type
  29830. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29831. * @param name The name of the camera the result will be able to instantiate
  29832. * @param scene The scene the result will construct the camera in
  29833. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29834. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29835. * @returns a factory method to construc the camera
  29836. */
  29837. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29838. /**
  29839. * Compute the world matrix of the camera.
  29840. * @returns the camera workd matrix
  29841. */
  29842. computeWorldMatrix(): Matrix;
  29843. /**
  29844. * Parse a JSON and creates the camera from the parsed information
  29845. * @param parsedCamera The JSON to parse
  29846. * @param scene The scene to instantiate the camera in
  29847. * @returns the newly constructed camera
  29848. */
  29849. static Parse(parsedCamera: any, scene: Scene): Camera;
  29850. }
  29851. }
  29852. declare module BABYLON {
  29853. /**
  29854. * Interface for any object that can request an animation frame
  29855. */
  29856. export interface ICustomAnimationFrameRequester {
  29857. /**
  29858. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29859. */
  29860. renderFunction?: Function;
  29861. /**
  29862. * Called to request the next frame to render to
  29863. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29864. */
  29865. requestAnimationFrame: Function;
  29866. /**
  29867. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29868. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29869. */
  29870. requestID?: number;
  29871. }
  29872. /**
  29873. * Interface containing an array of animations
  29874. */
  29875. export interface IAnimatable {
  29876. /**
  29877. * Array of animations
  29878. */
  29879. animations: Array<Animation>;
  29880. }
  29881. /** Interface used by value gradients (color, factor, ...) */
  29882. export interface IValueGradient {
  29883. /**
  29884. * Gets or sets the gradient value (between 0 and 1)
  29885. */
  29886. gradient: number;
  29887. }
  29888. /** Class used to store color4 gradient */
  29889. export class ColorGradient implements IValueGradient {
  29890. /**
  29891. * Gets or sets the gradient value (between 0 and 1)
  29892. */
  29893. gradient: number;
  29894. /**
  29895. * Gets or sets first associated color
  29896. */
  29897. color1: Color4;
  29898. /**
  29899. * Gets or sets second associated color
  29900. */
  29901. color2?: Color4;
  29902. /**
  29903. * Will get a color picked randomly between color1 and color2.
  29904. * If color2 is undefined then color1 will be used
  29905. * @param result defines the target Color4 to store the result in
  29906. */
  29907. getColorToRef(result: Color4): void;
  29908. }
  29909. /** Class used to store color 3 gradient */
  29910. export class Color3Gradient implements IValueGradient {
  29911. /**
  29912. * Gets or sets the gradient value (between 0 and 1)
  29913. */
  29914. gradient: number;
  29915. /**
  29916. * Gets or sets the associated color
  29917. */
  29918. color: Color3;
  29919. }
  29920. /** Class used to store factor gradient */
  29921. export class FactorGradient implements IValueGradient {
  29922. /**
  29923. * Gets or sets the gradient value (between 0 and 1)
  29924. */
  29925. gradient: number;
  29926. /**
  29927. * Gets or sets first associated factor
  29928. */
  29929. factor1: number;
  29930. /**
  29931. * Gets or sets second associated factor
  29932. */
  29933. factor2?: number;
  29934. /**
  29935. * Will get a number picked randomly between factor1 and factor2.
  29936. * If factor2 is undefined then factor1 will be used
  29937. * @returns the picked number
  29938. */
  29939. getFactor(): number;
  29940. }
  29941. /**
  29942. * @ignore
  29943. * Application error to support additional information when loading a file
  29944. */
  29945. export class LoadFileError extends Error {
  29946. /** defines the optional XHR request */
  29947. request?: XMLHttpRequest | undefined;
  29948. private static _setPrototypeOf;
  29949. /**
  29950. * Creates a new LoadFileError
  29951. * @param message defines the message of the error
  29952. * @param request defines the optional XHR request
  29953. */
  29954. constructor(message: string,
  29955. /** defines the optional XHR request */
  29956. request?: XMLHttpRequest | undefined);
  29957. }
  29958. /**
  29959. * Class used to define a retry strategy when error happens while loading assets
  29960. */
  29961. export class RetryStrategy {
  29962. /**
  29963. * Function used to defines an exponential back off strategy
  29964. * @param maxRetries defines the maximum number of retries (3 by default)
  29965. * @param baseInterval defines the interval between retries
  29966. * @returns the strategy function to use
  29967. */
  29968. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29969. }
  29970. /**
  29971. * File request interface
  29972. */
  29973. export interface IFileRequest {
  29974. /**
  29975. * Raised when the request is complete (success or error).
  29976. */
  29977. onCompleteObservable: Observable<IFileRequest>;
  29978. /**
  29979. * Aborts the request for a file.
  29980. */
  29981. abort: () => void;
  29982. }
  29983. /**
  29984. * Class containing a set of static utilities functions
  29985. */
  29986. export class Tools {
  29987. /**
  29988. * Gets or sets the base URL to use to load assets
  29989. */
  29990. static BaseUrl: string;
  29991. /**
  29992. * Enable/Disable Custom HTTP Request Headers globally.
  29993. * default = false
  29994. * @see CustomRequestHeaders
  29995. */
  29996. static UseCustomRequestHeaders: boolean;
  29997. /**
  29998. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29999. * i.e. when loading files, where the server/service expects an Authorization header.
  30000. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30001. */
  30002. static CustomRequestHeaders: {
  30003. [key: string]: string;
  30004. };
  30005. /**
  30006. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30007. */
  30008. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30009. /**
  30010. * Default behaviour for cors in the application.
  30011. * It can be a string if the expected behavior is identical in the entire app.
  30012. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30013. */
  30014. static CorsBehavior: string | ((url: string | string[]) => string);
  30015. /**
  30016. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30017. * @ignorenaming
  30018. */
  30019. static UseFallbackTexture: boolean;
  30020. /**
  30021. * Use this object to register external classes like custom textures or material
  30022. * to allow the laoders to instantiate them
  30023. */
  30024. static RegisteredExternalClasses: {
  30025. [key: string]: Object;
  30026. };
  30027. /**
  30028. * Texture content used if a texture cannot loaded
  30029. * @ignorenaming
  30030. */
  30031. static fallbackTexture: string;
  30032. /**
  30033. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30034. * @param u defines the coordinate on X axis
  30035. * @param v defines the coordinate on Y axis
  30036. * @param width defines the width of the source data
  30037. * @param height defines the height of the source data
  30038. * @param pixels defines the source byte array
  30039. * @param color defines the output color
  30040. */
  30041. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30042. /**
  30043. * Interpolates between a and b via alpha
  30044. * @param a The lower value (returned when alpha = 0)
  30045. * @param b The upper value (returned when alpha = 1)
  30046. * @param alpha The interpolation-factor
  30047. * @return The mixed value
  30048. */
  30049. static Mix(a: number, b: number, alpha: number): number;
  30050. /**
  30051. * Tries to instantiate a new object from a given class name
  30052. * @param className defines the class name to instantiate
  30053. * @returns the new object or null if the system was not able to do the instantiation
  30054. */
  30055. static Instantiate(className: string): any;
  30056. /**
  30057. * Provides a slice function that will work even on IE
  30058. * @param data defines the array to slice
  30059. * @param start defines the start of the data (optional)
  30060. * @param end defines the end of the data (optional)
  30061. * @returns the new sliced array
  30062. */
  30063. static Slice<T>(data: T, start?: number, end?: number): T;
  30064. /**
  30065. * Polyfill for setImmediate
  30066. * @param action defines the action to execute after the current execution block
  30067. */
  30068. static SetImmediate(action: () => void): void;
  30069. /**
  30070. * Function indicating if a number is an exponent of 2
  30071. * @param value defines the value to test
  30072. * @returns true if the value is an exponent of 2
  30073. */
  30074. static IsExponentOfTwo(value: number): boolean;
  30075. private static _tmpFloatArray;
  30076. /**
  30077. * Returns the nearest 32-bit single precision float representation of a Number
  30078. * @param value A Number. If the parameter is of a different type, it will get converted
  30079. * to a number or to NaN if it cannot be converted
  30080. * @returns number
  30081. */
  30082. static FloatRound(value: number): number;
  30083. /**
  30084. * Find the next highest power of two.
  30085. * @param x Number to start search from.
  30086. * @return Next highest power of two.
  30087. */
  30088. static CeilingPOT(x: number): number;
  30089. /**
  30090. * Find the next lowest power of two.
  30091. * @param x Number to start search from.
  30092. * @return Next lowest power of two.
  30093. */
  30094. static FloorPOT(x: number): number;
  30095. /**
  30096. * Find the nearest power of two.
  30097. * @param x Number to start search from.
  30098. * @return Next nearest power of two.
  30099. */
  30100. static NearestPOT(x: number): number;
  30101. /**
  30102. * Get the closest exponent of two
  30103. * @param value defines the value to approximate
  30104. * @param max defines the maximum value to return
  30105. * @param mode defines how to define the closest value
  30106. * @returns closest exponent of two of the given value
  30107. */
  30108. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30109. /**
  30110. * Extracts the filename from a path
  30111. * @param path defines the path to use
  30112. * @returns the filename
  30113. */
  30114. static GetFilename(path: string): string;
  30115. /**
  30116. * Extracts the "folder" part of a path (everything before the filename).
  30117. * @param uri The URI to extract the info from
  30118. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30119. * @returns The "folder" part of the path
  30120. */
  30121. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30122. /**
  30123. * Extracts text content from a DOM element hierarchy
  30124. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30125. */
  30126. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30127. /**
  30128. * Convert an angle in radians to degrees
  30129. * @param angle defines the angle to convert
  30130. * @returns the angle in degrees
  30131. */
  30132. static ToDegrees(angle: number): number;
  30133. /**
  30134. * Convert an angle in degrees to radians
  30135. * @param angle defines the angle to convert
  30136. * @returns the angle in radians
  30137. */
  30138. static ToRadians(angle: number): number;
  30139. /**
  30140. * Encode a buffer to a base64 string
  30141. * @param buffer defines the buffer to encode
  30142. * @returns the encoded string
  30143. */
  30144. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30145. /**
  30146. * Extracts minimum and maximum values from a list of indexed positions
  30147. * @param positions defines the positions to use
  30148. * @param indices defines the indices to the positions
  30149. * @param indexStart defines the start index
  30150. * @param indexCount defines the end index
  30151. * @param bias defines bias value to add to the result
  30152. * @return minimum and maximum values
  30153. */
  30154. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30155. minimum: Vector3;
  30156. maximum: Vector3;
  30157. };
  30158. /**
  30159. * Extracts minimum and maximum values from a list of positions
  30160. * @param positions defines the positions to use
  30161. * @param start defines the start index in the positions array
  30162. * @param count defines the number of positions to handle
  30163. * @param bias defines bias value to add to the result
  30164. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30165. * @return minimum and maximum values
  30166. */
  30167. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30168. minimum: Vector3;
  30169. maximum: Vector3;
  30170. };
  30171. /**
  30172. * Returns an array if obj is not an array
  30173. * @param obj defines the object to evaluate as an array
  30174. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30175. * @returns either obj directly if obj is an array or a new array containing obj
  30176. */
  30177. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30178. /**
  30179. * Gets the pointer prefix to use
  30180. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30181. */
  30182. static GetPointerPrefix(): string;
  30183. /**
  30184. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30185. * @param func - the function to be called
  30186. * @param requester - the object that will request the next frame. Falls back to window.
  30187. * @returns frame number
  30188. */
  30189. static QueueNewFrame(func: () => void, requester?: any): number;
  30190. /**
  30191. * Ask the browser to promote the current element to fullscreen rendering mode
  30192. * @param element defines the DOM element to promote
  30193. */
  30194. static RequestFullscreen(element: HTMLElement): void;
  30195. /**
  30196. * Asks the browser to exit fullscreen mode
  30197. */
  30198. static ExitFullscreen(): void;
  30199. /**
  30200. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30201. * @param url define the url we are trying
  30202. * @param element define the dom element where to configure the cors policy
  30203. */
  30204. static SetCorsBehavior(url: string | string[], element: {
  30205. crossOrigin: string | null;
  30206. }): void;
  30207. /**
  30208. * Removes unwanted characters from an url
  30209. * @param url defines the url to clean
  30210. * @returns the cleaned url
  30211. */
  30212. static CleanUrl(url: string): string;
  30213. /**
  30214. * Gets or sets a function used to pre-process url before using them to load assets
  30215. */
  30216. static PreprocessUrl: (url: string) => string;
  30217. /**
  30218. * Loads an image as an HTMLImageElement.
  30219. * @param input url string, ArrayBuffer, or Blob to load
  30220. * @param onLoad callback called when the image successfully loads
  30221. * @param onError callback called when the image fails to load
  30222. * @param offlineProvider offline provider for caching
  30223. * @returns the HTMLImageElement of the loaded image
  30224. */
  30225. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30226. /**
  30227. * Loads a file
  30228. * @param url url string, ArrayBuffer, or Blob to load
  30229. * @param onSuccess callback called when the file successfully loads
  30230. * @param onProgress callback called while file is loading (if the server supports this mode)
  30231. * @param offlineProvider defines the offline provider for caching
  30232. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30233. * @param onError callback called when the file fails to load
  30234. * @returns a file request object
  30235. */
  30236. 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;
  30237. /**
  30238. * Load a script (identified by an url). When the url returns, the
  30239. * content of this file is added into a new script element, attached to the DOM (body element)
  30240. * @param scriptUrl defines the url of the script to laod
  30241. * @param onSuccess defines the callback called when the script is loaded
  30242. * @param onError defines the callback to call if an error occurs
  30243. */
  30244. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30245. /**
  30246. * Loads a file from a blob
  30247. * @param fileToLoad defines the blob to use
  30248. * @param callback defines the callback to call when data is loaded
  30249. * @param progressCallback defines the callback to call during loading process
  30250. * @returns a file request object
  30251. */
  30252. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30253. /**
  30254. * Loads a file
  30255. * @param fileToLoad defines the file to load
  30256. * @param callback defines the callback to call when data is loaded
  30257. * @param progressCallBack defines the callback to call during loading process
  30258. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30259. * @returns a file request object
  30260. */
  30261. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30262. /**
  30263. * Creates a data url from a given string content
  30264. * @param content defines the content to convert
  30265. * @returns the new data url link
  30266. */
  30267. static FileAsURL(content: string): string;
  30268. /**
  30269. * Format the given number to a specific decimal format
  30270. * @param value defines the number to format
  30271. * @param decimals defines the number of decimals to use
  30272. * @returns the formatted string
  30273. */
  30274. static Format(value: number, decimals?: number): string;
  30275. /**
  30276. * Checks if a given vector is inside a specific range
  30277. * @param v defines the vector to test
  30278. * @param min defines the minimum range
  30279. * @param max defines the maximum range
  30280. */
  30281. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30282. /**
  30283. * Tries to copy an object by duplicating every property
  30284. * @param source defines the source object
  30285. * @param destination defines the target object
  30286. * @param doNotCopyList defines a list of properties to avoid
  30287. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30288. */
  30289. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30290. /**
  30291. * Gets a boolean indicating if the given object has no own property
  30292. * @param obj defines the object to test
  30293. * @returns true if object has no own property
  30294. */
  30295. static IsEmpty(obj: any): boolean;
  30296. /**
  30297. * Function used to register events at window level
  30298. * @param events defines the events to register
  30299. */
  30300. static RegisterTopRootEvents(events: {
  30301. name: string;
  30302. handler: Nullable<(e: FocusEvent) => any>;
  30303. }[]): void;
  30304. /**
  30305. * Function used to unregister events from window level
  30306. * @param events defines the events to unregister
  30307. */
  30308. static UnregisterTopRootEvents(events: {
  30309. name: string;
  30310. handler: Nullable<(e: FocusEvent) => any>;
  30311. }[]): void;
  30312. /**
  30313. * Dumps the current bound framebuffer
  30314. * @param width defines the rendering width
  30315. * @param height defines the rendering height
  30316. * @param engine defines the hosting engine
  30317. * @param successCallback defines the callback triggered once the data are available
  30318. * @param mimeType defines the mime type of the result
  30319. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30320. */
  30321. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30322. /**
  30323. * Converts the canvas data to blob.
  30324. * This acts as a polyfill for browsers not supporting the to blob function.
  30325. * @param canvas Defines the canvas to extract the data from
  30326. * @param successCallback Defines the callback triggered once the data are available
  30327. * @param mimeType Defines the mime type of the result
  30328. */
  30329. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30330. /**
  30331. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30332. * @param successCallback defines the callback triggered once the data are available
  30333. * @param mimeType defines the mime type of the result
  30334. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30335. */
  30336. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30337. /**
  30338. * Downloads a blob in the browser
  30339. * @param blob defines the blob to download
  30340. * @param fileName defines the name of the downloaded file
  30341. */
  30342. static Download(blob: Blob, fileName: string): void;
  30343. /**
  30344. * Captures a screenshot of the current rendering
  30345. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30346. * @param engine defines the rendering engine
  30347. * @param camera defines the source camera
  30348. * @param size This parameter can be set to a single number or to an object with the
  30349. * following (optional) properties: precision, width, height. If a single number is passed,
  30350. * it will be used for both width and height. If an object is passed, the screenshot size
  30351. * will be derived from the parameters. The precision property is a multiplier allowing
  30352. * rendering at a higher or lower resolution
  30353. * @param successCallback defines the callback receives a single parameter which contains the
  30354. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30355. * src parameter of an <img> to display it
  30356. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30357. * Check your browser for supported MIME types
  30358. */
  30359. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30360. /**
  30361. * Generates an image screenshot from the specified camera.
  30362. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30363. * @param engine The engine to use for rendering
  30364. * @param camera The camera to use for rendering
  30365. * @param size This parameter can be set to a single number or to an object with the
  30366. * following (optional) properties: precision, width, height. If a single number is passed,
  30367. * it will be used for both width and height. If an object is passed, the screenshot size
  30368. * will be derived from the parameters. The precision property is a multiplier allowing
  30369. * rendering at a higher or lower resolution
  30370. * @param successCallback The callback receives a single parameter which contains the
  30371. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30372. * src parameter of an <img> to display it
  30373. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30374. * Check your browser for supported MIME types
  30375. * @param samples Texture samples (default: 1)
  30376. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30377. * @param fileName A name for for the downloaded file.
  30378. */
  30379. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30380. /**
  30381. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30382. * Be aware Math.random() could cause collisions, but:
  30383. * "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"
  30384. * @returns a pseudo random id
  30385. */
  30386. static RandomId(): string;
  30387. /**
  30388. * Test if the given uri is a base64 string
  30389. * @param uri The uri to test
  30390. * @return True if the uri is a base64 string or false otherwise
  30391. */
  30392. static IsBase64(uri: string): boolean;
  30393. /**
  30394. * Decode the given base64 uri.
  30395. * @param uri The uri to decode
  30396. * @return The decoded base64 data.
  30397. */
  30398. static DecodeBase64(uri: string): ArrayBuffer;
  30399. /**
  30400. * No log
  30401. */
  30402. static readonly NoneLogLevel: number;
  30403. /**
  30404. * Only message logs
  30405. */
  30406. static readonly MessageLogLevel: number;
  30407. /**
  30408. * Only warning logs
  30409. */
  30410. static readonly WarningLogLevel: number;
  30411. /**
  30412. * Only error logs
  30413. */
  30414. static readonly ErrorLogLevel: number;
  30415. /**
  30416. * All logs
  30417. */
  30418. static readonly AllLogLevel: number;
  30419. /**
  30420. * Gets a value indicating the number of loading errors
  30421. * @ignorenaming
  30422. */
  30423. static readonly errorsCount: number;
  30424. /**
  30425. * Callback called when a new log is added
  30426. */
  30427. static OnNewCacheEntry: (entry: string) => void;
  30428. /**
  30429. * Log a message to the console
  30430. * @param message defines the message to log
  30431. */
  30432. static Log(message: string): void;
  30433. /**
  30434. * Write a warning message to the console
  30435. * @param message defines the message to log
  30436. */
  30437. static Warn(message: string): void;
  30438. /**
  30439. * Write an error message to the console
  30440. * @param message defines the message to log
  30441. */
  30442. static Error(message: string): void;
  30443. /**
  30444. * Gets current log cache (list of logs)
  30445. */
  30446. static readonly LogCache: string;
  30447. /**
  30448. * Clears the log cache
  30449. */
  30450. static ClearLogCache(): void;
  30451. /**
  30452. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30453. */
  30454. static LogLevels: number;
  30455. /**
  30456. * Checks if the loaded document was accessed via `file:`-Protocol.
  30457. * @returns boolean
  30458. */
  30459. static IsFileURL(): boolean;
  30460. /**
  30461. * Checks if the window object exists
  30462. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30463. */
  30464. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30465. /**
  30466. * No performance log
  30467. */
  30468. static readonly PerformanceNoneLogLevel: number;
  30469. /**
  30470. * Use user marks to log performance
  30471. */
  30472. static readonly PerformanceUserMarkLogLevel: number;
  30473. /**
  30474. * Log performance to the console
  30475. */
  30476. static readonly PerformanceConsoleLogLevel: number;
  30477. private static _performance;
  30478. /**
  30479. * Sets the current performance log level
  30480. */
  30481. static PerformanceLogLevel: number;
  30482. private static _StartPerformanceCounterDisabled;
  30483. private static _EndPerformanceCounterDisabled;
  30484. private static _StartUserMark;
  30485. private static _EndUserMark;
  30486. private static _StartPerformanceConsole;
  30487. private static _EndPerformanceConsole;
  30488. /**
  30489. * Injects the @see CustomRequestHeaders into the given request
  30490. * @param request the request that should be used for injection
  30491. */
  30492. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  30493. /**
  30494. * Starts a performance counter
  30495. */
  30496. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30497. /**
  30498. * Ends a specific performance coutner
  30499. */
  30500. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30501. /**
  30502. * Gets either window.performance.now() if supported or Date.now() else
  30503. */
  30504. static readonly Now: number;
  30505. /**
  30506. * This method will return the name of the class used to create the instance of the given object.
  30507. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30508. * @param object the object to get the class name from
  30509. * @param isType defines if the object is actually a type
  30510. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30511. */
  30512. static GetClassName(object: any, isType?: boolean): string;
  30513. /**
  30514. * Gets the first element of an array satisfying a given predicate
  30515. * @param array defines the array to browse
  30516. * @param predicate defines the predicate to use
  30517. * @returns null if not found or the element
  30518. */
  30519. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30520. /**
  30521. * This method will return the name of the full name of the class, including its owning module (if any).
  30522. * 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).
  30523. * @param object the object to get the class name from
  30524. * @param isType defines if the object is actually a type
  30525. * @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.
  30526. * @ignorenaming
  30527. */
  30528. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30529. /**
  30530. * Returns a promise that resolves after the given amount of time.
  30531. * @param delay Number of milliseconds to delay
  30532. * @returns Promise that resolves after the given amount of time
  30533. */
  30534. static DelayAsync(delay: number): Promise<void>;
  30535. /**
  30536. * Gets the current gradient from an array of IValueGradient
  30537. * @param ratio defines the current ratio to get
  30538. * @param gradients defines the array of IValueGradient
  30539. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30540. */
  30541. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30542. }
  30543. /**
  30544. * This class is used to track a performance counter which is number based.
  30545. * The user has access to many properties which give statistics of different nature.
  30546. *
  30547. * The implementer can track two kinds of Performance Counter: time and count.
  30548. * 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.
  30549. * 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.
  30550. */
  30551. export class PerfCounter {
  30552. /**
  30553. * Gets or sets a global boolean to turn on and off all the counters
  30554. */
  30555. static Enabled: boolean;
  30556. /**
  30557. * Returns the smallest value ever
  30558. */
  30559. readonly min: number;
  30560. /**
  30561. * Returns the biggest value ever
  30562. */
  30563. readonly max: number;
  30564. /**
  30565. * Returns the average value since the performance counter is running
  30566. */
  30567. readonly average: number;
  30568. /**
  30569. * Returns the average value of the last second the counter was monitored
  30570. */
  30571. readonly lastSecAverage: number;
  30572. /**
  30573. * Returns the current value
  30574. */
  30575. readonly current: number;
  30576. /**
  30577. * Gets the accumulated total
  30578. */
  30579. readonly total: number;
  30580. /**
  30581. * Gets the total value count
  30582. */
  30583. readonly count: number;
  30584. /**
  30585. * Creates a new counter
  30586. */
  30587. constructor();
  30588. /**
  30589. * Call this method to start monitoring a new frame.
  30590. * 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.
  30591. */
  30592. fetchNewFrame(): void;
  30593. /**
  30594. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30595. * @param newCount the count value to add to the monitored count
  30596. * @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.
  30597. */
  30598. addCount(newCount: number, fetchResult: boolean): void;
  30599. /**
  30600. * Start monitoring this performance counter
  30601. */
  30602. beginMonitoring(): void;
  30603. /**
  30604. * Compute the time lapsed since the previous beginMonitoring() call.
  30605. * @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
  30606. */
  30607. endMonitoring(newFrame?: boolean): void;
  30608. private _fetchResult;
  30609. private _startMonitoringTime;
  30610. private _min;
  30611. private _max;
  30612. private _average;
  30613. private _current;
  30614. private _totalValueCount;
  30615. private _totalAccumulated;
  30616. private _lastSecAverage;
  30617. private _lastSecAccumulated;
  30618. private _lastSecTime;
  30619. private _lastSecValueCount;
  30620. }
  30621. /**
  30622. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30623. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30624. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30625. * @param name The name of the class, case should be preserved
  30626. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30627. */
  30628. export function className(name: string, module?: string): (target: Object) => void;
  30629. /**
  30630. * An implementation of a loop for asynchronous functions.
  30631. */
  30632. export class AsyncLoop {
  30633. /**
  30634. * Defines the number of iterations for the loop
  30635. */
  30636. iterations: number;
  30637. /**
  30638. * Defines the current index of the loop.
  30639. */
  30640. index: number;
  30641. private _done;
  30642. private _fn;
  30643. private _successCallback;
  30644. /**
  30645. * Constructor.
  30646. * @param iterations the number of iterations.
  30647. * @param func the function to run each iteration
  30648. * @param successCallback the callback that will be called upon succesful execution
  30649. * @param offset starting offset.
  30650. */
  30651. constructor(
  30652. /**
  30653. * Defines the number of iterations for the loop
  30654. */
  30655. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30656. /**
  30657. * Execute the next iteration. Must be called after the last iteration was finished.
  30658. */
  30659. executeNext(): void;
  30660. /**
  30661. * Break the loop and run the success callback.
  30662. */
  30663. breakLoop(): void;
  30664. /**
  30665. * Create and run an async loop.
  30666. * @param iterations the number of iterations.
  30667. * @param fn the function to run each iteration
  30668. * @param successCallback the callback that will be called upon succesful execution
  30669. * @param offset starting offset.
  30670. * @returns the created async loop object
  30671. */
  30672. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30673. /**
  30674. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30675. * @param iterations total number of iterations
  30676. * @param syncedIterations number of synchronous iterations in each async iteration.
  30677. * @param fn the function to call each iteration.
  30678. * @param callback a success call back that will be called when iterating stops.
  30679. * @param breakFunction a break condition (optional)
  30680. * @param timeout timeout settings for the setTimeout function. default - 0.
  30681. * @returns the created async loop object
  30682. */
  30683. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30684. }
  30685. }
  30686. declare module BABYLON {
  30687. /** @hidden */
  30688. export interface ICollisionCoordinator {
  30689. createCollider(): Collider;
  30690. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30691. init(scene: Scene): void;
  30692. }
  30693. /** @hidden */
  30694. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30695. private _scene;
  30696. private _scaledPosition;
  30697. private _scaledVelocity;
  30698. private _finalPosition;
  30699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30700. createCollider(): Collider;
  30701. init(scene: Scene): void;
  30702. private _collideWithWorld;
  30703. }
  30704. }
  30705. declare module BABYLON {
  30706. /**
  30707. * This class defines the direct association between an animation and a target
  30708. */
  30709. export class TargetedAnimation {
  30710. /**
  30711. * Animation to perform
  30712. */
  30713. animation: Animation;
  30714. /**
  30715. * Target to animate
  30716. */
  30717. target: any;
  30718. }
  30719. /**
  30720. * Use this class to create coordinated animations on multiple targets
  30721. */
  30722. export class AnimationGroup implements IDisposable {
  30723. /** The name of the animation group */
  30724. name: string;
  30725. private _scene;
  30726. private _targetedAnimations;
  30727. private _animatables;
  30728. private _from;
  30729. private _to;
  30730. private _isStarted;
  30731. private _isPaused;
  30732. private _speedRatio;
  30733. /**
  30734. * Gets or sets the unique id of the node
  30735. */
  30736. uniqueId: number;
  30737. /**
  30738. * This observable will notify when one animation have ended
  30739. */
  30740. onAnimationEndObservable: Observable<TargetedAnimation>;
  30741. /**
  30742. * Observer raised when one animation loops
  30743. */
  30744. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30745. /**
  30746. * This observable will notify when all animations have ended.
  30747. */
  30748. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30749. /**
  30750. * This observable will notify when all animations have paused.
  30751. */
  30752. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30753. /**
  30754. * This observable will notify when all animations are playing.
  30755. */
  30756. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30757. /**
  30758. * Gets the first frame
  30759. */
  30760. readonly from: number;
  30761. /**
  30762. * Gets the last frame
  30763. */
  30764. readonly to: number;
  30765. /**
  30766. * Define if the animations are started
  30767. */
  30768. readonly isStarted: boolean;
  30769. /**
  30770. * Gets a value indicating that the current group is playing
  30771. */
  30772. readonly isPlaying: boolean;
  30773. /**
  30774. * Gets or sets the speed ratio to use for all animations
  30775. */
  30776. /**
  30777. * Gets or sets the speed ratio to use for all animations
  30778. */
  30779. speedRatio: number;
  30780. /**
  30781. * Gets the targeted animations for this animation group
  30782. */
  30783. readonly targetedAnimations: Array<TargetedAnimation>;
  30784. /**
  30785. * returning the list of animatables controlled by this animation group.
  30786. */
  30787. readonly animatables: Array<Animatable>;
  30788. /**
  30789. * Instantiates a new Animation Group.
  30790. * This helps managing several animations at once.
  30791. * @see http://doc.babylonjs.com/how_to/group
  30792. * @param name Defines the name of the group
  30793. * @param scene Defines the scene the group belongs to
  30794. */
  30795. constructor(
  30796. /** The name of the animation group */
  30797. name: string, scene?: Nullable<Scene>);
  30798. /**
  30799. * Add an animation (with its target) in the group
  30800. * @param animation defines the animation we want to add
  30801. * @param target defines the target of the animation
  30802. * @returns the TargetedAnimation object
  30803. */
  30804. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30805. /**
  30806. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30807. * It can add constant keys at begin or end
  30808. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30809. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30810. * @returns the animation group
  30811. */
  30812. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30813. /**
  30814. * Start all animations on given targets
  30815. * @param loop defines if animations must loop
  30816. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30817. * @param from defines the from key (optional)
  30818. * @param to defines the to key (optional)
  30819. * @returns the current animation group
  30820. */
  30821. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30822. /**
  30823. * Pause all animations
  30824. * @returns the animation group
  30825. */
  30826. pause(): AnimationGroup;
  30827. /**
  30828. * Play all animations to initial state
  30829. * This function will start() the animations if they were not started or will restart() them if they were paused
  30830. * @param loop defines if animations must loop
  30831. * @returns the animation group
  30832. */
  30833. play(loop?: boolean): AnimationGroup;
  30834. /**
  30835. * Reset all animations to initial state
  30836. * @returns the animation group
  30837. */
  30838. reset(): AnimationGroup;
  30839. /**
  30840. * Restart animations from key 0
  30841. * @returns the animation group
  30842. */
  30843. restart(): AnimationGroup;
  30844. /**
  30845. * Stop all animations
  30846. * @returns the animation group
  30847. */
  30848. stop(): AnimationGroup;
  30849. /**
  30850. * Set animation weight for all animatables
  30851. * @param weight defines the weight to use
  30852. * @return the animationGroup
  30853. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30854. */
  30855. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30856. /**
  30857. * Synchronize and normalize all animatables with a source animatable
  30858. * @param root defines the root animatable to synchronize with
  30859. * @return the animationGroup
  30860. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30861. */
  30862. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30863. /**
  30864. * Goes to a specific frame in this animation group
  30865. * @param frame the frame number to go to
  30866. * @return the animationGroup
  30867. */
  30868. goToFrame(frame: number): AnimationGroup;
  30869. /**
  30870. * Dispose all associated resources
  30871. */
  30872. dispose(): void;
  30873. private _checkAnimationGroupEnded;
  30874. /**
  30875. * Clone the current animation group and returns a copy
  30876. * @param newName defines the name of the new group
  30877. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  30878. * @returns the new aniamtion group
  30879. */
  30880. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  30881. /**
  30882. * Returns a new AnimationGroup object parsed from the source provided.
  30883. * @param parsedAnimationGroup defines the source
  30884. * @param scene defines the scene that will receive the animationGroup
  30885. * @returns a new AnimationGroup
  30886. */
  30887. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30888. /**
  30889. * Returns the string "AnimationGroup"
  30890. * @returns "AnimationGroup"
  30891. */
  30892. getClassName(): string;
  30893. /**
  30894. * Creates a detailled string about the object
  30895. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30896. * @returns a string representing the object
  30897. */
  30898. toString(fullDetails?: boolean): string;
  30899. }
  30900. }
  30901. declare module BABYLON {
  30902. /**
  30903. * Define an interface for all classes that will hold resources
  30904. */
  30905. export interface IDisposable {
  30906. /**
  30907. * Releases all held resources
  30908. */
  30909. dispose(): void;
  30910. }
  30911. /** Interface defining initialization parameters for Scene class */
  30912. export interface SceneOptions {
  30913. /**
  30914. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30915. * It will improve performance when the number of geometries becomes important.
  30916. */
  30917. useGeometryUniqueIdsMap?: boolean;
  30918. /**
  30919. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30920. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30921. */
  30922. useMaterialMeshMap?: boolean;
  30923. /**
  30924. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30925. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30926. */
  30927. useClonedMeshhMap?: boolean;
  30928. }
  30929. /**
  30930. * Represents a scene to be rendered by the engine.
  30931. * @see http://doc.babylonjs.com/features/scene
  30932. */
  30933. export class Scene extends AbstractScene implements IAnimatable {
  30934. private static _uniqueIdCounter;
  30935. /** The fog is deactivated */
  30936. static readonly FOGMODE_NONE: number;
  30937. /** The fog density is following an exponential function */
  30938. static readonly FOGMODE_EXP: number;
  30939. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30940. static readonly FOGMODE_EXP2: number;
  30941. /** The fog density is following a linear function. */
  30942. static readonly FOGMODE_LINEAR: number;
  30943. /**
  30944. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30945. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30946. */
  30947. static MinDeltaTime: number;
  30948. /**
  30949. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30950. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30951. */
  30952. static MaxDeltaTime: number;
  30953. /**
  30954. * Factory used to create the default material.
  30955. * @param name The name of the material to create
  30956. * @param scene The scene to create the material for
  30957. * @returns The default material
  30958. */
  30959. static DefaultMaterialFactory(scene: Scene): Material;
  30960. /**
  30961. * Factory used to create the a collision coordinator.
  30962. * @returns The collision coordinator
  30963. */
  30964. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30965. /** @hidden */
  30966. readonly _isScene: boolean;
  30967. /**
  30968. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30969. */
  30970. autoClear: boolean;
  30971. /**
  30972. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30973. */
  30974. autoClearDepthAndStencil: boolean;
  30975. /**
  30976. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30977. */
  30978. clearColor: Color4;
  30979. /**
  30980. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30981. */
  30982. ambientColor: Color3;
  30983. /** @hidden */
  30984. _environmentBRDFTexture: BaseTexture;
  30985. /** @hidden */
  30986. protected _environmentTexture: Nullable<BaseTexture>;
  30987. /**
  30988. * Texture used in all pbr material as the reflection texture.
  30989. * As in the majority of the scene they are the same (exception for multi room and so on),
  30990. * this is easier to reference from here than from all the materials.
  30991. */
  30992. /**
  30993. * Texture used in all pbr material as the reflection texture.
  30994. * As in the majority of the scene they are the same (exception for multi room and so on),
  30995. * this is easier to set here than in all the materials.
  30996. */
  30997. environmentTexture: Nullable<BaseTexture>;
  30998. /** @hidden */
  30999. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31000. /**
  31001. * Default image processing configuration used either in the rendering
  31002. * Forward main pass or through the imageProcessingPostProcess if present.
  31003. * As in the majority of the scene they are the same (exception for multi camera),
  31004. * this is easier to reference from here than from all the materials and post process.
  31005. *
  31006. * No setter as we it is a shared configuration, you can set the values instead.
  31007. */
  31008. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31009. private _forceWireframe;
  31010. /**
  31011. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31012. */
  31013. forceWireframe: boolean;
  31014. private _forcePointsCloud;
  31015. /**
  31016. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31017. */
  31018. forcePointsCloud: boolean;
  31019. /**
  31020. * Gets or sets the active clipplane 1
  31021. */
  31022. clipPlane: Nullable<Plane>;
  31023. /**
  31024. * Gets or sets the active clipplane 2
  31025. */
  31026. clipPlane2: Nullable<Plane>;
  31027. /**
  31028. * Gets or sets the active clipplane 3
  31029. */
  31030. clipPlane3: Nullable<Plane>;
  31031. /**
  31032. * Gets or sets the active clipplane 4
  31033. */
  31034. clipPlane4: Nullable<Plane>;
  31035. /**
  31036. * Gets or sets a boolean indicating if animations are enabled
  31037. */
  31038. animationsEnabled: boolean;
  31039. private _animationPropertiesOverride;
  31040. /**
  31041. * Gets or sets the animation properties override
  31042. */
  31043. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31044. /**
  31045. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31046. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31047. */
  31048. useConstantAnimationDeltaTime: boolean;
  31049. /**
  31050. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31051. * Please note that it requires to run a ray cast through the scene on every frame
  31052. */
  31053. constantlyUpdateMeshUnderPointer: boolean;
  31054. /**
  31055. * Defines the HTML cursor to use when hovering over interactive elements
  31056. */
  31057. hoverCursor: string;
  31058. /**
  31059. * Defines the HTML default cursor to use (empty by default)
  31060. */
  31061. defaultCursor: string;
  31062. /**
  31063. * This is used to call preventDefault() on pointer down
  31064. * in order to block unwanted artifacts like system double clicks
  31065. */
  31066. preventDefaultOnPointerDown: boolean;
  31067. /**
  31068. * This is used to call preventDefault() on pointer up
  31069. * in order to block unwanted artifacts like system double clicks
  31070. */
  31071. preventDefaultOnPointerUp: boolean;
  31072. /**
  31073. * Gets or sets user defined metadata
  31074. */
  31075. metadata: any;
  31076. /**
  31077. * For internal use only. Please do not use.
  31078. */
  31079. reservedDataStore: any;
  31080. /**
  31081. * Gets the name of the plugin used to load this scene (null by default)
  31082. */
  31083. loadingPluginName: string;
  31084. /**
  31085. * Use this array to add regular expressions used to disable offline support for specific urls
  31086. */
  31087. disableOfflineSupportExceptionRules: RegExp[];
  31088. /**
  31089. * An event triggered when the scene is disposed.
  31090. */
  31091. onDisposeObservable: Observable<Scene>;
  31092. private _onDisposeObserver;
  31093. /** Sets a function to be executed when this scene is disposed. */
  31094. onDispose: () => void;
  31095. /**
  31096. * An event triggered before rendering the scene (right after animations and physics)
  31097. */
  31098. onBeforeRenderObservable: Observable<Scene>;
  31099. private _onBeforeRenderObserver;
  31100. /** Sets a function to be executed before rendering this scene */
  31101. beforeRender: Nullable<() => void>;
  31102. /**
  31103. * An event triggered after rendering the scene
  31104. */
  31105. onAfterRenderObservable: Observable<Scene>;
  31106. private _onAfterRenderObserver;
  31107. /** Sets a function to be executed after rendering this scene */
  31108. afterRender: Nullable<() => void>;
  31109. /**
  31110. * An event triggered before animating the scene
  31111. */
  31112. onBeforeAnimationsObservable: Observable<Scene>;
  31113. /**
  31114. * An event triggered after animations processing
  31115. */
  31116. onAfterAnimationsObservable: Observable<Scene>;
  31117. /**
  31118. * An event triggered before draw calls are ready to be sent
  31119. */
  31120. onBeforeDrawPhaseObservable: Observable<Scene>;
  31121. /**
  31122. * An event triggered after draw calls have been sent
  31123. */
  31124. onAfterDrawPhaseObservable: Observable<Scene>;
  31125. /**
  31126. * An event triggered when the scene is ready
  31127. */
  31128. onReadyObservable: Observable<Scene>;
  31129. /**
  31130. * An event triggered before rendering a camera
  31131. */
  31132. onBeforeCameraRenderObservable: Observable<Camera>;
  31133. private _onBeforeCameraRenderObserver;
  31134. /** Sets a function to be executed before rendering a camera*/
  31135. beforeCameraRender: () => void;
  31136. /**
  31137. * An event triggered after rendering a camera
  31138. */
  31139. onAfterCameraRenderObservable: Observable<Camera>;
  31140. private _onAfterCameraRenderObserver;
  31141. /** Sets a function to be executed after rendering a camera*/
  31142. afterCameraRender: () => void;
  31143. /**
  31144. * An event triggered when active meshes evaluation is about to start
  31145. */
  31146. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31147. /**
  31148. * An event triggered when active meshes evaluation is done
  31149. */
  31150. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31151. /**
  31152. * An event triggered when particles rendering is about to start
  31153. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31154. */
  31155. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31156. /**
  31157. * An event triggered when particles rendering is done
  31158. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31159. */
  31160. onAfterParticlesRenderingObservable: Observable<Scene>;
  31161. /**
  31162. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31163. */
  31164. onDataLoadedObservable: Observable<Scene>;
  31165. /**
  31166. * An event triggered when a camera is created
  31167. */
  31168. onNewCameraAddedObservable: Observable<Camera>;
  31169. /**
  31170. * An event triggered when a camera is removed
  31171. */
  31172. onCameraRemovedObservable: Observable<Camera>;
  31173. /**
  31174. * An event triggered when a light is created
  31175. */
  31176. onNewLightAddedObservable: Observable<Light>;
  31177. /**
  31178. * An event triggered when a light is removed
  31179. */
  31180. onLightRemovedObservable: Observable<Light>;
  31181. /**
  31182. * An event triggered when a geometry is created
  31183. */
  31184. onNewGeometryAddedObservable: Observable<Geometry>;
  31185. /**
  31186. * An event triggered when a geometry is removed
  31187. */
  31188. onGeometryRemovedObservable: Observable<Geometry>;
  31189. /**
  31190. * An event triggered when a transform node is created
  31191. */
  31192. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31193. /**
  31194. * An event triggered when a transform node is removed
  31195. */
  31196. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31197. /**
  31198. * An event triggered when a mesh is created
  31199. */
  31200. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31201. /**
  31202. * An event triggered when a mesh is removed
  31203. */
  31204. onMeshRemovedObservable: Observable<AbstractMesh>;
  31205. /**
  31206. * An event triggered when a material is created
  31207. */
  31208. onNewMaterialAddedObservable: Observable<Material>;
  31209. /**
  31210. * An event triggered when a material is removed
  31211. */
  31212. onMaterialRemovedObservable: Observable<Material>;
  31213. /**
  31214. * An event triggered when a texture is created
  31215. */
  31216. onNewTextureAddedObservable: Observable<BaseTexture>;
  31217. /**
  31218. * An event triggered when a texture is removed
  31219. */
  31220. onTextureRemovedObservable: Observable<BaseTexture>;
  31221. /**
  31222. * An event triggered when render targets are about to be rendered
  31223. * Can happen multiple times per frame.
  31224. */
  31225. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31226. /**
  31227. * An event triggered when render targets were rendered.
  31228. * Can happen multiple times per frame.
  31229. */
  31230. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31231. /**
  31232. * An event triggered before calculating deterministic simulation step
  31233. */
  31234. onBeforeStepObservable: Observable<Scene>;
  31235. /**
  31236. * An event triggered after calculating deterministic simulation step
  31237. */
  31238. onAfterStepObservable: Observable<Scene>;
  31239. /**
  31240. * An event triggered when the activeCamera property is updated
  31241. */
  31242. onActiveCameraChanged: Observable<Scene>;
  31243. /**
  31244. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31245. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31246. * 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)
  31247. */
  31248. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31249. /**
  31250. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31251. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31252. * 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)
  31253. */
  31254. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31255. /**
  31256. * This Observable will when a mesh has been imported into the scene.
  31257. */
  31258. onMeshImportedObservable: Observable<AbstractMesh>;
  31259. /**
  31260. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31261. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31262. */
  31263. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31264. /** @hidden */
  31265. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31266. /**
  31267. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31268. */
  31269. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31270. /**
  31271. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31272. */
  31273. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31274. /**
  31275. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31276. */
  31277. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31278. private _onPointerMove;
  31279. private _onPointerDown;
  31280. private _onPointerUp;
  31281. /** Callback called when a pointer move is detected */
  31282. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31283. /** Callback called when a pointer down is detected */
  31284. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31285. /** Callback called when a pointer up is detected */
  31286. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31287. /** Callback called when a pointer pick is detected */
  31288. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31289. /**
  31290. * 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).
  31291. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31292. */
  31293. onPrePointerObservable: Observable<PointerInfoPre>;
  31294. /**
  31295. * Observable event triggered each time an input event is received from the rendering canvas
  31296. */
  31297. onPointerObservable: Observable<PointerInfo>;
  31298. /**
  31299. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31300. */
  31301. readonly unTranslatedPointer: Vector2;
  31302. /** The distance in pixel that you have to move to prevent some events */
  31303. static DragMovementThreshold: number;
  31304. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31305. static LongPressDelay: number;
  31306. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31307. static DoubleClickDelay: number;
  31308. /** If you need to check double click without raising a single click at first click, enable this flag */
  31309. static ExclusiveDoubleClickMode: boolean;
  31310. private _initClickEvent;
  31311. private _initActionManager;
  31312. private _delayedSimpleClick;
  31313. private _delayedSimpleClickTimeout;
  31314. private _previousDelayedSimpleClickTimeout;
  31315. private _meshPickProceed;
  31316. private _previousButtonPressed;
  31317. private _currentPickResult;
  31318. private _previousPickResult;
  31319. private _totalPointersPressed;
  31320. private _doubleClickOccured;
  31321. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31322. cameraToUseForPointers: Nullable<Camera>;
  31323. private _pointerX;
  31324. private _pointerY;
  31325. private _unTranslatedPointerX;
  31326. private _unTranslatedPointerY;
  31327. private _startingPointerPosition;
  31328. private _previousStartingPointerPosition;
  31329. private _startingPointerTime;
  31330. private _previousStartingPointerTime;
  31331. private _pointerCaptures;
  31332. private _timeAccumulator;
  31333. private _currentStepId;
  31334. private _currentInternalStep;
  31335. /** @hidden */
  31336. _mirroredCameraPosition: Nullable<Vector3>;
  31337. /**
  31338. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31339. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31340. */
  31341. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31342. /**
  31343. * Observable event triggered each time an keyboard event is received from the hosting window
  31344. */
  31345. onKeyboardObservable: Observable<KeyboardInfo>;
  31346. private _onKeyDown;
  31347. private _onKeyUp;
  31348. private _onCanvasFocusObserver;
  31349. private _onCanvasBlurObserver;
  31350. private _useRightHandedSystem;
  31351. /**
  31352. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31353. */
  31354. useRightHandedSystem: boolean;
  31355. /**
  31356. * Sets the step Id used by deterministic lock step
  31357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31358. * @param newStepId defines the step Id
  31359. */
  31360. setStepId(newStepId: number): void;
  31361. /**
  31362. * Gets the step Id used by deterministic lock step
  31363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31364. * @returns the step Id
  31365. */
  31366. getStepId(): number;
  31367. /**
  31368. * Gets the internal step used by deterministic lock step
  31369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31370. * @returns the internal step
  31371. */
  31372. getInternalStep(): number;
  31373. private _fogEnabled;
  31374. /**
  31375. * Gets or sets a boolean indicating if fog is enabled on this scene
  31376. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31377. * (Default is true)
  31378. */
  31379. fogEnabled: boolean;
  31380. private _fogMode;
  31381. /**
  31382. * Gets or sets the fog mode to use
  31383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31384. * | mode | value |
  31385. * | --- | --- |
  31386. * | FOGMODE_NONE | 0 |
  31387. * | FOGMODE_EXP | 1 |
  31388. * | FOGMODE_EXP2 | 2 |
  31389. * | FOGMODE_LINEAR | 3 |
  31390. */
  31391. fogMode: number;
  31392. /**
  31393. * Gets or sets the fog color to use
  31394. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31395. * (Default is Color3(0.2, 0.2, 0.3))
  31396. */
  31397. fogColor: Color3;
  31398. /**
  31399. * Gets or sets the fog density to use
  31400. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31401. * (Default is 0.1)
  31402. */
  31403. fogDensity: number;
  31404. /**
  31405. * Gets or sets the fog start distance to use
  31406. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31407. * (Default is 0)
  31408. */
  31409. fogStart: number;
  31410. /**
  31411. * Gets or sets the fog end distance to use
  31412. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31413. * (Default is 1000)
  31414. */
  31415. fogEnd: number;
  31416. private _shadowsEnabled;
  31417. /**
  31418. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31419. */
  31420. shadowsEnabled: boolean;
  31421. private _lightsEnabled;
  31422. /**
  31423. * Gets or sets a boolean indicating if lights are enabled on this scene
  31424. */
  31425. lightsEnabled: boolean;
  31426. /** All of the active cameras added to this scene. */
  31427. activeCameras: Camera[];
  31428. private _activeCamera;
  31429. /** Gets or sets the current active camera */
  31430. activeCamera: Nullable<Camera>;
  31431. private _defaultMaterial;
  31432. /** The default material used on meshes when no material is affected */
  31433. /** The default material used on meshes when no material is affected */
  31434. defaultMaterial: Material;
  31435. private _texturesEnabled;
  31436. /**
  31437. * Gets or sets a boolean indicating if textures are enabled on this scene
  31438. */
  31439. texturesEnabled: boolean;
  31440. /**
  31441. * Gets or sets a boolean indicating if particles are enabled on this scene
  31442. */
  31443. particlesEnabled: boolean;
  31444. /**
  31445. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31446. */
  31447. spritesEnabled: boolean;
  31448. private _skeletonsEnabled;
  31449. /**
  31450. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31451. */
  31452. skeletonsEnabled: boolean;
  31453. /**
  31454. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31455. */
  31456. lensFlaresEnabled: boolean;
  31457. /**
  31458. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31460. */
  31461. collisionsEnabled: boolean;
  31462. private _collisionCoordinator;
  31463. /** @hidden */
  31464. readonly collisionCoordinator: ICollisionCoordinator;
  31465. /**
  31466. * Defines the gravity applied to this scene (used only for collisions)
  31467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31468. */
  31469. gravity: Vector3;
  31470. /**
  31471. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31472. */
  31473. postProcessesEnabled: boolean;
  31474. /**
  31475. * The list of postprocesses added to the scene
  31476. */
  31477. postProcesses: PostProcess[];
  31478. /**
  31479. * Gets the current postprocess manager
  31480. */
  31481. postProcessManager: PostProcessManager;
  31482. /**
  31483. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31484. */
  31485. renderTargetsEnabled: boolean;
  31486. /**
  31487. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31488. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31489. */
  31490. dumpNextRenderTargets: boolean;
  31491. /**
  31492. * The list of user defined render targets added to the scene
  31493. */
  31494. customRenderTargets: RenderTargetTexture[];
  31495. /**
  31496. * Defines if texture loading must be delayed
  31497. * If true, textures will only be loaded when they need to be rendered
  31498. */
  31499. useDelayedTextureLoading: boolean;
  31500. /**
  31501. * Gets the list of meshes imported to the scene through SceneLoader
  31502. */
  31503. importedMeshesFiles: String[];
  31504. /**
  31505. * Gets or sets a boolean indicating if probes are enabled on this scene
  31506. */
  31507. probesEnabled: boolean;
  31508. /**
  31509. * Gets or sets the current offline provider to use to store scene data
  31510. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31511. */
  31512. offlineProvider: IOfflineProvider;
  31513. /**
  31514. * Gets or sets the action manager associated with the scene
  31515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31516. */
  31517. actionManager: AbstractActionManager;
  31518. private _meshesForIntersections;
  31519. /**
  31520. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31521. */
  31522. proceduralTexturesEnabled: boolean;
  31523. private _engine;
  31524. private _totalVertices;
  31525. /** @hidden */
  31526. _activeIndices: PerfCounter;
  31527. /** @hidden */
  31528. _activeParticles: PerfCounter;
  31529. /** @hidden */
  31530. _activeBones: PerfCounter;
  31531. private _animationRatio;
  31532. /** @hidden */
  31533. _animationTimeLast: number;
  31534. /** @hidden */
  31535. _animationTime: number;
  31536. /**
  31537. * Gets or sets a general scale for animation speed
  31538. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31539. */
  31540. animationTimeScale: number;
  31541. /** @hidden */
  31542. _cachedMaterial: Nullable<Material>;
  31543. /** @hidden */
  31544. _cachedEffect: Nullable<Effect>;
  31545. /** @hidden */
  31546. _cachedVisibility: Nullable<number>;
  31547. private _renderId;
  31548. private _frameId;
  31549. private _executeWhenReadyTimeoutId;
  31550. private _intermediateRendering;
  31551. private _viewUpdateFlag;
  31552. private _projectionUpdateFlag;
  31553. private _alternateViewUpdateFlag;
  31554. private _alternateProjectionUpdateFlag;
  31555. /** @hidden */
  31556. _toBeDisposed: Nullable<IDisposable>[];
  31557. private _activeRequests;
  31558. /** @hidden */
  31559. _pendingData: any[];
  31560. private _isDisposed;
  31561. /**
  31562. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31563. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31564. */
  31565. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31566. private _activeMeshes;
  31567. private _processedMaterials;
  31568. private _renderTargets;
  31569. /** @hidden */
  31570. _activeParticleSystems: SmartArray<IParticleSystem>;
  31571. private _activeSkeletons;
  31572. private _softwareSkinnedMeshes;
  31573. private _renderingManager;
  31574. /** @hidden */
  31575. _activeAnimatables: Animatable[];
  31576. private _transformMatrix;
  31577. private _sceneUbo;
  31578. private _alternateSceneUbo;
  31579. private _viewMatrix;
  31580. private _projectionMatrix;
  31581. private _alternateViewMatrix;
  31582. private _alternateProjectionMatrix;
  31583. private _alternateTransformMatrix;
  31584. private _useAlternateCameraConfiguration;
  31585. private _alternateRendering;
  31586. private _wheelEventName;
  31587. /** @hidden */
  31588. _forcedViewPosition: Nullable<Vector3>;
  31589. /** @hidden */
  31590. readonly _isAlternateRenderingEnabled: boolean;
  31591. private _frustumPlanes;
  31592. /**
  31593. * Gets the list of frustum planes (built from the active camera)
  31594. */
  31595. readonly frustumPlanes: Plane[];
  31596. /**
  31597. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31598. * This is useful if there are more lights that the maximum simulteanous authorized
  31599. */
  31600. requireLightSorting: boolean;
  31601. /** @hidden */
  31602. readonly useMaterialMeshMap: boolean;
  31603. /** @hidden */
  31604. readonly useClonedMeshhMap: boolean;
  31605. private _pointerOverMesh;
  31606. private _pickedDownMesh;
  31607. private _pickedUpMesh;
  31608. private _externalData;
  31609. private _uid;
  31610. /**
  31611. * @hidden
  31612. * Backing store of defined scene components.
  31613. */
  31614. _components: ISceneComponent[];
  31615. /**
  31616. * @hidden
  31617. * Backing store of defined scene components.
  31618. */
  31619. _serializableComponents: ISceneSerializableComponent[];
  31620. /**
  31621. * List of components to register on the next registration step.
  31622. */
  31623. private _transientComponents;
  31624. /**
  31625. * Registers the transient components if needed.
  31626. */
  31627. private _registerTransientComponents;
  31628. /**
  31629. * @hidden
  31630. * Add a component to the scene.
  31631. * Note that the ccomponent could be registered on th next frame if this is called after
  31632. * the register component stage.
  31633. * @param component Defines the component to add to the scene
  31634. */
  31635. _addComponent(component: ISceneComponent): void;
  31636. /**
  31637. * @hidden
  31638. * Gets a component from the scene.
  31639. * @param name defines the name of the component to retrieve
  31640. * @returns the component or null if not present
  31641. */
  31642. _getComponent(name: string): Nullable<ISceneComponent>;
  31643. /**
  31644. * @hidden
  31645. * Defines the actions happening before camera updates.
  31646. */
  31647. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31648. /**
  31649. * @hidden
  31650. * Defines the actions happening before clear the canvas.
  31651. */
  31652. _beforeClearStage: Stage<SimpleStageAction>;
  31653. /**
  31654. * @hidden
  31655. * Defines the actions when collecting render targets for the frame.
  31656. */
  31657. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31658. /**
  31659. * @hidden
  31660. * Defines the actions happening for one camera in the frame.
  31661. */
  31662. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31663. /**
  31664. * @hidden
  31665. * Defines the actions happening during the per mesh ready checks.
  31666. */
  31667. _isReadyForMeshStage: Stage<MeshStageAction>;
  31668. /**
  31669. * @hidden
  31670. * Defines the actions happening before evaluate active mesh checks.
  31671. */
  31672. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31673. /**
  31674. * @hidden
  31675. * Defines the actions happening during the evaluate sub mesh checks.
  31676. */
  31677. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31678. /**
  31679. * @hidden
  31680. * Defines the actions happening during the active mesh stage.
  31681. */
  31682. _activeMeshStage: Stage<ActiveMeshStageAction>;
  31683. /**
  31684. * @hidden
  31685. * Defines the actions happening during the per camera render target step.
  31686. */
  31687. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31688. /**
  31689. * @hidden
  31690. * Defines the actions happening just before the active camera is drawing.
  31691. */
  31692. _beforeCameraDrawStage: Stage<CameraStageAction>;
  31693. /**
  31694. * @hidden
  31695. * Defines the actions happening just before a render target is drawing.
  31696. */
  31697. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31698. /**
  31699. * @hidden
  31700. * Defines the actions happening just before a rendering group is drawing.
  31701. */
  31702. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31703. /**
  31704. * @hidden
  31705. * Defines the actions happening just before a mesh is drawing.
  31706. */
  31707. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31708. /**
  31709. * @hidden
  31710. * Defines the actions happening just after a mesh has been drawn.
  31711. */
  31712. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31713. /**
  31714. * @hidden
  31715. * Defines the actions happening just after a rendering group has been drawn.
  31716. */
  31717. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31718. /**
  31719. * @hidden
  31720. * Defines the actions happening just after the active camera has been drawn.
  31721. */
  31722. _afterCameraDrawStage: Stage<CameraStageAction>;
  31723. /**
  31724. * @hidden
  31725. * Defines the actions happening just after a render target has been drawn.
  31726. */
  31727. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31728. /**
  31729. * @hidden
  31730. * Defines the actions happening just after rendering all cameras and computing intersections.
  31731. */
  31732. _afterRenderStage: Stage<SimpleStageAction>;
  31733. /**
  31734. * @hidden
  31735. * Defines the actions happening when a pointer move event happens.
  31736. */
  31737. _pointerMoveStage: Stage<PointerMoveStageAction>;
  31738. /**
  31739. * @hidden
  31740. * Defines the actions happening when a pointer down event happens.
  31741. */
  31742. _pointerDownStage: Stage<PointerUpDownStageAction>;
  31743. /**
  31744. * @hidden
  31745. * Defines the actions happening when a pointer up event happens.
  31746. */
  31747. _pointerUpStage: Stage<PointerUpDownStageAction>;
  31748. /**
  31749. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31750. */
  31751. private geometriesByUniqueId;
  31752. /**
  31753. * Creates a new Scene
  31754. * @param engine defines the engine to use to render this scene
  31755. * @param options defines the scene options
  31756. */
  31757. constructor(engine: Engine, options?: SceneOptions);
  31758. private _defaultMeshCandidates;
  31759. /**
  31760. * @hidden
  31761. */
  31762. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31763. private _defaultSubMeshCandidates;
  31764. /**
  31765. * @hidden
  31766. */
  31767. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31768. /**
  31769. * Sets the default candidate providers for the scene.
  31770. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31771. * and getCollidingSubMeshCandidates to their default function
  31772. */
  31773. setDefaultCandidateProviders(): void;
  31774. /**
  31775. * Gets the mesh that is currently under the pointer
  31776. */
  31777. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31778. /**
  31779. * Gets or sets the current on-screen X position of the pointer
  31780. */
  31781. pointerX: number;
  31782. /**
  31783. * Gets or sets the current on-screen Y position of the pointer
  31784. */
  31785. pointerY: number;
  31786. /**
  31787. * Gets the cached material (ie. the latest rendered one)
  31788. * @returns the cached material
  31789. */
  31790. getCachedMaterial(): Nullable<Material>;
  31791. /**
  31792. * Gets the cached effect (ie. the latest rendered one)
  31793. * @returns the cached effect
  31794. */
  31795. getCachedEffect(): Nullable<Effect>;
  31796. /**
  31797. * Gets the cached visibility state (ie. the latest rendered one)
  31798. * @returns the cached visibility state
  31799. */
  31800. getCachedVisibility(): Nullable<number>;
  31801. /**
  31802. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31803. * @param material defines the current material
  31804. * @param effect defines the current effect
  31805. * @param visibility defines the current visibility state
  31806. * @returns true if one parameter is not cached
  31807. */
  31808. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31809. /**
  31810. * Gets the engine associated with the scene
  31811. * @returns an Engine
  31812. */
  31813. getEngine(): Engine;
  31814. /**
  31815. * Gets the total number of vertices rendered per frame
  31816. * @returns the total number of vertices rendered per frame
  31817. */
  31818. getTotalVertices(): number;
  31819. /**
  31820. * Gets the performance counter for total vertices
  31821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31822. */
  31823. readonly totalVerticesPerfCounter: PerfCounter;
  31824. /**
  31825. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31826. * @returns the total number of active indices rendered per frame
  31827. */
  31828. getActiveIndices(): number;
  31829. /**
  31830. * Gets the performance counter for active indices
  31831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31832. */
  31833. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31834. /**
  31835. * Gets the total number of active particles rendered per frame
  31836. * @returns the total number of active particles rendered per frame
  31837. */
  31838. getActiveParticles(): number;
  31839. /**
  31840. * Gets the performance counter for active particles
  31841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31842. */
  31843. readonly activeParticlesPerfCounter: PerfCounter;
  31844. /**
  31845. * Gets the total number of active bones rendered per frame
  31846. * @returns the total number of active bones rendered per frame
  31847. */
  31848. getActiveBones(): number;
  31849. /**
  31850. * Gets the performance counter for active bones
  31851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31852. */
  31853. readonly activeBonesPerfCounter: PerfCounter;
  31854. /**
  31855. * Gets the array of active meshes
  31856. * @returns an array of AbstractMesh
  31857. */
  31858. getActiveMeshes(): SmartArray<AbstractMesh>;
  31859. /**
  31860. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31861. * @returns a number
  31862. */
  31863. getAnimationRatio(): number;
  31864. /**
  31865. * Gets an unique Id for the current render phase
  31866. * @returns a number
  31867. */
  31868. getRenderId(): number;
  31869. /**
  31870. * Gets an unique Id for the current frame
  31871. * @returns a number
  31872. */
  31873. getFrameId(): number;
  31874. /** Call this function if you want to manually increment the render Id*/
  31875. incrementRenderId(): void;
  31876. private _updatePointerPosition;
  31877. private _createUbo;
  31878. private _createAlternateUbo;
  31879. private _setRayOnPointerInfo;
  31880. /**
  31881. * Use this method to simulate a pointer move on a mesh
  31882. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31883. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31884. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31885. * @returns the current scene
  31886. */
  31887. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31888. private _processPointerMove;
  31889. private _checkPrePointerObservable;
  31890. /**
  31891. * Use this method to simulate a pointer down on a mesh
  31892. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31893. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31894. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31895. * @returns the current scene
  31896. */
  31897. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31898. private _processPointerDown;
  31899. /**
  31900. * Use this method to simulate a pointer up on a mesh
  31901. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31902. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31903. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31904. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31905. * @returns the current scene
  31906. */
  31907. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31908. private _processPointerUp;
  31909. /**
  31910. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31911. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31912. * @returns true if the pointer was captured
  31913. */
  31914. isPointerCaptured(pointerId?: number): boolean;
  31915. /** @hidden */
  31916. _isPointerSwiping(): boolean;
  31917. /**
  31918. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31919. * @param attachUp defines if you want to attach events to pointerup
  31920. * @param attachDown defines if you want to attach events to pointerdown
  31921. * @param attachMove defines if you want to attach events to pointermove
  31922. */
  31923. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31924. /** Detaches all event handlers*/
  31925. detachControl(): void;
  31926. /**
  31927. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31928. * Delay loaded resources are not taking in account
  31929. * @return true if all required resources are ready
  31930. */
  31931. isReady(): boolean;
  31932. /** Resets all cached information relative to material (including effect and visibility) */
  31933. resetCachedMaterial(): void;
  31934. /**
  31935. * Registers a function to be called before every frame render
  31936. * @param func defines the function to register
  31937. */
  31938. registerBeforeRender(func: () => void): void;
  31939. /**
  31940. * Unregisters a function called before every frame render
  31941. * @param func defines the function to unregister
  31942. */
  31943. unregisterBeforeRender(func: () => void): void;
  31944. /**
  31945. * Registers a function to be called after every frame render
  31946. * @param func defines the function to register
  31947. */
  31948. registerAfterRender(func: () => void): void;
  31949. /**
  31950. * Unregisters a function called after every frame render
  31951. * @param func defines the function to unregister
  31952. */
  31953. unregisterAfterRender(func: () => void): void;
  31954. private _executeOnceBeforeRender;
  31955. /**
  31956. * The provided function will run before render once and will be disposed afterwards.
  31957. * A timeout delay can be provided so that the function will be executed in N ms.
  31958. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31959. * @param func The function to be executed.
  31960. * @param timeout optional delay in ms
  31961. */
  31962. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31963. /** @hidden */
  31964. _addPendingData(data: any): void;
  31965. /** @hidden */
  31966. _removePendingData(data: any): void;
  31967. /**
  31968. * Returns the number of items waiting to be loaded
  31969. * @returns the number of items waiting to be loaded
  31970. */
  31971. getWaitingItemsCount(): number;
  31972. /**
  31973. * Returns a boolean indicating if the scene is still loading data
  31974. */
  31975. readonly isLoading: boolean;
  31976. /**
  31977. * Registers a function to be executed when the scene is ready
  31978. * @param {Function} func - the function to be executed
  31979. */
  31980. executeWhenReady(func: () => void): void;
  31981. /**
  31982. * Returns a promise that resolves when the scene is ready
  31983. * @returns A promise that resolves when the scene is ready
  31984. */
  31985. whenReadyAsync(): Promise<void>;
  31986. /** @hidden */
  31987. _checkIsReady(): void;
  31988. /**
  31989. * Gets all animatable attached to the scene
  31990. */
  31991. readonly animatables: Animatable[];
  31992. /**
  31993. * Resets the last animation time frame.
  31994. * Useful to override when animations start running when loading a scene for the first time.
  31995. */
  31996. resetLastAnimationTimeFrame(): void;
  31997. /** @hidden */
  31998. _switchToAlternateCameraConfiguration(active: boolean): void;
  31999. /**
  32000. * Gets the current view matrix
  32001. * @returns a Matrix
  32002. */
  32003. getViewMatrix(): Matrix;
  32004. /**
  32005. * Gets the current projection matrix
  32006. * @returns a Matrix
  32007. */
  32008. getProjectionMatrix(): Matrix;
  32009. /**
  32010. * Gets the current transform matrix
  32011. * @returns a Matrix made of View * Projection
  32012. */
  32013. getTransformMatrix(): Matrix;
  32014. /**
  32015. * Sets the current transform matrix
  32016. * @param view defines the View matrix to use
  32017. * @param projection defines the Projection matrix to use
  32018. */
  32019. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32020. /** @hidden */
  32021. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32022. /**
  32023. * Gets the uniform buffer used to store scene data
  32024. * @returns a UniformBuffer
  32025. */
  32026. getSceneUniformBuffer(): UniformBuffer;
  32027. /**
  32028. * Gets an unique (relatively to the current scene) Id
  32029. * @returns an unique number for the scene
  32030. */
  32031. getUniqueId(): number;
  32032. /**
  32033. * Add a mesh to the list of scene's meshes
  32034. * @param newMesh defines the mesh to add
  32035. * @param recursive if all child meshes should also be added to the scene
  32036. */
  32037. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32038. /**
  32039. * Remove a mesh for the list of scene's meshes
  32040. * @param toRemove defines the mesh to remove
  32041. * @param recursive if all child meshes should also be removed from the scene
  32042. * @returns the index where the mesh was in the mesh list
  32043. */
  32044. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32045. /**
  32046. * Add a transform node to the list of scene's transform nodes
  32047. * @param newTransformNode defines the transform node to add
  32048. */
  32049. addTransformNode(newTransformNode: TransformNode): void;
  32050. /**
  32051. * Remove a transform node for the list of scene's transform nodes
  32052. * @param toRemove defines the transform node to remove
  32053. * @returns the index where the transform node was in the transform node list
  32054. */
  32055. removeTransformNode(toRemove: TransformNode): number;
  32056. /**
  32057. * Remove a skeleton for the list of scene's skeletons
  32058. * @param toRemove defines the skeleton to remove
  32059. * @returns the index where the skeleton was in the skeleton list
  32060. */
  32061. removeSkeleton(toRemove: Skeleton): number;
  32062. /**
  32063. * Remove a morph target for the list of scene's morph targets
  32064. * @param toRemove defines the morph target to remove
  32065. * @returns the index where the morph target was in the morph target list
  32066. */
  32067. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32068. /**
  32069. * Remove a light for the list of scene's lights
  32070. * @param toRemove defines the light to remove
  32071. * @returns the index where the light was in the light list
  32072. */
  32073. removeLight(toRemove: Light): number;
  32074. /**
  32075. * Remove a camera for the list of scene's cameras
  32076. * @param toRemove defines the camera to remove
  32077. * @returns the index where the camera was in the camera list
  32078. */
  32079. removeCamera(toRemove: Camera): number;
  32080. /**
  32081. * Remove a particle system for the list of scene's particle systems
  32082. * @param toRemove defines the particle system to remove
  32083. * @returns the index where the particle system was in the particle system list
  32084. */
  32085. removeParticleSystem(toRemove: IParticleSystem): number;
  32086. /**
  32087. * Remove a animation for the list of scene's animations
  32088. * @param toRemove defines the animation to remove
  32089. * @returns the index where the animation was in the animation list
  32090. */
  32091. removeAnimation(toRemove: Animation): number;
  32092. /**
  32093. * Removes the given animation group from this scene.
  32094. * @param toRemove The animation group to remove
  32095. * @returns The index of the removed animation group
  32096. */
  32097. removeAnimationGroup(toRemove: AnimationGroup): number;
  32098. /**
  32099. * Removes the given multi-material from this scene.
  32100. * @param toRemove The multi-material to remove
  32101. * @returns The index of the removed multi-material
  32102. */
  32103. removeMultiMaterial(toRemove: MultiMaterial): number;
  32104. /**
  32105. * Removes the given material from this scene.
  32106. * @param toRemove The material to remove
  32107. * @returns The index of the removed material
  32108. */
  32109. removeMaterial(toRemove: Material): number;
  32110. /**
  32111. * Removes the given action manager from this scene.
  32112. * @param toRemove The action manager to remove
  32113. * @returns The index of the removed action manager
  32114. */
  32115. removeActionManager(toRemove: AbstractActionManager): number;
  32116. /**
  32117. * Removes the given texture from this scene.
  32118. * @param toRemove The texture to remove
  32119. * @returns The index of the removed texture
  32120. */
  32121. removeTexture(toRemove: BaseTexture): number;
  32122. /**
  32123. * Adds the given light to this scene
  32124. * @param newLight The light to add
  32125. */
  32126. addLight(newLight: Light): void;
  32127. /**
  32128. * Sorts the list list based on light priorities
  32129. */
  32130. sortLightsByPriority(): void;
  32131. /**
  32132. * Adds the given camera to this scene
  32133. * @param newCamera The camera to add
  32134. */
  32135. addCamera(newCamera: Camera): void;
  32136. /**
  32137. * Adds the given skeleton to this scene
  32138. * @param newSkeleton The skeleton to add
  32139. */
  32140. addSkeleton(newSkeleton: Skeleton): void;
  32141. /**
  32142. * Adds the given particle system to this scene
  32143. * @param newParticleSystem The particle system to add
  32144. */
  32145. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32146. /**
  32147. * Adds the given animation to this scene
  32148. * @param newAnimation The animation to add
  32149. */
  32150. addAnimation(newAnimation: Animation): void;
  32151. /**
  32152. * Adds the given animation group to this scene.
  32153. * @param newAnimationGroup The animation group to add
  32154. */
  32155. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32156. /**
  32157. * Adds the given multi-material to this scene
  32158. * @param newMultiMaterial The multi-material to add
  32159. */
  32160. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32161. /**
  32162. * Adds the given material to this scene
  32163. * @param newMaterial The material to add
  32164. */
  32165. addMaterial(newMaterial: Material): void;
  32166. /**
  32167. * Adds the given morph target to this scene
  32168. * @param newMorphTargetManager The morph target to add
  32169. */
  32170. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32171. /**
  32172. * Adds the given geometry to this scene
  32173. * @param newGeometry The geometry to add
  32174. */
  32175. addGeometry(newGeometry: Geometry): void;
  32176. /**
  32177. * Adds the given action manager to this scene
  32178. * @param newActionManager The action manager to add
  32179. */
  32180. addActionManager(newActionManager: AbstractActionManager): void;
  32181. /**
  32182. * Adds the given texture to this scene.
  32183. * @param newTexture The texture to add
  32184. */
  32185. addTexture(newTexture: BaseTexture): void;
  32186. /**
  32187. * Switch active camera
  32188. * @param newCamera defines the new active camera
  32189. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32190. */
  32191. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32192. /**
  32193. * sets the active camera of the scene using its ID
  32194. * @param id defines the camera's ID
  32195. * @return the new active camera or null if none found.
  32196. */
  32197. setActiveCameraByID(id: string): Nullable<Camera>;
  32198. /**
  32199. * sets the active camera of the scene using its name
  32200. * @param name defines the camera's name
  32201. * @returns the new active camera or null if none found.
  32202. */
  32203. setActiveCameraByName(name: string): Nullable<Camera>;
  32204. /**
  32205. * get an animation group using its name
  32206. * @param name defines the material's name
  32207. * @return the animation group or null if none found.
  32208. */
  32209. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32210. /**
  32211. * get a material using its id
  32212. * @param id defines the material's ID
  32213. * @return the material or null if none found.
  32214. */
  32215. getMaterialByID(id: string): Nullable<Material>;
  32216. /**
  32217. * Gets a material using its name
  32218. * @param name defines the material's name
  32219. * @return the material or null if none found.
  32220. */
  32221. getMaterialByName(name: string): Nullable<Material>;
  32222. /**
  32223. * Gets a camera using its id
  32224. * @param id defines the id to look for
  32225. * @returns the camera or null if not found
  32226. */
  32227. getCameraByID(id: string): Nullable<Camera>;
  32228. /**
  32229. * Gets a camera using its unique id
  32230. * @param uniqueId defines the unique id to look for
  32231. * @returns the camera or null if not found
  32232. */
  32233. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32234. /**
  32235. * Gets a camera using its name
  32236. * @param name defines the camera's name
  32237. * @return the camera or null if none found.
  32238. */
  32239. getCameraByName(name: string): Nullable<Camera>;
  32240. /**
  32241. * Gets a bone using its id
  32242. * @param id defines the bone's id
  32243. * @return the bone or null if not found
  32244. */
  32245. getBoneByID(id: string): Nullable<Bone>;
  32246. /**
  32247. * Gets a bone using its id
  32248. * @param name defines the bone's name
  32249. * @return the bone or null if not found
  32250. */
  32251. getBoneByName(name: string): Nullable<Bone>;
  32252. /**
  32253. * Gets a light node using its name
  32254. * @param name defines the the light's name
  32255. * @return the light or null if none found.
  32256. */
  32257. getLightByName(name: string): Nullable<Light>;
  32258. /**
  32259. * Gets a light node using its id
  32260. * @param id defines the light's id
  32261. * @return the light or null if none found.
  32262. */
  32263. getLightByID(id: string): Nullable<Light>;
  32264. /**
  32265. * Gets a light node using its scene-generated unique ID
  32266. * @param uniqueId defines the light's unique id
  32267. * @return the light or null if none found.
  32268. */
  32269. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32270. /**
  32271. * Gets a particle system by id
  32272. * @param id defines the particle system id
  32273. * @return the corresponding system or null if none found
  32274. */
  32275. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32276. /**
  32277. * Gets a geometry using its ID
  32278. * @param id defines the geometry's id
  32279. * @return the geometry or null if none found.
  32280. */
  32281. getGeometryByID(id: string): Nullable<Geometry>;
  32282. private _getGeometryByUniqueID;
  32283. /**
  32284. * Add a new geometry to this scene
  32285. * @param geometry defines the geometry to be added to the scene.
  32286. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32287. * @return a boolean defining if the geometry was added or not
  32288. */
  32289. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32290. /**
  32291. * Removes an existing geometry
  32292. * @param geometry defines the geometry to be removed from the scene
  32293. * @return a boolean defining if the geometry was removed or not
  32294. */
  32295. removeGeometry(geometry: Geometry): boolean;
  32296. /**
  32297. * Gets the list of geometries attached to the scene
  32298. * @returns an array of Geometry
  32299. */
  32300. getGeometries(): Geometry[];
  32301. /**
  32302. * Gets the first added mesh found of a given ID
  32303. * @param id defines the id to search for
  32304. * @return the mesh found or null if not found at all
  32305. */
  32306. getMeshByID(id: string): Nullable<AbstractMesh>;
  32307. /**
  32308. * Gets a list of meshes using their id
  32309. * @param id defines the id to search for
  32310. * @returns a list of meshes
  32311. */
  32312. getMeshesByID(id: string): Array<AbstractMesh>;
  32313. /**
  32314. * Gets the first added transform node found of a given ID
  32315. * @param id defines the id to search for
  32316. * @return the found transform node or null if not found at all.
  32317. */
  32318. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32319. /**
  32320. * Gets a list of transform nodes using their id
  32321. * @param id defines the id to search for
  32322. * @returns a list of transform nodes
  32323. */
  32324. getTransformNodesByID(id: string): Array<TransformNode>;
  32325. /**
  32326. * Gets a mesh with its auto-generated unique id
  32327. * @param uniqueId defines the unique id to search for
  32328. * @return the found mesh or null if not found at all.
  32329. */
  32330. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32331. /**
  32332. * Gets a the last added mesh using a given id
  32333. * @param id defines the id to search for
  32334. * @return the found mesh or null if not found at all.
  32335. */
  32336. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32337. /**
  32338. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32339. * @param id defines the id to search for
  32340. * @return the found node or null if not found at all
  32341. */
  32342. getLastEntryByID(id: string): Nullable<Node>;
  32343. /**
  32344. * Gets a node (Mesh, Camera, Light) using a given id
  32345. * @param id defines the id to search for
  32346. * @return the found node or null if not found at all
  32347. */
  32348. getNodeByID(id: string): Nullable<Node>;
  32349. /**
  32350. * Gets a node (Mesh, Camera, Light) using a given name
  32351. * @param name defines the name to search for
  32352. * @return the found node or null if not found at all.
  32353. */
  32354. getNodeByName(name: string): Nullable<Node>;
  32355. /**
  32356. * Gets a mesh using a given name
  32357. * @param name defines the name to search for
  32358. * @return the found mesh or null if not found at all.
  32359. */
  32360. getMeshByName(name: string): Nullable<AbstractMesh>;
  32361. /**
  32362. * Gets a transform node using a given name
  32363. * @param name defines the name to search for
  32364. * @return the found transform node or null if not found at all.
  32365. */
  32366. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32367. /**
  32368. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32369. * @param id defines the id to search for
  32370. * @return the found skeleton or null if not found at all.
  32371. */
  32372. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32373. /**
  32374. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32375. * @param id defines the id to search for
  32376. * @return the found skeleton or null if not found at all.
  32377. */
  32378. getSkeletonById(id: string): Nullable<Skeleton>;
  32379. /**
  32380. * Gets a skeleton using a given name
  32381. * @param name defines the name to search for
  32382. * @return the found skeleton or null if not found at all.
  32383. */
  32384. getSkeletonByName(name: string): Nullable<Skeleton>;
  32385. /**
  32386. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32387. * @param id defines the id to search for
  32388. * @return the found morph target manager or null if not found at all.
  32389. */
  32390. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32391. /**
  32392. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32393. * @param id defines the id to search for
  32394. * @return the found morph target or null if not found at all.
  32395. */
  32396. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32397. /**
  32398. * Gets a boolean indicating if the given mesh is active
  32399. * @param mesh defines the mesh to look for
  32400. * @returns true if the mesh is in the active list
  32401. */
  32402. isActiveMesh(mesh: AbstractMesh): boolean;
  32403. /**
  32404. * Return a unique id as a string which can serve as an identifier for the scene
  32405. */
  32406. readonly uid: string;
  32407. /**
  32408. * Add an externaly attached data from its key.
  32409. * This method call will fail and return false, if such key already exists.
  32410. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32411. * @param key the unique key that identifies the data
  32412. * @param data the data object to associate to the key for this Engine instance
  32413. * @return true if no such key were already present and the data was added successfully, false otherwise
  32414. */
  32415. addExternalData<T>(key: string, data: T): boolean;
  32416. /**
  32417. * Get an externaly attached data from its key
  32418. * @param key the unique key that identifies the data
  32419. * @return the associated data, if present (can be null), or undefined if not present
  32420. */
  32421. getExternalData<T>(key: string): Nullable<T>;
  32422. /**
  32423. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32424. * @param key the unique key that identifies the data
  32425. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32426. * @return the associated data, can be null if the factory returned null.
  32427. */
  32428. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32429. /**
  32430. * Remove an externaly attached data from the Engine instance
  32431. * @param key the unique key that identifies the data
  32432. * @return true if the data was successfully removed, false if it doesn't exist
  32433. */
  32434. removeExternalData(key: string): boolean;
  32435. private _evaluateSubMesh;
  32436. /**
  32437. * Clear the processed materials smart array preventing retention point in material dispose.
  32438. */
  32439. freeProcessedMaterials(): void;
  32440. private _preventFreeActiveMeshesAndRenderingGroups;
  32441. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32442. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32443. * when disposing several meshes in a row or a hierarchy of meshes.
  32444. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32445. */
  32446. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32447. /**
  32448. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32449. */
  32450. freeActiveMeshes(): void;
  32451. /**
  32452. * Clear the info related to rendering groups preventing retention points during dispose.
  32453. */
  32454. freeRenderingGroups(): void;
  32455. /** @hidden */
  32456. _isInIntermediateRendering(): boolean;
  32457. /**
  32458. * Lambda returning the list of potentially active meshes.
  32459. */
  32460. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32461. /**
  32462. * Lambda returning the list of potentially active sub meshes.
  32463. */
  32464. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32465. /**
  32466. * Lambda returning the list of potentially intersecting sub meshes.
  32467. */
  32468. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32469. /**
  32470. * Lambda returning the list of potentially colliding sub meshes.
  32471. */
  32472. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32473. private _activeMeshesFrozen;
  32474. /**
  32475. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32476. * @returns the current scene
  32477. */
  32478. freezeActiveMeshes(): Scene;
  32479. /**
  32480. * Use this function to restart evaluating active meshes on every frame
  32481. * @returns the current scene
  32482. */
  32483. unfreezeActiveMeshes(): Scene;
  32484. private _evaluateActiveMeshes;
  32485. private _activeMesh;
  32486. /**
  32487. * Update the transform matrix to update from the current active camera
  32488. * @param force defines a boolean used to force the update even if cache is up to date
  32489. */
  32490. updateTransformMatrix(force?: boolean): void;
  32491. /**
  32492. * 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)
  32493. * @param alternateCamera defines the camera to use
  32494. */
  32495. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  32496. /** @hidden */
  32497. _allowPostProcessClearColor: boolean;
  32498. private _renderForCamera;
  32499. private _processSubCameras;
  32500. private _checkIntersections;
  32501. /** @hidden */
  32502. _advancePhysicsEngineStep(step: number): void;
  32503. /**
  32504. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32505. */
  32506. getDeterministicFrameTime: () => number;
  32507. /** @hidden */
  32508. _animate(): void;
  32509. /**
  32510. * Render the scene
  32511. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32512. */
  32513. render(updateCameras?: boolean): void;
  32514. /**
  32515. * Freeze all materials
  32516. * A frozen material will not be updatable but should be faster to render
  32517. */
  32518. freezeMaterials(): void;
  32519. /**
  32520. * Unfreeze all materials
  32521. * A frozen material will not be updatable but should be faster to render
  32522. */
  32523. unfreezeMaterials(): void;
  32524. /**
  32525. * Releases all held ressources
  32526. */
  32527. dispose(): void;
  32528. /**
  32529. * Gets if the scene is already disposed
  32530. */
  32531. readonly isDisposed: boolean;
  32532. /**
  32533. * Call this function to reduce memory footprint of the scene.
  32534. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32535. */
  32536. clearCachedVertexData(): void;
  32537. /**
  32538. * This function will remove the local cached buffer data from texture.
  32539. * It will save memory but will prevent the texture from being rebuilt
  32540. */
  32541. cleanCachedTextureBuffer(): void;
  32542. /**
  32543. * Get the world extend vectors with an optional filter
  32544. *
  32545. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32546. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32547. */
  32548. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32549. min: Vector3;
  32550. max: Vector3;
  32551. };
  32552. /**
  32553. * Creates a ray that can be used to pick in the scene
  32554. * @param x defines the x coordinate of the origin (on-screen)
  32555. * @param y defines the y coordinate of the origin (on-screen)
  32556. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32557. * @param camera defines the camera to use for the picking
  32558. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32559. * @returns a Ray
  32560. */
  32561. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32562. /**
  32563. * Creates a ray that can be used to pick in the scene
  32564. * @param x defines the x coordinate of the origin (on-screen)
  32565. * @param y defines the y coordinate of the origin (on-screen)
  32566. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32567. * @param result defines the ray where to store the picking ray
  32568. * @param camera defines the camera to use for the picking
  32569. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32570. * @returns the current scene
  32571. */
  32572. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32573. /**
  32574. * Creates a ray that can be used to pick in the scene
  32575. * @param x defines the x coordinate of the origin (on-screen)
  32576. * @param y defines the y coordinate of the origin (on-screen)
  32577. * @param camera defines the camera to use for the picking
  32578. * @returns a Ray
  32579. */
  32580. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32581. /**
  32582. * Creates a ray that can be used to pick in the scene
  32583. * @param x defines the x coordinate of the origin (on-screen)
  32584. * @param y defines the y coordinate of the origin (on-screen)
  32585. * @param result defines the ray where to store the picking ray
  32586. * @param camera defines the camera to use for the picking
  32587. * @returns the current scene
  32588. */
  32589. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32590. /** Launch a ray to try to pick a mesh in the scene
  32591. * @param x position on screen
  32592. * @param y position on screen
  32593. * @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
  32594. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32595. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32596. * @returns a PickingInfo
  32597. */
  32598. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  32599. /** Use the given ray to pick a mesh in the scene
  32600. * @param ray The ray to use to pick meshes
  32601. * @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
  32602. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32603. * @returns a PickingInfo
  32604. */
  32605. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  32606. /**
  32607. * Launch a ray to try to pick a mesh in the scene
  32608. * @param x X position on screen
  32609. * @param y Y position on screen
  32610. * @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
  32611. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32612. * @returns an array of PickingInfo
  32613. */
  32614. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32615. /**
  32616. * Launch a ray to try to pick a mesh in the scene
  32617. * @param ray Ray to use
  32618. * @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
  32619. * @returns an array of PickingInfo
  32620. */
  32621. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32622. /**
  32623. * Force the value of meshUnderPointer
  32624. * @param mesh defines the mesh to use
  32625. */
  32626. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32627. /**
  32628. * Gets the mesh under the pointer
  32629. * @returns a Mesh or null if no mesh is under the pointer
  32630. */
  32631. getPointerOverMesh(): Nullable<AbstractMesh>;
  32632. /** @hidden */
  32633. _rebuildGeometries(): void;
  32634. /** @hidden */
  32635. _rebuildTextures(): void;
  32636. private _getByTags;
  32637. /**
  32638. * Get a list of meshes by tags
  32639. * @param tagsQuery defines the tags query to use
  32640. * @param forEach defines a predicate used to filter results
  32641. * @returns an array of Mesh
  32642. */
  32643. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32644. /**
  32645. * Get a list of cameras by tags
  32646. * @param tagsQuery defines the tags query to use
  32647. * @param forEach defines a predicate used to filter results
  32648. * @returns an array of Camera
  32649. */
  32650. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32651. /**
  32652. * Get a list of lights by tags
  32653. * @param tagsQuery defines the tags query to use
  32654. * @param forEach defines a predicate used to filter results
  32655. * @returns an array of Light
  32656. */
  32657. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32658. /**
  32659. * Get a list of materials by tags
  32660. * @param tagsQuery defines the tags query to use
  32661. * @param forEach defines a predicate used to filter results
  32662. * @returns an array of Material
  32663. */
  32664. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32665. /**
  32666. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32667. * This allowed control for front to back rendering or reversly depending of the special needs.
  32668. *
  32669. * @param renderingGroupId The rendering group id corresponding to its index
  32670. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32671. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32672. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32673. */
  32674. 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;
  32675. /**
  32676. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32677. *
  32678. * @param renderingGroupId The rendering group id corresponding to its index
  32679. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32680. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32681. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32682. */
  32683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32684. /**
  32685. * Gets the current auto clear configuration for one rendering group of the rendering
  32686. * manager.
  32687. * @param index the rendering group index to get the information for
  32688. * @returns The auto clear setup for the requested rendering group
  32689. */
  32690. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32691. private _blockMaterialDirtyMechanism;
  32692. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32693. blockMaterialDirtyMechanism: boolean;
  32694. /**
  32695. * Will flag all materials as dirty to trigger new shader compilation
  32696. * @param flag defines the flag used to specify which material part must be marked as dirty
  32697. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32698. */
  32699. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32700. /** @hidden */
  32701. _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;
  32702. /** @hidden */
  32703. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32704. }
  32705. }
  32706. declare module BABYLON {
  32707. /**
  32708. * Set of assets to keep when moving a scene into an asset container.
  32709. */
  32710. export class KeepAssets extends AbstractScene {
  32711. }
  32712. /**
  32713. * Container with a set of assets that can be added or removed from a scene.
  32714. */
  32715. export class AssetContainer extends AbstractScene {
  32716. /**
  32717. * The scene the AssetContainer belongs to.
  32718. */
  32719. scene: Scene;
  32720. /**
  32721. * Instantiates an AssetContainer.
  32722. * @param scene The scene the AssetContainer belongs to.
  32723. */
  32724. constructor(scene: Scene);
  32725. /**
  32726. * Adds all the assets from the container to the scene.
  32727. */
  32728. addAllToScene(): void;
  32729. /**
  32730. * Removes all the assets in the container from the scene
  32731. */
  32732. removeAllFromScene(): void;
  32733. /**
  32734. * Disposes all the assets in the container
  32735. */
  32736. dispose(): void;
  32737. private _moveAssets;
  32738. /**
  32739. * Removes all the assets contained in the scene and adds them to the container.
  32740. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32741. */
  32742. moveAllFromScene(keepAssets?: KeepAssets): void;
  32743. /**
  32744. * 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.
  32745. * @returns the root mesh
  32746. */
  32747. createRootMesh(): Mesh;
  32748. }
  32749. }
  32750. declare module BABYLON {
  32751. /**
  32752. * Defines how the parser contract is defined.
  32753. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32754. */
  32755. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32756. /**
  32757. * Defines how the individual parser contract is defined.
  32758. * These parser can parse an individual asset
  32759. */
  32760. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32761. /**
  32762. * Base class of the scene acting as a container for the different elements composing a scene.
  32763. * This class is dynamically extended by the different components of the scene increasing
  32764. * flexibility and reducing coupling
  32765. */
  32766. export abstract class AbstractScene {
  32767. /**
  32768. * Stores the list of available parsers in the application.
  32769. */
  32770. private static _BabylonFileParsers;
  32771. /**
  32772. * Stores the list of available individual parsers in the application.
  32773. */
  32774. private static _IndividualBabylonFileParsers;
  32775. /**
  32776. * Adds a parser in the list of available ones
  32777. * @param name Defines the name of the parser
  32778. * @param parser Defines the parser to add
  32779. */
  32780. static AddParser(name: string, parser: BabylonFileParser): void;
  32781. /**
  32782. * Gets a general parser from the list of avaialble ones
  32783. * @param name Defines the name of the parser
  32784. * @returns the requested parser or null
  32785. */
  32786. static GetParser(name: string): Nullable<BabylonFileParser>;
  32787. /**
  32788. * Adds n individual parser in the list of available ones
  32789. * @param name Defines the name of the parser
  32790. * @param parser Defines the parser to add
  32791. */
  32792. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32793. /**
  32794. * Gets an individual parser from the list of avaialble ones
  32795. * @param name Defines the name of the parser
  32796. * @returns the requested parser or null
  32797. */
  32798. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32799. /**
  32800. * Parser json data and populate both a scene and its associated container object
  32801. * @param jsonData Defines the data to parse
  32802. * @param scene Defines the scene to parse the data for
  32803. * @param container Defines the container attached to the parsing sequence
  32804. * @param rootUrl Defines the root url of the data
  32805. */
  32806. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32807. /**
  32808. * Gets the list of root nodes (ie. nodes with no parent)
  32809. */
  32810. rootNodes: Node[];
  32811. /** All of the cameras added to this scene
  32812. * @see http://doc.babylonjs.com/babylon101/cameras
  32813. */
  32814. cameras: Camera[];
  32815. /**
  32816. * All of the lights added to this scene
  32817. * @see http://doc.babylonjs.com/babylon101/lights
  32818. */
  32819. lights: Light[];
  32820. /**
  32821. * All of the (abstract) meshes added to this scene
  32822. */
  32823. meshes: AbstractMesh[];
  32824. /**
  32825. * The list of skeletons added to the scene
  32826. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32827. */
  32828. skeletons: Skeleton[];
  32829. /**
  32830. * All of the particle systems added to this scene
  32831. * @see http://doc.babylonjs.com/babylon101/particles
  32832. */
  32833. particleSystems: IParticleSystem[];
  32834. /**
  32835. * Gets a list of Animations associated with the scene
  32836. */
  32837. animations: Animation[];
  32838. /**
  32839. * All of the animation groups added to this scene
  32840. * @see http://doc.babylonjs.com/how_to/group
  32841. */
  32842. animationGroups: AnimationGroup[];
  32843. /**
  32844. * All of the multi-materials added to this scene
  32845. * @see http://doc.babylonjs.com/how_to/multi_materials
  32846. */
  32847. multiMaterials: MultiMaterial[];
  32848. /**
  32849. * All of the materials added to this scene
  32850. * In the context of a Scene, it is not supposed to be modified manually.
  32851. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32852. * Note also that the order of the Material wihin the array is not significant and might change.
  32853. * @see http://doc.babylonjs.com/babylon101/materials
  32854. */
  32855. materials: Material[];
  32856. /**
  32857. * The list of morph target managers added to the scene
  32858. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32859. */
  32860. morphTargetManagers: MorphTargetManager[];
  32861. /**
  32862. * The list of geometries used in the scene.
  32863. */
  32864. geometries: Geometry[];
  32865. /**
  32866. * All of the tranform nodes added to this scene
  32867. * In the context of a Scene, it is not supposed to be modified manually.
  32868. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32869. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32870. * @see http://doc.babylonjs.com/how_to/transformnode
  32871. */
  32872. transformNodes: TransformNode[];
  32873. /**
  32874. * ActionManagers available on the scene.
  32875. */
  32876. actionManagers: AbstractActionManager[];
  32877. /**
  32878. * Textures to keep.
  32879. */
  32880. textures: BaseTexture[];
  32881. }
  32882. }
  32883. declare module BABYLON {
  32884. /**
  32885. * Defines a sound that can be played in the application.
  32886. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32888. */
  32889. export class Sound {
  32890. /**
  32891. * The name of the sound in the scene.
  32892. */
  32893. name: string;
  32894. /**
  32895. * Does the sound autoplay once loaded.
  32896. */
  32897. autoplay: boolean;
  32898. /**
  32899. * Does the sound loop after it finishes playing once.
  32900. */
  32901. loop: boolean;
  32902. /**
  32903. * Does the sound use a custom attenuation curve to simulate the falloff
  32904. * happening when the source gets further away from the camera.
  32905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32906. */
  32907. useCustomAttenuation: boolean;
  32908. /**
  32909. * The sound track id this sound belongs to.
  32910. */
  32911. soundTrackId: number;
  32912. /**
  32913. * Is this sound currently played.
  32914. */
  32915. isPlaying: boolean;
  32916. /**
  32917. * Is this sound currently paused.
  32918. */
  32919. isPaused: boolean;
  32920. /**
  32921. * Does this sound enables spatial sound.
  32922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32923. */
  32924. spatialSound: boolean;
  32925. /**
  32926. * Define the reference distance the sound should be heard perfectly.
  32927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32928. */
  32929. refDistance: number;
  32930. /**
  32931. * Define the roll off factor of spatial sounds.
  32932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32933. */
  32934. rolloffFactor: number;
  32935. /**
  32936. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32938. */
  32939. maxDistance: number;
  32940. /**
  32941. * Define the distance attenuation model the sound will follow.
  32942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32943. */
  32944. distanceModel: string;
  32945. /**
  32946. * @hidden
  32947. * Back Compat
  32948. **/
  32949. onended: () => any;
  32950. /**
  32951. * Observable event when the current playing sound finishes.
  32952. */
  32953. onEndedObservable: Observable<Sound>;
  32954. private _panningModel;
  32955. private _playbackRate;
  32956. private _streaming;
  32957. private _startTime;
  32958. private _startOffset;
  32959. private _position;
  32960. /** @hidden */
  32961. _positionInEmitterSpace: boolean;
  32962. private _localDirection;
  32963. private _volume;
  32964. private _isReadyToPlay;
  32965. private _isDirectional;
  32966. private _readyToPlayCallback;
  32967. private _audioBuffer;
  32968. private _soundSource;
  32969. private _streamingSource;
  32970. private _soundPanner;
  32971. private _soundGain;
  32972. private _inputAudioNode;
  32973. private _outputAudioNode;
  32974. private _coneInnerAngle;
  32975. private _coneOuterAngle;
  32976. private _coneOuterGain;
  32977. private _scene;
  32978. private _connectedTransformNode;
  32979. private _customAttenuationFunction;
  32980. private _registerFunc;
  32981. private _isOutputConnected;
  32982. private _htmlAudioElement;
  32983. private _urlType;
  32984. /** @hidden */
  32985. static _SceneComponentInitialization: (scene: Scene) => void;
  32986. /**
  32987. * Create a sound and attach it to a scene
  32988. * @param name Name of your sound
  32989. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32990. * @param scene defines the scene the sound belongs to
  32991. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32992. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32993. */
  32994. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32995. /**
  32996. * Release the sound and its associated resources
  32997. */
  32998. dispose(): void;
  32999. /**
  33000. * Gets if the sounds is ready to be played or not.
  33001. * @returns true if ready, otherwise false
  33002. */
  33003. isReady(): boolean;
  33004. private _soundLoaded;
  33005. /**
  33006. * Sets the data of the sound from an audiobuffer
  33007. * @param audioBuffer The audioBuffer containing the data
  33008. */
  33009. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33010. /**
  33011. * Updates the current sounds options such as maxdistance, loop...
  33012. * @param options A JSON object containing values named as the object properties
  33013. */
  33014. updateOptions(options: any): void;
  33015. private _createSpatialParameters;
  33016. private _updateSpatialParameters;
  33017. /**
  33018. * Switch the panning model to HRTF:
  33019. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33021. */
  33022. switchPanningModelToHRTF(): void;
  33023. /**
  33024. * Switch the panning model to Equal Power:
  33025. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33027. */
  33028. switchPanningModelToEqualPower(): void;
  33029. private _switchPanningModel;
  33030. /**
  33031. * Connect this sound to a sound track audio node like gain...
  33032. * @param soundTrackAudioNode the sound track audio node to connect to
  33033. */
  33034. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33035. /**
  33036. * Transform this sound into a directional source
  33037. * @param coneInnerAngle Size of the inner cone in degree
  33038. * @param coneOuterAngle Size of the outer cone in degree
  33039. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33040. */
  33041. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33042. /**
  33043. * Gets or sets the inner angle for the directional cone.
  33044. */
  33045. /**
  33046. * Gets or sets the inner angle for the directional cone.
  33047. */
  33048. directionalConeInnerAngle: number;
  33049. /**
  33050. * Gets or sets the outer angle for the directional cone.
  33051. */
  33052. /**
  33053. * Gets or sets the outer angle for the directional cone.
  33054. */
  33055. directionalConeOuterAngle: number;
  33056. /**
  33057. * Sets the position of the emitter if spatial sound is enabled
  33058. * @param newPosition Defines the new posisiton
  33059. */
  33060. setPosition(newPosition: Vector3): void;
  33061. /**
  33062. * Sets the local direction of the emitter if spatial sound is enabled
  33063. * @param newLocalDirection Defines the new local direction
  33064. */
  33065. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33066. private _updateDirection;
  33067. /** @hidden */
  33068. updateDistanceFromListener(): void;
  33069. /**
  33070. * Sets a new custom attenuation function for the sound.
  33071. * @param callback Defines the function used for the attenuation
  33072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33073. */
  33074. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33075. /**
  33076. * Play the sound
  33077. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33078. * @param offset (optional) Start the sound setting it at a specific time
  33079. */
  33080. play(time?: number, offset?: number): void;
  33081. private _onended;
  33082. /**
  33083. * Stop the sound
  33084. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33085. */
  33086. stop(time?: number): void;
  33087. /**
  33088. * Put the sound in pause
  33089. */
  33090. pause(): void;
  33091. /**
  33092. * Sets a dedicated volume for this sounds
  33093. * @param newVolume Define the new volume of the sound
  33094. * @param time Define in how long the sound should be at this value
  33095. */
  33096. setVolume(newVolume: number, time?: number): void;
  33097. /**
  33098. * Set the sound play back rate
  33099. * @param newPlaybackRate Define the playback rate the sound should be played at
  33100. */
  33101. setPlaybackRate(newPlaybackRate: number): void;
  33102. /**
  33103. * Gets the volume of the sound.
  33104. * @returns the volume of the sound
  33105. */
  33106. getVolume(): number;
  33107. /**
  33108. * Attach the sound to a dedicated mesh
  33109. * @param transformNode The transform node to connect the sound with
  33110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33111. */
  33112. attachToMesh(transformNode: TransformNode): void;
  33113. /**
  33114. * Detach the sound from the previously attached mesh
  33115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33116. */
  33117. detachFromMesh(): void;
  33118. private _onRegisterAfterWorldMatrixUpdate;
  33119. /**
  33120. * Clone the current sound in the scene.
  33121. * @returns the new sound clone
  33122. */
  33123. clone(): Nullable<Sound>;
  33124. /**
  33125. * Gets the current underlying audio buffer containing the data
  33126. * @returns the audio buffer
  33127. */
  33128. getAudioBuffer(): Nullable<AudioBuffer>;
  33129. /**
  33130. * Serializes the Sound in a JSON representation
  33131. * @returns the JSON representation of the sound
  33132. */
  33133. serialize(): any;
  33134. /**
  33135. * Parse a JSON representation of a sound to innstantiate in a given scene
  33136. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33137. * @param scene Define the scene the new parsed sound should be created in
  33138. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33139. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33140. * @returns the newly parsed sound
  33141. */
  33142. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33143. }
  33144. }
  33145. declare module BABYLON {
  33146. /**
  33147. * This defines an action helpful to play a defined sound on a triggered action.
  33148. */
  33149. export class PlaySoundAction extends Action {
  33150. private _sound;
  33151. /**
  33152. * Instantiate the action
  33153. * @param triggerOptions defines the trigger options
  33154. * @param sound defines the sound to play
  33155. * @param condition defines the trigger related conditions
  33156. */
  33157. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33158. /** @hidden */
  33159. _prepare(): void;
  33160. /**
  33161. * Execute the action and play the sound.
  33162. */
  33163. execute(): void;
  33164. /**
  33165. * Serializes the actions and its related information.
  33166. * @param parent defines the object to serialize in
  33167. * @returns the serialized object
  33168. */
  33169. serialize(parent: any): any;
  33170. }
  33171. /**
  33172. * This defines an action helpful to stop a defined sound on a triggered action.
  33173. */
  33174. export class StopSoundAction extends Action {
  33175. private _sound;
  33176. /**
  33177. * Instantiate the action
  33178. * @param triggerOptions defines the trigger options
  33179. * @param sound defines the sound to stop
  33180. * @param condition defines the trigger related conditions
  33181. */
  33182. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33183. /** @hidden */
  33184. _prepare(): void;
  33185. /**
  33186. * Execute the action and stop the sound.
  33187. */
  33188. execute(): void;
  33189. /**
  33190. * Serializes the actions and its related information.
  33191. * @param parent defines the object to serialize in
  33192. * @returns the serialized object
  33193. */
  33194. serialize(parent: any): any;
  33195. }
  33196. }
  33197. declare module BABYLON {
  33198. /**
  33199. * This defines an action responsible to change the value of a property
  33200. * by interpolating between its current value and the newly set one once triggered.
  33201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33202. */
  33203. export class InterpolateValueAction extends Action {
  33204. /**
  33205. * Defines the path of the property where the value should be interpolated
  33206. */
  33207. propertyPath: string;
  33208. /**
  33209. * Defines the target value at the end of the interpolation.
  33210. */
  33211. value: any;
  33212. /**
  33213. * Defines the time it will take for the property to interpolate to the value.
  33214. */
  33215. duration: number;
  33216. /**
  33217. * Defines if the other scene animations should be stopped when the action has been triggered
  33218. */
  33219. stopOtherAnimations?: boolean;
  33220. /**
  33221. * Defines a callback raised once the interpolation animation has been done.
  33222. */
  33223. onInterpolationDone?: () => void;
  33224. /**
  33225. * Observable triggered once the interpolation animation has been done.
  33226. */
  33227. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33228. private _target;
  33229. private _effectiveTarget;
  33230. private _property;
  33231. /**
  33232. * Instantiate the action
  33233. * @param triggerOptions defines the trigger options
  33234. * @param target defines the object containing the value to interpolate
  33235. * @param propertyPath defines the path to the property in the target object
  33236. * @param value defines the target value at the end of the interpolation
  33237. * @param duration deines the time it will take for the property to interpolate to the value.
  33238. * @param condition defines the trigger related conditions
  33239. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33240. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33241. */
  33242. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33243. /** @hidden */
  33244. _prepare(): void;
  33245. /**
  33246. * Execute the action starts the value interpolation.
  33247. */
  33248. execute(): void;
  33249. /**
  33250. * Serializes the actions and its related information.
  33251. * @param parent defines the object to serialize in
  33252. * @returns the serialized object
  33253. */
  33254. serialize(parent: any): any;
  33255. }
  33256. }
  33257. declare module BABYLON {
  33258. /**
  33259. * Options allowed during the creation of a sound track.
  33260. */
  33261. export interface ISoundTrackOptions {
  33262. /**
  33263. * The volume the sound track should take during creation
  33264. */
  33265. volume?: number;
  33266. /**
  33267. * Define if the sound track is the main sound track of the scene
  33268. */
  33269. mainTrack?: boolean;
  33270. }
  33271. /**
  33272. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33273. * It will be also used in a future release to apply effects on a specific track.
  33274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33275. */
  33276. export class SoundTrack {
  33277. /**
  33278. * The unique identifier of the sound track in the scene.
  33279. */
  33280. id: number;
  33281. /**
  33282. * The list of sounds included in the sound track.
  33283. */
  33284. soundCollection: Array<Sound>;
  33285. private _outputAudioNode;
  33286. private _scene;
  33287. private _isMainTrack;
  33288. private _connectedAnalyser;
  33289. private _options;
  33290. private _isInitialized;
  33291. /**
  33292. * Creates a new sound track.
  33293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33294. * @param scene Define the scene the sound track belongs to
  33295. * @param options
  33296. */
  33297. constructor(scene: Scene, options?: ISoundTrackOptions);
  33298. private _initializeSoundTrackAudioGraph;
  33299. /**
  33300. * Release the sound track and its associated resources
  33301. */
  33302. dispose(): void;
  33303. /**
  33304. * Adds a sound to this sound track
  33305. * @param sound define the cound to add
  33306. * @ignoreNaming
  33307. */
  33308. AddSound(sound: Sound): void;
  33309. /**
  33310. * Removes a sound to this sound track
  33311. * @param sound define the cound to remove
  33312. * @ignoreNaming
  33313. */
  33314. RemoveSound(sound: Sound): void;
  33315. /**
  33316. * Set a global volume for the full sound track.
  33317. * @param newVolume Define the new volume of the sound track
  33318. */
  33319. setVolume(newVolume: number): void;
  33320. /**
  33321. * Switch the panning model to HRTF:
  33322. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33324. */
  33325. switchPanningModelToHRTF(): void;
  33326. /**
  33327. * Switch the panning model to Equal Power:
  33328. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33330. */
  33331. switchPanningModelToEqualPower(): void;
  33332. /**
  33333. * Connect the sound track to an audio analyser allowing some amazing
  33334. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33336. * @param analyser The analyser to connect to the engine
  33337. */
  33338. connectToAnalyser(analyser: Analyser): void;
  33339. }
  33340. }
  33341. declare module BABYLON {
  33342. interface AbstractScene {
  33343. /**
  33344. * The list of sounds used in the scene.
  33345. */
  33346. sounds: Nullable<Array<Sound>>;
  33347. }
  33348. interface Scene {
  33349. /**
  33350. * @hidden
  33351. * Backing field
  33352. */
  33353. _mainSoundTrack: SoundTrack;
  33354. /**
  33355. * The main sound track played by the scene.
  33356. * It cotains your primary collection of sounds.
  33357. */
  33358. mainSoundTrack: SoundTrack;
  33359. /**
  33360. * The list of sound tracks added to the scene
  33361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33362. */
  33363. soundTracks: Nullable<Array<SoundTrack>>;
  33364. /**
  33365. * Gets a sound using a given name
  33366. * @param name defines the name to search for
  33367. * @return the found sound or null if not found at all.
  33368. */
  33369. getSoundByName(name: string): Nullable<Sound>;
  33370. /**
  33371. * Gets or sets if audio support is enabled
  33372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33373. */
  33374. audioEnabled: boolean;
  33375. /**
  33376. * Gets or sets if audio will be output to headphones
  33377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33378. */
  33379. headphone: boolean;
  33380. }
  33381. /**
  33382. * Defines the sound scene component responsible to manage any sounds
  33383. * in a given scene.
  33384. */
  33385. export class AudioSceneComponent implements ISceneSerializableComponent {
  33386. /**
  33387. * The component name helpfull to identify the component in the list of scene components.
  33388. */
  33389. readonly name: string;
  33390. /**
  33391. * The scene the component belongs to.
  33392. */
  33393. scene: Scene;
  33394. private _audioEnabled;
  33395. /**
  33396. * Gets whether audio is enabled or not.
  33397. * Please use related enable/disable method to switch state.
  33398. */
  33399. readonly audioEnabled: boolean;
  33400. private _headphone;
  33401. /**
  33402. * Gets whether audio is outputing to headphone or not.
  33403. * Please use the according Switch methods to change output.
  33404. */
  33405. readonly headphone: boolean;
  33406. /**
  33407. * Creates a new instance of the component for the given scene
  33408. * @param scene Defines the scene to register the component in
  33409. */
  33410. constructor(scene: Scene);
  33411. /**
  33412. * Registers the component in a given scene
  33413. */
  33414. register(): void;
  33415. /**
  33416. * Rebuilds the elements related to this component in case of
  33417. * context lost for instance.
  33418. */
  33419. rebuild(): void;
  33420. /**
  33421. * Serializes the component data to the specified json object
  33422. * @param serializationObject The object to serialize to
  33423. */
  33424. serialize(serializationObject: any): void;
  33425. /**
  33426. * Adds all the element from the container to the scene
  33427. * @param container the container holding the elements
  33428. */
  33429. addFromContainer(container: AbstractScene): void;
  33430. /**
  33431. * Removes all the elements in the container from the scene
  33432. * @param container contains the elements to remove
  33433. */
  33434. removeFromContainer(container: AbstractScene): void;
  33435. /**
  33436. * Disposes the component and the associated ressources.
  33437. */
  33438. dispose(): void;
  33439. /**
  33440. * Disables audio in the associated scene.
  33441. */
  33442. disableAudio(): void;
  33443. /**
  33444. * Enables audio in the associated scene.
  33445. */
  33446. enableAudio(): void;
  33447. /**
  33448. * Switch audio to headphone output.
  33449. */
  33450. switchAudioModeForHeadphones(): void;
  33451. /**
  33452. * Switch audio to normal speakers.
  33453. */
  33454. switchAudioModeForNormalSpeakers(): void;
  33455. private _afterRender;
  33456. }
  33457. }
  33458. declare module BABYLON {
  33459. /**
  33460. * Wraps one or more Sound objects and selects one with random weight for playback.
  33461. */
  33462. export class WeightedSound {
  33463. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33464. loop: boolean;
  33465. private _coneInnerAngle;
  33466. private _coneOuterAngle;
  33467. private _volume;
  33468. /** A Sound is currently playing. */
  33469. isPlaying: boolean;
  33470. /** A Sound is currently paused. */
  33471. isPaused: boolean;
  33472. private _sounds;
  33473. private _weights;
  33474. private _currentIndex?;
  33475. /**
  33476. * Creates a new WeightedSound from the list of sounds given.
  33477. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33478. * @param sounds Array of Sounds that will be selected from.
  33479. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33480. */
  33481. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33482. /**
  33483. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33484. */
  33485. /**
  33486. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33487. */
  33488. directionalConeInnerAngle: number;
  33489. /**
  33490. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33491. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33492. */
  33493. /**
  33494. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33495. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33496. */
  33497. directionalConeOuterAngle: number;
  33498. /**
  33499. * Playback volume.
  33500. */
  33501. /**
  33502. * Playback volume.
  33503. */
  33504. volume: number;
  33505. private _onended;
  33506. /**
  33507. * Suspend playback
  33508. */
  33509. pause(): void;
  33510. /**
  33511. * Stop playback
  33512. */
  33513. stop(): void;
  33514. /**
  33515. * Start playback.
  33516. * @param startOffset Position the clip head at a specific time in seconds.
  33517. */
  33518. play(startOffset?: number): void;
  33519. }
  33520. }
  33521. declare module BABYLON {
  33522. /**
  33523. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33525. */
  33526. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33527. /**
  33528. * Gets the name of the behavior.
  33529. */
  33530. readonly name: string;
  33531. /**
  33532. * The easing function used by animations
  33533. */
  33534. static EasingFunction: BackEase;
  33535. /**
  33536. * The easing mode used by animations
  33537. */
  33538. static EasingMode: number;
  33539. /**
  33540. * The duration of the animation, in milliseconds
  33541. */
  33542. transitionDuration: number;
  33543. /**
  33544. * Length of the distance animated by the transition when lower radius is reached
  33545. */
  33546. lowerRadiusTransitionRange: number;
  33547. /**
  33548. * Length of the distance animated by the transition when upper radius is reached
  33549. */
  33550. upperRadiusTransitionRange: number;
  33551. private _autoTransitionRange;
  33552. /**
  33553. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33554. */
  33555. /**
  33556. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33557. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33558. */
  33559. autoTransitionRange: boolean;
  33560. private _attachedCamera;
  33561. private _onAfterCheckInputsObserver;
  33562. private _onMeshTargetChangedObserver;
  33563. /**
  33564. * Initializes the behavior.
  33565. */
  33566. init(): void;
  33567. /**
  33568. * Attaches the behavior to its arc rotate camera.
  33569. * @param camera Defines the camera to attach the behavior to
  33570. */
  33571. attach(camera: ArcRotateCamera): void;
  33572. /**
  33573. * Detaches the behavior from its current arc rotate camera.
  33574. */
  33575. detach(): void;
  33576. private _radiusIsAnimating;
  33577. private _radiusBounceTransition;
  33578. private _animatables;
  33579. private _cachedWheelPrecision;
  33580. /**
  33581. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33582. * @param radiusLimit The limit to check against.
  33583. * @return Bool to indicate if at limit.
  33584. */
  33585. private _isRadiusAtLimit;
  33586. /**
  33587. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33588. * @param radiusDelta The delta by which to animate to. Can be negative.
  33589. */
  33590. private _applyBoundRadiusAnimation;
  33591. /**
  33592. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33593. */
  33594. protected _clearAnimationLocks(): void;
  33595. /**
  33596. * Stops and removes all animations that have been applied to the camera
  33597. */
  33598. stopAllAnimations(): void;
  33599. }
  33600. }
  33601. declare module BABYLON {
  33602. /**
  33603. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  33604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33605. */
  33606. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33607. /**
  33608. * Gets the name of the behavior.
  33609. */
  33610. readonly name: string;
  33611. private _mode;
  33612. private _radiusScale;
  33613. private _positionScale;
  33614. private _defaultElevation;
  33615. private _elevationReturnTime;
  33616. private _elevationReturnWaitTime;
  33617. private _zoomStopsAnimation;
  33618. private _framingTime;
  33619. /**
  33620. * The easing function used by animations
  33621. */
  33622. static EasingFunction: ExponentialEase;
  33623. /**
  33624. * The easing mode used by animations
  33625. */
  33626. static EasingMode: number;
  33627. /**
  33628. * Sets the current mode used by the behavior
  33629. */
  33630. /**
  33631. * Gets current mode used by the behavior.
  33632. */
  33633. mode: number;
  33634. /**
  33635. * Sets the scale applied to the radius (1 by default)
  33636. */
  33637. /**
  33638. * Gets the scale applied to the radius
  33639. */
  33640. radiusScale: number;
  33641. /**
  33642. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33643. */
  33644. /**
  33645. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33646. */
  33647. positionScale: number;
  33648. /**
  33649. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33650. * behaviour is triggered, in radians.
  33651. */
  33652. /**
  33653. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33654. * behaviour is triggered, in radians.
  33655. */
  33656. defaultElevation: number;
  33657. /**
  33658. * Sets the time (in milliseconds) taken to return to the default beta position.
  33659. * Negative value indicates camera should not return to default.
  33660. */
  33661. /**
  33662. * Gets the time (in milliseconds) taken to return to the default beta position.
  33663. * Negative value indicates camera should not return to default.
  33664. */
  33665. elevationReturnTime: number;
  33666. /**
  33667. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33668. */
  33669. /**
  33670. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33671. */
  33672. elevationReturnWaitTime: number;
  33673. /**
  33674. * Sets the flag that indicates if user zooming should stop animation.
  33675. */
  33676. /**
  33677. * Gets the flag that indicates if user zooming should stop animation.
  33678. */
  33679. zoomStopsAnimation: boolean;
  33680. /**
  33681. * Sets the transition time when framing the mesh, in milliseconds
  33682. */
  33683. /**
  33684. * Gets the transition time when framing the mesh, in milliseconds
  33685. */
  33686. framingTime: number;
  33687. /**
  33688. * Define if the behavior should automatically change the configured
  33689. * camera limits and sensibilities.
  33690. */
  33691. autoCorrectCameraLimitsAndSensibility: boolean;
  33692. private _onPrePointerObservableObserver;
  33693. private _onAfterCheckInputsObserver;
  33694. private _onMeshTargetChangedObserver;
  33695. private _attachedCamera;
  33696. private _isPointerDown;
  33697. private _lastInteractionTime;
  33698. /**
  33699. * Initializes the behavior.
  33700. */
  33701. init(): void;
  33702. /**
  33703. * Attaches the behavior to its arc rotate camera.
  33704. * @param camera Defines the camera to attach the behavior to
  33705. */
  33706. attach(camera: ArcRotateCamera): void;
  33707. /**
  33708. * Detaches the behavior from its current arc rotate camera.
  33709. */
  33710. detach(): void;
  33711. private _animatables;
  33712. private _betaIsAnimating;
  33713. private _betaTransition;
  33714. private _radiusTransition;
  33715. private _vectorTransition;
  33716. /**
  33717. * Targets the given mesh and updates zoom level accordingly.
  33718. * @param mesh The mesh to target.
  33719. * @param radius Optional. If a cached radius position already exists, overrides default.
  33720. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33721. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33722. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33723. */
  33724. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33725. /**
  33726. * Targets the given mesh with its children and updates zoom level accordingly.
  33727. * @param mesh The mesh to target.
  33728. * @param radius Optional. If a cached radius position already exists, overrides default.
  33729. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33730. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33731. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33732. */
  33733. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33734. /**
  33735. * Targets the given meshes with their children and updates zoom level accordingly.
  33736. * @param meshes The mesh to target.
  33737. * @param radius Optional. If a cached radius position already exists, overrides default.
  33738. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33739. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33740. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33741. */
  33742. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33743. /**
  33744. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33745. * @param minimumWorld Determines the smaller position of the bounding box extend
  33746. * @param maximumWorld Determines the bigger position of the bounding box extend
  33747. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33748. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33749. */
  33750. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33751. /**
  33752. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33753. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33754. * frustum width.
  33755. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33756. * to fully enclose the mesh in the viewing frustum.
  33757. */
  33758. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33759. /**
  33760. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33761. * is automatically returned to its default position (expected to be above ground plane).
  33762. */
  33763. private _maintainCameraAboveGround;
  33764. /**
  33765. * Returns the frustum slope based on the canvas ratio and camera FOV
  33766. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33767. */
  33768. private _getFrustumSlope;
  33769. /**
  33770. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33771. */
  33772. private _clearAnimationLocks;
  33773. /**
  33774. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33775. */
  33776. private _applyUserInteraction;
  33777. /**
  33778. * Stops and removes all animations that have been applied to the camera
  33779. */
  33780. stopAllAnimations(): void;
  33781. /**
  33782. * Gets a value indicating if the user is moving the camera
  33783. */
  33784. readonly isUserIsMoving: boolean;
  33785. /**
  33786. * The camera can move all the way towards the mesh.
  33787. */
  33788. static IgnoreBoundsSizeMode: number;
  33789. /**
  33790. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33791. */
  33792. static FitFrustumSidesMode: number;
  33793. }
  33794. }
  33795. declare module BABYLON {
  33796. /**
  33797. * Base class for Camera Pointer Inputs.
  33798. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33799. * for example usage.
  33800. */
  33801. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33802. /**
  33803. * Defines the camera the input is attached to.
  33804. */
  33805. abstract camera: Camera;
  33806. /**
  33807. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33808. */
  33809. protected _altKey: boolean;
  33810. protected _ctrlKey: boolean;
  33811. protected _metaKey: boolean;
  33812. protected _shiftKey: boolean;
  33813. /**
  33814. * Which mouse buttons were pressed at time of last mouse event.
  33815. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33816. */
  33817. protected _buttonsPressed: number;
  33818. /**
  33819. * Defines the buttons associated with the input to handle camera move.
  33820. */
  33821. buttons: number[];
  33822. /**
  33823. * Attach the input controls to a specific dom element to get the input from.
  33824. * @param element Defines the element the controls should be listened from
  33825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33826. */
  33827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33828. /**
  33829. * Detach the current controls from the specified dom element.
  33830. * @param element Defines the element to stop listening the inputs from
  33831. */
  33832. detachControl(element: Nullable<HTMLElement>): void;
  33833. /**
  33834. * Gets the class name of the current input.
  33835. * @returns the class name
  33836. */
  33837. getClassName(): string;
  33838. /**
  33839. * Get the friendly name associated with the input class.
  33840. * @returns the input friendly name
  33841. */
  33842. getSimpleName(): string;
  33843. /**
  33844. * Called on pointer POINTERDOUBLETAP event.
  33845. * Override this method to provide functionality on POINTERDOUBLETAP event.
  33846. */
  33847. protected onDoubleTap(type: string): void;
  33848. /**
  33849. * Called on pointer POINTERMOVE event if only a single touch is active.
  33850. * Override this method to provide functionality.
  33851. */
  33852. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  33853. /**
  33854. * Called on pointer POINTERMOVE event if multiple touches are active.
  33855. * Override this method to provide functionality.
  33856. */
  33857. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  33858. /**
  33859. * Called on JS contextmenu event.
  33860. * Override this method to provide functionality.
  33861. */
  33862. protected onContextMenu(evt: PointerEvent): void;
  33863. /**
  33864. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  33865. * press.
  33866. * Override this method to provide functionality.
  33867. */
  33868. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  33869. /**
  33870. * Called each time a new POINTERUP event occurs. Ie, for each button
  33871. * release.
  33872. * Override this method to provide functionality.
  33873. */
  33874. protected onButtonUp(evt: PointerEvent): void;
  33875. /**
  33876. * Called when window becomes inactive.
  33877. * Override this method to provide functionality.
  33878. */
  33879. protected onLostFocus(): void;
  33880. private _pointerInput;
  33881. private _observer;
  33882. private _onLostFocus;
  33883. }
  33884. }
  33885. declare module BABYLON {
  33886. /**
  33887. * Manage the pointers inputs to control an arc rotate camera.
  33888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33889. */
  33890. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  33891. /**
  33892. * Defines the camera the input is attached to.
  33893. */
  33894. camera: ArcRotateCamera;
  33895. /**
  33896. * Gets the class name of the current input.
  33897. * @returns the class name
  33898. */
  33899. getClassName(): string;
  33900. /**
  33901. * Defines the buttons associated with the input to handle camera move.
  33902. */
  33903. buttons: number[];
  33904. /**
  33905. * Defines the pointer angular sensibility along the X axis or how fast is
  33906. * the camera rotating.
  33907. */
  33908. angularSensibilityX: number;
  33909. /**
  33910. * Defines the pointer angular sensibility along the Y axis or how fast is
  33911. * the camera rotating.
  33912. */
  33913. angularSensibilityY: number;
  33914. /**
  33915. * Defines the pointer pinch precision or how fast is the camera zooming.
  33916. */
  33917. pinchPrecision: number;
  33918. /**
  33919. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  33920. * from 0.
  33921. * It defines the percentage of current camera.radius to use as delta when
  33922. * pinch zoom is used.
  33923. */
  33924. pinchDeltaPercentage: number;
  33925. /**
  33926. * Defines the pointer panning sensibility or how fast is the camera moving.
  33927. */
  33928. panningSensibility: number;
  33929. /**
  33930. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33931. */
  33932. multiTouchPanning: boolean;
  33933. /**
  33934. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  33935. * zoom (pinch) through multitouch.
  33936. */
  33937. multiTouchPanAndZoom: boolean;
  33938. /**
  33939. * Revers pinch action direction.
  33940. */
  33941. pinchInwards: boolean;
  33942. private _isPanClick;
  33943. private _twoFingerActivityCount;
  33944. private _isPinching;
  33945. /**
  33946. * Called on pointer POINTERMOVE event if only a single touch is active.
  33947. */
  33948. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  33949. /**
  33950. * Called on pointer POINTERDOUBLETAP event.
  33951. */
  33952. protected onDoubleTap(type: string): void;
  33953. /**
  33954. * Called on pointer POINTERMOVE event if multiple touches are active.
  33955. */
  33956. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  33957. /**
  33958. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  33959. * press.
  33960. */
  33961. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  33962. /**
  33963. * Called each time a new POINTERUP event occurs. Ie, for each button
  33964. * release.
  33965. */
  33966. protected onButtonUp(evt: PointerEvent): void;
  33967. /**
  33968. * Called when window becomes inactive.
  33969. */
  33970. protected onLostFocus(): void;
  33971. }
  33972. }
  33973. declare module BABYLON {
  33974. /**
  33975. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33977. */
  33978. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33979. /**
  33980. * Defines the camera the input is attached to.
  33981. */
  33982. camera: ArcRotateCamera;
  33983. /**
  33984. * Defines the list of key codes associated with the up action (increase alpha)
  33985. */
  33986. keysUp: number[];
  33987. /**
  33988. * Defines the list of key codes associated with the down action (decrease alpha)
  33989. */
  33990. keysDown: number[];
  33991. /**
  33992. * Defines the list of key codes associated with the left action (increase beta)
  33993. */
  33994. keysLeft: number[];
  33995. /**
  33996. * Defines the list of key codes associated with the right action (decrease beta)
  33997. */
  33998. keysRight: number[];
  33999. /**
  34000. * Defines the list of key codes associated with the reset action.
  34001. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34002. */
  34003. keysReset: number[];
  34004. /**
  34005. * Defines the panning sensibility of the inputs.
  34006. * (How fast is the camera paning)
  34007. */
  34008. panningSensibility: number;
  34009. /**
  34010. * Defines the zooming sensibility of the inputs.
  34011. * (How fast is the camera zooming)
  34012. */
  34013. zoomingSensibility: number;
  34014. /**
  34015. * Defines wether maintaining the alt key down switch the movement mode from
  34016. * orientation to zoom.
  34017. */
  34018. useAltToZoom: boolean;
  34019. /**
  34020. * Rotation speed of the camera
  34021. */
  34022. angularSpeed: number;
  34023. private _keys;
  34024. private _ctrlPressed;
  34025. private _altPressed;
  34026. private _onCanvasBlurObserver;
  34027. private _onKeyboardObserver;
  34028. private _engine;
  34029. private _scene;
  34030. /**
  34031. * Attach the input controls to a specific dom element to get the input from.
  34032. * @param element Defines the element the controls should be listened from
  34033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34034. */
  34035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34036. /**
  34037. * Detach the current controls from the specified dom element.
  34038. * @param element Defines the element to stop listening the inputs from
  34039. */
  34040. detachControl(element: Nullable<HTMLElement>): void;
  34041. /**
  34042. * Update the current camera state depending on the inputs that have been used this frame.
  34043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34044. */
  34045. checkInputs(): void;
  34046. /**
  34047. * Gets the class name of the current intput.
  34048. * @returns the class name
  34049. */
  34050. getClassName(): string;
  34051. /**
  34052. * Get the friendly name associated with the input class.
  34053. * @returns the input friendly name
  34054. */
  34055. getSimpleName(): string;
  34056. }
  34057. }
  34058. declare module BABYLON {
  34059. /**
  34060. * Manage the mouse wheel inputs to control an arc rotate camera.
  34061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34062. */
  34063. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34064. /**
  34065. * Defines the camera the input is attached to.
  34066. */
  34067. camera: ArcRotateCamera;
  34068. /**
  34069. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34070. */
  34071. wheelPrecision: number;
  34072. /**
  34073. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34074. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34075. */
  34076. wheelDeltaPercentage: number;
  34077. private _wheel;
  34078. private _observer;
  34079. /**
  34080. * Attach the input controls to a specific dom element to get the input from.
  34081. * @param element Defines the element the controls should be listened from
  34082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34083. */
  34084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34085. /**
  34086. * Detach the current controls from the specified dom element.
  34087. * @param element Defines the element to stop listening the inputs from
  34088. */
  34089. detachControl(element: Nullable<HTMLElement>): void;
  34090. /**
  34091. * Gets the class name of the current intput.
  34092. * @returns the class name
  34093. */
  34094. getClassName(): string;
  34095. /**
  34096. * Get the friendly name associated with the input class.
  34097. * @returns the input friendly name
  34098. */
  34099. getSimpleName(): string;
  34100. }
  34101. }
  34102. declare module BABYLON {
  34103. /**
  34104. * Default Inputs manager for the ArcRotateCamera.
  34105. * It groups all the default supported inputs for ease of use.
  34106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34107. */
  34108. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34109. /**
  34110. * Instantiates a new ArcRotateCameraInputsManager.
  34111. * @param camera Defines the camera the inputs belong to
  34112. */
  34113. constructor(camera: ArcRotateCamera);
  34114. /**
  34115. * Add mouse wheel input support to the input manager.
  34116. * @returns the current input manager
  34117. */
  34118. addMouseWheel(): ArcRotateCameraInputsManager;
  34119. /**
  34120. * Add pointers input support to the input manager.
  34121. * @returns the current input manager
  34122. */
  34123. addPointers(): ArcRotateCameraInputsManager;
  34124. /**
  34125. * Add keyboard input support to the input manager.
  34126. * @returns the current input manager
  34127. */
  34128. addKeyboard(): ArcRotateCameraInputsManager;
  34129. }
  34130. }
  34131. declare module BABYLON {
  34132. /**
  34133. * This represents an orbital type of camera.
  34134. *
  34135. * 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.
  34136. * 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.
  34137. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34138. */
  34139. export class ArcRotateCamera extends TargetCamera {
  34140. /**
  34141. * Defines the rotation angle of the camera along the longitudinal axis.
  34142. */
  34143. alpha: number;
  34144. /**
  34145. * Defines the rotation angle of the camera along the latitudinal axis.
  34146. */
  34147. beta: number;
  34148. /**
  34149. * Defines the radius of the camera from it s target point.
  34150. */
  34151. radius: number;
  34152. protected _target: Vector3;
  34153. protected _targetHost: Nullable<AbstractMesh>;
  34154. /**
  34155. * Defines the target point of the camera.
  34156. * The camera looks towards it form the radius distance.
  34157. */
  34158. target: Vector3;
  34159. /**
  34160. * Define the current local position of the camera in the scene
  34161. */
  34162. position: Vector3;
  34163. /**
  34164. * Current inertia value on the longitudinal axis.
  34165. * The bigger this number the longer it will take for the camera to stop.
  34166. */
  34167. inertialAlphaOffset: number;
  34168. /**
  34169. * Current inertia value on the latitudinal axis.
  34170. * The bigger this number the longer it will take for the camera to stop.
  34171. */
  34172. inertialBetaOffset: number;
  34173. /**
  34174. * Current inertia value on the radius axis.
  34175. * The bigger this number the longer it will take for the camera to stop.
  34176. */
  34177. inertialRadiusOffset: number;
  34178. /**
  34179. * Minimum allowed angle on the longitudinal axis.
  34180. * This can help limiting how the Camera is able to move in the scene.
  34181. */
  34182. lowerAlphaLimit: Nullable<number>;
  34183. /**
  34184. * Maximum allowed angle on the longitudinal axis.
  34185. * This can help limiting how the Camera is able to move in the scene.
  34186. */
  34187. upperAlphaLimit: Nullable<number>;
  34188. /**
  34189. * Minimum allowed angle on the latitudinal axis.
  34190. * This can help limiting how the Camera is able to move in the scene.
  34191. */
  34192. lowerBetaLimit: number;
  34193. /**
  34194. * Maximum allowed angle on the latitudinal axis.
  34195. * This can help limiting how the Camera is able to move in the scene.
  34196. */
  34197. upperBetaLimit: number;
  34198. /**
  34199. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34200. * This can help limiting how the Camera is able to move in the scene.
  34201. */
  34202. lowerRadiusLimit: Nullable<number>;
  34203. /**
  34204. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34205. * This can help limiting how the Camera is able to move in the scene.
  34206. */
  34207. upperRadiusLimit: Nullable<number>;
  34208. /**
  34209. * Defines the current inertia value used during panning of the camera along the X axis.
  34210. */
  34211. inertialPanningX: number;
  34212. /**
  34213. * Defines the current inertia value used during panning of the camera along the Y axis.
  34214. */
  34215. inertialPanningY: number;
  34216. /**
  34217. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34218. * Basically if your fingers moves away from more than this distance you will be considered
  34219. * in pinch mode.
  34220. */
  34221. pinchToPanMaxDistance: number;
  34222. /**
  34223. * Defines the maximum distance the camera can pan.
  34224. * This could help keeping the cammera always in your scene.
  34225. */
  34226. panningDistanceLimit: Nullable<number>;
  34227. /**
  34228. * Defines the target of the camera before paning.
  34229. */
  34230. panningOriginTarget: Vector3;
  34231. /**
  34232. * Defines the value of the inertia used during panning.
  34233. * 0 would mean stop inertia and one would mean no decelleration at all.
  34234. */
  34235. panningInertia: number;
  34236. /**
  34237. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34238. */
  34239. angularSensibilityX: number;
  34240. /**
  34241. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34242. */
  34243. angularSensibilityY: number;
  34244. /**
  34245. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34246. */
  34247. pinchPrecision: number;
  34248. /**
  34249. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34250. * It will be used instead of pinchDeltaPrecision if different from 0.
  34251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34252. */
  34253. pinchDeltaPercentage: number;
  34254. /**
  34255. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34256. */
  34257. panningSensibility: number;
  34258. /**
  34259. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34260. */
  34261. keysUp: number[];
  34262. /**
  34263. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34264. */
  34265. keysDown: number[];
  34266. /**
  34267. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34268. */
  34269. keysLeft: number[];
  34270. /**
  34271. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34272. */
  34273. keysRight: number[];
  34274. /**
  34275. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34276. */
  34277. wheelPrecision: number;
  34278. /**
  34279. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34280. * It will be used instead of pinchDeltaPrecision if different from 0.
  34281. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34282. */
  34283. wheelDeltaPercentage: number;
  34284. /**
  34285. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34286. */
  34287. zoomOnFactor: number;
  34288. /**
  34289. * Defines a screen offset for the camera position.
  34290. */
  34291. targetScreenOffset: Vector2;
  34292. /**
  34293. * Allows the camera to be completely reversed.
  34294. * If false the camera can not arrive upside down.
  34295. */
  34296. allowUpsideDown: boolean;
  34297. /**
  34298. * Define if double tap/click is used to restore the previously saved state of the camera.
  34299. */
  34300. useInputToRestoreState: boolean;
  34301. /** @hidden */
  34302. _viewMatrix: Matrix;
  34303. /** @hidden */
  34304. _useCtrlForPanning: boolean;
  34305. /** @hidden */
  34306. _panningMouseButton: number;
  34307. /**
  34308. * Defines the input associated to the camera.
  34309. */
  34310. inputs: ArcRotateCameraInputsManager;
  34311. /** @hidden */
  34312. _reset: () => void;
  34313. /**
  34314. * Defines the allowed panning axis.
  34315. */
  34316. panningAxis: Vector3;
  34317. protected _localDirection: Vector3;
  34318. protected _transformedDirection: Vector3;
  34319. private _bouncingBehavior;
  34320. /**
  34321. * Gets the bouncing behavior of the camera if it has been enabled.
  34322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34323. */
  34324. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34325. /**
  34326. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34327. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34328. */
  34329. useBouncingBehavior: boolean;
  34330. private _framingBehavior;
  34331. /**
  34332. * Gets the framing behavior of the camera if it has been enabled.
  34333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34334. */
  34335. readonly framingBehavior: Nullable<FramingBehavior>;
  34336. /**
  34337. * Defines if the framing behavior of the camera is enabled on the camera.
  34338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34339. */
  34340. useFramingBehavior: boolean;
  34341. private _autoRotationBehavior;
  34342. /**
  34343. * Gets the auto rotation behavior of the camera if it has been enabled.
  34344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34345. */
  34346. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34347. /**
  34348. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34350. */
  34351. useAutoRotationBehavior: boolean;
  34352. /**
  34353. * Observable triggered when the mesh target has been changed on the camera.
  34354. */
  34355. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34356. /**
  34357. * Event raised when the camera is colliding with a mesh.
  34358. */
  34359. onCollide: (collidedMesh: AbstractMesh) => void;
  34360. /**
  34361. * Defines whether the camera should check collision with the objects oh the scene.
  34362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34363. */
  34364. checkCollisions: boolean;
  34365. /**
  34366. * Defines the collision radius of the camera.
  34367. * This simulates a sphere around the camera.
  34368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34369. */
  34370. collisionRadius: Vector3;
  34371. protected _collider: Collider;
  34372. protected _previousPosition: Vector3;
  34373. protected _collisionVelocity: Vector3;
  34374. protected _newPosition: Vector3;
  34375. protected _previousAlpha: number;
  34376. protected _previousBeta: number;
  34377. protected _previousRadius: number;
  34378. protected _collisionTriggered: boolean;
  34379. protected _targetBoundingCenter: Nullable<Vector3>;
  34380. private _computationVector;
  34381. private _tempAxisVector;
  34382. private _tempAxisRotationMatrix;
  34383. /**
  34384. * Instantiates a new ArcRotateCamera in a given scene
  34385. * @param name Defines the name of the camera
  34386. * @param alpha Defines the camera rotation along the logitudinal axis
  34387. * @param beta Defines the camera rotation along the latitudinal axis
  34388. * @param radius Defines the camera distance from its target
  34389. * @param target Defines the camera target
  34390. * @param scene Defines the scene the camera belongs to
  34391. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34392. */
  34393. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34394. /** @hidden */
  34395. _initCache(): void;
  34396. /** @hidden */
  34397. _updateCache(ignoreParentClass?: boolean): void;
  34398. protected _getTargetPosition(): Vector3;
  34399. private _storedAlpha;
  34400. private _storedBeta;
  34401. private _storedRadius;
  34402. private _storedTarget;
  34403. /**
  34404. * Stores the current state of the camera (alpha, beta, radius and target)
  34405. * @returns the camera itself
  34406. */
  34407. storeState(): Camera;
  34408. /**
  34409. * @hidden
  34410. * Restored camera state. You must call storeState() first
  34411. */
  34412. _restoreStateValues(): boolean;
  34413. /** @hidden */
  34414. _isSynchronizedViewMatrix(): boolean;
  34415. /**
  34416. * Attached controls to the current camera.
  34417. * @param element Defines the element the controls should be listened from
  34418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34419. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34420. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34421. */
  34422. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34423. /**
  34424. * Detach the current controls from the camera.
  34425. * The camera will stop reacting to inputs.
  34426. * @param element Defines the element to stop listening the inputs from
  34427. */
  34428. detachControl(element: HTMLElement): void;
  34429. /** @hidden */
  34430. _checkInputs(): void;
  34431. protected _checkLimits(): void;
  34432. /**
  34433. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34434. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  34435. */
  34436. rebuildAnglesAndRadius(updateView?: boolean): void;
  34437. /**
  34438. * Use a position to define the current camera related information like aplha, beta and radius
  34439. * @param position Defines the position to set the camera at
  34440. */
  34441. setPosition(position: Vector3): void;
  34442. /**
  34443. * Defines the target the camera should look at.
  34444. * This will automatically adapt alpha beta and radius to fit within the new target.
  34445. * @param target Defines the new target as a Vector or a mesh
  34446. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34447. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34448. */
  34449. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34450. /** @hidden */
  34451. _getViewMatrix(): Matrix;
  34452. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34453. /**
  34454. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34455. * @param meshes Defines the mesh to zoom on
  34456. * @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)
  34457. */
  34458. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34459. /**
  34460. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34461. * The target will be changed but the radius
  34462. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34463. * @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)
  34464. */
  34465. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34466. min: Vector3;
  34467. max: Vector3;
  34468. distance: number;
  34469. }, doNotUpdateMaxZ?: boolean): void;
  34470. /**
  34471. * @override
  34472. * Override Camera.createRigCamera
  34473. */
  34474. createRigCamera(name: string, cameraIndex: number): Camera;
  34475. /**
  34476. * @hidden
  34477. * @override
  34478. * Override Camera._updateRigCameras
  34479. */
  34480. _updateRigCameras(): void;
  34481. /**
  34482. * Destroy the camera and release the current resources hold by it.
  34483. */
  34484. dispose(): void;
  34485. /**
  34486. * Gets the current object class name.
  34487. * @return the class name
  34488. */
  34489. getClassName(): string;
  34490. }
  34491. }
  34492. declare module BABYLON {
  34493. /**
  34494. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34495. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34496. */
  34497. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34498. /**
  34499. * Gets the name of the behavior.
  34500. */
  34501. readonly name: string;
  34502. private _zoomStopsAnimation;
  34503. private _idleRotationSpeed;
  34504. private _idleRotationWaitTime;
  34505. private _idleRotationSpinupTime;
  34506. /**
  34507. * Sets the flag that indicates if user zooming should stop animation.
  34508. */
  34509. /**
  34510. * Gets the flag that indicates if user zooming should stop animation.
  34511. */
  34512. zoomStopsAnimation: boolean;
  34513. /**
  34514. * Sets the default speed at which the camera rotates around the model.
  34515. */
  34516. /**
  34517. * Gets the default speed at which the camera rotates around the model.
  34518. */
  34519. idleRotationSpeed: number;
  34520. /**
  34521. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34522. */
  34523. /**
  34524. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34525. */
  34526. idleRotationWaitTime: number;
  34527. /**
  34528. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34529. */
  34530. /**
  34531. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34532. */
  34533. idleRotationSpinupTime: number;
  34534. /**
  34535. * Gets a value indicating if the camera is currently rotating because of this behavior
  34536. */
  34537. readonly rotationInProgress: boolean;
  34538. private _onPrePointerObservableObserver;
  34539. private _onAfterCheckInputsObserver;
  34540. private _attachedCamera;
  34541. private _isPointerDown;
  34542. private _lastFrameTime;
  34543. private _lastInteractionTime;
  34544. private _cameraRotationSpeed;
  34545. /**
  34546. * Initializes the behavior.
  34547. */
  34548. init(): void;
  34549. /**
  34550. * Attaches the behavior to its arc rotate camera.
  34551. * @param camera Defines the camera to attach the behavior to
  34552. */
  34553. attach(camera: ArcRotateCamera): void;
  34554. /**
  34555. * Detaches the behavior from its current arc rotate camera.
  34556. */
  34557. detach(): void;
  34558. /**
  34559. * Returns true if user is scrolling.
  34560. * @return true if user is scrolling.
  34561. */
  34562. private _userIsZooming;
  34563. private _lastFrameRadius;
  34564. private _shouldAnimationStopForInteraction;
  34565. /**
  34566. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34567. */
  34568. private _applyUserInteraction;
  34569. private _userIsMoving;
  34570. }
  34571. }
  34572. declare module BABYLON {
  34573. /**
  34574. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34575. */
  34576. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34577. private ui;
  34578. /**
  34579. * The name of the behavior
  34580. */
  34581. name: string;
  34582. /**
  34583. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34584. */
  34585. distanceAwayFromFace: number;
  34586. /**
  34587. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34588. */
  34589. distanceAwayFromBottomOfFace: number;
  34590. private _faceVectors;
  34591. private _target;
  34592. private _scene;
  34593. private _onRenderObserver;
  34594. private _tmpMatrix;
  34595. private _tmpVector;
  34596. /**
  34597. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34598. * @param ui The transform node that should be attched to the mesh
  34599. */
  34600. constructor(ui: TransformNode);
  34601. /**
  34602. * Initializes the behavior
  34603. */
  34604. init(): void;
  34605. private _closestFace;
  34606. private _zeroVector;
  34607. private _lookAtTmpMatrix;
  34608. private _lookAtToRef;
  34609. /**
  34610. * Attaches the AttachToBoxBehavior to the passed in mesh
  34611. * @param target The mesh that the specified node will be attached to
  34612. */
  34613. attach(target: Mesh): void;
  34614. /**
  34615. * Detaches the behavior from the mesh
  34616. */
  34617. detach(): void;
  34618. }
  34619. }
  34620. declare module BABYLON {
  34621. /**
  34622. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34623. */
  34624. export class FadeInOutBehavior implements Behavior<Mesh> {
  34625. /**
  34626. * Time in milliseconds to delay before fading in (Default: 0)
  34627. */
  34628. delay: number;
  34629. /**
  34630. * Time in milliseconds for the mesh to fade in (Default: 300)
  34631. */
  34632. fadeInTime: number;
  34633. private _millisecondsPerFrame;
  34634. private _hovered;
  34635. private _hoverValue;
  34636. private _ownerNode;
  34637. /**
  34638. * Instatiates the FadeInOutBehavior
  34639. */
  34640. constructor();
  34641. /**
  34642. * The name of the behavior
  34643. */
  34644. readonly name: string;
  34645. /**
  34646. * Initializes the behavior
  34647. */
  34648. init(): void;
  34649. /**
  34650. * Attaches the fade behavior on the passed in mesh
  34651. * @param ownerNode The mesh that will be faded in/out once attached
  34652. */
  34653. attach(ownerNode: Mesh): void;
  34654. /**
  34655. * Detaches the behavior from the mesh
  34656. */
  34657. detach(): void;
  34658. /**
  34659. * Triggers the mesh to begin fading in or out
  34660. * @param value if the object should fade in or out (true to fade in)
  34661. */
  34662. fadeIn(value: boolean): void;
  34663. private _update;
  34664. private _setAllVisibility;
  34665. }
  34666. }
  34667. declare module BABYLON {
  34668. /**
  34669. * Class containing a set of static utilities functions for managing Pivots
  34670. * @hidden
  34671. */
  34672. export class PivotTools {
  34673. private static _PivotCached;
  34674. private static _OldPivotPoint;
  34675. private static _PivotTranslation;
  34676. private static _PivotTmpVector;
  34677. /** @hidden */
  34678. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34679. /** @hidden */
  34680. static _RestorePivotPoint(mesh: AbstractMesh): void;
  34681. }
  34682. }
  34683. declare module BABYLON {
  34684. /**
  34685. * Class containing static functions to help procedurally build meshes
  34686. */
  34687. export class PlaneBuilder {
  34688. /**
  34689. * Creates a plane mesh
  34690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34694. * * 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
  34695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34696. * @param name defines the name of the mesh
  34697. * @param options defines the options used to create the mesh
  34698. * @param scene defines the hosting scene
  34699. * @returns the plane mesh
  34700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34701. */
  34702. static CreatePlane(name: string, options: {
  34703. size?: number;
  34704. width?: number;
  34705. height?: number;
  34706. sideOrientation?: number;
  34707. frontUVs?: Vector4;
  34708. backUVs?: Vector4;
  34709. updatable?: boolean;
  34710. sourcePlane?: Plane;
  34711. }, scene: Scene): Mesh;
  34712. }
  34713. }
  34714. declare module BABYLON {
  34715. /**
  34716. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34717. */
  34718. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34719. private static _AnyMouseID;
  34720. private _attachedNode;
  34721. private _dragPlane;
  34722. private _scene;
  34723. private _pointerObserver;
  34724. private _beforeRenderObserver;
  34725. private static _planeScene;
  34726. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34727. /**
  34728. * 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)
  34729. */
  34730. maxDragAngle: number;
  34731. /**
  34732. * @hidden
  34733. */
  34734. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  34735. /**
  34736. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34737. */
  34738. currentDraggingPointerID: number;
  34739. /**
  34740. * The last position where the pointer hit the drag plane in world space
  34741. */
  34742. lastDragPosition: Vector3;
  34743. /**
  34744. * If the behavior is currently in a dragging state
  34745. */
  34746. dragging: boolean;
  34747. /**
  34748. * 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)
  34749. */
  34750. dragDeltaRatio: number;
  34751. /**
  34752. * If the drag plane orientation should be updated during the dragging (Default: true)
  34753. */
  34754. updateDragPlane: boolean;
  34755. private _debugMode;
  34756. private _moving;
  34757. /**
  34758. * Fires each time the attached mesh is dragged with the pointer
  34759. * * delta between last drag position and current drag position in world space
  34760. * * dragDistance along the drag axis
  34761. * * dragPlaneNormal normal of the current drag plane used during the drag
  34762. * * dragPlanePoint in world space where the drag intersects the drag plane
  34763. */
  34764. onDragObservable: Observable<{
  34765. delta: Vector3;
  34766. dragPlanePoint: Vector3;
  34767. dragPlaneNormal: Vector3;
  34768. dragDistance: number;
  34769. pointerId: number;
  34770. }>;
  34771. /**
  34772. * Fires each time a drag begins (eg. mouse down on mesh)
  34773. */
  34774. onDragStartObservable: Observable<{
  34775. dragPlanePoint: Vector3;
  34776. pointerId: number;
  34777. }>;
  34778. /**
  34779. * Fires each time a drag ends (eg. mouse release after drag)
  34780. */
  34781. onDragEndObservable: Observable<{
  34782. dragPlanePoint: Vector3;
  34783. pointerId: number;
  34784. }>;
  34785. /**
  34786. * If the attached mesh should be moved when dragged
  34787. */
  34788. moveAttached: boolean;
  34789. /**
  34790. * If the drag behavior will react to drag events (Default: true)
  34791. */
  34792. enabled: boolean;
  34793. /**
  34794. * If camera controls should be detached during the drag
  34795. */
  34796. detachCameraControls: boolean;
  34797. /**
  34798. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34799. */
  34800. useObjectOrienationForDragging: boolean;
  34801. private _options;
  34802. /**
  34803. * Creates a pointer drag behavior that can be attached to a mesh
  34804. * @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)
  34805. */
  34806. constructor(options?: {
  34807. dragAxis?: Vector3;
  34808. dragPlaneNormal?: Vector3;
  34809. });
  34810. /**
  34811. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34812. */
  34813. validateDrag: (targetPosition: Vector3) => boolean;
  34814. /**
  34815. * The name of the behavior
  34816. */
  34817. readonly name: string;
  34818. /**
  34819. * Initializes the behavior
  34820. */
  34821. init(): void;
  34822. private _tmpVector;
  34823. private _alternatePickedPoint;
  34824. private _worldDragAxis;
  34825. private _targetPosition;
  34826. private _attachedElement;
  34827. /**
  34828. * Attaches the drag behavior the passed in mesh
  34829. * @param ownerNode The mesh that will be dragged around once attached
  34830. */
  34831. attach(ownerNode: AbstractMesh): void;
  34832. /**
  34833. * Force relase the drag action by code.
  34834. */
  34835. releaseDrag(): void;
  34836. private _startDragRay;
  34837. private _lastPointerRay;
  34838. /**
  34839. * Simulates the start of a pointer drag event on the behavior
  34840. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34841. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34842. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34843. */
  34844. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34845. private _startDrag;
  34846. private _dragDelta;
  34847. private _moveDrag;
  34848. private _pickWithRayOnDragPlane;
  34849. private _pointA;
  34850. private _pointB;
  34851. private _pointC;
  34852. private _lineA;
  34853. private _lineB;
  34854. private _localAxis;
  34855. private _lookAt;
  34856. private _updateDragPlanePosition;
  34857. /**
  34858. * Detaches the behavior from the mesh
  34859. */
  34860. detach(): void;
  34861. }
  34862. }
  34863. declare module BABYLON {
  34864. /**
  34865. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34866. */
  34867. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34868. private _dragBehaviorA;
  34869. private _dragBehaviorB;
  34870. private _startDistance;
  34871. private _initialScale;
  34872. private _targetScale;
  34873. private _ownerNode;
  34874. private _sceneRenderObserver;
  34875. /**
  34876. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34877. */
  34878. constructor();
  34879. /**
  34880. * The name of the behavior
  34881. */
  34882. readonly name: string;
  34883. /**
  34884. * Initializes the behavior
  34885. */
  34886. init(): void;
  34887. private _getCurrentDistance;
  34888. /**
  34889. * Attaches the scale behavior the passed in mesh
  34890. * @param ownerNode The mesh that will be scaled around once attached
  34891. */
  34892. attach(ownerNode: Mesh): void;
  34893. /**
  34894. * Detaches the behavior from the mesh
  34895. */
  34896. detach(): void;
  34897. }
  34898. }
  34899. declare module BABYLON {
  34900. /**
  34901. * 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
  34902. */
  34903. export class SixDofDragBehavior implements Behavior<Mesh> {
  34904. private static _virtualScene;
  34905. private _ownerNode;
  34906. private _sceneRenderObserver;
  34907. private _scene;
  34908. private _targetPosition;
  34909. private _virtualOriginMesh;
  34910. private _virtualDragMesh;
  34911. private _pointerObserver;
  34912. private _moving;
  34913. private _startingOrientation;
  34914. /**
  34915. * 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)
  34916. */
  34917. private zDragFactor;
  34918. /**
  34919. * If the object should rotate to face the drag origin
  34920. */
  34921. rotateDraggedObject: boolean;
  34922. /**
  34923. * If the behavior is currently in a dragging state
  34924. */
  34925. dragging: boolean;
  34926. /**
  34927. * 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)
  34928. */
  34929. dragDeltaRatio: number;
  34930. /**
  34931. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34932. */
  34933. currentDraggingPointerID: number;
  34934. /**
  34935. * If camera controls should be detached during the drag
  34936. */
  34937. detachCameraControls: boolean;
  34938. /**
  34939. * Fires each time a drag starts
  34940. */
  34941. onDragStartObservable: Observable<{}>;
  34942. /**
  34943. * Fires each time a drag ends (eg. mouse release after drag)
  34944. */
  34945. onDragEndObservable: Observable<{}>;
  34946. /**
  34947. * 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
  34948. */
  34949. constructor();
  34950. /**
  34951. * The name of the behavior
  34952. */
  34953. readonly name: string;
  34954. /**
  34955. * Initializes the behavior
  34956. */
  34957. init(): void;
  34958. /**
  34959. * Attaches the scale behavior the passed in mesh
  34960. * @param ownerNode The mesh that will be scaled around once attached
  34961. */
  34962. attach(ownerNode: Mesh): void;
  34963. /**
  34964. * Detaches the behavior from the mesh
  34965. */
  34966. detach(): void;
  34967. }
  34968. }
  34969. declare module BABYLON {
  34970. /**
  34971. * Class used to apply inverse kinematics to bones
  34972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34973. */
  34974. export class BoneIKController {
  34975. private static _tmpVecs;
  34976. private static _tmpQuat;
  34977. private static _tmpMats;
  34978. /**
  34979. * Gets or sets the target mesh
  34980. */
  34981. targetMesh: AbstractMesh;
  34982. /** Gets or sets the mesh used as pole */
  34983. poleTargetMesh: AbstractMesh;
  34984. /**
  34985. * Gets or sets the bone used as pole
  34986. */
  34987. poleTargetBone: Nullable<Bone>;
  34988. /**
  34989. * Gets or sets the target position
  34990. */
  34991. targetPosition: Vector3;
  34992. /**
  34993. * Gets or sets the pole target position
  34994. */
  34995. poleTargetPosition: Vector3;
  34996. /**
  34997. * Gets or sets the pole target local offset
  34998. */
  34999. poleTargetLocalOffset: Vector3;
  35000. /**
  35001. * Gets or sets the pole angle
  35002. */
  35003. poleAngle: number;
  35004. /**
  35005. * Gets or sets the mesh associated with the controller
  35006. */
  35007. mesh: AbstractMesh;
  35008. /**
  35009. * 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)
  35010. */
  35011. slerpAmount: number;
  35012. private _bone1Quat;
  35013. private _bone1Mat;
  35014. private _bone2Ang;
  35015. private _bone1;
  35016. private _bone2;
  35017. private _bone1Length;
  35018. private _bone2Length;
  35019. private _maxAngle;
  35020. private _maxReach;
  35021. private _rightHandedSystem;
  35022. private _bendAxis;
  35023. private _slerping;
  35024. private _adjustRoll;
  35025. /**
  35026. * Gets or sets maximum allowed angle
  35027. */
  35028. maxAngle: number;
  35029. /**
  35030. * Creates a new BoneIKController
  35031. * @param mesh defines the mesh to control
  35032. * @param bone defines the bone to control
  35033. * @param options defines options to set up the controller
  35034. */
  35035. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35036. targetMesh?: AbstractMesh;
  35037. poleTargetMesh?: AbstractMesh;
  35038. poleTargetBone?: Bone;
  35039. poleTargetLocalOffset?: Vector3;
  35040. poleAngle?: number;
  35041. bendAxis?: Vector3;
  35042. maxAngle?: number;
  35043. slerpAmount?: number;
  35044. });
  35045. private _setMaxAngle;
  35046. /**
  35047. * Force the controller to update the bones
  35048. */
  35049. update(): void;
  35050. }
  35051. }
  35052. declare module BABYLON {
  35053. /**
  35054. * Class used to make a bone look toward a point in space
  35055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35056. */
  35057. export class BoneLookController {
  35058. private static _tmpVecs;
  35059. private static _tmpQuat;
  35060. private static _tmpMats;
  35061. /**
  35062. * The target Vector3 that the bone will look at
  35063. */
  35064. target: Vector3;
  35065. /**
  35066. * The mesh that the bone is attached to
  35067. */
  35068. mesh: AbstractMesh;
  35069. /**
  35070. * The bone that will be looking to the target
  35071. */
  35072. bone: Bone;
  35073. /**
  35074. * The up axis of the coordinate system that is used when the bone is rotated
  35075. */
  35076. upAxis: Vector3;
  35077. /**
  35078. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35079. */
  35080. upAxisSpace: Space;
  35081. /**
  35082. * Used to make an adjustment to the yaw of the bone
  35083. */
  35084. adjustYaw: number;
  35085. /**
  35086. * Used to make an adjustment to the pitch of the bone
  35087. */
  35088. adjustPitch: number;
  35089. /**
  35090. * Used to make an adjustment to the roll of the bone
  35091. */
  35092. adjustRoll: number;
  35093. /**
  35094. * 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)
  35095. */
  35096. slerpAmount: number;
  35097. private _minYaw;
  35098. private _maxYaw;
  35099. private _minPitch;
  35100. private _maxPitch;
  35101. private _minYawSin;
  35102. private _minYawCos;
  35103. private _maxYawSin;
  35104. private _maxYawCos;
  35105. private _midYawConstraint;
  35106. private _minPitchTan;
  35107. private _maxPitchTan;
  35108. private _boneQuat;
  35109. private _slerping;
  35110. private _transformYawPitch;
  35111. private _transformYawPitchInv;
  35112. private _firstFrameSkipped;
  35113. private _yawRange;
  35114. private _fowardAxis;
  35115. /**
  35116. * Gets or sets the minimum yaw angle that the bone can look to
  35117. */
  35118. minYaw: number;
  35119. /**
  35120. * Gets or sets the maximum yaw angle that the bone can look to
  35121. */
  35122. maxYaw: number;
  35123. /**
  35124. * Gets or sets the minimum pitch angle that the bone can look to
  35125. */
  35126. minPitch: number;
  35127. /**
  35128. * Gets or sets the maximum pitch angle that the bone can look to
  35129. */
  35130. maxPitch: number;
  35131. /**
  35132. * Create a BoneLookController
  35133. * @param mesh the mesh that the bone belongs to
  35134. * @param bone the bone that will be looking to the target
  35135. * @param target the target Vector3 to look at
  35136. * @param options optional settings:
  35137. * * maxYaw: the maximum angle the bone will yaw to
  35138. * * minYaw: the minimum angle the bone will yaw to
  35139. * * maxPitch: the maximum angle the bone will pitch to
  35140. * * minPitch: the minimum angle the bone will yaw to
  35141. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35142. * * upAxis: the up axis of the coordinate system
  35143. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35144. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35145. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35146. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35147. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35148. * * adjustRoll: used to make an adjustment to the roll of the bone
  35149. **/
  35150. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35151. maxYaw?: number;
  35152. minYaw?: number;
  35153. maxPitch?: number;
  35154. minPitch?: number;
  35155. slerpAmount?: number;
  35156. upAxis?: Vector3;
  35157. upAxisSpace?: Space;
  35158. yawAxis?: Vector3;
  35159. pitchAxis?: Vector3;
  35160. adjustYaw?: number;
  35161. adjustPitch?: number;
  35162. adjustRoll?: number;
  35163. });
  35164. /**
  35165. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35166. */
  35167. update(): void;
  35168. private _getAngleDiff;
  35169. private _getAngleBetween;
  35170. private _isAngleBetween;
  35171. }
  35172. }
  35173. declare module BABYLON {
  35174. /**
  35175. * Manage the gamepad inputs to control an arc rotate camera.
  35176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35177. */
  35178. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35179. /**
  35180. * Defines the camera the input is attached to.
  35181. */
  35182. camera: ArcRotateCamera;
  35183. /**
  35184. * Defines the gamepad the input is gathering event from.
  35185. */
  35186. gamepad: Nullable<Gamepad>;
  35187. /**
  35188. * Defines the gamepad rotation sensiblity.
  35189. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35190. */
  35191. gamepadRotationSensibility: number;
  35192. /**
  35193. * Defines the gamepad move sensiblity.
  35194. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35195. */
  35196. gamepadMoveSensibility: number;
  35197. private _onGamepadConnectedObserver;
  35198. private _onGamepadDisconnectedObserver;
  35199. /**
  35200. * Attach the input controls to a specific dom element to get the input from.
  35201. * @param element Defines the element the controls should be listened from
  35202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35203. */
  35204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35205. /**
  35206. * Detach the current controls from the specified dom element.
  35207. * @param element Defines the element to stop listening the inputs from
  35208. */
  35209. detachControl(element: Nullable<HTMLElement>): void;
  35210. /**
  35211. * Update the current camera state depending on the inputs that have been used this frame.
  35212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35213. */
  35214. checkInputs(): void;
  35215. /**
  35216. * Gets the class name of the current intput.
  35217. * @returns the class name
  35218. */
  35219. getClassName(): string;
  35220. /**
  35221. * Get the friendly name associated with the input class.
  35222. * @returns the input friendly name
  35223. */
  35224. getSimpleName(): string;
  35225. }
  35226. }
  35227. declare module BABYLON {
  35228. interface ArcRotateCameraInputsManager {
  35229. /**
  35230. * Add orientation input support to the input manager.
  35231. * @returns the current input manager
  35232. */
  35233. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35234. }
  35235. /**
  35236. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35238. */
  35239. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35240. /**
  35241. * Defines the camera the input is attached to.
  35242. */
  35243. camera: ArcRotateCamera;
  35244. /**
  35245. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35246. */
  35247. alphaCorrection: number;
  35248. /**
  35249. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35250. */
  35251. gammaCorrection: number;
  35252. private _alpha;
  35253. private _gamma;
  35254. private _dirty;
  35255. private _deviceOrientationHandler;
  35256. /**
  35257. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35258. */
  35259. constructor();
  35260. /**
  35261. * Attach the input controls to a specific dom element to get the input from.
  35262. * @param element Defines the element the controls should be listened from
  35263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35264. */
  35265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35266. /** @hidden */
  35267. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35268. /**
  35269. * Update the current camera state depending on the inputs that have been used this frame.
  35270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35271. */
  35272. checkInputs(): void;
  35273. /**
  35274. * Detach the current controls from the specified dom element.
  35275. * @param element Defines the element to stop listening the inputs from
  35276. */
  35277. detachControl(element: Nullable<HTMLElement>): void;
  35278. /**
  35279. * Gets the class name of the current intput.
  35280. * @returns the class name
  35281. */
  35282. getClassName(): string;
  35283. /**
  35284. * Get the friendly name associated with the input class.
  35285. * @returns the input friendly name
  35286. */
  35287. getSimpleName(): string;
  35288. }
  35289. }
  35290. declare module BABYLON {
  35291. /**
  35292. * Listen to mouse events to control the camera.
  35293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35294. */
  35295. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35296. /**
  35297. * Defines the camera the input is attached to.
  35298. */
  35299. camera: FlyCamera;
  35300. /**
  35301. * Defines if touch is enabled. (Default is true.)
  35302. */
  35303. touchEnabled: boolean;
  35304. /**
  35305. * Defines the buttons associated with the input to handle camera rotation.
  35306. */
  35307. buttons: number[];
  35308. /**
  35309. * Assign buttons for Yaw control.
  35310. */
  35311. buttonsYaw: number[];
  35312. /**
  35313. * Assign buttons for Pitch control.
  35314. */
  35315. buttonsPitch: number[];
  35316. /**
  35317. * Assign buttons for Roll control.
  35318. */
  35319. buttonsRoll: number[];
  35320. /**
  35321. * Detect if any button is being pressed while mouse is moved.
  35322. * -1 = Mouse locked.
  35323. * 0 = Left button.
  35324. * 1 = Middle Button.
  35325. * 2 = Right Button.
  35326. */
  35327. activeButton: number;
  35328. /**
  35329. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35330. * Higher values reduce its sensitivity.
  35331. */
  35332. angularSensibility: number;
  35333. private _mousemoveCallback;
  35334. private _observer;
  35335. private _rollObserver;
  35336. private previousPosition;
  35337. private noPreventDefault;
  35338. private element;
  35339. /**
  35340. * Listen to mouse events to control the camera.
  35341. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35343. */
  35344. constructor(touchEnabled?: boolean);
  35345. /**
  35346. * Attach the mouse control to the HTML DOM element.
  35347. * @param element Defines the element that listens to the input events.
  35348. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35349. */
  35350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35351. /**
  35352. * Detach the current controls from the specified dom element.
  35353. * @param element Defines the element to stop listening the inputs from
  35354. */
  35355. detachControl(element: Nullable<HTMLElement>): void;
  35356. /**
  35357. * Gets the class name of the current input.
  35358. * @returns the class name.
  35359. */
  35360. getClassName(): string;
  35361. /**
  35362. * Get the friendly name associated with the input class.
  35363. * @returns the input's friendly name.
  35364. */
  35365. getSimpleName(): string;
  35366. private _pointerInput;
  35367. private _onMouseMove;
  35368. /**
  35369. * Rotate camera by mouse offset.
  35370. */
  35371. private rotateCamera;
  35372. }
  35373. }
  35374. declare module BABYLON {
  35375. /**
  35376. * Default Inputs manager for the FlyCamera.
  35377. * It groups all the default supported inputs for ease of use.
  35378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35379. */
  35380. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35381. /**
  35382. * Instantiates a new FlyCameraInputsManager.
  35383. * @param camera Defines the camera the inputs belong to.
  35384. */
  35385. constructor(camera: FlyCamera);
  35386. /**
  35387. * Add keyboard input support to the input manager.
  35388. * @returns the new FlyCameraKeyboardMoveInput().
  35389. */
  35390. addKeyboard(): FlyCameraInputsManager;
  35391. /**
  35392. * Add mouse input support to the input manager.
  35393. * @param touchEnabled Enable touch screen support.
  35394. * @returns the new FlyCameraMouseInput().
  35395. */
  35396. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35397. }
  35398. }
  35399. declare module BABYLON {
  35400. /**
  35401. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35402. * such as in a 3D Space Shooter or a Flight Simulator.
  35403. */
  35404. export class FlyCamera extends TargetCamera {
  35405. /**
  35406. * Define the collision ellipsoid of the camera.
  35407. * This is helpful for simulating a camera body, like a player's body.
  35408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35409. */
  35410. ellipsoid: Vector3;
  35411. /**
  35412. * Define an offset for the position of the ellipsoid around the camera.
  35413. * This can be helpful if the camera is attached away from the player's body center,
  35414. * such as at its head.
  35415. */
  35416. ellipsoidOffset: Vector3;
  35417. /**
  35418. * Enable or disable collisions of the camera with the rest of the scene objects.
  35419. */
  35420. checkCollisions: boolean;
  35421. /**
  35422. * Enable or disable gravity on the camera.
  35423. */
  35424. applyGravity: boolean;
  35425. /**
  35426. * Define the current direction the camera is moving to.
  35427. */
  35428. cameraDirection: Vector3;
  35429. /**
  35430. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35431. * This overrides and empties cameraRotation.
  35432. */
  35433. rotationQuaternion: Quaternion;
  35434. /**
  35435. * Track Roll to maintain the wanted Rolling when looking around.
  35436. */
  35437. _trackRoll: number;
  35438. /**
  35439. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35440. */
  35441. rollCorrect: number;
  35442. /**
  35443. * Mimic a banked turn, Rolling the camera when Yawing.
  35444. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35445. */
  35446. bankedTurn: boolean;
  35447. /**
  35448. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35449. */
  35450. bankedTurnLimit: number;
  35451. /**
  35452. * Value of 0 disables the banked Roll.
  35453. * Value of 1 is equal to the Yaw angle in radians.
  35454. */
  35455. bankedTurnMultiplier: number;
  35456. /**
  35457. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35458. */
  35459. inputs: FlyCameraInputsManager;
  35460. /**
  35461. * Gets the input sensibility for mouse input.
  35462. * Higher values reduce sensitivity.
  35463. */
  35464. /**
  35465. * Sets the input sensibility for a mouse input.
  35466. * Higher values reduce sensitivity.
  35467. */
  35468. angularSensibility: number;
  35469. /**
  35470. * Get the keys for camera movement forward.
  35471. */
  35472. /**
  35473. * Set the keys for camera movement forward.
  35474. */
  35475. keysForward: number[];
  35476. /**
  35477. * Get the keys for camera movement backward.
  35478. */
  35479. keysBackward: number[];
  35480. /**
  35481. * Get the keys for camera movement up.
  35482. */
  35483. /**
  35484. * Set the keys for camera movement up.
  35485. */
  35486. keysUp: number[];
  35487. /**
  35488. * Get the keys for camera movement down.
  35489. */
  35490. /**
  35491. * Set the keys for camera movement down.
  35492. */
  35493. keysDown: number[];
  35494. /**
  35495. * Get the keys for camera movement left.
  35496. */
  35497. /**
  35498. * Set the keys for camera movement left.
  35499. */
  35500. keysLeft: number[];
  35501. /**
  35502. * Set the keys for camera movement right.
  35503. */
  35504. /**
  35505. * Set the keys for camera movement right.
  35506. */
  35507. keysRight: number[];
  35508. /**
  35509. * Event raised when the camera collides with a mesh in the scene.
  35510. */
  35511. onCollide: (collidedMesh: AbstractMesh) => void;
  35512. private _collider;
  35513. private _needMoveForGravity;
  35514. private _oldPosition;
  35515. private _diffPosition;
  35516. private _newPosition;
  35517. /** @hidden */
  35518. _localDirection: Vector3;
  35519. /** @hidden */
  35520. _transformedDirection: Vector3;
  35521. /**
  35522. * Instantiates a FlyCamera.
  35523. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35524. * such as in a 3D Space Shooter or a Flight Simulator.
  35525. * @param name Define the name of the camera in the scene.
  35526. * @param position Define the starting position of the camera in the scene.
  35527. * @param scene Define the scene the camera belongs to.
  35528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35529. */
  35530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35531. /**
  35532. * Attach a control to the HTML DOM element.
  35533. * @param element Defines the element that listens to the input events.
  35534. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35535. */
  35536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35537. /**
  35538. * Detach a control from the HTML DOM element.
  35539. * The camera will stop reacting to that input.
  35540. * @param element Defines the element that listens to the input events.
  35541. */
  35542. detachControl(element: HTMLElement): void;
  35543. private _collisionMask;
  35544. /**
  35545. * Get the mask that the camera ignores in collision events.
  35546. */
  35547. /**
  35548. * Set the mask that the camera ignores in collision events.
  35549. */
  35550. collisionMask: number;
  35551. /** @hidden */
  35552. _collideWithWorld(displacement: Vector3): void;
  35553. /** @hidden */
  35554. private _onCollisionPositionChange;
  35555. /** @hidden */
  35556. _checkInputs(): void;
  35557. /** @hidden */
  35558. _decideIfNeedsToMove(): boolean;
  35559. /** @hidden */
  35560. _updatePosition(): void;
  35561. /**
  35562. * Restore the Roll to its target value at the rate specified.
  35563. * @param rate - Higher means slower restoring.
  35564. * @hidden
  35565. */
  35566. restoreRoll(rate: number): void;
  35567. /**
  35568. * Destroy the camera and release the current resources held by it.
  35569. */
  35570. dispose(): void;
  35571. /**
  35572. * Get the current object class name.
  35573. * @returns the class name.
  35574. */
  35575. getClassName(): string;
  35576. }
  35577. }
  35578. declare module BABYLON {
  35579. /**
  35580. * Listen to keyboard events to control the camera.
  35581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35582. */
  35583. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35584. /**
  35585. * Defines the camera the input is attached to.
  35586. */
  35587. camera: FlyCamera;
  35588. /**
  35589. * The list of keyboard keys used to control the forward move of the camera.
  35590. */
  35591. keysForward: number[];
  35592. /**
  35593. * The list of keyboard keys used to control the backward move of the camera.
  35594. */
  35595. keysBackward: number[];
  35596. /**
  35597. * The list of keyboard keys used to control the forward move of the camera.
  35598. */
  35599. keysUp: number[];
  35600. /**
  35601. * The list of keyboard keys used to control the backward move of the camera.
  35602. */
  35603. keysDown: number[];
  35604. /**
  35605. * The list of keyboard keys used to control the right strafe move of the camera.
  35606. */
  35607. keysRight: number[];
  35608. /**
  35609. * The list of keyboard keys used to control the left strafe move of the camera.
  35610. */
  35611. keysLeft: number[];
  35612. private _keys;
  35613. private _onCanvasBlurObserver;
  35614. private _onKeyboardObserver;
  35615. private _engine;
  35616. private _scene;
  35617. /**
  35618. * Attach the input controls to a specific dom element to get the input from.
  35619. * @param element Defines the element the controls should be listened from
  35620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35621. */
  35622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35623. /**
  35624. * Detach the current controls from the specified dom element.
  35625. * @param element Defines the element to stop listening the inputs from
  35626. */
  35627. detachControl(element: Nullable<HTMLElement>): void;
  35628. /**
  35629. * Gets the class name of the current intput.
  35630. * @returns the class name
  35631. */
  35632. getClassName(): string;
  35633. /** @hidden */
  35634. _onLostFocus(e: FocusEvent): void;
  35635. /**
  35636. * Get the friendly name associated with the input class.
  35637. * @returns the input friendly name
  35638. */
  35639. getSimpleName(): string;
  35640. /**
  35641. * Update the current camera state depending on the inputs that have been used this frame.
  35642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35643. */
  35644. checkInputs(): void;
  35645. }
  35646. }
  35647. declare module BABYLON {
  35648. /**
  35649. * Manage the mouse wheel inputs to control a follow camera.
  35650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35651. */
  35652. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35653. /**
  35654. * Defines the camera the input is attached to.
  35655. */
  35656. camera: FollowCamera;
  35657. /**
  35658. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35659. */
  35660. axisControlRadius: boolean;
  35661. /**
  35662. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35663. */
  35664. axisControlHeight: boolean;
  35665. /**
  35666. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35667. */
  35668. axisControlRotation: boolean;
  35669. /**
  35670. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35671. * relation to mouseWheel events.
  35672. */
  35673. wheelPrecision: number;
  35674. /**
  35675. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35676. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35677. */
  35678. wheelDeltaPercentage: number;
  35679. private _wheel;
  35680. private _observer;
  35681. /**
  35682. * Attach the input controls to a specific dom element to get the input from.
  35683. * @param element Defines the element the controls should be listened from
  35684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35685. */
  35686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35687. /**
  35688. * Detach the current controls from the specified dom element.
  35689. * @param element Defines the element to stop listening the inputs from
  35690. */
  35691. detachControl(element: Nullable<HTMLElement>): void;
  35692. /**
  35693. * Gets the class name of the current intput.
  35694. * @returns the class name
  35695. */
  35696. getClassName(): string;
  35697. /**
  35698. * Get the friendly name associated with the input class.
  35699. * @returns the input friendly name
  35700. */
  35701. getSimpleName(): string;
  35702. }
  35703. }
  35704. declare module BABYLON {
  35705. /**
  35706. * Manage the pointers inputs to control an follow camera.
  35707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35708. */
  35709. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35710. /**
  35711. * Defines the camera the input is attached to.
  35712. */
  35713. camera: FollowCamera;
  35714. /**
  35715. * Gets the class name of the current input.
  35716. * @returns the class name
  35717. */
  35718. getClassName(): string;
  35719. /**
  35720. * Defines the pointer angular sensibility along the X axis or how fast is
  35721. * the camera rotating.
  35722. * A negative number will reverse the axis direction.
  35723. */
  35724. angularSensibilityX: number;
  35725. /**
  35726. * Defines the pointer angular sensibility along the Y axis or how fast is
  35727. * the camera rotating.
  35728. * A negative number will reverse the axis direction.
  35729. */
  35730. angularSensibilityY: number;
  35731. /**
  35732. * Defines the pointer pinch precision or how fast is the camera zooming.
  35733. * A negative number will reverse the axis direction.
  35734. */
  35735. pinchPrecision: number;
  35736. /**
  35737. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35738. * from 0.
  35739. * It defines the percentage of current camera.radius to use as delta when
  35740. * pinch zoom is used.
  35741. */
  35742. pinchDeltaPercentage: number;
  35743. /**
  35744. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35745. */
  35746. axisXControlRadius: boolean;
  35747. /**
  35748. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35749. */
  35750. axisXControlHeight: boolean;
  35751. /**
  35752. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35753. */
  35754. axisXControlRotation: boolean;
  35755. /**
  35756. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35757. */
  35758. axisYControlRadius: boolean;
  35759. /**
  35760. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35761. */
  35762. axisYControlHeight: boolean;
  35763. /**
  35764. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35765. */
  35766. axisYControlRotation: boolean;
  35767. /**
  35768. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35769. */
  35770. axisPinchControlRadius: boolean;
  35771. /**
  35772. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35773. */
  35774. axisPinchControlHeight: boolean;
  35775. /**
  35776. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35777. */
  35778. axisPinchControlRotation: boolean;
  35779. /**
  35780. * Log error messages if basic misconfiguration has occurred.
  35781. */
  35782. warningEnable: boolean;
  35783. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35784. protected doMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35785. private _warningCounter;
  35786. private _warning;
  35787. }
  35788. }
  35789. declare module BABYLON {
  35790. /**
  35791. * Default Inputs manager for the FollowCamera.
  35792. * It groups all the default supported inputs for ease of use.
  35793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35794. */
  35795. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35796. /**
  35797. * Instantiates a new FollowCameraInputsManager.
  35798. * @param camera Defines the camera the inputs belong to
  35799. */
  35800. constructor(camera: FollowCamera);
  35801. /**
  35802. * Add keyboard input support to the input manager.
  35803. * @returns the current input manager
  35804. */
  35805. addKeyboard(): FollowCameraInputsManager;
  35806. /**
  35807. * Add mouse wheel input support to the input manager.
  35808. * @returns the current input manager
  35809. */
  35810. addMouseWheel(): FollowCameraInputsManager;
  35811. /**
  35812. * Add pointers input support to the input manager.
  35813. * @returns the current input manager
  35814. */
  35815. addPointers(): FollowCameraInputsManager;
  35816. /**
  35817. * Add orientation input support to the input manager.
  35818. * @returns the current input manager
  35819. */
  35820. addVRDeviceOrientation(): FollowCameraInputsManager;
  35821. }
  35822. }
  35823. declare module BABYLON {
  35824. /**
  35825. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35826. * an arc rotate version arcFollowCamera are available.
  35827. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35828. */
  35829. export class FollowCamera extends TargetCamera {
  35830. /**
  35831. * Distance the follow camera should follow an object at
  35832. */
  35833. radius: number;
  35834. /**
  35835. * Minimum allowed distance of the camera to the axis of rotation
  35836. * (The camera can not get closer).
  35837. * This can help limiting how the Camera is able to move in the scene.
  35838. */
  35839. lowerRadiusLimit: Nullable<number>;
  35840. /**
  35841. * Maximum allowed distance of the camera to the axis of rotation
  35842. * (The camera can not get further).
  35843. * This can help limiting how the Camera is able to move in the scene.
  35844. */
  35845. upperRadiusLimit: Nullable<number>;
  35846. /**
  35847. * Define a rotation offset between the camera and the object it follows
  35848. */
  35849. rotationOffset: number;
  35850. /**
  35851. * Minimum allowed angle to camera position relative to target object.
  35852. * This can help limiting how the Camera is able to move in the scene.
  35853. */
  35854. lowerRotationOffsetLimit: Nullable<number>;
  35855. /**
  35856. * Maximum allowed angle to camera position relative to target object.
  35857. * This can help limiting how the Camera is able to move in the scene.
  35858. */
  35859. upperRotationOffsetLimit: Nullable<number>;
  35860. /**
  35861. * Define a height offset between the camera and the object it follows.
  35862. * It can help following an object from the top (like a car chaing a plane)
  35863. */
  35864. heightOffset: number;
  35865. /**
  35866. * Minimum allowed height of camera position relative to target object.
  35867. * This can help limiting how the Camera is able to move in the scene.
  35868. */
  35869. lowerHeightOffsetLimit: Nullable<number>;
  35870. /**
  35871. * Maximum allowed height of camera position relative to target object.
  35872. * This can help limiting how the Camera is able to move in the scene.
  35873. */
  35874. upperHeightOffsetLimit: Nullable<number>;
  35875. /**
  35876. * Define how fast the camera can accelerate to follow it s target.
  35877. */
  35878. cameraAcceleration: number;
  35879. /**
  35880. * Define the speed limit of the camera following an object.
  35881. */
  35882. maxCameraSpeed: number;
  35883. /**
  35884. * Define the target of the camera.
  35885. */
  35886. lockedTarget: Nullable<AbstractMesh>;
  35887. /**
  35888. * Defines the input associated with the camera.
  35889. */
  35890. inputs: FollowCameraInputsManager;
  35891. /**
  35892. * Instantiates the follow camera.
  35893. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35894. * @param name Define the name of the camera in the scene
  35895. * @param position Define the position of the camera
  35896. * @param scene Define the scene the camera belong to
  35897. * @param lockedTarget Define the target of the camera
  35898. */
  35899. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  35900. private _follow;
  35901. /**
  35902. * Attached controls to the current camera.
  35903. * @param element Defines the element the controls should be listened from
  35904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35905. */
  35906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35907. /**
  35908. * Detach the current controls from the camera.
  35909. * The camera will stop reacting to inputs.
  35910. * @param element Defines the element to stop listening the inputs from
  35911. */
  35912. detachControl(element: HTMLElement): void;
  35913. /** @hidden */
  35914. _checkInputs(): void;
  35915. private _checkLimits;
  35916. /**
  35917. * Gets the camera class name.
  35918. * @returns the class name
  35919. */
  35920. getClassName(): string;
  35921. }
  35922. /**
  35923. * Arc Rotate version of the follow camera.
  35924. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  35925. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35926. */
  35927. export class ArcFollowCamera extends TargetCamera {
  35928. /** The longitudinal angle of the camera */
  35929. alpha: number;
  35930. /** The latitudinal angle of the camera */
  35931. beta: number;
  35932. /** The radius of the camera from its target */
  35933. radius: number;
  35934. /** Define the camera target (the messh it should follow) */
  35935. target: Nullable<AbstractMesh>;
  35936. private _cartesianCoordinates;
  35937. /**
  35938. * Instantiates a new ArcFollowCamera
  35939. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35940. * @param name Define the name of the camera
  35941. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  35942. * @param beta Define the rotation angle of the camera around the elevation axis
  35943. * @param radius Define the radius of the camera from its target point
  35944. * @param target Define the target of the camera
  35945. * @param scene Define the scene the camera belongs to
  35946. */
  35947. constructor(name: string,
  35948. /** The longitudinal angle of the camera */
  35949. alpha: number,
  35950. /** The latitudinal angle of the camera */
  35951. beta: number,
  35952. /** The radius of the camera from its target */
  35953. radius: number,
  35954. /** Define the camera target (the messh it should follow) */
  35955. target: Nullable<AbstractMesh>, scene: Scene);
  35956. private _follow;
  35957. /** @hidden */
  35958. _checkInputs(): void;
  35959. /**
  35960. * Returns the class name of the object.
  35961. * It is mostly used internally for serialization purposes.
  35962. */
  35963. getClassName(): string;
  35964. }
  35965. }
  35966. declare module BABYLON {
  35967. /**
  35968. * Manage the keyboard inputs to control the movement of a follow camera.
  35969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35970. */
  35971. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35972. /**
  35973. * Defines the camera the input is attached to.
  35974. */
  35975. camera: FollowCamera;
  35976. /**
  35977. * Defines the list of key codes associated with the up action (increase heightOffset)
  35978. */
  35979. keysHeightOffsetIncr: number[];
  35980. /**
  35981. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35982. */
  35983. keysHeightOffsetDecr: number[];
  35984. /**
  35985. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35986. */
  35987. keysHeightOffsetModifierAlt: boolean;
  35988. /**
  35989. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35990. */
  35991. keysHeightOffsetModifierCtrl: boolean;
  35992. /**
  35993. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35994. */
  35995. keysHeightOffsetModifierShift: boolean;
  35996. /**
  35997. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35998. */
  35999. keysRotationOffsetIncr: number[];
  36000. /**
  36001. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36002. */
  36003. keysRotationOffsetDecr: number[];
  36004. /**
  36005. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36006. */
  36007. keysRotationOffsetModifierAlt: boolean;
  36008. /**
  36009. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36010. */
  36011. keysRotationOffsetModifierCtrl: boolean;
  36012. /**
  36013. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36014. */
  36015. keysRotationOffsetModifierShift: boolean;
  36016. /**
  36017. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36018. */
  36019. keysRadiusIncr: number[];
  36020. /**
  36021. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36022. */
  36023. keysRadiusDecr: number[];
  36024. /**
  36025. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36026. */
  36027. keysRadiusModifierAlt: boolean;
  36028. /**
  36029. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36030. */
  36031. keysRadiusModifierCtrl: boolean;
  36032. /**
  36033. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36034. */
  36035. keysRadiusModifierShift: boolean;
  36036. /**
  36037. * Defines the rate of change of heightOffset.
  36038. */
  36039. heightSensibility: number;
  36040. /**
  36041. * Defines the rate of change of rotationOffset.
  36042. */
  36043. rotationSensibility: number;
  36044. /**
  36045. * Defines the rate of change of radius.
  36046. */
  36047. radiusSensibility: number;
  36048. private _keys;
  36049. private _ctrlPressed;
  36050. private _altPressed;
  36051. private _shiftPressed;
  36052. private _onCanvasBlurObserver;
  36053. private _onKeyboardObserver;
  36054. private _engine;
  36055. private _scene;
  36056. /**
  36057. * Attach the input controls to a specific dom element to get the input from.
  36058. * @param element Defines the element the controls should be listened from
  36059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36060. */
  36061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36062. /**
  36063. * Detach the current controls from the specified dom element.
  36064. * @param element Defines the element to stop listening the inputs from
  36065. */
  36066. detachControl(element: Nullable<HTMLElement>): void;
  36067. /**
  36068. * Update the current camera state depending on the inputs that have been used this frame.
  36069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36070. */
  36071. checkInputs(): void;
  36072. /**
  36073. * Gets the class name of the current input.
  36074. * @returns the class name
  36075. */
  36076. getClassName(): string;
  36077. /**
  36078. * Get the friendly name associated with the input class.
  36079. * @returns the input friendly name
  36080. */
  36081. getSimpleName(): string;
  36082. /**
  36083. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36084. * allow modification of the heightOffset value.
  36085. */
  36086. private _modifierHeightOffset;
  36087. /**
  36088. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36089. * allow modification of the rotationOffset value.
  36090. */
  36091. private _modifierRotationOffset;
  36092. /**
  36093. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36094. * allow modification of the radius value.
  36095. */
  36096. private _modifierRadius;
  36097. }
  36098. }
  36099. declare module BABYLON {
  36100. interface FreeCameraInputsManager {
  36101. /**
  36102. * Add orientation input support to the input manager.
  36103. * @returns the current input manager
  36104. */
  36105. addDeviceOrientation(): FreeCameraInputsManager;
  36106. }
  36107. /**
  36108. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36109. * Screen rotation is taken into account.
  36110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36111. */
  36112. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36113. private _camera;
  36114. private _screenOrientationAngle;
  36115. private _constantTranform;
  36116. private _screenQuaternion;
  36117. private _alpha;
  36118. private _beta;
  36119. private _gamma;
  36120. /**
  36121. * Instantiates a new input
  36122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36123. */
  36124. constructor();
  36125. /**
  36126. * Define the camera controlled by the input.
  36127. */
  36128. camera: FreeCamera;
  36129. /**
  36130. * Attach the input controls to a specific dom element to get the input from.
  36131. * @param element Defines the element the controls should be listened from
  36132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36133. */
  36134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36135. private _orientationChanged;
  36136. private _deviceOrientation;
  36137. /**
  36138. * Detach the current controls from the specified dom element.
  36139. * @param element Defines the element to stop listening the inputs from
  36140. */
  36141. detachControl(element: Nullable<HTMLElement>): void;
  36142. /**
  36143. * Update the current camera state depending on the inputs that have been used this frame.
  36144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36145. */
  36146. checkInputs(): void;
  36147. /**
  36148. * Gets the class name of the current intput.
  36149. * @returns the class name
  36150. */
  36151. getClassName(): string;
  36152. /**
  36153. * Get the friendly name associated with the input class.
  36154. * @returns the input friendly name
  36155. */
  36156. getSimpleName(): string;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. /**
  36161. * Manage the gamepad inputs to control a free camera.
  36162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36163. */
  36164. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36165. /**
  36166. * Define the camera the input is attached to.
  36167. */
  36168. camera: FreeCamera;
  36169. /**
  36170. * Define the Gamepad controlling the input
  36171. */
  36172. gamepad: Nullable<Gamepad>;
  36173. /**
  36174. * Defines the gamepad rotation sensiblity.
  36175. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36176. */
  36177. gamepadAngularSensibility: number;
  36178. /**
  36179. * Defines the gamepad move sensiblity.
  36180. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36181. */
  36182. gamepadMoveSensibility: number;
  36183. private _onGamepadConnectedObserver;
  36184. private _onGamepadDisconnectedObserver;
  36185. private _cameraTransform;
  36186. private _deltaTransform;
  36187. private _vector3;
  36188. private _vector2;
  36189. /**
  36190. * Attach the input controls to a specific dom element to get the input from.
  36191. * @param element Defines the element the controls should be listened from
  36192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36193. */
  36194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36195. /**
  36196. * Detach the current controls from the specified dom element.
  36197. * @param element Defines the element to stop listening the inputs from
  36198. */
  36199. detachControl(element: Nullable<HTMLElement>): void;
  36200. /**
  36201. * Update the current camera state depending on the inputs that have been used this frame.
  36202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36203. */
  36204. checkInputs(): void;
  36205. /**
  36206. * Gets the class name of the current intput.
  36207. * @returns the class name
  36208. */
  36209. getClassName(): string;
  36210. /**
  36211. * Get the friendly name associated with the input class.
  36212. * @returns the input friendly name
  36213. */
  36214. getSimpleName(): string;
  36215. }
  36216. }
  36217. declare module BABYLON {
  36218. /**
  36219. * Defines the potential axis of a Joystick
  36220. */
  36221. export enum JoystickAxis {
  36222. /** X axis */
  36223. X = 0,
  36224. /** Y axis */
  36225. Y = 1,
  36226. /** Z axis */
  36227. Z = 2
  36228. }
  36229. /**
  36230. * Class used to define virtual joystick (used in touch mode)
  36231. */
  36232. export class VirtualJoystick {
  36233. /**
  36234. * Gets or sets a boolean indicating that left and right values must be inverted
  36235. */
  36236. reverseLeftRight: boolean;
  36237. /**
  36238. * Gets or sets a boolean indicating that up and down values must be inverted
  36239. */
  36240. reverseUpDown: boolean;
  36241. /**
  36242. * Gets the offset value for the position (ie. the change of the position value)
  36243. */
  36244. deltaPosition: Vector3;
  36245. /**
  36246. * Gets a boolean indicating if the virtual joystick was pressed
  36247. */
  36248. pressed: boolean;
  36249. /**
  36250. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36251. */
  36252. static Canvas: Nullable<HTMLCanvasElement>;
  36253. private static _globalJoystickIndex;
  36254. private static vjCanvasContext;
  36255. private static vjCanvasWidth;
  36256. private static vjCanvasHeight;
  36257. private static halfWidth;
  36258. private _action;
  36259. private _axisTargetedByLeftAndRight;
  36260. private _axisTargetedByUpAndDown;
  36261. private _joystickSensibility;
  36262. private _inversedSensibility;
  36263. private _joystickPointerID;
  36264. private _joystickColor;
  36265. private _joystickPointerPos;
  36266. private _joystickPreviousPointerPos;
  36267. private _joystickPointerStartPos;
  36268. private _deltaJoystickVector;
  36269. private _leftJoystick;
  36270. private _touches;
  36271. private _onPointerDownHandlerRef;
  36272. private _onPointerMoveHandlerRef;
  36273. private _onPointerUpHandlerRef;
  36274. private _onResize;
  36275. /**
  36276. * Creates a new virtual joystick
  36277. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36278. */
  36279. constructor(leftJoystick?: boolean);
  36280. /**
  36281. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36282. * @param newJoystickSensibility defines the new sensibility
  36283. */
  36284. setJoystickSensibility(newJoystickSensibility: number): void;
  36285. private _onPointerDown;
  36286. private _onPointerMove;
  36287. private _onPointerUp;
  36288. /**
  36289. * Change the color of the virtual joystick
  36290. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36291. */
  36292. setJoystickColor(newColor: string): void;
  36293. /**
  36294. * Defines a callback to call when the joystick is touched
  36295. * @param action defines the callback
  36296. */
  36297. setActionOnTouch(action: () => any): void;
  36298. /**
  36299. * Defines which axis you'd like to control for left & right
  36300. * @param axis defines the axis to use
  36301. */
  36302. setAxisForLeftRight(axis: JoystickAxis): void;
  36303. /**
  36304. * Defines which axis you'd like to control for up & down
  36305. * @param axis defines the axis to use
  36306. */
  36307. setAxisForUpDown(axis: JoystickAxis): void;
  36308. private _drawVirtualJoystick;
  36309. /**
  36310. * Release internal HTML canvas
  36311. */
  36312. releaseCanvas(): void;
  36313. }
  36314. }
  36315. declare module BABYLON {
  36316. interface FreeCameraInputsManager {
  36317. /**
  36318. * Add virtual joystick input support to the input manager.
  36319. * @returns the current input manager
  36320. */
  36321. addVirtualJoystick(): FreeCameraInputsManager;
  36322. }
  36323. /**
  36324. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36326. */
  36327. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36328. /**
  36329. * Defines the camera the input is attached to.
  36330. */
  36331. camera: FreeCamera;
  36332. private _leftjoystick;
  36333. private _rightjoystick;
  36334. /**
  36335. * Gets the left stick of the virtual joystick.
  36336. * @returns The virtual Joystick
  36337. */
  36338. getLeftJoystick(): VirtualJoystick;
  36339. /**
  36340. * Gets the right stick of the virtual joystick.
  36341. * @returns The virtual Joystick
  36342. */
  36343. getRightJoystick(): VirtualJoystick;
  36344. /**
  36345. * Update the current camera state depending on the inputs that have been used this frame.
  36346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36347. */
  36348. checkInputs(): void;
  36349. /**
  36350. * Attach the input controls to a specific dom element to get the input from.
  36351. * @param element Defines the element the controls should be listened from
  36352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36353. */
  36354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36355. /**
  36356. * Detach the current controls from the specified dom element.
  36357. * @param element Defines the element to stop listening the inputs from
  36358. */
  36359. detachControl(element: Nullable<HTMLElement>): void;
  36360. /**
  36361. * Gets the class name of the current intput.
  36362. * @returns the class name
  36363. */
  36364. getClassName(): string;
  36365. /**
  36366. * Get the friendly name associated with the input class.
  36367. * @returns the input friendly name
  36368. */
  36369. getSimpleName(): string;
  36370. }
  36371. }
  36372. declare module BABYLON {
  36373. /**
  36374. * This represents a FPS type of camera controlled by touch.
  36375. * This is like a universal camera minus the Gamepad controls.
  36376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36377. */
  36378. export class TouchCamera extends FreeCamera {
  36379. /**
  36380. * Defines the touch sensibility for rotation.
  36381. * The higher the faster.
  36382. */
  36383. touchAngularSensibility: number;
  36384. /**
  36385. * Defines the touch sensibility for move.
  36386. * The higher the faster.
  36387. */
  36388. touchMoveSensibility: number;
  36389. /**
  36390. * Instantiates a new touch camera.
  36391. * This represents a FPS type of camera controlled by touch.
  36392. * This is like a universal camera minus the Gamepad controls.
  36393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36394. * @param name Define the name of the camera in the scene
  36395. * @param position Define the start position of the camera in the scene
  36396. * @param scene Define the scene the camera belongs to
  36397. */
  36398. constructor(name: string, position: Vector3, scene: Scene);
  36399. /**
  36400. * Gets the current object class name.
  36401. * @return the class name
  36402. */
  36403. getClassName(): string;
  36404. /** @hidden */
  36405. _setupInputs(): void;
  36406. }
  36407. }
  36408. declare module BABYLON {
  36409. /**
  36410. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36411. * being tilted forward or back and left or right.
  36412. */
  36413. export class DeviceOrientationCamera extends FreeCamera {
  36414. private _initialQuaternion;
  36415. private _quaternionCache;
  36416. /**
  36417. * Creates a new device orientation camera
  36418. * @param name The name of the camera
  36419. * @param position The start position camera
  36420. * @param scene The scene the camera belongs to
  36421. */
  36422. constructor(name: string, position: Vector3, scene: Scene);
  36423. /**
  36424. * Gets the current instance class name ("DeviceOrientationCamera").
  36425. * This helps avoiding instanceof at run time.
  36426. * @returns the class name
  36427. */
  36428. getClassName(): string;
  36429. /**
  36430. * @hidden
  36431. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36432. */
  36433. _checkInputs(): void;
  36434. /**
  36435. * Reset the camera to its default orientation on the specified axis only.
  36436. * @param axis The axis to reset
  36437. */
  36438. resetToCurrentRotation(axis?: Axis): void;
  36439. }
  36440. }
  36441. declare module BABYLON {
  36442. /**
  36443. * 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,
  36444. * which still works and will still be found in many Playgrounds.
  36445. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36446. */
  36447. export class UniversalCamera extends TouchCamera {
  36448. /**
  36449. * Defines the gamepad rotation sensiblity.
  36450. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36451. */
  36452. gamepadAngularSensibility: number;
  36453. /**
  36454. * Defines the gamepad move sensiblity.
  36455. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36456. */
  36457. gamepadMoveSensibility: number;
  36458. /**
  36459. * 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,
  36460. * which still works and will still be found in many Playgrounds.
  36461. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36462. * @param name Define the name of the camera in the scene
  36463. * @param position Define the start position of the camera in the scene
  36464. * @param scene Define the scene the camera belongs to
  36465. */
  36466. constructor(name: string, position: Vector3, scene: Scene);
  36467. /**
  36468. * Gets the current object class name.
  36469. * @return the class name
  36470. */
  36471. getClassName(): string;
  36472. }
  36473. }
  36474. declare module BABYLON {
  36475. /**
  36476. * This represents a FPS type of camera. This is only here for back compat purpose.
  36477. * Please use the UniversalCamera instead as both are identical.
  36478. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36479. */
  36480. export class GamepadCamera extends UniversalCamera {
  36481. /**
  36482. * Instantiates a new Gamepad Camera
  36483. * This represents a FPS type of camera. This is only here for back compat purpose.
  36484. * Please use the UniversalCamera instead as both are identical.
  36485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36486. * @param name Define the name of the camera in the scene
  36487. * @param position Define the start position of the camera in the scene
  36488. * @param scene Define the scene the camera belongs to
  36489. */
  36490. constructor(name: string, position: Vector3, scene: Scene);
  36491. /**
  36492. * Gets the current object class name.
  36493. * @return the class name
  36494. */
  36495. getClassName(): string;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /** @hidden */
  36500. export var passPixelShader: {
  36501. name: string;
  36502. shader: string;
  36503. };
  36504. }
  36505. declare module BABYLON {
  36506. /** @hidden */
  36507. export var passCubePixelShader: {
  36508. name: string;
  36509. shader: string;
  36510. };
  36511. }
  36512. declare module BABYLON {
  36513. /**
  36514. * PassPostProcess which produces an output the same as it's input
  36515. */
  36516. export class PassPostProcess extends PostProcess {
  36517. /**
  36518. * Creates the PassPostProcess
  36519. * @param name The name of the effect.
  36520. * @param options The required width/height ratio to downsize to before computing the render pass.
  36521. * @param camera The camera to apply the render pass to.
  36522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36523. * @param engine The engine which the post process will be applied. (default: current engine)
  36524. * @param reusable If the post process can be reused on the same frame. (default: false)
  36525. * @param textureType The type of texture to be used when performing the post processing.
  36526. * @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)
  36527. */
  36528. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36529. }
  36530. /**
  36531. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36532. */
  36533. export class PassCubePostProcess extends PostProcess {
  36534. private _face;
  36535. /**
  36536. * Gets or sets the cube face to display.
  36537. * * 0 is +X
  36538. * * 1 is -X
  36539. * * 2 is +Y
  36540. * * 3 is -Y
  36541. * * 4 is +Z
  36542. * * 5 is -Z
  36543. */
  36544. face: number;
  36545. /**
  36546. * Creates the PassCubePostProcess
  36547. * @param name The name of the effect.
  36548. * @param options The required width/height ratio to downsize to before computing the render pass.
  36549. * @param camera The camera to apply the render pass to.
  36550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36551. * @param engine The engine which the post process will be applied. (default: current engine)
  36552. * @param reusable If the post process can be reused on the same frame. (default: false)
  36553. * @param textureType The type of texture to be used when performing the post processing.
  36554. * @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)
  36555. */
  36556. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. /** @hidden */
  36561. export var anaglyphPixelShader: {
  36562. name: string;
  36563. shader: string;
  36564. };
  36565. }
  36566. declare module BABYLON {
  36567. /**
  36568. * Postprocess used to generate anaglyphic rendering
  36569. */
  36570. export class AnaglyphPostProcess extends PostProcess {
  36571. private _passedProcess;
  36572. /**
  36573. * Creates a new AnaglyphPostProcess
  36574. * @param name defines postprocess name
  36575. * @param options defines creation options or target ratio scale
  36576. * @param rigCameras defines cameras using this postprocess
  36577. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36578. * @param engine defines hosting engine
  36579. * @param reusable defines if the postprocess will be reused multiple times per frame
  36580. */
  36581. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36582. }
  36583. }
  36584. declare module BABYLON {
  36585. /**
  36586. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36587. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36588. */
  36589. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36590. /**
  36591. * Creates a new AnaglyphArcRotateCamera
  36592. * @param name defines camera name
  36593. * @param alpha defines alpha angle (in radians)
  36594. * @param beta defines beta angle (in radians)
  36595. * @param radius defines radius
  36596. * @param target defines camera target
  36597. * @param interaxialDistance defines distance between each color axis
  36598. * @param scene defines the hosting scene
  36599. */
  36600. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36601. /**
  36602. * Gets camera class name
  36603. * @returns AnaglyphArcRotateCamera
  36604. */
  36605. getClassName(): string;
  36606. }
  36607. }
  36608. declare module BABYLON {
  36609. /**
  36610. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36611. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36612. */
  36613. export class AnaglyphFreeCamera extends FreeCamera {
  36614. /**
  36615. * Creates a new AnaglyphFreeCamera
  36616. * @param name defines camera name
  36617. * @param position defines initial position
  36618. * @param interaxialDistance defines distance between each color axis
  36619. * @param scene defines the hosting scene
  36620. */
  36621. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36622. /**
  36623. * Gets camera class name
  36624. * @returns AnaglyphFreeCamera
  36625. */
  36626. getClassName(): string;
  36627. }
  36628. }
  36629. declare module BABYLON {
  36630. /**
  36631. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36632. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36633. */
  36634. export class AnaglyphGamepadCamera extends GamepadCamera {
  36635. /**
  36636. * Creates a new AnaglyphGamepadCamera
  36637. * @param name defines camera name
  36638. * @param position defines initial position
  36639. * @param interaxialDistance defines distance between each color axis
  36640. * @param scene defines the hosting scene
  36641. */
  36642. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36643. /**
  36644. * Gets camera class name
  36645. * @returns AnaglyphGamepadCamera
  36646. */
  36647. getClassName(): string;
  36648. }
  36649. }
  36650. declare module BABYLON {
  36651. /**
  36652. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36653. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36654. */
  36655. export class AnaglyphUniversalCamera extends UniversalCamera {
  36656. /**
  36657. * Creates a new AnaglyphUniversalCamera
  36658. * @param name defines camera name
  36659. * @param position defines initial position
  36660. * @param interaxialDistance defines distance between each color axis
  36661. * @param scene defines the hosting scene
  36662. */
  36663. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36664. /**
  36665. * Gets camera class name
  36666. * @returns AnaglyphUniversalCamera
  36667. */
  36668. getClassName(): string;
  36669. }
  36670. }
  36671. declare module BABYLON {
  36672. /** @hidden */
  36673. export var stereoscopicInterlacePixelShader: {
  36674. name: string;
  36675. shader: string;
  36676. };
  36677. }
  36678. declare module BABYLON {
  36679. /**
  36680. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36681. */
  36682. export class StereoscopicInterlacePostProcess extends PostProcess {
  36683. private _stepSize;
  36684. private _passedProcess;
  36685. /**
  36686. * Initializes a StereoscopicInterlacePostProcess
  36687. * @param name The name of the effect.
  36688. * @param rigCameras The rig cameras to be appled to the post process
  36689. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36691. * @param engine The engine which the post process will be applied. (default: current engine)
  36692. * @param reusable If the post process can be reused on the same frame. (default: false)
  36693. */
  36694. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36695. }
  36696. }
  36697. declare module BABYLON {
  36698. /**
  36699. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36700. * @see http://doc.babylonjs.com/features/cameras
  36701. */
  36702. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36703. /**
  36704. * Creates a new StereoscopicArcRotateCamera
  36705. * @param name defines camera name
  36706. * @param alpha defines alpha angle (in radians)
  36707. * @param beta defines beta angle (in radians)
  36708. * @param radius defines radius
  36709. * @param target defines camera target
  36710. * @param interaxialDistance defines distance between each color axis
  36711. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36712. * @param scene defines the hosting scene
  36713. */
  36714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36715. /**
  36716. * Gets camera class name
  36717. * @returns StereoscopicArcRotateCamera
  36718. */
  36719. getClassName(): string;
  36720. }
  36721. }
  36722. declare module BABYLON {
  36723. /**
  36724. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36725. * @see http://doc.babylonjs.com/features/cameras
  36726. */
  36727. export class StereoscopicFreeCamera extends FreeCamera {
  36728. /**
  36729. * Creates a new StereoscopicFreeCamera
  36730. * @param name defines camera name
  36731. * @param position defines initial position
  36732. * @param interaxialDistance defines distance between each color axis
  36733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36734. * @param scene defines the hosting scene
  36735. */
  36736. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36737. /**
  36738. * Gets camera class name
  36739. * @returns StereoscopicFreeCamera
  36740. */
  36741. getClassName(): string;
  36742. }
  36743. }
  36744. declare module BABYLON {
  36745. /**
  36746. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36747. * @see http://doc.babylonjs.com/features/cameras
  36748. */
  36749. export class StereoscopicGamepadCamera extends GamepadCamera {
  36750. /**
  36751. * Creates a new StereoscopicGamepadCamera
  36752. * @param name defines camera name
  36753. * @param position defines initial position
  36754. * @param interaxialDistance defines distance between each color axis
  36755. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36756. * @param scene defines the hosting scene
  36757. */
  36758. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36759. /**
  36760. * Gets camera class name
  36761. * @returns StereoscopicGamepadCamera
  36762. */
  36763. getClassName(): string;
  36764. }
  36765. }
  36766. declare module BABYLON {
  36767. /**
  36768. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36769. * @see http://doc.babylonjs.com/features/cameras
  36770. */
  36771. export class StereoscopicUniversalCamera extends UniversalCamera {
  36772. /**
  36773. * Creates a new StereoscopicUniversalCamera
  36774. * @param name defines camera name
  36775. * @param position defines initial position
  36776. * @param interaxialDistance defines distance between each color axis
  36777. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36778. * @param scene defines the hosting scene
  36779. */
  36780. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36781. /**
  36782. * Gets camera class name
  36783. * @returns StereoscopicUniversalCamera
  36784. */
  36785. getClassName(): string;
  36786. }
  36787. }
  36788. declare module BABYLON {
  36789. /**
  36790. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36791. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36792. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36793. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36794. */
  36795. export class VirtualJoysticksCamera extends FreeCamera {
  36796. /**
  36797. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36798. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36799. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36800. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36801. * @param name Define the name of the camera in the scene
  36802. * @param position Define the start position of the camera in the scene
  36803. * @param scene Define the scene the camera belongs to
  36804. */
  36805. constructor(name: string, position: Vector3, scene: Scene);
  36806. /**
  36807. * Gets the current object class name.
  36808. * @return the class name
  36809. */
  36810. getClassName(): string;
  36811. }
  36812. }
  36813. declare module BABYLON {
  36814. /**
  36815. * This represents all the required metrics to create a VR camera.
  36816. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36817. */
  36818. export class VRCameraMetrics {
  36819. /**
  36820. * Define the horizontal resolution off the screen.
  36821. */
  36822. hResolution: number;
  36823. /**
  36824. * Define the vertical resolution off the screen.
  36825. */
  36826. vResolution: number;
  36827. /**
  36828. * Define the horizontal screen size.
  36829. */
  36830. hScreenSize: number;
  36831. /**
  36832. * Define the vertical screen size.
  36833. */
  36834. vScreenSize: number;
  36835. /**
  36836. * Define the vertical screen center position.
  36837. */
  36838. vScreenCenter: number;
  36839. /**
  36840. * Define the distance of the eyes to the screen.
  36841. */
  36842. eyeToScreenDistance: number;
  36843. /**
  36844. * Define the distance between both lenses
  36845. */
  36846. lensSeparationDistance: number;
  36847. /**
  36848. * Define the distance between both viewer's eyes.
  36849. */
  36850. interpupillaryDistance: number;
  36851. /**
  36852. * Define the distortion factor of the VR postprocess.
  36853. * Please, touch with care.
  36854. */
  36855. distortionK: number[];
  36856. /**
  36857. * Define the chromatic aberration correction factors for the VR post process.
  36858. */
  36859. chromaAbCorrection: number[];
  36860. /**
  36861. * Define the scale factor of the post process.
  36862. * The smaller the better but the slower.
  36863. */
  36864. postProcessScaleFactor: number;
  36865. /**
  36866. * Define an offset for the lens center.
  36867. */
  36868. lensCenterOffset: number;
  36869. /**
  36870. * Define if the current vr camera should compensate the distortion of the lense or not.
  36871. */
  36872. compensateDistortion: boolean;
  36873. /**
  36874. * Gets the rendering aspect ratio based on the provided resolutions.
  36875. */
  36876. readonly aspectRatio: number;
  36877. /**
  36878. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36879. */
  36880. readonly aspectRatioFov: number;
  36881. /**
  36882. * @hidden
  36883. */
  36884. readonly leftHMatrix: Matrix;
  36885. /**
  36886. * @hidden
  36887. */
  36888. readonly rightHMatrix: Matrix;
  36889. /**
  36890. * @hidden
  36891. */
  36892. readonly leftPreViewMatrix: Matrix;
  36893. /**
  36894. * @hidden
  36895. */
  36896. readonly rightPreViewMatrix: Matrix;
  36897. /**
  36898. * Get the default VRMetrics based on the most generic setup.
  36899. * @returns the default vr metrics
  36900. */
  36901. static GetDefault(): VRCameraMetrics;
  36902. }
  36903. }
  36904. declare module BABYLON {
  36905. /** @hidden */
  36906. export var vrDistortionCorrectionPixelShader: {
  36907. name: string;
  36908. shader: string;
  36909. };
  36910. }
  36911. declare module BABYLON {
  36912. /**
  36913. * VRDistortionCorrectionPostProcess used for mobile VR
  36914. */
  36915. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36916. private _isRightEye;
  36917. private _distortionFactors;
  36918. private _postProcessScaleFactor;
  36919. private _lensCenterOffset;
  36920. private _scaleIn;
  36921. private _scaleFactor;
  36922. private _lensCenter;
  36923. /**
  36924. * Initializes the VRDistortionCorrectionPostProcess
  36925. * @param name The name of the effect.
  36926. * @param camera The camera to apply the render pass to.
  36927. * @param isRightEye If this is for the right eye distortion
  36928. * @param vrMetrics All the required metrics for the VR camera
  36929. */
  36930. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36931. }
  36932. }
  36933. declare module BABYLON {
  36934. /**
  36935. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36936. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36937. */
  36938. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36939. /**
  36940. * Creates a new VRDeviceOrientationArcRotateCamera
  36941. * @param name defines camera name
  36942. * @param alpha defines the camera rotation along the logitudinal axis
  36943. * @param beta defines the camera rotation along the latitudinal axis
  36944. * @param radius defines the camera distance from its target
  36945. * @param target defines the camera target
  36946. * @param scene defines the scene the camera belongs to
  36947. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36948. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36949. */
  36950. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36951. /**
  36952. * Gets camera class name
  36953. * @returns VRDeviceOrientationArcRotateCamera
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * Camera used to simulate VR rendering (based on FreeCamera)
  36961. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36962. */
  36963. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36964. /**
  36965. * Creates a new VRDeviceOrientationFreeCamera
  36966. * @param name defines camera name
  36967. * @param position defines the start position of the camera
  36968. * @param scene defines the scene the camera belongs to
  36969. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36970. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36971. */
  36972. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36973. /**
  36974. * Gets camera class name
  36975. * @returns VRDeviceOrientationFreeCamera
  36976. */
  36977. getClassName(): string;
  36978. }
  36979. }
  36980. declare module BABYLON {
  36981. /**
  36982. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36983. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36984. */
  36985. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36986. /**
  36987. * Creates a new VRDeviceOrientationGamepadCamera
  36988. * @param name defines camera name
  36989. * @param position defines the start position of the camera
  36990. * @param scene defines the scene the camera belongs to
  36991. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36992. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36993. */
  36994. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36995. /**
  36996. * Gets camera class name
  36997. * @returns VRDeviceOrientationGamepadCamera
  36998. */
  36999. getClassName(): string;
  37000. }
  37001. }
  37002. declare module BABYLON {
  37003. /**
  37004. * Defines supported buttons for XBox360 compatible gamepads
  37005. */
  37006. export enum Xbox360Button {
  37007. /** A */
  37008. A = 0,
  37009. /** B */
  37010. B = 1,
  37011. /** X */
  37012. X = 2,
  37013. /** Y */
  37014. Y = 3,
  37015. /** Start */
  37016. Start = 4,
  37017. /** Back */
  37018. Back = 5,
  37019. /** Left button */
  37020. LB = 6,
  37021. /** Right button */
  37022. RB = 7,
  37023. /** Left stick */
  37024. LeftStick = 8,
  37025. /** Right stick */
  37026. RightStick = 9
  37027. }
  37028. /** Defines values for XBox360 DPad */
  37029. export enum Xbox360Dpad {
  37030. /** Up */
  37031. Up = 0,
  37032. /** Down */
  37033. Down = 1,
  37034. /** Left */
  37035. Left = 2,
  37036. /** Right */
  37037. Right = 3
  37038. }
  37039. /**
  37040. * Defines a XBox360 gamepad
  37041. */
  37042. export class Xbox360Pad extends Gamepad {
  37043. private _leftTrigger;
  37044. private _rightTrigger;
  37045. private _onlefttriggerchanged;
  37046. private _onrighttriggerchanged;
  37047. private _onbuttondown;
  37048. private _onbuttonup;
  37049. private _ondpaddown;
  37050. private _ondpadup;
  37051. /** Observable raised when a button is pressed */
  37052. onButtonDownObservable: Observable<Xbox360Button>;
  37053. /** Observable raised when a button is released */
  37054. onButtonUpObservable: Observable<Xbox360Button>;
  37055. /** Observable raised when a pad is pressed */
  37056. onPadDownObservable: Observable<Xbox360Dpad>;
  37057. /** Observable raised when a pad is released */
  37058. onPadUpObservable: Observable<Xbox360Dpad>;
  37059. private _buttonA;
  37060. private _buttonB;
  37061. private _buttonX;
  37062. private _buttonY;
  37063. private _buttonBack;
  37064. private _buttonStart;
  37065. private _buttonLB;
  37066. private _buttonRB;
  37067. private _buttonLeftStick;
  37068. private _buttonRightStick;
  37069. private _dPadUp;
  37070. private _dPadDown;
  37071. private _dPadLeft;
  37072. private _dPadRight;
  37073. private _isXboxOnePad;
  37074. /**
  37075. * Creates a new XBox360 gamepad object
  37076. * @param id defines the id of this gamepad
  37077. * @param index defines its index
  37078. * @param gamepad defines the internal HTML gamepad object
  37079. * @param xboxOne defines if it is a XBox One gamepad
  37080. */
  37081. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37082. /**
  37083. * Defines the callback to call when left trigger is pressed
  37084. * @param callback defines the callback to use
  37085. */
  37086. onlefttriggerchanged(callback: (value: number) => void): void;
  37087. /**
  37088. * Defines the callback to call when right trigger is pressed
  37089. * @param callback defines the callback to use
  37090. */
  37091. onrighttriggerchanged(callback: (value: number) => void): void;
  37092. /**
  37093. * Gets the left trigger value
  37094. */
  37095. /**
  37096. * Sets the left trigger value
  37097. */
  37098. leftTrigger: number;
  37099. /**
  37100. * Gets the right trigger value
  37101. */
  37102. /**
  37103. * Sets the right trigger value
  37104. */
  37105. rightTrigger: number;
  37106. /**
  37107. * Defines the callback to call when a button is pressed
  37108. * @param callback defines the callback to use
  37109. */
  37110. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37111. /**
  37112. * Defines the callback to call when a button is released
  37113. * @param callback defines the callback to use
  37114. */
  37115. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37116. /**
  37117. * Defines the callback to call when a pad is pressed
  37118. * @param callback defines the callback to use
  37119. */
  37120. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37121. /**
  37122. * Defines the callback to call when a pad is released
  37123. * @param callback defines the callback to use
  37124. */
  37125. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37126. private _setButtonValue;
  37127. private _setDPadValue;
  37128. /**
  37129. * Gets the value of the `A` button
  37130. */
  37131. /**
  37132. * Sets the value of the `A` button
  37133. */
  37134. buttonA: number;
  37135. /**
  37136. * Gets the value of the `B` button
  37137. */
  37138. /**
  37139. * Sets the value of the `B` button
  37140. */
  37141. buttonB: number;
  37142. /**
  37143. * Gets the value of the `X` button
  37144. */
  37145. /**
  37146. * Sets the value of the `X` button
  37147. */
  37148. buttonX: number;
  37149. /**
  37150. * Gets the value of the `Y` button
  37151. */
  37152. /**
  37153. * Sets the value of the `Y` button
  37154. */
  37155. buttonY: number;
  37156. /**
  37157. * Gets the value of the `Start` button
  37158. */
  37159. /**
  37160. * Sets the value of the `Start` button
  37161. */
  37162. buttonStart: number;
  37163. /**
  37164. * Gets the value of the `Back` button
  37165. */
  37166. /**
  37167. * Sets the value of the `Back` button
  37168. */
  37169. buttonBack: number;
  37170. /**
  37171. * Gets the value of the `Left` button
  37172. */
  37173. /**
  37174. * Sets the value of the `Left` button
  37175. */
  37176. buttonLB: number;
  37177. /**
  37178. * Gets the value of the `Right` button
  37179. */
  37180. /**
  37181. * Sets the value of the `Right` button
  37182. */
  37183. buttonRB: number;
  37184. /**
  37185. * Gets the value of the Left joystick
  37186. */
  37187. /**
  37188. * Sets the value of the Left joystick
  37189. */
  37190. buttonLeftStick: number;
  37191. /**
  37192. * Gets the value of the Right joystick
  37193. */
  37194. /**
  37195. * Sets the value of the Right joystick
  37196. */
  37197. buttonRightStick: number;
  37198. /**
  37199. * Gets the value of D-pad up
  37200. */
  37201. /**
  37202. * Sets the value of D-pad up
  37203. */
  37204. dPadUp: number;
  37205. /**
  37206. * Gets the value of D-pad down
  37207. */
  37208. /**
  37209. * Sets the value of D-pad down
  37210. */
  37211. dPadDown: number;
  37212. /**
  37213. * Gets the value of D-pad left
  37214. */
  37215. /**
  37216. * Sets the value of D-pad left
  37217. */
  37218. dPadLeft: number;
  37219. /**
  37220. * Gets the value of D-pad right
  37221. */
  37222. /**
  37223. * Sets the value of D-pad right
  37224. */
  37225. dPadRight: number;
  37226. /**
  37227. * Force the gamepad to synchronize with device values
  37228. */
  37229. update(): void;
  37230. /**
  37231. * Disposes the gamepad
  37232. */
  37233. dispose(): void;
  37234. }
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * Base class of materials working in push mode in babylon JS
  37239. * @hidden
  37240. */
  37241. export class PushMaterial extends Material {
  37242. protected _activeEffect: Effect;
  37243. protected _normalMatrix: Matrix;
  37244. /**
  37245. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37246. * This means that the material can keep using a previous shader while a new one is being compiled.
  37247. * This is mostly used when shader parallel compilation is supported (true by default)
  37248. */
  37249. allowShaderHotSwapping: boolean;
  37250. constructor(name: string, scene: Scene);
  37251. getEffect(): Effect;
  37252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37253. /**
  37254. * Binds the given world matrix to the active effect
  37255. *
  37256. * @param world the matrix to bind
  37257. */
  37258. bindOnlyWorldMatrix(world: Matrix): void;
  37259. /**
  37260. * Binds the given normal matrix to the active effect
  37261. *
  37262. * @param normalMatrix the matrix to bind
  37263. */
  37264. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37265. bind(world: Matrix, mesh?: Mesh): void;
  37266. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37267. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37268. }
  37269. }
  37270. declare module BABYLON {
  37271. /**
  37272. * This groups all the flags used to control the materials channel.
  37273. */
  37274. export class MaterialFlags {
  37275. private static _DiffuseTextureEnabled;
  37276. /**
  37277. * Are diffuse textures enabled in the application.
  37278. */
  37279. static DiffuseTextureEnabled: boolean;
  37280. private static _AmbientTextureEnabled;
  37281. /**
  37282. * Are ambient textures enabled in the application.
  37283. */
  37284. static AmbientTextureEnabled: boolean;
  37285. private static _OpacityTextureEnabled;
  37286. /**
  37287. * Are opacity textures enabled in the application.
  37288. */
  37289. static OpacityTextureEnabled: boolean;
  37290. private static _ReflectionTextureEnabled;
  37291. /**
  37292. * Are reflection textures enabled in the application.
  37293. */
  37294. static ReflectionTextureEnabled: boolean;
  37295. private static _EmissiveTextureEnabled;
  37296. /**
  37297. * Are emissive textures enabled in the application.
  37298. */
  37299. static EmissiveTextureEnabled: boolean;
  37300. private static _SpecularTextureEnabled;
  37301. /**
  37302. * Are specular textures enabled in the application.
  37303. */
  37304. static SpecularTextureEnabled: boolean;
  37305. private static _BumpTextureEnabled;
  37306. /**
  37307. * Are bump textures enabled in the application.
  37308. */
  37309. static BumpTextureEnabled: boolean;
  37310. private static _LightmapTextureEnabled;
  37311. /**
  37312. * Are lightmap textures enabled in the application.
  37313. */
  37314. static LightmapTextureEnabled: boolean;
  37315. private static _RefractionTextureEnabled;
  37316. /**
  37317. * Are refraction textures enabled in the application.
  37318. */
  37319. static RefractionTextureEnabled: boolean;
  37320. private static _ColorGradingTextureEnabled;
  37321. /**
  37322. * Are color grading textures enabled in the application.
  37323. */
  37324. static ColorGradingTextureEnabled: boolean;
  37325. private static _FresnelEnabled;
  37326. /**
  37327. * Are fresnels enabled in the application.
  37328. */
  37329. static FresnelEnabled: boolean;
  37330. private static _ClearCoatTextureEnabled;
  37331. /**
  37332. * Are clear coat textures enabled in the application.
  37333. */
  37334. static ClearCoatTextureEnabled: boolean;
  37335. private static _ClearCoatBumpTextureEnabled;
  37336. /**
  37337. * Are clear coat bump textures enabled in the application.
  37338. */
  37339. static ClearCoatBumpTextureEnabled: boolean;
  37340. private static _ClearCoatTintTextureEnabled;
  37341. /**
  37342. * Are clear coat tint textures enabled in the application.
  37343. */
  37344. static ClearCoatTintTextureEnabled: boolean;
  37345. }
  37346. }
  37347. declare module BABYLON {
  37348. /** @hidden */
  37349. export var defaultFragmentDeclaration: {
  37350. name: string;
  37351. shader: string;
  37352. };
  37353. }
  37354. declare module BABYLON {
  37355. /** @hidden */
  37356. export var defaultUboDeclaration: {
  37357. name: string;
  37358. shader: string;
  37359. };
  37360. }
  37361. declare module BABYLON {
  37362. /** @hidden */
  37363. export var lightFragmentDeclaration: {
  37364. name: string;
  37365. shader: string;
  37366. };
  37367. }
  37368. declare module BABYLON {
  37369. /** @hidden */
  37370. export var lightUboDeclaration: {
  37371. name: string;
  37372. shader: string;
  37373. };
  37374. }
  37375. declare module BABYLON {
  37376. /** @hidden */
  37377. export var lightsFragmentFunctions: {
  37378. name: string;
  37379. shader: string;
  37380. };
  37381. }
  37382. declare module BABYLON {
  37383. /** @hidden */
  37384. export var shadowsFragmentFunctions: {
  37385. name: string;
  37386. shader: string;
  37387. };
  37388. }
  37389. declare module BABYLON {
  37390. /** @hidden */
  37391. export var fresnelFunction: {
  37392. name: string;
  37393. shader: string;
  37394. };
  37395. }
  37396. declare module BABYLON {
  37397. /** @hidden */
  37398. export var reflectionFunction: {
  37399. name: string;
  37400. shader: string;
  37401. };
  37402. }
  37403. declare module BABYLON {
  37404. /** @hidden */
  37405. export var bumpFragmentFunctions: {
  37406. name: string;
  37407. shader: string;
  37408. };
  37409. }
  37410. declare module BABYLON {
  37411. /** @hidden */
  37412. export var logDepthDeclaration: {
  37413. name: string;
  37414. shader: string;
  37415. };
  37416. }
  37417. declare module BABYLON {
  37418. /** @hidden */
  37419. export var bumpFragment: {
  37420. name: string;
  37421. shader: string;
  37422. };
  37423. }
  37424. declare module BABYLON {
  37425. /** @hidden */
  37426. export var depthPrePass: {
  37427. name: string;
  37428. shader: string;
  37429. };
  37430. }
  37431. declare module BABYLON {
  37432. /** @hidden */
  37433. export var lightFragment: {
  37434. name: string;
  37435. shader: string;
  37436. };
  37437. }
  37438. declare module BABYLON {
  37439. /** @hidden */
  37440. export var logDepthFragment: {
  37441. name: string;
  37442. shader: string;
  37443. };
  37444. }
  37445. declare module BABYLON {
  37446. /** @hidden */
  37447. export var defaultPixelShader: {
  37448. name: string;
  37449. shader: string;
  37450. };
  37451. }
  37452. declare module BABYLON {
  37453. /** @hidden */
  37454. export var defaultVertexDeclaration: {
  37455. name: string;
  37456. shader: string;
  37457. };
  37458. }
  37459. declare module BABYLON {
  37460. /** @hidden */
  37461. export var bumpVertexDeclaration: {
  37462. name: string;
  37463. shader: string;
  37464. };
  37465. }
  37466. declare module BABYLON {
  37467. /** @hidden */
  37468. export var bumpVertex: {
  37469. name: string;
  37470. shader: string;
  37471. };
  37472. }
  37473. declare module BABYLON {
  37474. /** @hidden */
  37475. export var fogVertex: {
  37476. name: string;
  37477. shader: string;
  37478. };
  37479. }
  37480. declare module BABYLON {
  37481. /** @hidden */
  37482. export var shadowsVertex: {
  37483. name: string;
  37484. shader: string;
  37485. };
  37486. }
  37487. declare module BABYLON {
  37488. /** @hidden */
  37489. export var pointCloudVertex: {
  37490. name: string;
  37491. shader: string;
  37492. };
  37493. }
  37494. declare module BABYLON {
  37495. /** @hidden */
  37496. export var logDepthVertex: {
  37497. name: string;
  37498. shader: string;
  37499. };
  37500. }
  37501. declare module BABYLON {
  37502. /** @hidden */
  37503. export var defaultVertexShader: {
  37504. name: string;
  37505. shader: string;
  37506. };
  37507. }
  37508. declare module BABYLON {
  37509. /** @hidden */
  37510. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37511. MAINUV1: boolean;
  37512. MAINUV2: boolean;
  37513. DIFFUSE: boolean;
  37514. DIFFUSEDIRECTUV: number;
  37515. AMBIENT: boolean;
  37516. AMBIENTDIRECTUV: number;
  37517. OPACITY: boolean;
  37518. OPACITYDIRECTUV: number;
  37519. OPACITYRGB: boolean;
  37520. REFLECTION: boolean;
  37521. EMISSIVE: boolean;
  37522. EMISSIVEDIRECTUV: number;
  37523. SPECULAR: boolean;
  37524. SPECULARDIRECTUV: number;
  37525. BUMP: boolean;
  37526. BUMPDIRECTUV: number;
  37527. PARALLAX: boolean;
  37528. PARALLAXOCCLUSION: boolean;
  37529. SPECULAROVERALPHA: boolean;
  37530. CLIPPLANE: boolean;
  37531. CLIPPLANE2: boolean;
  37532. CLIPPLANE3: boolean;
  37533. CLIPPLANE4: boolean;
  37534. ALPHATEST: boolean;
  37535. DEPTHPREPASS: boolean;
  37536. ALPHAFROMDIFFUSE: boolean;
  37537. POINTSIZE: boolean;
  37538. FOG: boolean;
  37539. SPECULARTERM: boolean;
  37540. DIFFUSEFRESNEL: boolean;
  37541. OPACITYFRESNEL: boolean;
  37542. REFLECTIONFRESNEL: boolean;
  37543. REFRACTIONFRESNEL: boolean;
  37544. EMISSIVEFRESNEL: boolean;
  37545. FRESNEL: boolean;
  37546. NORMAL: boolean;
  37547. UV1: boolean;
  37548. UV2: boolean;
  37549. VERTEXCOLOR: boolean;
  37550. VERTEXALPHA: boolean;
  37551. NUM_BONE_INFLUENCERS: number;
  37552. BonesPerMesh: number;
  37553. BONETEXTURE: boolean;
  37554. INSTANCES: boolean;
  37555. GLOSSINESS: boolean;
  37556. ROUGHNESS: boolean;
  37557. EMISSIVEASILLUMINATION: boolean;
  37558. LINKEMISSIVEWITHDIFFUSE: boolean;
  37559. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37560. LIGHTMAP: boolean;
  37561. LIGHTMAPDIRECTUV: number;
  37562. OBJECTSPACE_NORMALMAP: boolean;
  37563. USELIGHTMAPASSHADOWMAP: boolean;
  37564. REFLECTIONMAP_3D: boolean;
  37565. REFLECTIONMAP_SPHERICAL: boolean;
  37566. REFLECTIONMAP_PLANAR: boolean;
  37567. REFLECTIONMAP_CUBIC: boolean;
  37568. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37569. REFLECTIONMAP_PROJECTION: boolean;
  37570. REFLECTIONMAP_SKYBOX: boolean;
  37571. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37572. REFLECTIONMAP_EXPLICIT: boolean;
  37573. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37574. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37575. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37576. INVERTCUBICMAP: boolean;
  37577. LOGARITHMICDEPTH: boolean;
  37578. REFRACTION: boolean;
  37579. REFRACTIONMAP_3D: boolean;
  37580. REFLECTIONOVERALPHA: boolean;
  37581. TWOSIDEDLIGHTING: boolean;
  37582. SHADOWFLOAT: boolean;
  37583. MORPHTARGETS: boolean;
  37584. MORPHTARGETS_NORMAL: boolean;
  37585. MORPHTARGETS_TANGENT: boolean;
  37586. NUM_MORPH_INFLUENCERS: number;
  37587. NONUNIFORMSCALING: boolean;
  37588. PREMULTIPLYALPHA: boolean;
  37589. IMAGEPROCESSING: boolean;
  37590. VIGNETTE: boolean;
  37591. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37592. VIGNETTEBLENDMODEOPAQUE: boolean;
  37593. TONEMAPPING: boolean;
  37594. TONEMAPPING_ACES: boolean;
  37595. CONTRAST: boolean;
  37596. COLORCURVES: boolean;
  37597. COLORGRADING: boolean;
  37598. COLORGRADING3D: boolean;
  37599. SAMPLER3DGREENDEPTH: boolean;
  37600. SAMPLER3DBGRMAP: boolean;
  37601. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37602. /**
  37603. * If the reflection texture on this material is in linear color space
  37604. * @hidden
  37605. */
  37606. IS_REFLECTION_LINEAR: boolean;
  37607. /**
  37608. * If the refraction texture on this material is in linear color space
  37609. * @hidden
  37610. */
  37611. IS_REFRACTION_LINEAR: boolean;
  37612. EXPOSURE: boolean;
  37613. constructor();
  37614. setReflectionMode(modeToEnable: string): void;
  37615. }
  37616. /**
  37617. * This is the default material used in Babylon. It is the best trade off between quality
  37618. * and performances.
  37619. * @see http://doc.babylonjs.com/babylon101/materials
  37620. */
  37621. export class StandardMaterial extends PushMaterial {
  37622. private _diffuseTexture;
  37623. /**
  37624. * The basic texture of the material as viewed under a light.
  37625. */
  37626. diffuseTexture: Nullable<BaseTexture>;
  37627. private _ambientTexture;
  37628. /**
  37629. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37630. */
  37631. ambientTexture: Nullable<BaseTexture>;
  37632. private _opacityTexture;
  37633. /**
  37634. * Define the transparency of the material from a texture.
  37635. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37636. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37637. */
  37638. opacityTexture: Nullable<BaseTexture>;
  37639. private _reflectionTexture;
  37640. /**
  37641. * Define the texture used to display the reflection.
  37642. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37643. */
  37644. reflectionTexture: Nullable<BaseTexture>;
  37645. private _emissiveTexture;
  37646. /**
  37647. * Define texture of the material as if self lit.
  37648. * This will be mixed in the final result even in the absence of light.
  37649. */
  37650. emissiveTexture: Nullable<BaseTexture>;
  37651. private _specularTexture;
  37652. /**
  37653. * Define how the color and intensity of the highlight given by the light in the material.
  37654. */
  37655. specularTexture: Nullable<BaseTexture>;
  37656. private _bumpTexture;
  37657. /**
  37658. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37659. * 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.
  37660. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37661. */
  37662. bumpTexture: Nullable<BaseTexture>;
  37663. private _lightmapTexture;
  37664. /**
  37665. * Complex lighting can be computationally expensive to compute at runtime.
  37666. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37667. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37668. */
  37669. lightmapTexture: Nullable<BaseTexture>;
  37670. private _refractionTexture;
  37671. /**
  37672. * Define the texture used to display the refraction.
  37673. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37674. */
  37675. refractionTexture: Nullable<BaseTexture>;
  37676. /**
  37677. * The color of the material lit by the environmental background lighting.
  37678. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37679. */
  37680. ambientColor: Color3;
  37681. /**
  37682. * The basic color of the material as viewed under a light.
  37683. */
  37684. diffuseColor: Color3;
  37685. /**
  37686. * Define how the color and intensity of the highlight given by the light in the material.
  37687. */
  37688. specularColor: Color3;
  37689. /**
  37690. * Define the color of the material as if self lit.
  37691. * This will be mixed in the final result even in the absence of light.
  37692. */
  37693. emissiveColor: Color3;
  37694. /**
  37695. * Defines how sharp are the highlights in the material.
  37696. * The bigger the value the sharper giving a more glossy feeling to the result.
  37697. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37698. */
  37699. specularPower: number;
  37700. private _useAlphaFromDiffuseTexture;
  37701. /**
  37702. * Does the transparency come from the diffuse texture alpha channel.
  37703. */
  37704. useAlphaFromDiffuseTexture: boolean;
  37705. private _useEmissiveAsIllumination;
  37706. /**
  37707. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37708. */
  37709. useEmissiveAsIllumination: boolean;
  37710. private _linkEmissiveWithDiffuse;
  37711. /**
  37712. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37713. * the emissive level when the final color is close to one.
  37714. */
  37715. linkEmissiveWithDiffuse: boolean;
  37716. private _useSpecularOverAlpha;
  37717. /**
  37718. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37719. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37720. */
  37721. useSpecularOverAlpha: boolean;
  37722. private _useReflectionOverAlpha;
  37723. /**
  37724. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37725. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37726. */
  37727. useReflectionOverAlpha: boolean;
  37728. private _disableLighting;
  37729. /**
  37730. * Does lights from the scene impacts this material.
  37731. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37732. */
  37733. disableLighting: boolean;
  37734. private _useObjectSpaceNormalMap;
  37735. /**
  37736. * Allows using an object space normal map (instead of tangent space).
  37737. */
  37738. useObjectSpaceNormalMap: boolean;
  37739. private _useParallax;
  37740. /**
  37741. * Is parallax enabled or not.
  37742. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37743. */
  37744. useParallax: boolean;
  37745. private _useParallaxOcclusion;
  37746. /**
  37747. * Is parallax occlusion enabled or not.
  37748. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37749. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37750. */
  37751. useParallaxOcclusion: boolean;
  37752. /**
  37753. * 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.
  37754. */
  37755. parallaxScaleBias: number;
  37756. private _roughness;
  37757. /**
  37758. * Helps to define how blurry the reflections should appears in the material.
  37759. */
  37760. roughness: number;
  37761. /**
  37762. * In case of refraction, define the value of the indice of refraction.
  37763. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37764. */
  37765. indexOfRefraction: number;
  37766. /**
  37767. * Invert the refraction texture alongside the y axis.
  37768. * It can be useful with procedural textures or probe for instance.
  37769. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37770. */
  37771. invertRefractionY: boolean;
  37772. /**
  37773. * Defines the alpha limits in alpha test mode.
  37774. */
  37775. alphaCutOff: number;
  37776. private _useLightmapAsShadowmap;
  37777. /**
  37778. * In case of light mapping, define whether the map contains light or shadow informations.
  37779. */
  37780. useLightmapAsShadowmap: boolean;
  37781. private _diffuseFresnelParameters;
  37782. /**
  37783. * Define the diffuse fresnel parameters of the material.
  37784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37785. */
  37786. diffuseFresnelParameters: FresnelParameters;
  37787. private _opacityFresnelParameters;
  37788. /**
  37789. * Define the opacity fresnel parameters of the material.
  37790. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37791. */
  37792. opacityFresnelParameters: FresnelParameters;
  37793. private _reflectionFresnelParameters;
  37794. /**
  37795. * Define the reflection fresnel parameters of the material.
  37796. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37797. */
  37798. reflectionFresnelParameters: FresnelParameters;
  37799. private _refractionFresnelParameters;
  37800. /**
  37801. * Define the refraction fresnel parameters of the material.
  37802. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37803. */
  37804. refractionFresnelParameters: FresnelParameters;
  37805. private _emissiveFresnelParameters;
  37806. /**
  37807. * Define the emissive fresnel parameters of the material.
  37808. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37809. */
  37810. emissiveFresnelParameters: FresnelParameters;
  37811. private _useReflectionFresnelFromSpecular;
  37812. /**
  37813. * If true automatically deducts the fresnels values from the material specularity.
  37814. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37815. */
  37816. useReflectionFresnelFromSpecular: boolean;
  37817. private _useGlossinessFromSpecularMapAlpha;
  37818. /**
  37819. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37820. */
  37821. useGlossinessFromSpecularMapAlpha: boolean;
  37822. private _maxSimultaneousLights;
  37823. /**
  37824. * Defines the maximum number of lights that can be used in the material
  37825. */
  37826. maxSimultaneousLights: number;
  37827. private _invertNormalMapX;
  37828. /**
  37829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37830. */
  37831. invertNormalMapX: boolean;
  37832. private _invertNormalMapY;
  37833. /**
  37834. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37835. */
  37836. invertNormalMapY: boolean;
  37837. private _twoSidedLighting;
  37838. /**
  37839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37840. */
  37841. twoSidedLighting: boolean;
  37842. /**
  37843. * Default configuration related to image processing available in the standard Material.
  37844. */
  37845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37846. /**
  37847. * Gets the image processing configuration used either in this material.
  37848. */
  37849. /**
  37850. * Sets the Default image processing configuration used either in the this material.
  37851. *
  37852. * If sets to null, the scene one is in use.
  37853. */
  37854. imageProcessingConfiguration: ImageProcessingConfiguration;
  37855. /**
  37856. * Keep track of the image processing observer to allow dispose and replace.
  37857. */
  37858. private _imageProcessingObserver;
  37859. /**
  37860. * Attaches a new image processing configuration to the Standard Material.
  37861. * @param configuration
  37862. */
  37863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37864. /**
  37865. * Gets wether the color curves effect is enabled.
  37866. */
  37867. /**
  37868. * Sets wether the color curves effect is enabled.
  37869. */
  37870. cameraColorCurvesEnabled: boolean;
  37871. /**
  37872. * Gets wether the color grading effect is enabled.
  37873. */
  37874. /**
  37875. * Gets wether the color grading effect is enabled.
  37876. */
  37877. cameraColorGradingEnabled: boolean;
  37878. /**
  37879. * Gets wether tonemapping is enabled or not.
  37880. */
  37881. /**
  37882. * Sets wether tonemapping is enabled or not
  37883. */
  37884. cameraToneMappingEnabled: boolean;
  37885. /**
  37886. * The camera exposure used on this material.
  37887. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37888. * This corresponds to a photographic exposure.
  37889. */
  37890. /**
  37891. * The camera exposure used on this material.
  37892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37893. * This corresponds to a photographic exposure.
  37894. */
  37895. cameraExposure: number;
  37896. /**
  37897. * Gets The camera contrast used on this material.
  37898. */
  37899. /**
  37900. * Sets The camera contrast used on this material.
  37901. */
  37902. cameraContrast: number;
  37903. /**
  37904. * Gets the Color Grading 2D Lookup Texture.
  37905. */
  37906. /**
  37907. * Sets the Color Grading 2D Lookup Texture.
  37908. */
  37909. cameraColorGradingTexture: Nullable<BaseTexture>;
  37910. /**
  37911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37913. * 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;
  37914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37915. */
  37916. /**
  37917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37919. * 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;
  37920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37921. */
  37922. cameraColorCurves: Nullable<ColorCurves>;
  37923. /**
  37924. * Custom callback helping to override the default shader used in the material.
  37925. */
  37926. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37927. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37928. protected _worldViewProjectionMatrix: Matrix;
  37929. protected _globalAmbientColor: Color3;
  37930. protected _useLogarithmicDepth: boolean;
  37931. /**
  37932. * Instantiates a new standard material.
  37933. * This is the default material used in Babylon. It is the best trade off between quality
  37934. * and performances.
  37935. * @see http://doc.babylonjs.com/babylon101/materials
  37936. * @param name Define the name of the material in the scene
  37937. * @param scene Define the scene the material belong to
  37938. */
  37939. constructor(name: string, scene: Scene);
  37940. /**
  37941. * Gets a boolean indicating that current material needs to register RTT
  37942. */
  37943. readonly hasRenderTargetTextures: boolean;
  37944. /**
  37945. * Gets the current class name of the material e.g. "StandardMaterial"
  37946. * Mainly use in serialization.
  37947. * @returns the class name
  37948. */
  37949. getClassName(): string;
  37950. /**
  37951. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37952. * You can try switching to logarithmic depth.
  37953. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37954. */
  37955. useLogarithmicDepth: boolean;
  37956. /**
  37957. * Specifies if the material will require alpha blending
  37958. * @returns a boolean specifying if alpha blending is needed
  37959. */
  37960. needAlphaBlending(): boolean;
  37961. /**
  37962. * Specifies if this material should be rendered in alpha test mode
  37963. * @returns a boolean specifying if an alpha test is needed.
  37964. */
  37965. needAlphaTesting(): boolean;
  37966. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37967. /**
  37968. * Get the texture used for alpha test purpose.
  37969. * @returns the diffuse texture in case of the standard material.
  37970. */
  37971. getAlphaTestTexture(): Nullable<BaseTexture>;
  37972. /**
  37973. * Get if the submesh is ready to be used and all its information available.
  37974. * Child classes can use it to update shaders
  37975. * @param mesh defines the mesh to check
  37976. * @param subMesh defines which submesh to check
  37977. * @param useInstances specifies that instances should be used
  37978. * @returns a boolean indicating that the submesh is ready or not
  37979. */
  37980. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37981. /**
  37982. * Builds the material UBO layouts.
  37983. * Used internally during the effect preparation.
  37984. */
  37985. buildUniformLayout(): void;
  37986. /**
  37987. * Unbinds the material from the mesh
  37988. */
  37989. unbind(): void;
  37990. /**
  37991. * Binds the submesh to this material by preparing the effect and shader to draw
  37992. * @param world defines the world transformation matrix
  37993. * @param mesh defines the mesh containing the submesh
  37994. * @param subMesh defines the submesh to bind the material to
  37995. */
  37996. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37997. /**
  37998. * Get the list of animatables in the material.
  37999. * @returns the list of animatables object used in the material
  38000. */
  38001. getAnimatables(): IAnimatable[];
  38002. /**
  38003. * Gets the active textures from the material
  38004. * @returns an array of textures
  38005. */
  38006. getActiveTextures(): BaseTexture[];
  38007. /**
  38008. * Specifies if the material uses a texture
  38009. * @param texture defines the texture to check against the material
  38010. * @returns a boolean specifying if the material uses the texture
  38011. */
  38012. hasTexture(texture: BaseTexture): boolean;
  38013. /**
  38014. * Disposes the material
  38015. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38016. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38017. */
  38018. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38019. /**
  38020. * Makes a duplicate of the material, and gives it a new name
  38021. * @param name defines the new name for the duplicated material
  38022. * @returns the cloned material
  38023. */
  38024. clone(name: string): StandardMaterial;
  38025. /**
  38026. * Serializes this material in a JSON representation
  38027. * @returns the serialized material object
  38028. */
  38029. serialize(): any;
  38030. /**
  38031. * Creates a standard material from parsed material data
  38032. * @param source defines the JSON representation of the material
  38033. * @param scene defines the hosting scene
  38034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38035. * @returns a new standard material
  38036. */
  38037. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38038. /**
  38039. * Are diffuse textures enabled in the application.
  38040. */
  38041. static DiffuseTextureEnabled: boolean;
  38042. /**
  38043. * Are ambient textures enabled in the application.
  38044. */
  38045. static AmbientTextureEnabled: boolean;
  38046. /**
  38047. * Are opacity textures enabled in the application.
  38048. */
  38049. static OpacityTextureEnabled: boolean;
  38050. /**
  38051. * Are reflection textures enabled in the application.
  38052. */
  38053. static ReflectionTextureEnabled: boolean;
  38054. /**
  38055. * Are emissive textures enabled in the application.
  38056. */
  38057. static EmissiveTextureEnabled: boolean;
  38058. /**
  38059. * Are specular textures enabled in the application.
  38060. */
  38061. static SpecularTextureEnabled: boolean;
  38062. /**
  38063. * Are bump textures enabled in the application.
  38064. */
  38065. static BumpTextureEnabled: boolean;
  38066. /**
  38067. * Are lightmap textures enabled in the application.
  38068. */
  38069. static LightmapTextureEnabled: boolean;
  38070. /**
  38071. * Are refraction textures enabled in the application.
  38072. */
  38073. static RefractionTextureEnabled: boolean;
  38074. /**
  38075. * Are color grading textures enabled in the application.
  38076. */
  38077. static ColorGradingTextureEnabled: boolean;
  38078. /**
  38079. * Are fresnels enabled in the application.
  38080. */
  38081. static FresnelEnabled: boolean;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. /**
  38086. * A class extending Texture allowing drawing on a texture
  38087. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38088. */
  38089. export class DynamicTexture extends Texture {
  38090. private _generateMipMaps;
  38091. private _canvas;
  38092. private _context;
  38093. private _engine;
  38094. /**
  38095. * Creates a DynamicTexture
  38096. * @param name defines the name of the texture
  38097. * @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
  38098. * @param scene defines the scene where you want the texture
  38099. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38100. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38101. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38102. */
  38103. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38104. /**
  38105. * Get the current class name of the texture useful for serialization or dynamic coding.
  38106. * @returns "DynamicTexture"
  38107. */
  38108. getClassName(): string;
  38109. /**
  38110. * Gets the current state of canRescale
  38111. */
  38112. readonly canRescale: boolean;
  38113. private _recreate;
  38114. /**
  38115. * Scales the texture
  38116. * @param ratio the scale factor to apply to both width and height
  38117. */
  38118. scale(ratio: number): void;
  38119. /**
  38120. * Resizes the texture
  38121. * @param width the new width
  38122. * @param height the new height
  38123. */
  38124. scaleTo(width: number, height: number): void;
  38125. /**
  38126. * Gets the context of the canvas used by the texture
  38127. * @returns the canvas context of the dynamic texture
  38128. */
  38129. getContext(): CanvasRenderingContext2D;
  38130. /**
  38131. * Clears the texture
  38132. */
  38133. clear(): void;
  38134. /**
  38135. * Updates the texture
  38136. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38137. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38138. */
  38139. update(invertY?: boolean, premulAlpha?: boolean): void;
  38140. /**
  38141. * Draws text onto the texture
  38142. * @param text defines the text to be drawn
  38143. * @param x defines the placement of the text from the left
  38144. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38145. * @param font defines the font to be used with font-style, font-size, font-name
  38146. * @param color defines the color used for the text
  38147. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38148. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38149. * @param update defines whether texture is immediately update (default is true)
  38150. */
  38151. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38152. /**
  38153. * Clones the texture
  38154. * @returns the clone of the texture.
  38155. */
  38156. clone(): DynamicTexture;
  38157. /**
  38158. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38159. * @returns a serialized dynamic texture object
  38160. */
  38161. serialize(): any;
  38162. /** @hidden */
  38163. _rebuild(): void;
  38164. }
  38165. }
  38166. declare module BABYLON {
  38167. /** @hidden */
  38168. export var imageProcessingPixelShader: {
  38169. name: string;
  38170. shader: string;
  38171. };
  38172. }
  38173. declare module BABYLON {
  38174. /**
  38175. * ImageProcessingPostProcess
  38176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38177. */
  38178. export class ImageProcessingPostProcess extends PostProcess {
  38179. /**
  38180. * Default configuration related to image processing available in the PBR Material.
  38181. */
  38182. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38183. /**
  38184. * Gets the image processing configuration used either in this material.
  38185. */
  38186. /**
  38187. * Sets the Default image processing configuration used either in the this material.
  38188. *
  38189. * If sets to null, the scene one is in use.
  38190. */
  38191. imageProcessingConfiguration: ImageProcessingConfiguration;
  38192. /**
  38193. * Keep track of the image processing observer to allow dispose and replace.
  38194. */
  38195. private _imageProcessingObserver;
  38196. /**
  38197. * Attaches a new image processing configuration to the PBR Material.
  38198. * @param configuration
  38199. */
  38200. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38201. /**
  38202. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38203. */
  38204. /**
  38205. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38206. */
  38207. colorCurves: Nullable<ColorCurves>;
  38208. /**
  38209. * Gets wether the color curves effect is enabled.
  38210. */
  38211. /**
  38212. * Sets wether the color curves effect is enabled.
  38213. */
  38214. colorCurvesEnabled: boolean;
  38215. /**
  38216. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38217. */
  38218. /**
  38219. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38220. */
  38221. colorGradingTexture: Nullable<BaseTexture>;
  38222. /**
  38223. * Gets wether the color grading effect is enabled.
  38224. */
  38225. /**
  38226. * Gets wether the color grading effect is enabled.
  38227. */
  38228. colorGradingEnabled: boolean;
  38229. /**
  38230. * Gets exposure used in the effect.
  38231. */
  38232. /**
  38233. * Sets exposure used in the effect.
  38234. */
  38235. exposure: number;
  38236. /**
  38237. * Gets wether tonemapping is enabled or not.
  38238. */
  38239. /**
  38240. * Sets wether tonemapping is enabled or not
  38241. */
  38242. toneMappingEnabled: boolean;
  38243. /**
  38244. * Gets contrast used in the effect.
  38245. */
  38246. /**
  38247. * Sets contrast used in the effect.
  38248. */
  38249. contrast: number;
  38250. /**
  38251. * Gets Vignette stretch size.
  38252. */
  38253. /**
  38254. * Sets Vignette stretch size.
  38255. */
  38256. vignetteStretch: number;
  38257. /**
  38258. * Gets Vignette centre X Offset.
  38259. */
  38260. /**
  38261. * Sets Vignette centre X Offset.
  38262. */
  38263. vignetteCentreX: number;
  38264. /**
  38265. * Gets Vignette centre Y Offset.
  38266. */
  38267. /**
  38268. * Sets Vignette centre Y Offset.
  38269. */
  38270. vignetteCentreY: number;
  38271. /**
  38272. * Gets Vignette weight or intensity of the vignette effect.
  38273. */
  38274. /**
  38275. * Sets Vignette weight or intensity of the vignette effect.
  38276. */
  38277. vignetteWeight: number;
  38278. /**
  38279. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38280. * if vignetteEnabled is set to true.
  38281. */
  38282. /**
  38283. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38284. * if vignetteEnabled is set to true.
  38285. */
  38286. vignetteColor: Color4;
  38287. /**
  38288. * Gets Camera field of view used by the Vignette effect.
  38289. */
  38290. /**
  38291. * Sets Camera field of view used by the Vignette effect.
  38292. */
  38293. vignetteCameraFov: number;
  38294. /**
  38295. * Gets the vignette blend mode allowing different kind of effect.
  38296. */
  38297. /**
  38298. * Sets the vignette blend mode allowing different kind of effect.
  38299. */
  38300. vignetteBlendMode: number;
  38301. /**
  38302. * Gets wether the vignette effect is enabled.
  38303. */
  38304. /**
  38305. * Sets wether the vignette effect is enabled.
  38306. */
  38307. vignetteEnabled: boolean;
  38308. private _fromLinearSpace;
  38309. /**
  38310. * Gets wether the input of the processing is in Gamma or Linear Space.
  38311. */
  38312. /**
  38313. * Sets wether the input of the processing is in Gamma or Linear Space.
  38314. */
  38315. fromLinearSpace: boolean;
  38316. /**
  38317. * Defines cache preventing GC.
  38318. */
  38319. private _defines;
  38320. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38321. /**
  38322. * "ImageProcessingPostProcess"
  38323. * @returns "ImageProcessingPostProcess"
  38324. */
  38325. getClassName(): string;
  38326. protected _updateParameters(): void;
  38327. dispose(camera?: Camera): void;
  38328. }
  38329. }
  38330. declare module BABYLON {
  38331. /**
  38332. * Class containing static functions to help procedurally build meshes
  38333. */
  38334. export class GroundBuilder {
  38335. /**
  38336. * Creates a ground mesh
  38337. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38338. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38340. * @param name defines the name of the mesh
  38341. * @param options defines the options used to create the mesh
  38342. * @param scene defines the hosting scene
  38343. * @returns the ground mesh
  38344. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38345. */
  38346. static CreateGround(name: string, options: {
  38347. width?: number;
  38348. height?: number;
  38349. subdivisions?: number;
  38350. subdivisionsX?: number;
  38351. subdivisionsY?: number;
  38352. updatable?: boolean;
  38353. }, scene: any): Mesh;
  38354. /**
  38355. * Creates a tiled ground mesh
  38356. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38357. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38358. * * 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
  38359. * * 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
  38360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38361. * @param name defines the name of the mesh
  38362. * @param options defines the options used to create the mesh
  38363. * @param scene defines the hosting scene
  38364. * @returns the tiled ground mesh
  38365. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38366. */
  38367. static CreateTiledGround(name: string, options: {
  38368. xmin: number;
  38369. zmin: number;
  38370. xmax: number;
  38371. zmax: number;
  38372. subdivisions?: {
  38373. w: number;
  38374. h: number;
  38375. };
  38376. precision?: {
  38377. w: number;
  38378. h: number;
  38379. };
  38380. updatable?: boolean;
  38381. }, scene: Scene): Mesh;
  38382. /**
  38383. * Creates a ground mesh from a height map
  38384. * * The parameter `url` sets the URL of the height map image resource.
  38385. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38386. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38387. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38388. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38389. * * 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.
  38390. * * 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).
  38391. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38393. * @param name defines the name of the mesh
  38394. * @param url defines the url to the height map
  38395. * @param options defines the options used to create the mesh
  38396. * @param scene defines the hosting scene
  38397. * @returns the ground mesh
  38398. * @see https://doc.babylonjs.com/babylon101/height_map
  38399. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38400. */
  38401. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38402. width?: number;
  38403. height?: number;
  38404. subdivisions?: number;
  38405. minHeight?: number;
  38406. maxHeight?: number;
  38407. colorFilter?: Color3;
  38408. alphaFilter?: number;
  38409. updatable?: boolean;
  38410. onReady?: (mesh: GroundMesh) => void;
  38411. }, scene: Scene): GroundMesh;
  38412. }
  38413. }
  38414. declare module BABYLON {
  38415. /**
  38416. * Class containing static functions to help procedurally build meshes
  38417. */
  38418. export class TorusBuilder {
  38419. /**
  38420. * Creates a torus mesh
  38421. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38422. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38423. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38425. * * 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
  38426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38427. * @param name defines the name of the mesh
  38428. * @param options defines the options used to create the mesh
  38429. * @param scene defines the hosting scene
  38430. * @returns the torus mesh
  38431. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38432. */
  38433. static CreateTorus(name: string, options: {
  38434. diameter?: number;
  38435. thickness?: number;
  38436. tessellation?: number;
  38437. updatable?: boolean;
  38438. sideOrientation?: number;
  38439. frontUVs?: Vector4;
  38440. backUVs?: Vector4;
  38441. }, scene: any): Mesh;
  38442. }
  38443. }
  38444. declare module BABYLON {
  38445. /**
  38446. * Class containing static functions to help procedurally build meshes
  38447. */
  38448. export class CylinderBuilder {
  38449. /**
  38450. * Creates a cylinder or a cone mesh
  38451. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38452. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38453. * * 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.
  38454. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38455. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38456. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38457. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38458. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38459. * * 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).
  38460. * * 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
  38461. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38462. * * 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
  38463. * * 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.
  38464. * * If `enclose` is false, a ring surface is one element.
  38465. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38466. * * 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
  38467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38468. * * 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
  38469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38470. * @param name defines the name of the mesh
  38471. * @param options defines the options used to create the mesh
  38472. * @param scene defines the hosting scene
  38473. * @returns the cylinder mesh
  38474. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38475. */
  38476. static CreateCylinder(name: string, options: {
  38477. height?: number;
  38478. diameterTop?: number;
  38479. diameterBottom?: number;
  38480. diameter?: number;
  38481. tessellation?: number;
  38482. subdivisions?: number;
  38483. arc?: number;
  38484. faceColors?: Color4[];
  38485. faceUV?: Vector4[];
  38486. updatable?: boolean;
  38487. hasRings?: boolean;
  38488. enclose?: boolean;
  38489. sideOrientation?: number;
  38490. frontUVs?: Vector4;
  38491. backUVs?: Vector4;
  38492. }, scene: any): Mesh;
  38493. }
  38494. }
  38495. declare module BABYLON {
  38496. /**
  38497. * Manager for handling gamepads
  38498. */
  38499. export class GamepadManager {
  38500. private _scene?;
  38501. private _babylonGamepads;
  38502. private _oneGamepadConnected;
  38503. /** @hidden */
  38504. _isMonitoring: boolean;
  38505. private _gamepadEventSupported;
  38506. private _gamepadSupport;
  38507. /**
  38508. * observable to be triggered when the gamepad controller has been connected
  38509. */
  38510. onGamepadConnectedObservable: Observable<Gamepad>;
  38511. /**
  38512. * observable to be triggered when the gamepad controller has been disconnected
  38513. */
  38514. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38515. private _onGamepadConnectedEvent;
  38516. private _onGamepadDisconnectedEvent;
  38517. /**
  38518. * Initializes the gamepad manager
  38519. * @param _scene BabylonJS scene
  38520. */
  38521. constructor(_scene?: Scene | undefined);
  38522. /**
  38523. * The gamepads in the game pad manager
  38524. */
  38525. readonly gamepads: Gamepad[];
  38526. /**
  38527. * Get the gamepad controllers based on type
  38528. * @param type The type of gamepad controller
  38529. * @returns Nullable gamepad
  38530. */
  38531. getGamepadByType(type?: number): Nullable<Gamepad>;
  38532. /**
  38533. * Disposes the gamepad manager
  38534. */
  38535. dispose(): void;
  38536. private _addNewGamepad;
  38537. private _startMonitoringGamepads;
  38538. private _stopMonitoringGamepads;
  38539. /** @hidden */
  38540. _checkGamepadsStatus(): void;
  38541. private _updateGamepadObjects;
  38542. }
  38543. }
  38544. declare module BABYLON {
  38545. interface Scene {
  38546. /** @hidden */
  38547. _gamepadManager: Nullable<GamepadManager>;
  38548. /**
  38549. * Gets the gamepad manager associated with the scene
  38550. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38551. */
  38552. gamepadManager: GamepadManager;
  38553. }
  38554. /**
  38555. * Interface representing a free camera inputs manager
  38556. */
  38557. interface FreeCameraInputsManager {
  38558. /**
  38559. * Adds gamepad input support to the FreeCameraInputsManager.
  38560. * @returns the FreeCameraInputsManager
  38561. */
  38562. addGamepad(): FreeCameraInputsManager;
  38563. }
  38564. /**
  38565. * Interface representing an arc rotate camera inputs manager
  38566. */
  38567. interface ArcRotateCameraInputsManager {
  38568. /**
  38569. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38570. * @returns the camera inputs manager
  38571. */
  38572. addGamepad(): ArcRotateCameraInputsManager;
  38573. }
  38574. /**
  38575. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38576. */
  38577. export class GamepadSystemSceneComponent implements ISceneComponent {
  38578. /**
  38579. * The component name helpfull to identify the component in the list of scene components.
  38580. */
  38581. readonly name: string;
  38582. /**
  38583. * The scene the component belongs to.
  38584. */
  38585. scene: Scene;
  38586. /**
  38587. * Creates a new instance of the component for the given scene
  38588. * @param scene Defines the scene to register the component in
  38589. */
  38590. constructor(scene: Scene);
  38591. /**
  38592. * Registers the component in a given scene
  38593. */
  38594. register(): void;
  38595. /**
  38596. * Rebuilds the elements related to this component in case of
  38597. * context lost for instance.
  38598. */
  38599. rebuild(): void;
  38600. /**
  38601. * Disposes the component and the associated ressources
  38602. */
  38603. dispose(): void;
  38604. private _beforeCameraUpdate;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * Options to modify the vr teleportation behavior.
  38610. */
  38611. export interface VRTeleportationOptions {
  38612. /**
  38613. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38614. */
  38615. floorMeshName?: string;
  38616. /**
  38617. * A list of meshes to be used as the teleportation floor. (default: empty)
  38618. */
  38619. floorMeshes?: Mesh[];
  38620. }
  38621. /**
  38622. * Options to modify the vr experience helper's behavior.
  38623. */
  38624. export interface VRExperienceHelperOptions extends WebVROptions {
  38625. /**
  38626. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38627. */
  38628. createDeviceOrientationCamera?: boolean;
  38629. /**
  38630. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38631. */
  38632. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38633. /**
  38634. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38635. */
  38636. laserToggle?: boolean;
  38637. /**
  38638. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38639. */
  38640. floorMeshes?: Mesh[];
  38641. /**
  38642. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38643. */
  38644. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38645. }
  38646. /**
  38647. * Helps to quickly add VR support to an existing scene.
  38648. * See http://doc.babylonjs.com/how_to/webvr_helper
  38649. */
  38650. export class VRExperienceHelper {
  38651. /** Options to modify the vr experience helper's behavior. */
  38652. webVROptions: VRExperienceHelperOptions;
  38653. private _scene;
  38654. private _position;
  38655. private _btnVR;
  38656. private _btnVRDisplayed;
  38657. private _webVRsupported;
  38658. private _webVRready;
  38659. private _webVRrequesting;
  38660. private _webVRpresenting;
  38661. private _hasEnteredVR;
  38662. private _fullscreenVRpresenting;
  38663. private _canvas;
  38664. private _webVRCamera;
  38665. private _vrDeviceOrientationCamera;
  38666. private _deviceOrientationCamera;
  38667. private _existingCamera;
  38668. private _onKeyDown;
  38669. private _onVrDisplayPresentChange;
  38670. private _onVRDisplayChanged;
  38671. private _onVRRequestPresentStart;
  38672. private _onVRRequestPresentComplete;
  38673. /**
  38674. * Observable raised when entering VR.
  38675. */
  38676. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38677. /**
  38678. * Observable raised when exiting VR.
  38679. */
  38680. onExitingVRObservable: Observable<VRExperienceHelper>;
  38681. /**
  38682. * Observable raised when controller mesh is loaded.
  38683. */
  38684. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38685. /** Return this.onEnteringVRObservable
  38686. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38687. */
  38688. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38689. /** Return this.onExitingVRObservable
  38690. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38691. */
  38692. readonly onExitingVR: Observable<VRExperienceHelper>;
  38693. /** Return this.onControllerMeshLoadedObservable
  38694. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38695. */
  38696. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38697. private _rayLength;
  38698. private _useCustomVRButton;
  38699. private _teleportationRequested;
  38700. private _teleportActive;
  38701. private _floorMeshName;
  38702. private _floorMeshesCollection;
  38703. private _rotationAllowed;
  38704. private _teleportBackwardsVector;
  38705. private _teleportationTarget;
  38706. private _isDefaultTeleportationTarget;
  38707. private _postProcessMove;
  38708. private _teleportationFillColor;
  38709. private _teleportationBorderColor;
  38710. private _rotationAngle;
  38711. private _haloCenter;
  38712. private _cameraGazer;
  38713. private _padSensibilityUp;
  38714. private _padSensibilityDown;
  38715. private _leftController;
  38716. private _rightController;
  38717. /**
  38718. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38719. */
  38720. onNewMeshSelected: Observable<AbstractMesh>;
  38721. /**
  38722. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38723. */
  38724. onNewMeshPicked: Observable<PickingInfo>;
  38725. private _circleEase;
  38726. /**
  38727. * Observable raised before camera teleportation
  38728. */
  38729. onBeforeCameraTeleport: Observable<Vector3>;
  38730. /**
  38731. * Observable raised after camera teleportation
  38732. */
  38733. onAfterCameraTeleport: Observable<Vector3>;
  38734. /**
  38735. * Observable raised when current selected mesh gets unselected
  38736. */
  38737. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38738. private _raySelectionPredicate;
  38739. /**
  38740. * To be optionaly changed by user to define custom ray selection
  38741. */
  38742. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38743. /**
  38744. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38745. */
  38746. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38747. /**
  38748. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38749. */
  38750. teleportationEnabled: boolean;
  38751. private _defaultHeight;
  38752. private _teleportationInitialized;
  38753. private _interactionsEnabled;
  38754. private _interactionsRequested;
  38755. private _displayGaze;
  38756. private _displayLaserPointer;
  38757. /**
  38758. * The mesh used to display where the user is going to teleport.
  38759. */
  38760. /**
  38761. * Sets the mesh to be used to display where the user is going to teleport.
  38762. */
  38763. teleportationTarget: Mesh;
  38764. /**
  38765. * 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
  38766. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38767. * See http://doc.babylonjs.com/resources/baking_transformations
  38768. */
  38769. gazeTrackerMesh: Mesh;
  38770. /**
  38771. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38772. */
  38773. updateGazeTrackerScale: boolean;
  38774. /**
  38775. * If the gaze trackers color should be updated when selecting meshes
  38776. */
  38777. updateGazeTrackerColor: boolean;
  38778. /**
  38779. * The gaze tracking mesh corresponding to the left controller
  38780. */
  38781. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38782. /**
  38783. * The gaze tracking mesh corresponding to the right controller
  38784. */
  38785. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38786. /**
  38787. * If the ray of the gaze should be displayed.
  38788. */
  38789. /**
  38790. * Sets if the ray of the gaze should be displayed.
  38791. */
  38792. displayGaze: boolean;
  38793. /**
  38794. * If the ray of the LaserPointer should be displayed.
  38795. */
  38796. /**
  38797. * Sets if the ray of the LaserPointer should be displayed.
  38798. */
  38799. displayLaserPointer: boolean;
  38800. /**
  38801. * The deviceOrientationCamera used as the camera when not in VR.
  38802. */
  38803. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38804. /**
  38805. * Based on the current WebVR support, returns the current VR camera used.
  38806. */
  38807. readonly currentVRCamera: Nullable<Camera>;
  38808. /**
  38809. * The webVRCamera which is used when in VR.
  38810. */
  38811. readonly webVRCamera: WebVRFreeCamera;
  38812. /**
  38813. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38814. */
  38815. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38816. private readonly _teleportationRequestInitiated;
  38817. /**
  38818. * Defines wether or not Pointer lock should be requested when switching to
  38819. * full screen.
  38820. */
  38821. requestPointerLockOnFullScreen: boolean;
  38822. /**
  38823. * Instantiates a VRExperienceHelper.
  38824. * Helps to quickly add VR support to an existing scene.
  38825. * @param scene The scene the VRExperienceHelper belongs to.
  38826. * @param webVROptions Options to modify the vr experience helper's behavior.
  38827. */
  38828. constructor(scene: Scene,
  38829. /** Options to modify the vr experience helper's behavior. */
  38830. webVROptions?: VRExperienceHelperOptions);
  38831. private _onDefaultMeshLoaded;
  38832. private _onResize;
  38833. private _onFullscreenChange;
  38834. /**
  38835. * Gets a value indicating if we are currently in VR mode.
  38836. */
  38837. readonly isInVRMode: boolean;
  38838. private onVrDisplayPresentChange;
  38839. private onVRDisplayChanged;
  38840. private moveButtonToBottomRight;
  38841. private displayVRButton;
  38842. private updateButtonVisibility;
  38843. private _cachedAngularSensibility;
  38844. /**
  38845. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38846. * Otherwise, will use the fullscreen API.
  38847. */
  38848. enterVR(): void;
  38849. /**
  38850. * Attempt to exit VR, or fullscreen.
  38851. */
  38852. exitVR(): void;
  38853. /**
  38854. * The position of the vr experience helper.
  38855. */
  38856. /**
  38857. * Sets the position of the vr experience helper.
  38858. */
  38859. position: Vector3;
  38860. /**
  38861. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38862. */
  38863. enableInteractions(): void;
  38864. private readonly _noControllerIsActive;
  38865. private beforeRender;
  38866. private _isTeleportationFloor;
  38867. /**
  38868. * Adds a floor mesh to be used for teleportation.
  38869. * @param floorMesh the mesh to be used for teleportation.
  38870. */
  38871. addFloorMesh(floorMesh: Mesh): void;
  38872. /**
  38873. * Removes a floor mesh from being used for teleportation.
  38874. * @param floorMesh the mesh to be removed.
  38875. */
  38876. removeFloorMesh(floorMesh: Mesh): void;
  38877. /**
  38878. * Enables interactions and teleportation using the VR controllers and gaze.
  38879. * @param vrTeleportationOptions options to modify teleportation behavior.
  38880. */
  38881. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38882. private _onNewGamepadConnected;
  38883. private _tryEnableInteractionOnController;
  38884. private _onNewGamepadDisconnected;
  38885. private _enableInteractionOnController;
  38886. private _checkTeleportWithRay;
  38887. private _checkRotate;
  38888. private _checkTeleportBackwards;
  38889. private _enableTeleportationOnController;
  38890. private _createTeleportationCircles;
  38891. private _displayTeleportationTarget;
  38892. private _hideTeleportationTarget;
  38893. private _rotateCamera;
  38894. private _moveTeleportationSelectorTo;
  38895. private _workingVector;
  38896. private _workingQuaternion;
  38897. private _workingMatrix;
  38898. /**
  38899. * Teleports the users feet to the desired location
  38900. * @param location The location where the user's feet should be placed
  38901. */
  38902. teleportCamera(location: Vector3): void;
  38903. private _convertNormalToDirectionOfRay;
  38904. private _castRayAndSelectObject;
  38905. private _notifySelectedMeshUnselected;
  38906. /**
  38907. * Sets the color of the laser ray from the vr controllers.
  38908. * @param color new color for the ray.
  38909. */
  38910. changeLaserColor(color: Color3): void;
  38911. /**
  38912. * Sets the color of the ray from the vr headsets gaze.
  38913. * @param color new color for the ray.
  38914. */
  38915. changeGazeColor(color: Color3): void;
  38916. /**
  38917. * Exits VR and disposes of the vr experience helper
  38918. */
  38919. dispose(): void;
  38920. /**
  38921. * Gets the name of the VRExperienceHelper class
  38922. * @returns "VRExperienceHelper"
  38923. */
  38924. getClassName(): string;
  38925. }
  38926. }
  38927. declare module BABYLON {
  38928. /**
  38929. * Manages an XRSession
  38930. * @see https://doc.babylonjs.com/how_to/webxr
  38931. */
  38932. export class WebXRSessionManager implements IDisposable {
  38933. private scene;
  38934. /**
  38935. * Fires every time a new xrFrame arrives which can be used to update the camera
  38936. */
  38937. onXRFrameObservable: Observable<any>;
  38938. /**
  38939. * Fires when the xr session is ended either by the device or manually done
  38940. */
  38941. onXRSessionEnded: Observable<any>;
  38942. /** @hidden */
  38943. _xrSession: XRSession;
  38944. /** @hidden */
  38945. _frameOfReference: XRFrameOfReference;
  38946. /** @hidden */
  38947. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38948. /** @hidden */
  38949. _currentXRFrame: Nullable<XRFrame>;
  38950. private _xrNavigator;
  38951. private _xrDevice;
  38952. private _tmpMatrix;
  38953. /**
  38954. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38955. * @param scene The scene which the session should be created for
  38956. */
  38957. constructor(scene: Scene);
  38958. /**
  38959. * Initializes the manager
  38960. * After initialization enterXR can be called to start an XR session
  38961. * @returns Promise which resolves after it is initialized
  38962. */
  38963. initializeAsync(): Promise<void>;
  38964. /**
  38965. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38966. * @param sessionCreationOptions xr options to create the session with
  38967. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38968. * @returns Promise which resolves after it enters XR
  38969. */
  38970. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38971. /**
  38972. * Stops the xrSession and restores the renderloop
  38973. * @returns Promise which resolves after it exits XR
  38974. */
  38975. exitXRAsync(): Promise<void>;
  38976. /**
  38977. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38978. * @param ray ray to cast into the environment
  38979. * @returns Promise which resolves with a collision point in the environment if it exists
  38980. */
  38981. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38982. /**
  38983. * Checks if a session would be supported for the creation options specified
  38984. * @param options creation options to check if they are supported
  38985. * @returns true if supported
  38986. */
  38987. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38988. /**
  38989. * @hidden
  38990. * Converts the render layer of xrSession to a render target
  38991. * @param session session to create render target for
  38992. * @param scene scene the new render target should be created for
  38993. */
  38994. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38995. /**
  38996. * Disposes of the session manager
  38997. */
  38998. dispose(): void;
  38999. }
  39000. }
  39001. declare module BABYLON {
  39002. /**
  39003. * WebXR Camera which holds the views for the xrSession
  39004. * @see https://doc.babylonjs.com/how_to/webxr
  39005. */
  39006. export class WebXRCamera extends FreeCamera {
  39007. private static _TmpMatrix;
  39008. /**
  39009. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39010. * @param name the name of the camera
  39011. * @param scene the scene to add the camera to
  39012. */
  39013. constructor(name: string, scene: Scene);
  39014. private _updateNumberOfRigCameras;
  39015. /** @hidden */
  39016. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39017. /**
  39018. * Updates the cameras position from the current pose information of the XR session
  39019. * @param xrSessionManager the session containing pose information
  39020. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39021. */
  39022. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39023. }
  39024. }
  39025. declare module BABYLON {
  39026. /**
  39027. * States of the webXR experience
  39028. */
  39029. export enum WebXRState {
  39030. /**
  39031. * Transitioning to being in XR mode
  39032. */
  39033. ENTERING_XR = 0,
  39034. /**
  39035. * Transitioning to non XR mode
  39036. */
  39037. EXITING_XR = 1,
  39038. /**
  39039. * In XR mode and presenting
  39040. */
  39041. IN_XR = 2,
  39042. /**
  39043. * Not entered XR mode
  39044. */
  39045. NOT_IN_XR = 3
  39046. }
  39047. /**
  39048. * Helper class used to enable XR
  39049. * @see https://doc.babylonjs.com/how_to/webxr
  39050. */
  39051. export class WebXRExperienceHelper implements IDisposable {
  39052. private scene;
  39053. /**
  39054. * 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
  39055. */
  39056. container: AbstractMesh;
  39057. /**
  39058. * Camera used to render xr content
  39059. */
  39060. camera: WebXRCamera;
  39061. /**
  39062. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39063. */
  39064. state: WebXRState;
  39065. private _setState;
  39066. private static _TmpVector;
  39067. /**
  39068. * Fires when the state of the experience helper has changed
  39069. */
  39070. onStateChangedObservable: Observable<WebXRState>;
  39071. /** @hidden */
  39072. _sessionManager: WebXRSessionManager;
  39073. private _nonVRCamera;
  39074. private _originalSceneAutoClear;
  39075. private _supported;
  39076. /**
  39077. * Creates the experience helper
  39078. * @param scene the scene to attach the experience helper to
  39079. * @returns a promise for the experience helper
  39080. */
  39081. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39082. /**
  39083. * Creates a WebXRExperienceHelper
  39084. * @param scene The scene the helper should be created in
  39085. */
  39086. private constructor();
  39087. /**
  39088. * Exits XR mode and returns the scene to its original state
  39089. * @returns promise that resolves after xr mode has exited
  39090. */
  39091. exitXRAsync(): Promise<void>;
  39092. /**
  39093. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39094. * @param sessionCreationOptions options for the XR session
  39095. * @param frameOfReference frame of reference of the XR session
  39096. * @returns promise that resolves after xr mode has entered
  39097. */
  39098. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39099. /**
  39100. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39101. * @param ray ray to cast into the environment
  39102. * @returns Promise which resolves with a collision point in the environment if it exists
  39103. */
  39104. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39105. /**
  39106. * Updates the global position of the camera by moving the camera's container
  39107. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39108. * @param position The desired global position of the camera
  39109. */
  39110. setPositionOfCameraUsingContainer(position: Vector3): void;
  39111. /**
  39112. * Rotates the xr camera by rotating the camera's container around the camera's position
  39113. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39114. * @param rotation the desired quaternion rotation to apply to the camera
  39115. */
  39116. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39117. /**
  39118. * Checks if the creation options are supported by the xr session
  39119. * @param options creation options
  39120. * @returns true if supported
  39121. */
  39122. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39123. /**
  39124. * Disposes of the experience helper
  39125. */
  39126. dispose(): void;
  39127. }
  39128. }
  39129. declare module BABYLON {
  39130. /**
  39131. * Button which can be used to enter a different mode of XR
  39132. */
  39133. export class WebXREnterExitUIButton {
  39134. /** button element */
  39135. element: HTMLElement;
  39136. /** XR initialization options for the button */
  39137. initializationOptions: XRSessionCreationOptions;
  39138. /**
  39139. * Creates a WebXREnterExitUIButton
  39140. * @param element button element
  39141. * @param initializationOptions XR initialization options for the button
  39142. */
  39143. constructor(
  39144. /** button element */
  39145. element: HTMLElement,
  39146. /** XR initialization options for the button */
  39147. initializationOptions: XRSessionCreationOptions);
  39148. /**
  39149. * Overwritable function which can be used to update the button's visuals when the state changes
  39150. * @param activeButton the current active button in the UI
  39151. */
  39152. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39153. }
  39154. /**
  39155. * Options to create the webXR UI
  39156. */
  39157. export class WebXREnterExitUIOptions {
  39158. /**
  39159. * Context to enter xr with
  39160. */
  39161. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39162. /**
  39163. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39164. */
  39165. customButtons?: Array<WebXREnterExitUIButton>;
  39166. }
  39167. /**
  39168. * UI to allow the user to enter/exit XR mode
  39169. */
  39170. export class WebXREnterExitUI implements IDisposable {
  39171. private scene;
  39172. private _overlay;
  39173. private _buttons;
  39174. private _activeButton;
  39175. /**
  39176. * Fired every time the active button is changed.
  39177. *
  39178. * When xr is entered via a button that launches xr that button will be the callback parameter
  39179. *
  39180. * When exiting xr the callback parameter will be null)
  39181. */
  39182. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39183. /**
  39184. * Creates UI to allow the user to enter/exit XR mode
  39185. * @param scene the scene to add the ui to
  39186. * @param helper the xr experience helper to enter/exit xr with
  39187. * @param options options to configure the UI
  39188. * @returns the created ui
  39189. */
  39190. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39191. private constructor();
  39192. private _updateButtons;
  39193. /**
  39194. * Disposes of the object
  39195. */
  39196. dispose(): void;
  39197. }
  39198. }
  39199. declare module BABYLON {
  39200. /**
  39201. * Represents an XR input
  39202. */
  39203. export class WebXRController {
  39204. /**
  39205. * 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
  39206. */
  39207. grip?: AbstractMesh;
  39208. /**
  39209. * Pointer which can be used to select objects or attach a visible laser to
  39210. */
  39211. pointer: AbstractMesh;
  39212. /**
  39213. * Creates the controller
  39214. * @see https://doc.babylonjs.com/how_to/webxr
  39215. * @param scene the scene which the controller should be associated to
  39216. */
  39217. constructor(scene: Scene);
  39218. /**
  39219. * Disposes of the object
  39220. */
  39221. dispose(): void;
  39222. }
  39223. /**
  39224. * XR input used to track XR inputs such as controllers/rays
  39225. */
  39226. export class WebXRInput implements IDisposable {
  39227. private helper;
  39228. /**
  39229. * XR controllers being tracked
  39230. */
  39231. controllers: Array<WebXRController>;
  39232. private _tmpMatrix;
  39233. private _frameObserver;
  39234. /**
  39235. * Initializes the WebXRInput
  39236. * @param helper experience helper which the input should be created for
  39237. */
  39238. constructor(helper: WebXRExperienceHelper);
  39239. /**
  39240. * Disposes of the object
  39241. */
  39242. dispose(): void;
  39243. }
  39244. }
  39245. declare module BABYLON {
  39246. /**
  39247. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39248. */
  39249. export class WebXRManagedOutputCanvas implements IDisposable {
  39250. private _canvas;
  39251. /**
  39252. * xrpresent context of the canvas which can be used to display/mirror xr content
  39253. */
  39254. canvasContext: Nullable<WebGLRenderingContext>;
  39255. /**
  39256. * Initializes the canvas to be added/removed upon entering/exiting xr
  39257. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39258. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39259. */
  39260. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39261. /**
  39262. * Disposes of the object
  39263. */
  39264. dispose(): void;
  39265. private _setManagedOutputCanvas;
  39266. private _addCanvas;
  39267. private _removeCanvas;
  39268. }
  39269. }
  39270. declare module BABYLON {
  39271. /**
  39272. * Contains an array of blocks representing the octree
  39273. */
  39274. export interface IOctreeContainer<T> {
  39275. /**
  39276. * Blocks within the octree
  39277. */
  39278. blocks: Array<OctreeBlock<T>>;
  39279. }
  39280. /**
  39281. * Class used to store a cell in an octree
  39282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39283. */
  39284. export class OctreeBlock<T> {
  39285. /**
  39286. * Gets the content of the current block
  39287. */
  39288. entries: T[];
  39289. /**
  39290. * Gets the list of block children
  39291. */
  39292. blocks: Array<OctreeBlock<T>>;
  39293. private _depth;
  39294. private _maxDepth;
  39295. private _capacity;
  39296. private _minPoint;
  39297. private _maxPoint;
  39298. private _boundingVectors;
  39299. private _creationFunc;
  39300. /**
  39301. * Creates a new block
  39302. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39303. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39304. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39305. * @param depth defines the current depth of this block in the octree
  39306. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39307. * @param creationFunc defines a callback to call when an element is added to the block
  39308. */
  39309. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39310. /**
  39311. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39312. */
  39313. readonly capacity: number;
  39314. /**
  39315. * Gets the minimum vector (in world space) of the block's bounding box
  39316. */
  39317. readonly minPoint: Vector3;
  39318. /**
  39319. * Gets the maximum vector (in world space) of the block's bounding box
  39320. */
  39321. readonly maxPoint: Vector3;
  39322. /**
  39323. * Add a new element to this block
  39324. * @param entry defines the element to add
  39325. */
  39326. addEntry(entry: T): void;
  39327. /**
  39328. * Remove an element from this block
  39329. * @param entry defines the element to remove
  39330. */
  39331. removeEntry(entry: T): void;
  39332. /**
  39333. * Add an array of elements to this block
  39334. * @param entries defines the array of elements to add
  39335. */
  39336. addEntries(entries: T[]): void;
  39337. /**
  39338. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39339. * @param frustumPlanes defines the frustum planes to test
  39340. * @param selection defines the array to store current content if selection is positive
  39341. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39342. */
  39343. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39344. /**
  39345. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39346. * @param sphereCenter defines the bounding sphere center
  39347. * @param sphereRadius defines the bounding sphere radius
  39348. * @param selection defines the array to store current content if selection is positive
  39349. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39350. */
  39351. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39352. /**
  39353. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39354. * @param ray defines the ray to test with
  39355. * @param selection defines the array to store current content if selection is positive
  39356. */
  39357. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39358. /**
  39359. * Subdivide the content into child blocks (this block will then be empty)
  39360. */
  39361. createInnerBlocks(): void;
  39362. /**
  39363. * @hidden
  39364. */
  39365. 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;
  39366. }
  39367. }
  39368. declare module BABYLON {
  39369. /**
  39370. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39371. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39372. */
  39373. export class Octree<T> {
  39374. /** 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.) */
  39375. maxDepth: number;
  39376. /**
  39377. * Blocks within the octree containing objects
  39378. */
  39379. blocks: Array<OctreeBlock<T>>;
  39380. /**
  39381. * Content stored in the octree
  39382. */
  39383. dynamicContent: T[];
  39384. private _maxBlockCapacity;
  39385. private _selectionContent;
  39386. private _creationFunc;
  39387. /**
  39388. * Creates a octree
  39389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39390. * @param creationFunc function to be used to instatiate the octree
  39391. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39392. * @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.)
  39393. */
  39394. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39395. /** 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.) */
  39396. maxDepth?: number);
  39397. /**
  39398. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39399. * @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);
  39400. * @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);
  39401. * @param entries meshes to be added to the octree blocks
  39402. */
  39403. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39404. /**
  39405. * Adds a mesh to the octree
  39406. * @param entry Mesh to add to the octree
  39407. */
  39408. addMesh(entry: T): void;
  39409. /**
  39410. * Remove an element from the octree
  39411. * @param entry defines the element to remove
  39412. */
  39413. removeMesh(entry: T): void;
  39414. /**
  39415. * Selects an array of meshes within the frustum
  39416. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39417. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39418. * @returns array of meshes within the frustum
  39419. */
  39420. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39421. /**
  39422. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39423. * @param sphereCenter defines the bounding sphere center
  39424. * @param sphereRadius defines the bounding sphere radius
  39425. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39426. * @returns an array of objects that intersect the sphere
  39427. */
  39428. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39429. /**
  39430. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39431. * @param ray defines the ray to test with
  39432. * @returns array of intersected objects
  39433. */
  39434. intersectsRay(ray: Ray): SmartArray<T>;
  39435. /**
  39436. * Adds a mesh into the octree block if it intersects the block
  39437. */
  39438. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39439. /**
  39440. * Adds a submesh into the octree block if it intersects the block
  39441. */
  39442. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39443. }
  39444. }
  39445. declare module BABYLON {
  39446. interface Scene {
  39447. /**
  39448. * @hidden
  39449. * Backing Filed
  39450. */
  39451. _selectionOctree: Octree<AbstractMesh>;
  39452. /**
  39453. * Gets the octree used to boost mesh selection (picking)
  39454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39455. */
  39456. selectionOctree: Octree<AbstractMesh>;
  39457. /**
  39458. * Creates or updates the octree used to boost selection (picking)
  39459. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39460. * @param maxCapacity defines the maximum capacity per leaf
  39461. * @param maxDepth defines the maximum depth of the octree
  39462. * @returns an octree of AbstractMesh
  39463. */
  39464. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39465. }
  39466. interface AbstractMesh {
  39467. /**
  39468. * @hidden
  39469. * Backing Field
  39470. */
  39471. _submeshesOctree: Octree<SubMesh>;
  39472. /**
  39473. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39474. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39475. * @param maxCapacity defines the maximum size of each block (64 by default)
  39476. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39477. * @returns the new octree
  39478. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39479. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39480. */
  39481. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39482. }
  39483. /**
  39484. * Defines the octree scene component responsible to manage any octrees
  39485. * in a given scene.
  39486. */
  39487. export class OctreeSceneComponent {
  39488. /**
  39489. * The component name helpfull to identify the component in the list of scene components.
  39490. */
  39491. readonly name: string;
  39492. /**
  39493. * The scene the component belongs to.
  39494. */
  39495. scene: Scene;
  39496. /**
  39497. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39498. */
  39499. readonly checksIsEnabled: boolean;
  39500. /**
  39501. * Creates a new instance of the component for the given scene
  39502. * @param scene Defines the scene to register the component in
  39503. */
  39504. constructor(scene: Scene);
  39505. /**
  39506. * Registers the component in a given scene
  39507. */
  39508. register(): void;
  39509. /**
  39510. * Return the list of active meshes
  39511. * @returns the list of active meshes
  39512. */
  39513. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39514. /**
  39515. * Return the list of active sub meshes
  39516. * @param mesh The mesh to get the candidates sub meshes from
  39517. * @returns the list of active sub meshes
  39518. */
  39519. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39520. private _tempRay;
  39521. /**
  39522. * Return the list of sub meshes intersecting with a given local ray
  39523. * @param mesh defines the mesh to find the submesh for
  39524. * @param localRay defines the ray in local space
  39525. * @returns the list of intersecting sub meshes
  39526. */
  39527. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39528. /**
  39529. * Return the list of sub meshes colliding with a collider
  39530. * @param mesh defines the mesh to find the submesh for
  39531. * @param collider defines the collider to evaluate the collision against
  39532. * @returns the list of colliding sub meshes
  39533. */
  39534. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39535. /**
  39536. * Rebuilds the elements related to this component in case of
  39537. * context lost for instance.
  39538. */
  39539. rebuild(): void;
  39540. /**
  39541. * Disposes the component and the associated ressources.
  39542. */
  39543. dispose(): void;
  39544. }
  39545. }
  39546. declare module BABYLON {
  39547. /**
  39548. * Class containing static functions to help procedurally build meshes
  39549. */
  39550. export class LinesBuilder {
  39551. /**
  39552. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  39553. * * 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
  39554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  39555. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  39556. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  39557. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  39558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  39559. * * 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
  39560. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  39561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  39563. * @param name defines the name of the new line system
  39564. * @param options defines the options used to create the line system
  39565. * @param scene defines the hosting scene
  39566. * @returns a new line system mesh
  39567. */
  39568. static CreateLineSystem(name: string, options: {
  39569. lines: Vector3[][];
  39570. updatable?: boolean;
  39571. instance?: Nullable<LinesMesh>;
  39572. colors?: Nullable<Color4[][]>;
  39573. useVertexAlpha?: boolean;
  39574. }, scene: Nullable<Scene>): LinesMesh;
  39575. /**
  39576. * Creates a line mesh
  39577. * 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
  39578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39579. * * The parameter `points` is an array successive Vector3
  39580. * * 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
  39581. * * The optional parameter `colors` is an array of successive Color4, one per line point
  39582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  39583. * * When updating an instance, remember that only point positions can change, not the number of points
  39584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  39586. * @param name defines the name of the new line system
  39587. * @param options defines the options used to create the line system
  39588. * @param scene defines the hosting scene
  39589. * @returns a new line mesh
  39590. */
  39591. static CreateLines(name: string, options: {
  39592. points: Vector3[];
  39593. updatable?: boolean;
  39594. instance?: Nullable<LinesMesh>;
  39595. colors?: Color4[];
  39596. useVertexAlpha?: boolean;
  39597. }, scene?: Nullable<Scene>): LinesMesh;
  39598. /**
  39599. * Creates a dashed line mesh
  39600. * * 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
  39601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39602. * * The parameter `points` is an array successive Vector3
  39603. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  39604. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  39605. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  39606. * * 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
  39607. * * When updating an instance, remember that only point positions can change, not the number of points
  39608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39609. * @param name defines the name of the mesh
  39610. * @param options defines the options used to create the mesh
  39611. * @param scene defines the hosting scene
  39612. * @returns the dashed line mesh
  39613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  39614. */
  39615. static CreateDashedLines(name: string, options: {
  39616. points: Vector3[];
  39617. dashSize?: number;
  39618. gapSize?: number;
  39619. dashNb?: number;
  39620. updatable?: boolean;
  39621. instance?: LinesMesh;
  39622. }, scene?: Nullable<Scene>): LinesMesh;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Renders a layer on top of an existing scene
  39628. */
  39629. export class UtilityLayerRenderer implements IDisposable {
  39630. /** the original scene that will be rendered on top of */
  39631. originalScene: Scene;
  39632. private _pointerCaptures;
  39633. private _lastPointerEvents;
  39634. private static _DefaultUtilityLayer;
  39635. private static _DefaultKeepDepthUtilityLayer;
  39636. /**
  39637. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39638. */
  39639. pickUtilitySceneFirst: boolean;
  39640. /**
  39641. * 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)
  39642. */
  39643. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39644. /**
  39645. * 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)
  39646. */
  39647. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39648. /**
  39649. * The scene that is rendered on top of the original scene
  39650. */
  39651. utilityLayerScene: Scene;
  39652. /**
  39653. * If the utility layer should automatically be rendered on top of existing scene
  39654. */
  39655. shouldRender: boolean;
  39656. /**
  39657. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39658. */
  39659. onlyCheckPointerDownEvents: boolean;
  39660. /**
  39661. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39662. */
  39663. processAllEvents: boolean;
  39664. /**
  39665. * Observable raised when the pointer move from the utility layer scene to the main scene
  39666. */
  39667. onPointerOutObservable: Observable<number>;
  39668. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39669. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39670. private _afterRenderObserver;
  39671. private _sceneDisposeObserver;
  39672. private _originalPointerObserver;
  39673. /**
  39674. * Instantiates a UtilityLayerRenderer
  39675. * @param originalScene the original scene that will be rendered on top of
  39676. * @param handleEvents boolean indicating if the utility layer should handle events
  39677. */
  39678. constructor(
  39679. /** the original scene that will be rendered on top of */
  39680. originalScene: Scene, handleEvents?: boolean);
  39681. private _notifyObservers;
  39682. /**
  39683. * Renders the utility layers scene on top of the original scene
  39684. */
  39685. render(): void;
  39686. /**
  39687. * Disposes of the renderer
  39688. */
  39689. dispose(): void;
  39690. private _updateCamera;
  39691. }
  39692. }
  39693. declare module BABYLON {
  39694. /**
  39695. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39696. */
  39697. export class Gizmo implements IDisposable {
  39698. /** The utility layer the gizmo will be added to */
  39699. gizmoLayer: UtilityLayerRenderer;
  39700. /**
  39701. * The root mesh of the gizmo
  39702. */
  39703. _rootMesh: Mesh;
  39704. private _attachedMesh;
  39705. /**
  39706. * Ratio for the scale of the gizmo (Default: 1)
  39707. */
  39708. scaleRatio: number;
  39709. private _tmpMatrix;
  39710. /**
  39711. * If a custom mesh has been set (Default: false)
  39712. */
  39713. protected _customMeshSet: boolean;
  39714. /**
  39715. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39716. * * When set, interactions will be enabled
  39717. */
  39718. attachedMesh: Nullable<AbstractMesh>;
  39719. /**
  39720. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39721. * @param mesh The mesh to replace the default mesh of the gizmo
  39722. */
  39723. setCustomMesh(mesh: Mesh): void;
  39724. /**
  39725. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39726. */
  39727. updateGizmoRotationToMatchAttachedMesh: boolean;
  39728. /**
  39729. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39730. */
  39731. updateGizmoPositionToMatchAttachedMesh: boolean;
  39732. /**
  39733. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39734. */
  39735. protected _updateScale: boolean;
  39736. protected _interactionsEnabled: boolean;
  39737. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39738. private _beforeRenderObserver;
  39739. /**
  39740. * Creates a gizmo
  39741. * @param gizmoLayer The utility layer the gizmo will be added to
  39742. */
  39743. constructor(
  39744. /** The utility layer the gizmo will be added to */
  39745. gizmoLayer?: UtilityLayerRenderer);
  39746. private _tempVector;
  39747. /**
  39748. * @hidden
  39749. * Updates the gizmo to match the attached mesh's position/rotation
  39750. */
  39751. protected _update(): void;
  39752. /**
  39753. * Disposes of the gizmo
  39754. */
  39755. dispose(): void;
  39756. }
  39757. }
  39758. declare module BABYLON {
  39759. /**
  39760. * Single axis drag gizmo
  39761. */
  39762. export class AxisDragGizmo extends Gizmo {
  39763. /**
  39764. * Drag behavior responsible for the gizmos dragging interactions
  39765. */
  39766. dragBehavior: PointerDragBehavior;
  39767. private _pointerObserver;
  39768. /**
  39769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39770. */
  39771. snapDistance: number;
  39772. /**
  39773. * Event that fires each time the gizmo snaps to a new location.
  39774. * * snapDistance is the the change in distance
  39775. */
  39776. onSnapObservable: Observable<{
  39777. snapDistance: number;
  39778. }>;
  39779. /** @hidden */
  39780. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39781. /** @hidden */
  39782. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39783. /**
  39784. * Creates an AxisDragGizmo
  39785. * @param gizmoLayer The utility layer the gizmo will be added to
  39786. * @param dragAxis The axis which the gizmo will be able to drag on
  39787. * @param color The color of the gizmo
  39788. */
  39789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39790. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39791. /**
  39792. * Disposes of the gizmo
  39793. */
  39794. dispose(): void;
  39795. }
  39796. }
  39797. declare module BABYLON.Debug {
  39798. /**
  39799. * The Axes viewer will show 3 axes in a specific point in space
  39800. */
  39801. export class AxesViewer {
  39802. private _xAxis;
  39803. private _yAxis;
  39804. private _zAxis;
  39805. private _scaleLinesFactor;
  39806. private _instanced;
  39807. /**
  39808. * Gets the hosting scene
  39809. */
  39810. scene: Scene;
  39811. /**
  39812. * Gets or sets a number used to scale line length
  39813. */
  39814. scaleLines: number;
  39815. /** Gets the node hierarchy used to render x-axis */
  39816. readonly xAxis: TransformNode;
  39817. /** Gets the node hierarchy used to render y-axis */
  39818. readonly yAxis: TransformNode;
  39819. /** Gets the node hierarchy used to render z-axis */
  39820. readonly zAxis: TransformNode;
  39821. /**
  39822. * Creates a new AxesViewer
  39823. * @param scene defines the hosting scene
  39824. * @param scaleLines defines a number used to scale line length (1 by default)
  39825. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39826. * @param xAxis defines the node hierarchy used to render the x-axis
  39827. * @param yAxis defines the node hierarchy used to render the y-axis
  39828. * @param zAxis defines the node hierarchy used to render the z-axis
  39829. */
  39830. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39831. /**
  39832. * Force the viewer to update
  39833. * @param position defines the position of the viewer
  39834. * @param xaxis defines the x axis of the viewer
  39835. * @param yaxis defines the y axis of the viewer
  39836. * @param zaxis defines the z axis of the viewer
  39837. */
  39838. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39839. /**
  39840. * Creates an instance of this axes viewer.
  39841. * @returns a new axes viewer with instanced meshes
  39842. */
  39843. createInstance(): AxesViewer;
  39844. /** Releases resources */
  39845. dispose(): void;
  39846. private static _SetRenderingGroupId;
  39847. }
  39848. }
  39849. declare module BABYLON.Debug {
  39850. /**
  39851. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39852. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39853. */
  39854. export class BoneAxesViewer extends AxesViewer {
  39855. /**
  39856. * Gets or sets the target mesh where to display the axes viewer
  39857. */
  39858. mesh: Nullable<Mesh>;
  39859. /**
  39860. * Gets or sets the target bone where to display the axes viewer
  39861. */
  39862. bone: Nullable<Bone>;
  39863. /** Gets current position */
  39864. pos: Vector3;
  39865. /** Gets direction of X axis */
  39866. xaxis: Vector3;
  39867. /** Gets direction of Y axis */
  39868. yaxis: Vector3;
  39869. /** Gets direction of Z axis */
  39870. zaxis: Vector3;
  39871. /**
  39872. * Creates a new BoneAxesViewer
  39873. * @param scene defines the hosting scene
  39874. * @param bone defines the target bone
  39875. * @param mesh defines the target mesh
  39876. * @param scaleLines defines a scaling factor for line length (1 by default)
  39877. */
  39878. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39879. /**
  39880. * Force the viewer to update
  39881. */
  39882. update(): void;
  39883. /** Releases resources */
  39884. dispose(): void;
  39885. }
  39886. }
  39887. declare module BABYLON {
  39888. /**
  39889. * Interface used to define scene explorer extensibility option
  39890. */
  39891. export interface IExplorerExtensibilityOption {
  39892. /**
  39893. * Define the option label
  39894. */
  39895. label: string;
  39896. /**
  39897. * Defines the action to execute on click
  39898. */
  39899. action: (entity: any) => void;
  39900. }
  39901. /**
  39902. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39903. */
  39904. export interface IExplorerExtensibilityGroup {
  39905. /**
  39906. * Defines a predicate to test if a given type mut be extended
  39907. */
  39908. predicate: (entity: any) => boolean;
  39909. /**
  39910. * Gets the list of options added to a type
  39911. */
  39912. entries: IExplorerExtensibilityOption[];
  39913. }
  39914. /**
  39915. * Interface used to define the options to use to create the Inspector
  39916. */
  39917. export interface IInspectorOptions {
  39918. /**
  39919. * Display in overlay mode (default: false)
  39920. */
  39921. overlay?: boolean;
  39922. /**
  39923. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39924. */
  39925. globalRoot?: HTMLElement;
  39926. /**
  39927. * Display the Scene explorer
  39928. */
  39929. showExplorer?: boolean;
  39930. /**
  39931. * Display the property inspector
  39932. */
  39933. showInspector?: boolean;
  39934. /**
  39935. * Display in embed mode (both panes on the right)
  39936. */
  39937. embedMode?: boolean;
  39938. /**
  39939. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39940. */
  39941. handleResize?: boolean;
  39942. /**
  39943. * Allow the panes to popup (default: true)
  39944. */
  39945. enablePopup?: boolean;
  39946. /**
  39947. * Allow the panes to be closed by users (default: true)
  39948. */
  39949. enableClose?: boolean;
  39950. /**
  39951. * Optional list of extensibility entries
  39952. */
  39953. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39954. /**
  39955. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  39956. */
  39957. inspectorURL?: string;
  39958. }
  39959. interface Scene {
  39960. /**
  39961. * @hidden
  39962. * Backing field
  39963. */
  39964. _debugLayer: DebugLayer;
  39965. /**
  39966. * Gets the debug layer (aka Inspector) associated with the scene
  39967. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39968. */
  39969. debugLayer: DebugLayer;
  39970. }
  39971. /**
  39972. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39973. * what is happening in your scene
  39974. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39975. */
  39976. export class DebugLayer {
  39977. /**
  39978. * Define the url to get the inspector script from.
  39979. * By default it uses the babylonjs CDN.
  39980. * @ignoreNaming
  39981. */
  39982. static InspectorURL: string;
  39983. private _scene;
  39984. private BJSINSPECTOR;
  39985. /**
  39986. * Observable triggered when a property is changed through the inspector.
  39987. */
  39988. onPropertyChangedObservable: Observable<{
  39989. object: any;
  39990. property: string;
  39991. value: any;
  39992. initialValue: any;
  39993. }>;
  39994. /**
  39995. * Instantiates a new debug layer.
  39996. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39997. * what is happening in your scene
  39998. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39999. * @param scene Defines the scene to inspect
  40000. */
  40001. constructor(scene: Scene);
  40002. /** Creates the inspector window. */
  40003. private _createInspector;
  40004. /**
  40005. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40006. * @param entity defines the entity to select
  40007. * @param lineContainerTitle defines the specific block to highlight
  40008. */
  40009. select(entity: any, lineContainerTitle?: string): void;
  40010. /** Get the inspector from bundle or global */
  40011. private _getGlobalInspector;
  40012. /**
  40013. * Get if the inspector is visible or not.
  40014. * @returns true if visible otherwise, false
  40015. */
  40016. isVisible(): boolean;
  40017. /**
  40018. * Hide the inspector and close its window.
  40019. */
  40020. hide(): void;
  40021. /**
  40022. * Launch the debugLayer.
  40023. * @param config Define the configuration of the inspector
  40024. * @return a promise fulfilled when the debug layer is visible
  40025. */
  40026. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40027. }
  40028. }
  40029. declare module BABYLON {
  40030. /**
  40031. * Class containing static functions to help procedurally build meshes
  40032. */
  40033. export class BoxBuilder {
  40034. /**
  40035. * Creates a box mesh
  40036. * * The parameter `size` sets the size (float) of each box side (default 1)
  40037. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40038. * * 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)
  40039. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40041. * * 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
  40042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40043. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40044. * @param name defines the name of the mesh
  40045. * @param options defines the options used to create the mesh
  40046. * @param scene defines the hosting scene
  40047. * @returns the box mesh
  40048. */
  40049. static CreateBox(name: string, options: {
  40050. size?: number;
  40051. width?: number;
  40052. height?: number;
  40053. depth?: number;
  40054. faceUV?: Vector4[];
  40055. faceColors?: Color4[];
  40056. sideOrientation?: number;
  40057. frontUVs?: Vector4;
  40058. backUVs?: Vector4;
  40059. updatable?: boolean;
  40060. }, scene?: Nullable<Scene>): Mesh;
  40061. }
  40062. }
  40063. declare module BABYLON {
  40064. /**
  40065. * Class containing static functions to help procedurally build meshes
  40066. */
  40067. export class SphereBuilder {
  40068. /**
  40069. * Creates a sphere mesh
  40070. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40071. * * 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`)
  40072. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40073. * * 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
  40074. * * 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)
  40075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40076. * * 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
  40077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40078. * @param name defines the name of the mesh
  40079. * @param options defines the options used to create the mesh
  40080. * @param scene defines the hosting scene
  40081. * @returns the sphere mesh
  40082. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40083. */
  40084. static CreateSphere(name: string, options: {
  40085. segments?: number;
  40086. diameter?: number;
  40087. diameterX?: number;
  40088. diameterY?: number;
  40089. diameterZ?: number;
  40090. arc?: number;
  40091. slice?: number;
  40092. sideOrientation?: number;
  40093. frontUVs?: Vector4;
  40094. backUVs?: Vector4;
  40095. updatable?: boolean;
  40096. }, scene: any): Mesh;
  40097. }
  40098. }
  40099. declare module BABYLON.Debug {
  40100. /**
  40101. * Used to show the physics impostor around the specific mesh
  40102. */
  40103. export class PhysicsViewer {
  40104. /** @hidden */
  40105. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40106. /** @hidden */
  40107. protected _meshes: Array<Nullable<AbstractMesh>>;
  40108. /** @hidden */
  40109. protected _scene: Nullable<Scene>;
  40110. /** @hidden */
  40111. protected _numMeshes: number;
  40112. /** @hidden */
  40113. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40114. private _renderFunction;
  40115. private _utilityLayer;
  40116. private _debugBoxMesh;
  40117. private _debugSphereMesh;
  40118. private _debugMaterial;
  40119. /**
  40120. * Creates a new PhysicsViewer
  40121. * @param scene defines the hosting scene
  40122. */
  40123. constructor(scene: Scene);
  40124. /** @hidden */
  40125. protected _updateDebugMeshes(): void;
  40126. /**
  40127. * Renders a specified physic impostor
  40128. * @param impostor defines the impostor to render
  40129. * @returns the new debug mesh used to render the impostor
  40130. */
  40131. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  40132. /**
  40133. * Hides a specified physic impostor
  40134. * @param impostor defines the impostor to hide
  40135. */
  40136. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40137. private _getDebugMaterial;
  40138. private _getDebugBoxMesh;
  40139. private _getDebugSphereMesh;
  40140. private _getDebugMesh;
  40141. /** Releases all resources */
  40142. dispose(): void;
  40143. }
  40144. }
  40145. declare module BABYLON {
  40146. /**
  40147. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40148. * in order to better appreciate the issue one might have.
  40149. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40150. */
  40151. export class RayHelper {
  40152. /**
  40153. * Defines the ray we are currently tryin to visualize.
  40154. */
  40155. ray: Nullable<Ray>;
  40156. private _renderPoints;
  40157. private _renderLine;
  40158. private _renderFunction;
  40159. private _scene;
  40160. private _updateToMeshFunction;
  40161. private _attachedToMesh;
  40162. private _meshSpaceDirection;
  40163. private _meshSpaceOrigin;
  40164. /**
  40165. * Helper function to create a colored helper in a scene in one line.
  40166. * @param ray Defines the ray we are currently tryin to visualize
  40167. * @param scene Defines the scene the ray is used in
  40168. * @param color Defines the color we want to see the ray in
  40169. * @returns The newly created ray helper.
  40170. */
  40171. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40172. /**
  40173. * Instantiate a new ray helper.
  40174. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40175. * in order to better appreciate the issue one might have.
  40176. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40177. * @param ray Defines the ray we are currently tryin to visualize
  40178. */
  40179. constructor(ray: Ray);
  40180. /**
  40181. * Shows the ray we are willing to debug.
  40182. * @param scene Defines the scene the ray needs to be rendered in
  40183. * @param color Defines the color the ray needs to be rendered in
  40184. */
  40185. show(scene: Scene, color?: Color3): void;
  40186. /**
  40187. * Hides the ray we are debugging.
  40188. */
  40189. hide(): void;
  40190. private _render;
  40191. /**
  40192. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40193. * @param mesh Defines the mesh we want the helper attached to
  40194. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40195. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40196. * @param length Defines the length of the ray
  40197. */
  40198. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40199. /**
  40200. * Detach the ray helper from the mesh it has previously been attached to.
  40201. */
  40202. detachFromMesh(): void;
  40203. private _updateToMesh;
  40204. /**
  40205. * Dispose the helper and release its associated resources.
  40206. */
  40207. dispose(): void;
  40208. }
  40209. }
  40210. declare module BABYLON.Debug {
  40211. /**
  40212. * Class used to render a debug view of a given skeleton
  40213. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40214. */
  40215. export class SkeletonViewer {
  40216. /** defines the skeleton to render */
  40217. skeleton: Skeleton;
  40218. /** defines the mesh attached to the skeleton */
  40219. mesh: AbstractMesh;
  40220. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40221. autoUpdateBonesMatrices: boolean;
  40222. /** defines the rendering group id to use with the viewer */
  40223. renderingGroupId: number;
  40224. /** Gets or sets the color used to render the skeleton */
  40225. color: Color3;
  40226. private _scene;
  40227. private _debugLines;
  40228. private _debugMesh;
  40229. private _isEnabled;
  40230. private _renderFunction;
  40231. private _utilityLayer;
  40232. /**
  40233. * Returns the mesh used to render the bones
  40234. */
  40235. readonly debugMesh: Nullable<LinesMesh>;
  40236. /**
  40237. * Creates a new SkeletonViewer
  40238. * @param skeleton defines the skeleton to render
  40239. * @param mesh defines the mesh attached to the skeleton
  40240. * @param scene defines the hosting scene
  40241. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40242. * @param renderingGroupId defines the rendering group id to use with the viewer
  40243. */
  40244. constructor(
  40245. /** defines the skeleton to render */
  40246. skeleton: Skeleton,
  40247. /** defines the mesh attached to the skeleton */
  40248. mesh: AbstractMesh, scene: Scene,
  40249. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40250. autoUpdateBonesMatrices?: boolean,
  40251. /** defines the rendering group id to use with the viewer */
  40252. renderingGroupId?: number);
  40253. /** Gets or sets a boolean indicating if the viewer is enabled */
  40254. isEnabled: boolean;
  40255. private _getBonePosition;
  40256. private _getLinesForBonesWithLength;
  40257. private _getLinesForBonesNoLength;
  40258. /** Update the viewer to sync with current skeleton state */
  40259. update(): void;
  40260. /** Release associated resources */
  40261. dispose(): void;
  40262. }
  40263. }
  40264. declare module BABYLON {
  40265. /**
  40266. * Options to create the null engine
  40267. */
  40268. export class NullEngineOptions {
  40269. /**
  40270. * Render width (Default: 512)
  40271. */
  40272. renderWidth: number;
  40273. /**
  40274. * Render height (Default: 256)
  40275. */
  40276. renderHeight: number;
  40277. /**
  40278. * Texture size (Default: 512)
  40279. */
  40280. textureSize: number;
  40281. /**
  40282. * If delta time between frames should be constant
  40283. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40284. */
  40285. deterministicLockstep: boolean;
  40286. /**
  40287. * Maximum about of steps between frames (Default: 4)
  40288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40289. */
  40290. lockstepMaxSteps: number;
  40291. }
  40292. /**
  40293. * The null engine class provides support for headless version of babylon.js.
  40294. * This can be used in server side scenario or for testing purposes
  40295. */
  40296. export class NullEngine extends Engine {
  40297. private _options;
  40298. /**
  40299. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40300. */
  40301. isDeterministicLockStep(): boolean;
  40302. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40303. getLockstepMaxSteps(): number;
  40304. /**
  40305. * Sets hardware scaling, used to save performance if needed
  40306. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40307. */
  40308. getHardwareScalingLevel(): number;
  40309. constructor(options?: NullEngineOptions);
  40310. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40311. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40312. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40313. getRenderWidth(useScreen?: boolean): number;
  40314. getRenderHeight(useScreen?: boolean): number;
  40315. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40316. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40317. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40318. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40319. bindSamplers(effect: Effect): void;
  40320. enableEffect(effect: Effect): void;
  40321. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40322. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40323. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40324. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40325. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40326. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40327. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40328. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40329. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40330. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40331. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40332. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40333. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40334. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40335. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40336. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40337. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40338. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40339. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40340. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40341. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40342. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40343. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40344. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40345. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40346. bindBuffers(vertexBuffers: {
  40347. [key: string]: VertexBuffer;
  40348. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40349. wipeCaches(bruteForce?: boolean): void;
  40350. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40351. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40352. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40353. /** @hidden */
  40354. _createTexture(): WebGLTexture;
  40355. /** @hidden */
  40356. _releaseTexture(texture: InternalTexture): void;
  40357. 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;
  40358. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40359. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40360. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40361. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40362. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40363. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40364. areAllEffectsReady(): boolean;
  40365. /**
  40366. * @hidden
  40367. * Get the current error code of the webGL context
  40368. * @returns the error code
  40369. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40370. */
  40371. getError(): number;
  40372. /** @hidden */
  40373. _getUnpackAlignement(): number;
  40374. /** @hidden */
  40375. _unpackFlipY(value: boolean): void;
  40376. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40377. /**
  40378. * Updates a dynamic vertex buffer.
  40379. * @param vertexBuffer the vertex buffer to update
  40380. * @param data the data used to update the vertex buffer
  40381. * @param byteOffset the byte offset of the data (optional)
  40382. * @param byteLength the byte length of the data (optional)
  40383. */
  40384. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40385. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40386. /** @hidden */
  40387. _bindTexture(channel: number, texture: InternalTexture): void;
  40388. /** @hidden */
  40389. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40390. releaseEffects(): void;
  40391. displayLoadingUI(): void;
  40392. hideLoadingUI(): void;
  40393. /** @hidden */
  40394. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40395. /** @hidden */
  40396. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40397. /** @hidden */
  40398. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40399. /** @hidden */
  40400. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40401. }
  40402. }
  40403. declare module BABYLON {
  40404. /** @hidden */
  40405. export class _OcclusionDataStorage {
  40406. /** @hidden */
  40407. occlusionInternalRetryCounter: number;
  40408. /** @hidden */
  40409. isOcclusionQueryInProgress: boolean;
  40410. /** @hidden */
  40411. isOccluded: boolean;
  40412. /** @hidden */
  40413. occlusionRetryCount: number;
  40414. /** @hidden */
  40415. occlusionType: number;
  40416. /** @hidden */
  40417. occlusionQueryAlgorithmType: number;
  40418. }
  40419. interface Engine {
  40420. /**
  40421. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40422. * @return the new query
  40423. */
  40424. createQuery(): WebGLQuery;
  40425. /**
  40426. * Delete and release a webGL query
  40427. * @param query defines the query to delete
  40428. * @return the current engine
  40429. */
  40430. deleteQuery(query: WebGLQuery): Engine;
  40431. /**
  40432. * Check if a given query has resolved and got its value
  40433. * @param query defines the query to check
  40434. * @returns true if the query got its value
  40435. */
  40436. isQueryResultAvailable(query: WebGLQuery): boolean;
  40437. /**
  40438. * Gets the value of a given query
  40439. * @param query defines the query to check
  40440. * @returns the value of the query
  40441. */
  40442. getQueryResult(query: WebGLQuery): number;
  40443. /**
  40444. * Initiates an occlusion query
  40445. * @param algorithmType defines the algorithm to use
  40446. * @param query defines the query to use
  40447. * @returns the current engine
  40448. * @see http://doc.babylonjs.com/features/occlusionquery
  40449. */
  40450. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40451. /**
  40452. * Ends an occlusion query
  40453. * @see http://doc.babylonjs.com/features/occlusionquery
  40454. * @param algorithmType defines the algorithm to use
  40455. * @returns the current engine
  40456. */
  40457. endOcclusionQuery(algorithmType: number): Engine;
  40458. /**
  40459. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40460. * Please note that only one query can be issued at a time
  40461. * @returns a time token used to track the time span
  40462. */
  40463. startTimeQuery(): Nullable<_TimeToken>;
  40464. /**
  40465. * Ends a time query
  40466. * @param token defines the token used to measure the time span
  40467. * @returns the time spent (in ns)
  40468. */
  40469. endTimeQuery(token: _TimeToken): int;
  40470. /** @hidden */
  40471. _currentNonTimestampToken: Nullable<_TimeToken>;
  40472. /** @hidden */
  40473. _createTimeQuery(): WebGLQuery;
  40474. /** @hidden */
  40475. _deleteTimeQuery(query: WebGLQuery): void;
  40476. /** @hidden */
  40477. _getGlAlgorithmType(algorithmType: number): number;
  40478. /** @hidden */
  40479. _getTimeQueryResult(query: WebGLQuery): any;
  40480. /** @hidden */
  40481. _getTimeQueryAvailability(query: WebGLQuery): any;
  40482. }
  40483. interface AbstractMesh {
  40484. /**
  40485. * Backing filed
  40486. * @hidden
  40487. */
  40488. __occlusionDataStorage: _OcclusionDataStorage;
  40489. /**
  40490. * Access property
  40491. * @hidden
  40492. */
  40493. _occlusionDataStorage: _OcclusionDataStorage;
  40494. /**
  40495. * 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.
  40496. * The default value is -1 which means don't break the query and wait till the result
  40497. * @see http://doc.babylonjs.com/features/occlusionquery
  40498. */
  40499. occlusionRetryCount: number;
  40500. /**
  40501. * 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:
  40502. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40503. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40504. * * 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.
  40505. * @see http://doc.babylonjs.com/features/occlusionquery
  40506. */
  40507. occlusionType: number;
  40508. /**
  40509. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40510. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40511. * * 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.
  40512. * @see http://doc.babylonjs.com/features/occlusionquery
  40513. */
  40514. occlusionQueryAlgorithmType: number;
  40515. /**
  40516. * 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
  40517. * @see http://doc.babylonjs.com/features/occlusionquery
  40518. */
  40519. isOccluded: boolean;
  40520. /**
  40521. * Flag to check the progress status of the query
  40522. * @see http://doc.babylonjs.com/features/occlusionquery
  40523. */
  40524. isOcclusionQueryInProgress: boolean;
  40525. }
  40526. }
  40527. declare module BABYLON {
  40528. /** @hidden */
  40529. export var _forceTransformFeedbackToBundle: boolean;
  40530. interface Engine {
  40531. /**
  40532. * Creates a webGL transform feedback object
  40533. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40534. * @returns the webGL transform feedback object
  40535. */
  40536. createTransformFeedback(): WebGLTransformFeedback;
  40537. /**
  40538. * Delete a webGL transform feedback object
  40539. * @param value defines the webGL transform feedback object to delete
  40540. */
  40541. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40542. /**
  40543. * Bind a webGL transform feedback object to the webgl context
  40544. * @param value defines the webGL transform feedback object to bind
  40545. */
  40546. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40547. /**
  40548. * Begins a transform feedback operation
  40549. * @param usePoints defines if points or triangles must be used
  40550. */
  40551. beginTransformFeedback(usePoints: boolean): void;
  40552. /**
  40553. * Ends a transform feedback operation
  40554. */
  40555. endTransformFeedback(): void;
  40556. /**
  40557. * Specify the varyings to use with transform feedback
  40558. * @param program defines the associated webGL program
  40559. * @param value defines the list of strings representing the varying names
  40560. */
  40561. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40562. /**
  40563. * Bind a webGL buffer for a transform feedback operation
  40564. * @param value defines the webGL buffer to bind
  40565. */
  40566. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40567. }
  40568. }
  40569. declare module BABYLON {
  40570. /**
  40571. * Gather the list of clipboard event types as constants.
  40572. */
  40573. export class ClipboardEventTypes {
  40574. /**
  40575. * The clipboard event is fired when a copy command is active (pressed).
  40576. */
  40577. static readonly COPY: number;
  40578. /**
  40579. * The clipboard event is fired when a cut command is active (pressed).
  40580. */
  40581. static readonly CUT: number;
  40582. /**
  40583. * The clipboard event is fired when a paste command is active (pressed).
  40584. */
  40585. static readonly PASTE: number;
  40586. }
  40587. /**
  40588. * This class is used to store clipboard related info for the onClipboardObservable event.
  40589. */
  40590. export class ClipboardInfo {
  40591. /**
  40592. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40593. */
  40594. type: number;
  40595. /**
  40596. * Defines the related dom event
  40597. */
  40598. event: ClipboardEvent;
  40599. /**
  40600. *Creates an instance of ClipboardInfo.
  40601. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40602. * @param event Defines the related dom event
  40603. */
  40604. constructor(
  40605. /**
  40606. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40607. */
  40608. type: number,
  40609. /**
  40610. * Defines the related dom event
  40611. */
  40612. event: ClipboardEvent);
  40613. /**
  40614. * Get the clipboard event's type from the keycode.
  40615. * @param keyCode Defines the keyCode for the current keyboard event.
  40616. * @return {number}
  40617. */
  40618. static GetTypeFromCharacter(keyCode: number): number;
  40619. }
  40620. }
  40621. declare module BABYLON {
  40622. /**
  40623. * Class used to represent data loading progression
  40624. */
  40625. export class SceneLoaderProgressEvent {
  40626. /** defines if data length to load can be evaluated */
  40627. readonly lengthComputable: boolean;
  40628. /** defines the loaded data length */
  40629. readonly loaded: number;
  40630. /** defines the data length to load */
  40631. readonly total: number;
  40632. /**
  40633. * Create a new progress event
  40634. * @param lengthComputable defines if data length to load can be evaluated
  40635. * @param loaded defines the loaded data length
  40636. * @param total defines the data length to load
  40637. */
  40638. constructor(
  40639. /** defines if data length to load can be evaluated */
  40640. lengthComputable: boolean,
  40641. /** defines the loaded data length */
  40642. loaded: number,
  40643. /** defines the data length to load */
  40644. total: number);
  40645. /**
  40646. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40647. * @param event defines the source event
  40648. * @returns a new SceneLoaderProgressEvent
  40649. */
  40650. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40651. }
  40652. /**
  40653. * Interface used by SceneLoader plugins to define supported file extensions
  40654. */
  40655. export interface ISceneLoaderPluginExtensions {
  40656. /**
  40657. * Defines the list of supported extensions
  40658. */
  40659. [extension: string]: {
  40660. isBinary: boolean;
  40661. };
  40662. }
  40663. /**
  40664. * Interface used by SceneLoader plugin factory
  40665. */
  40666. export interface ISceneLoaderPluginFactory {
  40667. /**
  40668. * Defines the name of the factory
  40669. */
  40670. name: string;
  40671. /**
  40672. * Function called to create a new plugin
  40673. * @return the new plugin
  40674. */
  40675. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40676. /**
  40677. * Boolean indicating if the plugin can direct load specific data
  40678. */
  40679. canDirectLoad?: (data: string) => boolean;
  40680. }
  40681. /**
  40682. * Interface used to define a SceneLoader plugin
  40683. */
  40684. export interface ISceneLoaderPlugin {
  40685. /**
  40686. * The friendly name of this plugin.
  40687. */
  40688. name: string;
  40689. /**
  40690. * The file extensions supported by this plugin.
  40691. */
  40692. extensions: string | ISceneLoaderPluginExtensions;
  40693. /**
  40694. * Import meshes into a scene.
  40695. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40696. * @param scene The scene to import into
  40697. * @param data The data to import
  40698. * @param rootUrl The root url for scene and resources
  40699. * @param meshes The meshes array to import into
  40700. * @param particleSystems The particle systems array to import into
  40701. * @param skeletons The skeletons array to import into
  40702. * @param onError The callback when import fails
  40703. * @returns True if successful or false otherwise
  40704. */
  40705. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40706. /**
  40707. * Load into a scene.
  40708. * @param scene The scene to load into
  40709. * @param data The data to import
  40710. * @param rootUrl The root url for scene and resources
  40711. * @param onError The callback when import fails
  40712. * @returns true if successful or false otherwise
  40713. */
  40714. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40715. /**
  40716. * The callback that returns true if the data can be directly loaded.
  40717. */
  40718. canDirectLoad?: (data: string) => boolean;
  40719. /**
  40720. * The callback that allows custom handling of the root url based on the response url.
  40721. */
  40722. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40723. /**
  40724. * Load into an asset container.
  40725. * @param scene The scene to load into
  40726. * @param data The data to import
  40727. * @param rootUrl The root url for scene and resources
  40728. * @param onError The callback when import fails
  40729. * @returns The loaded asset container
  40730. */
  40731. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40732. }
  40733. /**
  40734. * Interface used to define an async SceneLoader plugin
  40735. */
  40736. export interface ISceneLoaderPluginAsync {
  40737. /**
  40738. * The friendly name of this plugin.
  40739. */
  40740. name: string;
  40741. /**
  40742. * The file extensions supported by this plugin.
  40743. */
  40744. extensions: string | ISceneLoaderPluginExtensions;
  40745. /**
  40746. * Import meshes into a scene.
  40747. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40748. * @param scene The scene to import into
  40749. * @param data The data to import
  40750. * @param rootUrl The root url for scene and resources
  40751. * @param onProgress The callback when the load progresses
  40752. * @param fileName Defines the name of the file to load
  40753. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40754. */
  40755. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40756. meshes: AbstractMesh[];
  40757. particleSystems: IParticleSystem[];
  40758. skeletons: Skeleton[];
  40759. animationGroups: AnimationGroup[];
  40760. }>;
  40761. /**
  40762. * Load into a scene.
  40763. * @param scene The scene to load into
  40764. * @param data The data to import
  40765. * @param rootUrl The root url for scene and resources
  40766. * @param onProgress The callback when the load progresses
  40767. * @param fileName Defines the name of the file to load
  40768. * @returns Nothing
  40769. */
  40770. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40771. /**
  40772. * The callback that returns true if the data can be directly loaded.
  40773. */
  40774. canDirectLoad?: (data: string) => boolean;
  40775. /**
  40776. * The callback that allows custom handling of the root url based on the response url.
  40777. */
  40778. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40779. /**
  40780. * Load into an asset container.
  40781. * @param scene The scene to load into
  40782. * @param data The data to import
  40783. * @param rootUrl The root url for scene and resources
  40784. * @param onProgress The callback when the load progresses
  40785. * @param fileName Defines the name of the file to load
  40786. * @returns The loaded asset container
  40787. */
  40788. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40789. }
  40790. /**
  40791. * Class used to load scene from various file formats using registered plugins
  40792. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40793. */
  40794. export class SceneLoader {
  40795. /**
  40796. * No logging while loading
  40797. */
  40798. static readonly NO_LOGGING: number;
  40799. /**
  40800. * Minimal logging while loading
  40801. */
  40802. static readonly MINIMAL_LOGGING: number;
  40803. /**
  40804. * Summary logging while loading
  40805. */
  40806. static readonly SUMMARY_LOGGING: number;
  40807. /**
  40808. * Detailled logging while loading
  40809. */
  40810. static readonly DETAILED_LOGGING: number;
  40811. /**
  40812. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40813. */
  40814. static ForceFullSceneLoadingForIncremental: boolean;
  40815. /**
  40816. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40817. */
  40818. static ShowLoadingScreen: boolean;
  40819. /**
  40820. * Defines the current logging level (while loading the scene)
  40821. * @ignorenaming
  40822. */
  40823. static loggingLevel: number;
  40824. /**
  40825. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40826. */
  40827. static CleanBoneMatrixWeights: boolean;
  40828. /**
  40829. * Event raised when a plugin is used to load a scene
  40830. */
  40831. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40832. private static _registeredPlugins;
  40833. private static _getDefaultPlugin;
  40834. private static _getPluginForExtension;
  40835. private static _getPluginForDirectLoad;
  40836. private static _getPluginForFilename;
  40837. private static _getDirectLoad;
  40838. private static _loadData;
  40839. private static _getFileInfo;
  40840. /**
  40841. * Gets a plugin that can load the given extension
  40842. * @param extension defines the extension to load
  40843. * @returns a plugin or null if none works
  40844. */
  40845. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40846. /**
  40847. * Gets a boolean indicating that the given extension can be loaded
  40848. * @param extension defines the extension to load
  40849. * @returns true if the extension is supported
  40850. */
  40851. static IsPluginForExtensionAvailable(extension: string): boolean;
  40852. /**
  40853. * Adds a new plugin to the list of registered plugins
  40854. * @param plugin defines the plugin to add
  40855. */
  40856. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40857. /**
  40858. * Import meshes into a scene
  40859. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40860. * @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)
  40861. * @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)
  40862. * @param scene the instance of BABYLON.Scene to append to
  40863. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40864. * @param onProgress a callback with a progress event for each file being loaded
  40865. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40866. * @param pluginExtension the extension used to determine the plugin
  40867. * @returns The loaded plugin
  40868. */
  40869. 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>;
  40870. /**
  40871. * Import meshes into a scene
  40872. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40873. * @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)
  40874. * @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)
  40875. * @param scene the instance of BABYLON.Scene to append to
  40876. * @param onProgress a callback with a progress event for each file being loaded
  40877. * @param pluginExtension the extension used to determine the plugin
  40878. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40879. */
  40880. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40881. meshes: AbstractMesh[];
  40882. particleSystems: IParticleSystem[];
  40883. skeletons: Skeleton[];
  40884. animationGroups: AnimationGroup[];
  40885. }>;
  40886. /**
  40887. * Load a scene
  40888. * @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)
  40889. * @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)
  40890. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40891. * @param onSuccess a callback with the scene when import succeeds
  40892. * @param onProgress a callback with a progress event for each file being loaded
  40893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40894. * @param pluginExtension the extension used to determine the plugin
  40895. * @returns The loaded plugin
  40896. */
  40897. 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>;
  40898. /**
  40899. * Load a scene
  40900. * @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)
  40901. * @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)
  40902. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40903. * @param onProgress a callback with a progress event for each file being loaded
  40904. * @param pluginExtension the extension used to determine the plugin
  40905. * @returns The loaded scene
  40906. */
  40907. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40908. /**
  40909. * Append a scene
  40910. * @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)
  40911. * @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)
  40912. * @param scene is the instance of BABYLON.Scene to append to
  40913. * @param onSuccess a callback with the scene when import succeeds
  40914. * @param onProgress a callback with a progress event for each file being loaded
  40915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40916. * @param pluginExtension the extension used to determine the plugin
  40917. * @returns The loaded plugin
  40918. */
  40919. 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>;
  40920. /**
  40921. * Append a scene
  40922. * @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)
  40923. * @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)
  40924. * @param scene is the instance of BABYLON.Scene to append to
  40925. * @param onProgress a callback with a progress event for each file being loaded
  40926. * @param pluginExtension the extension used to determine the plugin
  40927. * @returns The given scene
  40928. */
  40929. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40930. /**
  40931. * Load a scene into an asset container
  40932. * @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)
  40933. * @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)
  40934. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40935. * @param onSuccess a callback with the scene when import succeeds
  40936. * @param onProgress a callback with a progress event for each file being loaded
  40937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40938. * @param pluginExtension the extension used to determine the plugin
  40939. * @returns The loaded plugin
  40940. */
  40941. 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>;
  40942. /**
  40943. * Load a scene into an asset container
  40944. * @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)
  40945. * @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)
  40946. * @param scene is the instance of Scene to append to
  40947. * @param onProgress a callback with a progress event for each file being loaded
  40948. * @param pluginExtension the extension used to determine the plugin
  40949. * @returns The loaded asset container
  40950. */
  40951. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40952. }
  40953. }
  40954. declare module BABYLON {
  40955. /**
  40956. * Google Daydream controller
  40957. */
  40958. export class DaydreamController extends WebVRController {
  40959. /**
  40960. * Base Url for the controller model.
  40961. */
  40962. static MODEL_BASE_URL: string;
  40963. /**
  40964. * File name for the controller model.
  40965. */
  40966. static MODEL_FILENAME: string;
  40967. /**
  40968. * Gamepad Id prefix used to identify Daydream Controller.
  40969. */
  40970. static readonly GAMEPAD_ID_PREFIX: string;
  40971. /**
  40972. * Creates a new DaydreamController from a gamepad
  40973. * @param vrGamepad the gamepad that the controller should be created from
  40974. */
  40975. constructor(vrGamepad: any);
  40976. /**
  40977. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40978. * @param scene scene in which to add meshes
  40979. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40980. */
  40981. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40982. /**
  40983. * Called once for each button that changed state since the last frame
  40984. * @param buttonIdx Which button index changed
  40985. * @param state New state of the button
  40986. * @param changes Which properties on the state changed since last frame
  40987. */
  40988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40989. }
  40990. }
  40991. declare module BABYLON {
  40992. /**
  40993. * Gear VR Controller
  40994. */
  40995. export class GearVRController extends WebVRController {
  40996. /**
  40997. * Base Url for the controller model.
  40998. */
  40999. static MODEL_BASE_URL: string;
  41000. /**
  41001. * File name for the controller model.
  41002. */
  41003. static MODEL_FILENAME: string;
  41004. /**
  41005. * Gamepad Id prefix used to identify this controller.
  41006. */
  41007. static readonly GAMEPAD_ID_PREFIX: string;
  41008. private readonly _buttonIndexToObservableNameMap;
  41009. /**
  41010. * Creates a new GearVRController from a gamepad
  41011. * @param vrGamepad the gamepad that the controller should be created from
  41012. */
  41013. constructor(vrGamepad: any);
  41014. /**
  41015. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41016. * @param scene scene in which to add meshes
  41017. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41018. */
  41019. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41020. /**
  41021. * Called once for each button that changed state since the last frame
  41022. * @param buttonIdx Which button index changed
  41023. * @param state New state of the button
  41024. * @param changes Which properties on the state changed since last frame
  41025. */
  41026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41027. }
  41028. }
  41029. declare module BABYLON {
  41030. /**
  41031. * Generic Controller
  41032. */
  41033. export class GenericController extends WebVRController {
  41034. /**
  41035. * Base Url for the controller model.
  41036. */
  41037. static readonly MODEL_BASE_URL: string;
  41038. /**
  41039. * File name for the controller model.
  41040. */
  41041. static readonly MODEL_FILENAME: string;
  41042. /**
  41043. * Creates a new GenericController from a gamepad
  41044. * @param vrGamepad the gamepad that the controller should be created from
  41045. */
  41046. constructor(vrGamepad: any);
  41047. /**
  41048. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41049. * @param scene scene in which to add meshes
  41050. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41051. */
  41052. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41053. /**
  41054. * Called once for each button that changed state since the last frame
  41055. * @param buttonIdx Which button index changed
  41056. * @param state New state of the button
  41057. * @param changes Which properties on the state changed since last frame
  41058. */
  41059. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41060. }
  41061. }
  41062. declare module BABYLON {
  41063. /**
  41064. * Oculus Touch Controller
  41065. */
  41066. export class OculusTouchController extends WebVRController {
  41067. /**
  41068. * Base Url for the controller model.
  41069. */
  41070. static MODEL_BASE_URL: string;
  41071. /**
  41072. * File name for the left controller model.
  41073. */
  41074. static MODEL_LEFT_FILENAME: string;
  41075. /**
  41076. * File name for the right controller model.
  41077. */
  41078. static MODEL_RIGHT_FILENAME: string;
  41079. /**
  41080. * Fired when the secondary trigger on this controller is modified
  41081. */
  41082. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41083. /**
  41084. * Fired when the thumb rest on this controller is modified
  41085. */
  41086. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41087. /**
  41088. * Creates a new OculusTouchController from a gamepad
  41089. * @param vrGamepad the gamepad that the controller should be created from
  41090. */
  41091. constructor(vrGamepad: any);
  41092. /**
  41093. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41094. * @param scene scene in which to add meshes
  41095. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41096. */
  41097. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41098. /**
  41099. * Fired when the A button on this controller is modified
  41100. */
  41101. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41102. /**
  41103. * Fired when the B button on this controller is modified
  41104. */
  41105. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41106. /**
  41107. * Fired when the X button on this controller is modified
  41108. */
  41109. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41110. /**
  41111. * Fired when the Y button on this controller is modified
  41112. */
  41113. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41114. /**
  41115. * Called once for each button that changed state since the last frame
  41116. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41117. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41118. * 2) secondary trigger (same)
  41119. * 3) A (right) X (left), touch, pressed = value
  41120. * 4) B / Y
  41121. * 5) thumb rest
  41122. * @param buttonIdx Which button index changed
  41123. * @param state New state of the button
  41124. * @param changes Which properties on the state changed since last frame
  41125. */
  41126. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41127. }
  41128. }
  41129. declare module BABYLON {
  41130. /**
  41131. * Vive Controller
  41132. */
  41133. export class ViveController extends WebVRController {
  41134. /**
  41135. * Base Url for the controller model.
  41136. */
  41137. static MODEL_BASE_URL: string;
  41138. /**
  41139. * File name for the controller model.
  41140. */
  41141. static MODEL_FILENAME: string;
  41142. /**
  41143. * Creates a new ViveController from a gamepad
  41144. * @param vrGamepad the gamepad that the controller should be created from
  41145. */
  41146. constructor(vrGamepad: any);
  41147. /**
  41148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41149. * @param scene scene in which to add meshes
  41150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41151. */
  41152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41153. /**
  41154. * Fired when the left button on this controller is modified
  41155. */
  41156. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41157. /**
  41158. * Fired when the right button on this controller is modified
  41159. */
  41160. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41161. /**
  41162. * Fired when the menu button on this controller is modified
  41163. */
  41164. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41165. /**
  41166. * Called once for each button that changed state since the last frame
  41167. * Vive mapping:
  41168. * 0: touchpad
  41169. * 1: trigger
  41170. * 2: left AND right buttons
  41171. * 3: menu button
  41172. * @param buttonIdx Which button index changed
  41173. * @param state New state of the button
  41174. * @param changes Which properties on the state changed since last frame
  41175. */
  41176. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41177. }
  41178. }
  41179. declare module BABYLON {
  41180. /**
  41181. * Defines the WindowsMotionController object that the state of the windows motion controller
  41182. */
  41183. export class WindowsMotionController extends WebVRController {
  41184. /**
  41185. * The base url used to load the left and right controller models
  41186. */
  41187. static MODEL_BASE_URL: string;
  41188. /**
  41189. * The name of the left controller model file
  41190. */
  41191. static MODEL_LEFT_FILENAME: string;
  41192. /**
  41193. * The name of the right controller model file
  41194. */
  41195. static MODEL_RIGHT_FILENAME: string;
  41196. /**
  41197. * The controller name prefix for this controller type
  41198. */
  41199. static readonly GAMEPAD_ID_PREFIX: string;
  41200. /**
  41201. * The controller id pattern for this controller type
  41202. */
  41203. private static readonly GAMEPAD_ID_PATTERN;
  41204. private _loadedMeshInfo;
  41205. private readonly _mapping;
  41206. /**
  41207. * Fired when the trackpad on this controller is clicked
  41208. */
  41209. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41210. /**
  41211. * Fired when the trackpad on this controller is modified
  41212. */
  41213. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41214. /**
  41215. * The current x and y values of this controller's trackpad
  41216. */
  41217. trackpad: StickValues;
  41218. /**
  41219. * Creates a new WindowsMotionController from a gamepad
  41220. * @param vrGamepad the gamepad that the controller should be created from
  41221. */
  41222. constructor(vrGamepad: any);
  41223. /**
  41224. * Fired when the trigger on this controller is modified
  41225. */
  41226. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41227. /**
  41228. * Fired when the menu button on this controller is modified
  41229. */
  41230. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41231. /**
  41232. * Fired when the grip button on this controller is modified
  41233. */
  41234. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41235. /**
  41236. * Fired when the thumbstick button on this controller is modified
  41237. */
  41238. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41239. /**
  41240. * Fired when the touchpad button on this controller is modified
  41241. */
  41242. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41243. /**
  41244. * Fired when the touchpad values on this controller are modified
  41245. */
  41246. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41247. private _updateTrackpad;
  41248. /**
  41249. * Called once per frame by the engine.
  41250. */
  41251. update(): void;
  41252. /**
  41253. * Called once for each button that changed state since the last frame
  41254. * @param buttonIdx Which button index changed
  41255. * @param state New state of the button
  41256. * @param changes Which properties on the state changed since last frame
  41257. */
  41258. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41259. /**
  41260. * Moves the buttons on the controller mesh based on their current state
  41261. * @param buttonName the name of the button to move
  41262. * @param buttonValue the value of the button which determines the buttons new position
  41263. */
  41264. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41265. /**
  41266. * Moves the axis on the controller mesh based on its current state
  41267. * @param axis the index of the axis
  41268. * @param axisValue the value of the axis which determines the meshes new position
  41269. * @hidden
  41270. */
  41271. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41272. /**
  41273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41274. * @param scene scene in which to add meshes
  41275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41276. */
  41277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41278. /**
  41279. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41280. * can be transformed by button presses and axes values, based on this._mapping.
  41281. *
  41282. * @param scene scene in which the meshes exist
  41283. * @param meshes list of meshes that make up the controller model to process
  41284. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41285. */
  41286. private processModel;
  41287. private createMeshInfo;
  41288. /**
  41289. * Gets the ray of the controller in the direction the controller is pointing
  41290. * @param length the length the resulting ray should be
  41291. * @returns a ray in the direction the controller is pointing
  41292. */
  41293. getForwardRay(length?: number): Ray;
  41294. /**
  41295. * Disposes of the controller
  41296. */
  41297. dispose(): void;
  41298. }
  41299. }
  41300. declare module BABYLON {
  41301. /**
  41302. * Single axis scale gizmo
  41303. */
  41304. export class AxisScaleGizmo extends Gizmo {
  41305. private _coloredMaterial;
  41306. /**
  41307. * Drag behavior responsible for the gizmos dragging interactions
  41308. */
  41309. dragBehavior: PointerDragBehavior;
  41310. private _pointerObserver;
  41311. /**
  41312. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41313. */
  41314. snapDistance: number;
  41315. /**
  41316. * Event that fires each time the gizmo snaps to a new location.
  41317. * * snapDistance is the the change in distance
  41318. */
  41319. onSnapObservable: Observable<{
  41320. snapDistance: number;
  41321. }>;
  41322. /**
  41323. * If the scaling operation should be done on all axis (default: false)
  41324. */
  41325. uniformScaling: boolean;
  41326. /**
  41327. * Creates an AxisScaleGizmo
  41328. * @param gizmoLayer The utility layer the gizmo will be added to
  41329. * @param dragAxis The axis which the gizmo will be able to scale on
  41330. * @param color The color of the gizmo
  41331. */
  41332. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41333. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41334. /**
  41335. * Disposes of the gizmo
  41336. */
  41337. dispose(): void;
  41338. /**
  41339. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41340. * @param mesh The mesh to replace the default mesh of the gizmo
  41341. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41342. */
  41343. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41344. }
  41345. }
  41346. declare module BABYLON {
  41347. /**
  41348. * Bounding box gizmo
  41349. */
  41350. export class BoundingBoxGizmo extends Gizmo {
  41351. private _lineBoundingBox;
  41352. private _rotateSpheresParent;
  41353. private _scaleBoxesParent;
  41354. private _boundingDimensions;
  41355. private _renderObserver;
  41356. private _pointerObserver;
  41357. private _scaleDragSpeed;
  41358. private _tmpQuaternion;
  41359. private _tmpVector;
  41360. private _tmpRotationMatrix;
  41361. /**
  41362. * 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)
  41363. */
  41364. ignoreChildren: boolean;
  41365. /**
  41366. * 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)
  41367. */
  41368. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41369. /**
  41370. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41371. */
  41372. rotationSphereSize: number;
  41373. /**
  41374. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41375. */
  41376. scaleBoxSize: number;
  41377. /**
  41378. * 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)
  41379. */
  41380. fixedDragMeshScreenSize: boolean;
  41381. /**
  41382. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41383. */
  41384. fixedDragMeshScreenSizeDistanceFactor: number;
  41385. /**
  41386. * Fired when a rotation sphere or scale box is dragged
  41387. */
  41388. onDragStartObservable: Observable<{}>;
  41389. /**
  41390. * Fired when a scale box is dragged
  41391. */
  41392. onScaleBoxDragObservable: Observable<{}>;
  41393. /**
  41394. * Fired when a scale box drag is ended
  41395. */
  41396. onScaleBoxDragEndObservable: Observable<{}>;
  41397. /**
  41398. * Fired when a rotation sphere is dragged
  41399. */
  41400. onRotationSphereDragObservable: Observable<{}>;
  41401. /**
  41402. * Fired when a rotation sphere drag is ended
  41403. */
  41404. onRotationSphereDragEndObservable: Observable<{}>;
  41405. /**
  41406. * 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)
  41407. */
  41408. scalePivot: Nullable<Vector3>;
  41409. private _anchorMesh;
  41410. private _existingMeshScale;
  41411. private _dragMesh;
  41412. private pointerDragBehavior;
  41413. private coloredMaterial;
  41414. private hoverColoredMaterial;
  41415. /**
  41416. * Sets the color of the bounding box gizmo
  41417. * @param color the color to set
  41418. */
  41419. setColor(color: Color3): void;
  41420. /**
  41421. * Creates an BoundingBoxGizmo
  41422. * @param gizmoLayer The utility layer the gizmo will be added to
  41423. * @param color The color of the gizmo
  41424. */
  41425. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41427. private _selectNode;
  41428. /**
  41429. * Updates the bounding box information for the Gizmo
  41430. */
  41431. updateBoundingBox(): void;
  41432. private _updateRotationSpheres;
  41433. private _updateScaleBoxes;
  41434. /**
  41435. * Enables rotation on the specified axis and disables rotation on the others
  41436. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41437. */
  41438. setEnabledRotationAxis(axis: string): void;
  41439. /**
  41440. * Enables/disables scaling
  41441. * @param enable if scaling should be enabled
  41442. */
  41443. setEnabledScaling(enable: boolean): void;
  41444. private _updateDummy;
  41445. /**
  41446. * Enables a pointer drag behavior on the bounding box of the gizmo
  41447. */
  41448. enableDragBehavior(): void;
  41449. /**
  41450. * Disposes of the gizmo
  41451. */
  41452. dispose(): void;
  41453. /**
  41454. * 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)
  41455. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41456. * @returns the bounding box mesh with the passed in mesh as a child
  41457. */
  41458. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41459. /**
  41460. * CustomMeshes are not supported by this gizmo
  41461. * @param mesh The mesh to replace the default mesh of the gizmo
  41462. */
  41463. setCustomMesh(mesh: Mesh): void;
  41464. }
  41465. }
  41466. declare module BABYLON {
  41467. /**
  41468. * Single plane rotation gizmo
  41469. */
  41470. export class PlaneRotationGizmo extends Gizmo {
  41471. /**
  41472. * Drag behavior responsible for the gizmos dragging interactions
  41473. */
  41474. dragBehavior: PointerDragBehavior;
  41475. private _pointerObserver;
  41476. /**
  41477. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41478. */
  41479. snapDistance: number;
  41480. /**
  41481. * Event that fires each time the gizmo snaps to a new location.
  41482. * * snapDistance is the the change in distance
  41483. */
  41484. onSnapObservable: Observable<{
  41485. snapDistance: number;
  41486. }>;
  41487. /**
  41488. * Creates a PlaneRotationGizmo
  41489. * @param gizmoLayer The utility layer the gizmo will be added to
  41490. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41491. * @param color The color of the gizmo
  41492. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41493. */
  41494. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41495. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41496. /**
  41497. * Disposes of the gizmo
  41498. */
  41499. dispose(): void;
  41500. }
  41501. }
  41502. declare module BABYLON {
  41503. /**
  41504. * Gizmo that enables rotating a mesh along 3 axis
  41505. */
  41506. export class RotationGizmo extends Gizmo {
  41507. /**
  41508. * Internal gizmo used for interactions on the x axis
  41509. */
  41510. xGizmo: PlaneRotationGizmo;
  41511. /**
  41512. * Internal gizmo used for interactions on the y axis
  41513. */
  41514. yGizmo: PlaneRotationGizmo;
  41515. /**
  41516. * Internal gizmo used for interactions on the z axis
  41517. */
  41518. zGizmo: PlaneRotationGizmo;
  41519. /** Fires an event when any of it's sub gizmos are dragged */
  41520. onDragStartObservable: Observable<{}>;
  41521. /** Fires an event when any of it's sub gizmos are released from dragging */
  41522. onDragEndObservable: Observable<{}>;
  41523. attachedMesh: Nullable<AbstractMesh>;
  41524. /**
  41525. * Creates a RotationGizmo
  41526. * @param gizmoLayer The utility layer the gizmo will be added to
  41527. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41528. */
  41529. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41530. updateGizmoRotationToMatchAttachedMesh: boolean;
  41531. /**
  41532. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41533. */
  41534. snapDistance: number;
  41535. /**
  41536. * Ratio for the scale of the gizmo (Default: 1)
  41537. */
  41538. scaleRatio: number;
  41539. /**
  41540. * Disposes of the gizmo
  41541. */
  41542. dispose(): void;
  41543. /**
  41544. * CustomMeshes are not supported by this gizmo
  41545. * @param mesh The mesh to replace the default mesh of the gizmo
  41546. */
  41547. setCustomMesh(mesh: Mesh): void;
  41548. }
  41549. }
  41550. declare module BABYLON {
  41551. /**
  41552. * Gizmo that enables dragging a mesh along 3 axis
  41553. */
  41554. export class PositionGizmo extends Gizmo {
  41555. /**
  41556. * Internal gizmo used for interactions on the x axis
  41557. */
  41558. xGizmo: AxisDragGizmo;
  41559. /**
  41560. * Internal gizmo used for interactions on the y axis
  41561. */
  41562. yGizmo: AxisDragGizmo;
  41563. /**
  41564. * Internal gizmo used for interactions on the z axis
  41565. */
  41566. zGizmo: AxisDragGizmo;
  41567. /** Fires an event when any of it's sub gizmos are dragged */
  41568. onDragStartObservable: Observable<{}>;
  41569. /** Fires an event when any of it's sub gizmos are released from dragging */
  41570. onDragEndObservable: Observable<{}>;
  41571. attachedMesh: Nullable<AbstractMesh>;
  41572. /**
  41573. * Creates a PositionGizmo
  41574. * @param gizmoLayer The utility layer the gizmo will be added to
  41575. */
  41576. constructor(gizmoLayer?: UtilityLayerRenderer);
  41577. updateGizmoRotationToMatchAttachedMesh: boolean;
  41578. /**
  41579. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41580. */
  41581. snapDistance: number;
  41582. /**
  41583. * Ratio for the scale of the gizmo (Default: 1)
  41584. */
  41585. scaleRatio: number;
  41586. /**
  41587. * Disposes of the gizmo
  41588. */
  41589. dispose(): void;
  41590. /**
  41591. * CustomMeshes are not supported by this gizmo
  41592. * @param mesh The mesh to replace the default mesh of the gizmo
  41593. */
  41594. setCustomMesh(mesh: Mesh): void;
  41595. }
  41596. }
  41597. declare module BABYLON {
  41598. /**
  41599. * Class containing static functions to help procedurally build meshes
  41600. */
  41601. export class PolyhedronBuilder {
  41602. /**
  41603. * Creates a polyhedron mesh
  41604. * * 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
  41605. * * The parameter `size` (positive float, default 1) sets the polygon size
  41606. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41607. * * 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`
  41608. * * 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
  41609. * * 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)`)
  41610. * * 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
  41611. * * 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
  41612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41613. * * 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
  41614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41615. * @param name defines the name of the mesh
  41616. * @param options defines the options used to create the mesh
  41617. * @param scene defines the hosting scene
  41618. * @returns the polyhedron mesh
  41619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41620. */
  41621. static CreatePolyhedron(name: string, options: {
  41622. type?: number;
  41623. size?: number;
  41624. sizeX?: number;
  41625. sizeY?: number;
  41626. sizeZ?: number;
  41627. custom?: any;
  41628. faceUV?: Vector4[];
  41629. faceColors?: Color4[];
  41630. flat?: boolean;
  41631. updatable?: boolean;
  41632. sideOrientation?: number;
  41633. frontUVs?: Vector4;
  41634. backUVs?: Vector4;
  41635. }, scene: Scene): Mesh;
  41636. }
  41637. }
  41638. declare module BABYLON {
  41639. /**
  41640. * Gizmo that enables scaling a mesh along 3 axis
  41641. */
  41642. export class ScaleGizmo extends Gizmo {
  41643. /**
  41644. * Internal gizmo used for interactions on the x axis
  41645. */
  41646. xGizmo: AxisScaleGizmo;
  41647. /**
  41648. * Internal gizmo used for interactions on the y axis
  41649. */
  41650. yGizmo: AxisScaleGizmo;
  41651. /**
  41652. * Internal gizmo used for interactions on the z axis
  41653. */
  41654. zGizmo: AxisScaleGizmo;
  41655. /**
  41656. * Internal gizmo used to scale all axis equally
  41657. */
  41658. uniformScaleGizmo: AxisScaleGizmo;
  41659. /** Fires an event when any of it's sub gizmos are dragged */
  41660. onDragStartObservable: Observable<{}>;
  41661. /** Fires an event when any of it's sub gizmos are released from dragging */
  41662. onDragEndObservable: Observable<{}>;
  41663. attachedMesh: Nullable<AbstractMesh>;
  41664. /**
  41665. * Creates a ScaleGizmo
  41666. * @param gizmoLayer The utility layer the gizmo will be added to
  41667. */
  41668. constructor(gizmoLayer?: UtilityLayerRenderer);
  41669. updateGizmoRotationToMatchAttachedMesh: boolean;
  41670. /**
  41671. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41672. */
  41673. snapDistance: number;
  41674. /**
  41675. * Ratio for the scale of the gizmo (Default: 1)
  41676. */
  41677. scaleRatio: number;
  41678. /**
  41679. * Disposes of the gizmo
  41680. */
  41681. dispose(): void;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. /**
  41686. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41687. */
  41688. export class GizmoManager implements IDisposable {
  41689. private scene;
  41690. /**
  41691. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41692. */
  41693. gizmos: {
  41694. positionGizmo: Nullable<PositionGizmo>;
  41695. rotationGizmo: Nullable<RotationGizmo>;
  41696. scaleGizmo: Nullable<ScaleGizmo>;
  41697. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41698. };
  41699. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41700. clearGizmoOnEmptyPointerEvent: boolean;
  41701. /** Fires an event when the manager is attached to a mesh */
  41702. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41703. private _gizmosEnabled;
  41704. private _pointerObserver;
  41705. private _attachedMesh;
  41706. private _boundingBoxColor;
  41707. private _defaultUtilityLayer;
  41708. private _defaultKeepDepthUtilityLayer;
  41709. /**
  41710. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41711. */
  41712. boundingBoxDragBehavior: SixDofDragBehavior;
  41713. /**
  41714. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41715. */
  41716. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41717. /**
  41718. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41719. */
  41720. usePointerToAttachGizmos: boolean;
  41721. /**
  41722. * Instatiates a gizmo manager
  41723. * @param scene the scene to overlay the gizmos on top of
  41724. */
  41725. constructor(scene: Scene);
  41726. /**
  41727. * Attaches a set of gizmos to the specified mesh
  41728. * @param mesh The mesh the gizmo's should be attached to
  41729. */
  41730. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41731. /**
  41732. * If the position gizmo is enabled
  41733. */
  41734. positionGizmoEnabled: boolean;
  41735. /**
  41736. * If the rotation gizmo is enabled
  41737. */
  41738. rotationGizmoEnabled: boolean;
  41739. /**
  41740. * If the scale gizmo is enabled
  41741. */
  41742. scaleGizmoEnabled: boolean;
  41743. /**
  41744. * If the boundingBox gizmo is enabled
  41745. */
  41746. boundingBoxGizmoEnabled: boolean;
  41747. /**
  41748. * Disposes of the gizmo manager
  41749. */
  41750. dispose(): void;
  41751. }
  41752. }
  41753. declare module BABYLON {
  41754. /**
  41755. * Gizmo that enables viewing a light
  41756. */
  41757. export class LightGizmo extends Gizmo {
  41758. private _box;
  41759. /**
  41760. * Creates a LightGizmo
  41761. * @param gizmoLayer The utility layer the gizmo will be added to
  41762. */
  41763. constructor(gizmoLayer?: UtilityLayerRenderer);
  41764. private _light;
  41765. /**
  41766. * The light that the gizmo is attached to
  41767. */
  41768. light: Nullable<Light>;
  41769. /**
  41770. * @hidden
  41771. * Updates the gizmo to match the attached mesh's position/rotation
  41772. */
  41773. protected _update(): void;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. /** @hidden */
  41778. export var backgroundFragmentDeclaration: {
  41779. name: string;
  41780. shader: string;
  41781. };
  41782. }
  41783. declare module BABYLON {
  41784. /** @hidden */
  41785. export var backgroundUboDeclaration: {
  41786. name: string;
  41787. shader: string;
  41788. };
  41789. }
  41790. declare module BABYLON {
  41791. /** @hidden */
  41792. export var backgroundPixelShader: {
  41793. name: string;
  41794. shader: string;
  41795. };
  41796. }
  41797. declare module BABYLON {
  41798. /** @hidden */
  41799. export var backgroundVertexDeclaration: {
  41800. name: string;
  41801. shader: string;
  41802. };
  41803. }
  41804. declare module BABYLON {
  41805. /** @hidden */
  41806. export var backgroundVertexShader: {
  41807. name: string;
  41808. shader: string;
  41809. };
  41810. }
  41811. declare module BABYLON {
  41812. /**
  41813. * Background material used to create an efficient environement around your scene.
  41814. */
  41815. export class BackgroundMaterial extends PushMaterial {
  41816. /**
  41817. * Standard reflectance value at parallel view angle.
  41818. */
  41819. static StandardReflectance0: number;
  41820. /**
  41821. * Standard reflectance value at grazing angle.
  41822. */
  41823. static StandardReflectance90: number;
  41824. protected _primaryColor: Color3;
  41825. /**
  41826. * Key light Color (multiply against the environement texture)
  41827. */
  41828. primaryColor: Color3;
  41829. protected __perceptualColor: Nullable<Color3>;
  41830. /**
  41831. * Experimental Internal Use Only.
  41832. *
  41833. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  41834. * This acts as a helper to set the primary color to a more "human friendly" value.
  41835. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  41836. * output color as close as possible from the chosen value.
  41837. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  41838. * part of lighting setup.)
  41839. */
  41840. _perceptualColor: Nullable<Color3>;
  41841. protected _primaryColorShadowLevel: float;
  41842. /**
  41843. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  41844. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  41845. */
  41846. primaryColorShadowLevel: float;
  41847. protected _primaryColorHighlightLevel: float;
  41848. /**
  41849. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  41850. * The primary color is used at the level chosen to define what the white area would look.
  41851. */
  41852. primaryColorHighlightLevel: float;
  41853. protected _reflectionTexture: Nullable<BaseTexture>;
  41854. /**
  41855. * Reflection Texture used in the material.
  41856. * Should be author in a specific way for the best result (refer to the documentation).
  41857. */
  41858. reflectionTexture: Nullable<BaseTexture>;
  41859. protected _reflectionBlur: float;
  41860. /**
  41861. * Reflection Texture level of blur.
  41862. *
  41863. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  41864. * texture twice.
  41865. */
  41866. reflectionBlur: float;
  41867. protected _diffuseTexture: Nullable<BaseTexture>;
  41868. /**
  41869. * Diffuse Texture used in the material.
  41870. * Should be author in a specific way for the best result (refer to the documentation).
  41871. */
  41872. diffuseTexture: Nullable<BaseTexture>;
  41873. protected _shadowLights: Nullable<IShadowLight[]>;
  41874. /**
  41875. * Specify the list of lights casting shadow on the material.
  41876. * All scene shadow lights will be included if null.
  41877. */
  41878. shadowLights: Nullable<IShadowLight[]>;
  41879. protected _shadowLevel: float;
  41880. /**
  41881. * Helps adjusting the shadow to a softer level if required.
  41882. * 0 means black shadows and 1 means no shadows.
  41883. */
  41884. shadowLevel: float;
  41885. protected _sceneCenter: Vector3;
  41886. /**
  41887. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  41888. * It is usually zero but might be interesting to modify according to your setup.
  41889. */
  41890. sceneCenter: Vector3;
  41891. protected _opacityFresnel: boolean;
  41892. /**
  41893. * This helps specifying that the material is falling off to the sky box at grazing angle.
  41894. * This helps ensuring a nice transition when the camera goes under the ground.
  41895. */
  41896. opacityFresnel: boolean;
  41897. protected _reflectionFresnel: boolean;
  41898. /**
  41899. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  41900. * This helps adding a mirror texture on the ground.
  41901. */
  41902. reflectionFresnel: boolean;
  41903. protected _reflectionFalloffDistance: number;
  41904. /**
  41905. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  41906. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  41907. */
  41908. reflectionFalloffDistance: number;
  41909. protected _reflectionAmount: number;
  41910. /**
  41911. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  41912. */
  41913. reflectionAmount: number;
  41914. protected _reflectionReflectance0: number;
  41915. /**
  41916. * This specifies the weight of the reflection at grazing angle.
  41917. */
  41918. reflectionReflectance0: number;
  41919. protected _reflectionReflectance90: number;
  41920. /**
  41921. * This specifies the weight of the reflection at a perpendicular point of view.
  41922. */
  41923. reflectionReflectance90: number;
  41924. /**
  41925. * Sets the reflection reflectance fresnel values according to the default standard
  41926. * empirically know to work well :-)
  41927. */
  41928. reflectionStandardFresnelWeight: number;
  41929. protected _useRGBColor: boolean;
  41930. /**
  41931. * Helps to directly use the maps channels instead of their level.
  41932. */
  41933. useRGBColor: boolean;
  41934. protected _enableNoise: boolean;
  41935. /**
  41936. * This helps reducing the banding effect that could occur on the background.
  41937. */
  41938. enableNoise: boolean;
  41939. /**
  41940. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41941. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41942. * Recommended to be keep at 1.0 except for special cases.
  41943. */
  41944. fovMultiplier: number;
  41945. private _fovMultiplier;
  41946. /**
  41947. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41948. */
  41949. useEquirectangularFOV: boolean;
  41950. private _maxSimultaneousLights;
  41951. /**
  41952. * Number of Simultaneous lights allowed on the material.
  41953. */
  41954. maxSimultaneousLights: int;
  41955. /**
  41956. * Default configuration related to image processing available in the Background Material.
  41957. */
  41958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41959. /**
  41960. * Keep track of the image processing observer to allow dispose and replace.
  41961. */
  41962. private _imageProcessingObserver;
  41963. /**
  41964. * Attaches a new image processing configuration to the PBR Material.
  41965. * @param configuration (if null the scene configuration will be use)
  41966. */
  41967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41968. /**
  41969. * Gets the image processing configuration used either in this material.
  41970. */
  41971. /**
  41972. * Sets the Default image processing configuration used either in the this material.
  41973. *
  41974. * If sets to null, the scene one is in use.
  41975. */
  41976. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41977. /**
  41978. * Gets wether the color curves effect is enabled.
  41979. */
  41980. /**
  41981. * Sets wether the color curves effect is enabled.
  41982. */
  41983. cameraColorCurvesEnabled: boolean;
  41984. /**
  41985. * Gets wether the color grading effect is enabled.
  41986. */
  41987. /**
  41988. * Gets wether the color grading effect is enabled.
  41989. */
  41990. cameraColorGradingEnabled: boolean;
  41991. /**
  41992. * Gets wether tonemapping is enabled or not.
  41993. */
  41994. /**
  41995. * Sets wether tonemapping is enabled or not
  41996. */
  41997. cameraToneMappingEnabled: boolean;
  41998. /**
  41999. * The camera exposure used on this material.
  42000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42001. * This corresponds to a photographic exposure.
  42002. */
  42003. /**
  42004. * The camera exposure used on this material.
  42005. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42006. * This corresponds to a photographic exposure.
  42007. */
  42008. cameraExposure: float;
  42009. /**
  42010. * Gets The camera contrast used on this material.
  42011. */
  42012. /**
  42013. * Sets The camera contrast used on this material.
  42014. */
  42015. cameraContrast: float;
  42016. /**
  42017. * Gets the Color Grading 2D Lookup Texture.
  42018. */
  42019. /**
  42020. * Sets the Color Grading 2D Lookup Texture.
  42021. */
  42022. cameraColorGradingTexture: Nullable<BaseTexture>;
  42023. /**
  42024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42026. * 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;
  42027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42028. */
  42029. /**
  42030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42032. * 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;
  42033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42034. */
  42035. cameraColorCurves: Nullable<ColorCurves>;
  42036. /**
  42037. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42038. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42039. */
  42040. switchToBGR: boolean;
  42041. private _renderTargets;
  42042. private _reflectionControls;
  42043. private _white;
  42044. private _primaryShadowColor;
  42045. private _primaryHighlightColor;
  42046. /**
  42047. * Instantiates a Background Material in the given scene
  42048. * @param name The friendly name of the material
  42049. * @param scene The scene to add the material to
  42050. */
  42051. constructor(name: string, scene: Scene);
  42052. /**
  42053. * Gets a boolean indicating that current material needs to register RTT
  42054. */
  42055. readonly hasRenderTargetTextures: boolean;
  42056. /**
  42057. * The entire material has been created in order to prevent overdraw.
  42058. * @returns false
  42059. */
  42060. needAlphaTesting(): boolean;
  42061. /**
  42062. * The entire material has been created in order to prevent overdraw.
  42063. * @returns true if blending is enable
  42064. */
  42065. needAlphaBlending(): boolean;
  42066. /**
  42067. * Checks wether the material is ready to be rendered for a given mesh.
  42068. * @param mesh The mesh to render
  42069. * @param subMesh The submesh to check against
  42070. * @param useInstances Specify wether or not the material is used with instances
  42071. * @returns true if all the dependencies are ready (Textures, Effects...)
  42072. */
  42073. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42074. /**
  42075. * Compute the primary color according to the chosen perceptual color.
  42076. */
  42077. private _computePrimaryColorFromPerceptualColor;
  42078. /**
  42079. * Compute the highlights and shadow colors according to their chosen levels.
  42080. */
  42081. private _computePrimaryColors;
  42082. /**
  42083. * Build the uniform buffer used in the material.
  42084. */
  42085. buildUniformLayout(): void;
  42086. /**
  42087. * Unbind the material.
  42088. */
  42089. unbind(): void;
  42090. /**
  42091. * Bind only the world matrix to the material.
  42092. * @param world The world matrix to bind.
  42093. */
  42094. bindOnlyWorldMatrix(world: Matrix): void;
  42095. /**
  42096. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42097. * @param world The world matrix to bind.
  42098. * @param subMesh The submesh to bind for.
  42099. */
  42100. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42101. /**
  42102. * Dispose the material.
  42103. * @param forceDisposeEffect Force disposal of the associated effect.
  42104. * @param forceDisposeTextures Force disposal of the associated textures.
  42105. */
  42106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42107. /**
  42108. * Clones the material.
  42109. * @param name The cloned name.
  42110. * @returns The cloned material.
  42111. */
  42112. clone(name: string): BackgroundMaterial;
  42113. /**
  42114. * Serializes the current material to its JSON representation.
  42115. * @returns The JSON representation.
  42116. */
  42117. serialize(): any;
  42118. /**
  42119. * Gets the class name of the material
  42120. * @returns "BackgroundMaterial"
  42121. */
  42122. getClassName(): string;
  42123. /**
  42124. * Parse a JSON input to create back a background material.
  42125. * @param source The JSON data to parse
  42126. * @param scene The scene to create the parsed material in
  42127. * @param rootUrl The root url of the assets the material depends upon
  42128. * @returns the instantiated BackgroundMaterial.
  42129. */
  42130. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Represents the different options available during the creation of
  42136. * a Environment helper.
  42137. *
  42138. * This can control the default ground, skybox and image processing setup of your scene.
  42139. */
  42140. export interface IEnvironmentHelperOptions {
  42141. /**
  42142. * Specifies wether or not to create a ground.
  42143. * True by default.
  42144. */
  42145. createGround: boolean;
  42146. /**
  42147. * Specifies the ground size.
  42148. * 15 by default.
  42149. */
  42150. groundSize: number;
  42151. /**
  42152. * The texture used on the ground for the main color.
  42153. * Comes from the BabylonJS CDN by default.
  42154. *
  42155. * Remarks: Can be either a texture or a url.
  42156. */
  42157. groundTexture: string | BaseTexture;
  42158. /**
  42159. * The color mixed in the ground texture by default.
  42160. * BabylonJS clearColor by default.
  42161. */
  42162. groundColor: Color3;
  42163. /**
  42164. * Specifies the ground opacity.
  42165. * 1 by default.
  42166. */
  42167. groundOpacity: number;
  42168. /**
  42169. * Enables the ground to receive shadows.
  42170. * True by default.
  42171. */
  42172. enableGroundShadow: boolean;
  42173. /**
  42174. * Helps preventing the shadow to be fully black on the ground.
  42175. * 0.5 by default.
  42176. */
  42177. groundShadowLevel: number;
  42178. /**
  42179. * Creates a mirror texture attach to the ground.
  42180. * false by default.
  42181. */
  42182. enableGroundMirror: boolean;
  42183. /**
  42184. * Specifies the ground mirror size ratio.
  42185. * 0.3 by default as the default kernel is 64.
  42186. */
  42187. groundMirrorSizeRatio: number;
  42188. /**
  42189. * Specifies the ground mirror blur kernel size.
  42190. * 64 by default.
  42191. */
  42192. groundMirrorBlurKernel: number;
  42193. /**
  42194. * Specifies the ground mirror visibility amount.
  42195. * 1 by default
  42196. */
  42197. groundMirrorAmount: number;
  42198. /**
  42199. * Specifies the ground mirror reflectance weight.
  42200. * This uses the standard weight of the background material to setup the fresnel effect
  42201. * of the mirror.
  42202. * 1 by default.
  42203. */
  42204. groundMirrorFresnelWeight: number;
  42205. /**
  42206. * Specifies the ground mirror Falloff distance.
  42207. * This can helps reducing the size of the reflection.
  42208. * 0 by Default.
  42209. */
  42210. groundMirrorFallOffDistance: number;
  42211. /**
  42212. * Specifies the ground mirror texture type.
  42213. * Unsigned Int by Default.
  42214. */
  42215. groundMirrorTextureType: number;
  42216. /**
  42217. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42218. * the shown objects.
  42219. */
  42220. groundYBias: number;
  42221. /**
  42222. * Specifies wether or not to create a skybox.
  42223. * True by default.
  42224. */
  42225. createSkybox: boolean;
  42226. /**
  42227. * Specifies the skybox size.
  42228. * 20 by default.
  42229. */
  42230. skyboxSize: number;
  42231. /**
  42232. * The texture used on the skybox for the main color.
  42233. * Comes from the BabylonJS CDN by default.
  42234. *
  42235. * Remarks: Can be either a texture or a url.
  42236. */
  42237. skyboxTexture: string | BaseTexture;
  42238. /**
  42239. * The color mixed in the skybox texture by default.
  42240. * BabylonJS clearColor by default.
  42241. */
  42242. skyboxColor: Color3;
  42243. /**
  42244. * The background rotation around the Y axis of the scene.
  42245. * This helps aligning the key lights of your scene with the background.
  42246. * 0 by default.
  42247. */
  42248. backgroundYRotation: number;
  42249. /**
  42250. * Compute automatically the size of the elements to best fit with the scene.
  42251. */
  42252. sizeAuto: boolean;
  42253. /**
  42254. * Default position of the rootMesh if autoSize is not true.
  42255. */
  42256. rootPosition: Vector3;
  42257. /**
  42258. * Sets up the image processing in the scene.
  42259. * true by default.
  42260. */
  42261. setupImageProcessing: boolean;
  42262. /**
  42263. * The texture used as your environment texture in the scene.
  42264. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42265. *
  42266. * Remarks: Can be either a texture or a url.
  42267. */
  42268. environmentTexture: string | BaseTexture;
  42269. /**
  42270. * The value of the exposure to apply to the scene.
  42271. * 0.6 by default if setupImageProcessing is true.
  42272. */
  42273. cameraExposure: number;
  42274. /**
  42275. * The value of the contrast to apply to the scene.
  42276. * 1.6 by default if setupImageProcessing is true.
  42277. */
  42278. cameraContrast: number;
  42279. /**
  42280. * Specifies wether or not tonemapping should be enabled in the scene.
  42281. * true by default if setupImageProcessing is true.
  42282. */
  42283. toneMappingEnabled: boolean;
  42284. }
  42285. /**
  42286. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42287. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42288. * It also helps with the default setup of your imageProcessing configuration.
  42289. */
  42290. export class EnvironmentHelper {
  42291. /**
  42292. * Default ground texture URL.
  42293. */
  42294. private static _groundTextureCDNUrl;
  42295. /**
  42296. * Default skybox texture URL.
  42297. */
  42298. private static _skyboxTextureCDNUrl;
  42299. /**
  42300. * Default environment texture URL.
  42301. */
  42302. private static _environmentTextureCDNUrl;
  42303. /**
  42304. * Creates the default options for the helper.
  42305. */
  42306. private static _getDefaultOptions;
  42307. private _rootMesh;
  42308. /**
  42309. * Gets the root mesh created by the helper.
  42310. */
  42311. readonly rootMesh: Mesh;
  42312. private _skybox;
  42313. /**
  42314. * Gets the skybox created by the helper.
  42315. */
  42316. readonly skybox: Nullable<Mesh>;
  42317. private _skyboxTexture;
  42318. /**
  42319. * Gets the skybox texture created by the helper.
  42320. */
  42321. readonly skyboxTexture: Nullable<BaseTexture>;
  42322. private _skyboxMaterial;
  42323. /**
  42324. * Gets the skybox material created by the helper.
  42325. */
  42326. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42327. private _ground;
  42328. /**
  42329. * Gets the ground mesh created by the helper.
  42330. */
  42331. readonly ground: Nullable<Mesh>;
  42332. private _groundTexture;
  42333. /**
  42334. * Gets the ground texture created by the helper.
  42335. */
  42336. readonly groundTexture: Nullable<BaseTexture>;
  42337. private _groundMirror;
  42338. /**
  42339. * Gets the ground mirror created by the helper.
  42340. */
  42341. readonly groundMirror: Nullable<MirrorTexture>;
  42342. /**
  42343. * Gets the ground mirror render list to helps pushing the meshes
  42344. * you wish in the ground reflection.
  42345. */
  42346. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42347. private _groundMaterial;
  42348. /**
  42349. * Gets the ground material created by the helper.
  42350. */
  42351. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42352. /**
  42353. * Stores the creation options.
  42354. */
  42355. private readonly _scene;
  42356. private _options;
  42357. /**
  42358. * This observable will be notified with any error during the creation of the environment,
  42359. * mainly texture creation errors.
  42360. */
  42361. onErrorObservable: Observable<{
  42362. message?: string;
  42363. exception?: any;
  42364. }>;
  42365. /**
  42366. * constructor
  42367. * @param options Defines the options we want to customize the helper
  42368. * @param scene The scene to add the material to
  42369. */
  42370. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42371. /**
  42372. * Updates the background according to the new options
  42373. * @param options
  42374. */
  42375. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42376. /**
  42377. * Sets the primary color of all the available elements.
  42378. * @param color the main color to affect to the ground and the background
  42379. */
  42380. setMainColor(color: Color3): void;
  42381. /**
  42382. * Setup the image processing according to the specified options.
  42383. */
  42384. private _setupImageProcessing;
  42385. /**
  42386. * Setup the environment texture according to the specified options.
  42387. */
  42388. private _setupEnvironmentTexture;
  42389. /**
  42390. * Setup the background according to the specified options.
  42391. */
  42392. private _setupBackground;
  42393. /**
  42394. * Get the scene sizes according to the setup.
  42395. */
  42396. private _getSceneSize;
  42397. /**
  42398. * Setup the ground according to the specified options.
  42399. */
  42400. private _setupGround;
  42401. /**
  42402. * Setup the ground material according to the specified options.
  42403. */
  42404. private _setupGroundMaterial;
  42405. /**
  42406. * Setup the ground diffuse texture according to the specified options.
  42407. */
  42408. private _setupGroundDiffuseTexture;
  42409. /**
  42410. * Setup the ground mirror texture according to the specified options.
  42411. */
  42412. private _setupGroundMirrorTexture;
  42413. /**
  42414. * Setup the ground to receive the mirror texture.
  42415. */
  42416. private _setupMirrorInGroundMaterial;
  42417. /**
  42418. * Setup the skybox according to the specified options.
  42419. */
  42420. private _setupSkybox;
  42421. /**
  42422. * Setup the skybox material according to the specified options.
  42423. */
  42424. private _setupSkyboxMaterial;
  42425. /**
  42426. * Setup the skybox reflection texture according to the specified options.
  42427. */
  42428. private _setupSkyboxReflectionTexture;
  42429. private _errorHandler;
  42430. /**
  42431. * Dispose all the elements created by the Helper.
  42432. */
  42433. dispose(): void;
  42434. }
  42435. }
  42436. declare module BABYLON {
  42437. /**
  42438. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42439. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42440. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42441. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42442. */
  42443. export class PhotoDome extends TransformNode {
  42444. private _useDirectMapping;
  42445. /**
  42446. * The texture being displayed on the sphere
  42447. */
  42448. protected _photoTexture: Texture;
  42449. /**
  42450. * Gets or sets the texture being displayed on the sphere
  42451. */
  42452. photoTexture: Texture;
  42453. /**
  42454. * Observable raised when an error occured while loading the 360 image
  42455. */
  42456. onLoadErrorObservable: Observable<string>;
  42457. /**
  42458. * The skybox material
  42459. */
  42460. protected _material: BackgroundMaterial;
  42461. /**
  42462. * The surface used for the skybox
  42463. */
  42464. protected _mesh: Mesh;
  42465. /**
  42466. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42467. * Also see the options.resolution property.
  42468. */
  42469. fovMultiplier: number;
  42470. /**
  42471. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42472. * @param name Element's name, child elements will append suffixes for their own names.
  42473. * @param urlsOfPhoto defines the url of the photo to display
  42474. * @param options defines an object containing optional or exposed sub element properties
  42475. * @param onError defines a callback called when an error occured while loading the texture
  42476. */
  42477. constructor(name: string, urlOfPhoto: string, options: {
  42478. resolution?: number;
  42479. size?: number;
  42480. useDirectMapping?: boolean;
  42481. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42482. /**
  42483. * Releases resources associated with this node.
  42484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42486. */
  42487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42488. }
  42489. }
  42490. declare module BABYLON {
  42491. /**
  42492. * Class used to host texture specific utilities
  42493. */
  42494. export class TextureTools {
  42495. /**
  42496. * Uses the GPU to create a copy texture rescaled at a given size
  42497. * @param texture Texture to copy from
  42498. * @param width defines the desired width
  42499. * @param height defines the desired height
  42500. * @param useBilinearMode defines if bilinear mode has to be used
  42501. * @return the generated texture
  42502. */
  42503. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42504. /**
  42505. * Gets an environment BRDF texture for a given scene
  42506. * @param scene defines the hosting scene
  42507. * @returns the environment BRDF texture
  42508. */
  42509. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42510. private static _environmentBRDFBase64Texture;
  42511. }
  42512. }
  42513. declare module BABYLON {
  42514. /**
  42515. * @hidden
  42516. */
  42517. export interface IMaterialClearCoatDefines {
  42518. CLEARCOAT: boolean;
  42519. CLEARCOAT_DEFAULTIOR: boolean;
  42520. CLEARCOAT_TEXTURE: boolean;
  42521. CLEARCOAT_TEXTUREDIRECTUV: number;
  42522. CLEARCOAT_BUMP: boolean;
  42523. CLEARCOAT_BUMPDIRECTUV: number;
  42524. CLEARCOAT_TINT: boolean;
  42525. CLEARCOAT_TINT_TEXTURE: boolean;
  42526. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  42527. /** @hidden */
  42528. _areTexturesDirty: boolean;
  42529. }
  42530. /**
  42531. * Define the code related to the clear coat parameters of the pbr material.
  42532. */
  42533. export class PBRClearCoatConfiguration {
  42534. /**
  42535. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42536. * The default fits with a polyurethane material.
  42537. */
  42538. private static readonly _DefaultIndiceOfRefraction;
  42539. private _isEnabled;
  42540. /**
  42541. * Defines if the clear coat is enabled in the material.
  42542. */
  42543. isEnabled: boolean;
  42544. /**
  42545. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  42546. */
  42547. intensity: number;
  42548. /**
  42549. * Defines the clear coat layer roughness.
  42550. */
  42551. roughness: number;
  42552. private _indiceOfRefraction;
  42553. /**
  42554. * Defines the indice of refraction of the clear coat.
  42555. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42556. * The default fits with a polyurethane material.
  42557. * Changing the default value is more performance intensive.
  42558. */
  42559. indiceOfRefraction: number;
  42560. private _texture;
  42561. /**
  42562. * Stores the clear coat values in a texture.
  42563. */
  42564. texture: Nullable<BaseTexture>;
  42565. private _bumpTexture;
  42566. /**
  42567. * Define the clear coat specific bump texture.
  42568. */
  42569. bumpTexture: Nullable<BaseTexture>;
  42570. private _isTintEnabled;
  42571. /**
  42572. * Defines if the clear coat tint is enabled in the material.
  42573. */
  42574. isTintEnabled: boolean;
  42575. /**
  42576. * Defines if the clear coat tint is enabled in the material.
  42577. * This is only use if tint is enabled
  42578. */
  42579. tintColor: Color3;
  42580. /**
  42581. * Defines if the distance at which the tint color should be found in the
  42582. * clear coat media.
  42583. * This is only use if tint is enabled
  42584. */
  42585. tintColorAtDistance: number;
  42586. /**
  42587. * Defines the clear coat layer thickness.
  42588. * This is only use if tint is enabled
  42589. */
  42590. tintThickness: number;
  42591. private _tintTexture;
  42592. /**
  42593. * Stores the clear tint values in a texture.
  42594. * rgb is tint
  42595. * a is a thickness factor
  42596. */
  42597. tintTexture: Nullable<BaseTexture>;
  42598. /** @hidden */
  42599. private _internalMarkAllSubMeshesAsTexturesDirty;
  42600. /** @hidden */
  42601. _markAllSubMeshesAsTexturesDirty(): void;
  42602. /**
  42603. * Instantiate a new istance of clear coat configuration.
  42604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  42605. */
  42606. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  42607. /**
  42608. * Specifies that the submesh is ready to be used.
  42609. * @param defines the list of "defines" to update.
  42610. * @param scene defines the scene the material belongs to.
  42611. * @param engine defines the engine the material belongs to.
  42612. * @param disableBumpMap defines wether the material disables bump or not.
  42613. * @returns - boolean indicating that the submesh is ready or not.
  42614. */
  42615. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  42616. /**
  42617. * Checks to see if a texture is used in the material.
  42618. * @param defines the list of "defines" to update.
  42619. * @param scene defines the scene to the material belongs to.
  42620. */
  42621. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  42622. /**
  42623. * Binds the material data.
  42624. * @param uniformBuffer defines the Uniform buffer to fill in.
  42625. * @param scene defines the scene the material belongs to.
  42626. * @param engine defines the engine the material belongs to.
  42627. * @param disableBumpMap defines wether the material disables bump or not.
  42628. * @param isFrozen defines wether the material is frozen or not.
  42629. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42630. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42631. */
  42632. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  42633. /**
  42634. * Checks to see if a texture is used in the material.
  42635. * @param texture - Base texture to use.
  42636. * @returns - Boolean specifying if a texture is used in the material.
  42637. */
  42638. hasTexture(texture: BaseTexture): boolean;
  42639. /**
  42640. * Returns an array of the actively used textures.
  42641. * @param activeTextures Array of BaseTextures
  42642. */
  42643. getActiveTextures(activeTextures: BaseTexture[]): void;
  42644. /**
  42645. * Returns the animatable textures.
  42646. * @param animatables Array of animatable textures.
  42647. */
  42648. getAnimatables(animatables: IAnimatable[]): void;
  42649. /**
  42650. * Disposes the resources of the material.
  42651. * @param forceDisposeTextures - Forces the disposal of all textures.
  42652. */
  42653. dispose(forceDisposeTextures?: boolean): void;
  42654. /**
  42655. * Get the current class name of the texture useful for serialization or dynamic coding.
  42656. * @returns "PBRClearCoatConfiguration"
  42657. */
  42658. getClassName(): string;
  42659. /**
  42660. * Makes a duplicate of the current configuration into another one.
  42661. * @param clearCoatConfiguration define the config where to copy the info
  42662. */
  42663. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  42664. /**
  42665. * Serializes this clear coat configuration.
  42666. * @returns - An object with the serialized config.
  42667. */
  42668. serialize(): any;
  42669. /**
  42670. * Parses a Clear Coat Configuration from a serialized object.
  42671. * @param source - Serialized object.
  42672. */
  42673. parse(source: any): void;
  42674. /**
  42675. * Add fallbacks to the effect fallbacks list.
  42676. * @param defines defines the Base texture to use.
  42677. * @param fallbacks defines the current fallback list.
  42678. * @param currentRank defines the current fallback rank.
  42679. * @returns the new fallback rank.
  42680. */
  42681. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  42682. /**
  42683. * Add the required uniforms to the current list.
  42684. * @param uniforms defines the current uniform list.
  42685. */
  42686. static AddUniforms(uniforms: string[]): void;
  42687. /**
  42688. * Add the required samplers to the current list.
  42689. * @param samplers defines the current sampler list.
  42690. */
  42691. static AddSamplers(samplers: string[]): void;
  42692. /**
  42693. * Add the required uniforms to the current buffer.
  42694. * @param uniformBuffer defines the current uniform buffer.
  42695. */
  42696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  42697. }
  42698. }
  42699. declare module BABYLON {
  42700. /**
  42701. * @hidden
  42702. */
  42703. export interface IMaterialAnisotropicDefines {
  42704. ANISOTROPIC: boolean;
  42705. MAINUV1: boolean;
  42706. _areMiscDirty: boolean;
  42707. _needUVs: boolean;
  42708. }
  42709. /**
  42710. * Define the code related to the anisotropic parameters of the pbr material.
  42711. */
  42712. export class PBRAnisotropicConfiguration {
  42713. private _isEnabled;
  42714. /**
  42715. * Defines if the anisotropy is enabled in the material.
  42716. */
  42717. isEnabled: boolean;
  42718. /**
  42719. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  42720. */
  42721. intensity: number;
  42722. /**
  42723. * Defines if the effect is along the tangents or bitangents.
  42724. * By default, the effect is "strectching" the highlights along the tangents.
  42725. */
  42726. followTangents: boolean;
  42727. /** @hidden */
  42728. private _internalMarkAllSubMeshesAsMiscDirty;
  42729. /** @hidden */
  42730. _markAllSubMeshesAsMiscDirty(): void;
  42731. /**
  42732. * Instantiate a new istance of clear coat configuration.
  42733. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  42734. */
  42735. constructor(markAllSubMeshesAsMiscDirty: () => void);
  42736. /**
  42737. * Checks to see if a texture is used in the material.
  42738. * @param defines the list of "defines" to update.
  42739. * @param mesh the mesh we are preparing the defines for.
  42740. */
  42741. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  42742. /**
  42743. * Binds the material data.
  42744. * @param uniformBuffer defines the Uniform buffer to fill in.
  42745. * @param isFrozen defines wether the material is frozen or not.
  42746. */
  42747. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  42748. /**
  42749. * Get the current class name of the texture useful for serialization or dynamic coding.
  42750. * @returns "PBRAnisotropicConfiguration"
  42751. */
  42752. getClassName(): string;
  42753. /**
  42754. * Makes a duplicate of the current configuration into another one.
  42755. * @param anisotropicConfiguration define the config where to copy the info
  42756. */
  42757. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  42758. /**
  42759. * Serializes this clear coat configuration.
  42760. * @returns - An object with the serialized config.
  42761. */
  42762. serialize(): any;
  42763. /**
  42764. * Parses a Clear Coat Configuration from a serialized object.
  42765. * @param source - Serialized object.
  42766. */
  42767. parse(source: any): void;
  42768. /**
  42769. * Add fallbacks to the effect fallbacks list.
  42770. * @param defines defines the Base texture to use.
  42771. * @param fallbacks defines the current fallback list.
  42772. * @param currentRank defines the current fallback rank.
  42773. * @returns the new fallback rank.
  42774. */
  42775. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  42776. /**
  42777. * Add the required uniforms to the current list.
  42778. * @param uniforms defines the current uniform list.
  42779. */
  42780. static AddUniforms(uniforms: string[]): void;
  42781. /**
  42782. * Add the required uniforms to the current buffer.
  42783. * @param uniformBuffer defines the current uniform buffer.
  42784. */
  42785. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  42786. }
  42787. }
  42788. declare module BABYLON {
  42789. /** @hidden */
  42790. export var pbrFragmentDeclaration: {
  42791. name: string;
  42792. shader: string;
  42793. };
  42794. }
  42795. declare module BABYLON {
  42796. /** @hidden */
  42797. export var pbrUboDeclaration: {
  42798. name: string;
  42799. shader: string;
  42800. };
  42801. }
  42802. declare module BABYLON {
  42803. /** @hidden */
  42804. export var pbrFunctions: {
  42805. name: string;
  42806. shader: string;
  42807. };
  42808. }
  42809. declare module BABYLON {
  42810. /** @hidden */
  42811. export var harmonicsFunctions: {
  42812. name: string;
  42813. shader: string;
  42814. };
  42815. }
  42816. declare module BABYLON {
  42817. /** @hidden */
  42818. export var pbrPreLightingFunctions: {
  42819. name: string;
  42820. shader: string;
  42821. };
  42822. }
  42823. declare module BABYLON {
  42824. /** @hidden */
  42825. export var pbrFalloffLightingFunctions: {
  42826. name: string;
  42827. shader: string;
  42828. };
  42829. }
  42830. declare module BABYLON {
  42831. /** @hidden */
  42832. export var pbrLightingFunctions: {
  42833. name: string;
  42834. shader: string;
  42835. };
  42836. }
  42837. declare module BABYLON {
  42838. /** @hidden */
  42839. export var pbrPixelShader: {
  42840. name: string;
  42841. shader: string;
  42842. };
  42843. }
  42844. declare module BABYLON {
  42845. /** @hidden */
  42846. export var pbrVertexDeclaration: {
  42847. name: string;
  42848. shader: string;
  42849. };
  42850. }
  42851. declare module BABYLON {
  42852. /** @hidden */
  42853. export var pbrVertexShader: {
  42854. name: string;
  42855. shader: string;
  42856. };
  42857. }
  42858. declare module BABYLON {
  42859. /**
  42860. * The Physically based material base class of BJS.
  42861. *
  42862. * This offers the main features of a standard PBR material.
  42863. * For more information, please refer to the documentation :
  42864. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42865. */
  42866. export abstract class PBRBaseMaterial extends PushMaterial {
  42867. /**
  42868. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42869. */
  42870. static readonly PBRMATERIAL_OPAQUE: number;
  42871. /**
  42872. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42873. */
  42874. static readonly PBRMATERIAL_ALPHATEST: number;
  42875. /**
  42876. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42877. */
  42878. static readonly PBRMATERIAL_ALPHABLEND: number;
  42879. /**
  42880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42881. * They are also discarded below the alpha cutoff threshold to improve performances.
  42882. */
  42883. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42884. /**
  42885. * Defines the default value of how much AO map is occluding the analytical lights
  42886. * (point spot...).
  42887. */
  42888. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42889. /**
  42890. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42891. */
  42892. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42893. /**
  42894. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42895. * to enhance interoperability with other engines.
  42896. */
  42897. static readonly LIGHTFALLOFF_GLTF: number;
  42898. /**
  42899. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42900. * to enhance interoperability with other materials.
  42901. */
  42902. static readonly LIGHTFALLOFF_STANDARD: number;
  42903. /**
  42904. * Intensity of the direct lights e.g. the four lights available in your scene.
  42905. * This impacts both the direct diffuse and specular highlights.
  42906. */
  42907. protected _directIntensity: number;
  42908. /**
  42909. * Intensity of the emissive part of the material.
  42910. * This helps controlling the emissive effect without modifying the emissive color.
  42911. */
  42912. protected _emissiveIntensity: number;
  42913. /**
  42914. * Intensity of the environment e.g. how much the environment will light the object
  42915. * either through harmonics for rough material or through the refelction for shiny ones.
  42916. */
  42917. protected _environmentIntensity: number;
  42918. /**
  42919. * This is a special control allowing the reduction of the specular highlights coming from the
  42920. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42921. */
  42922. protected _specularIntensity: number;
  42923. /**
  42924. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42925. */
  42926. private _lightingInfos;
  42927. /**
  42928. * Debug Control allowing disabling the bump map on this material.
  42929. */
  42930. protected _disableBumpMap: boolean;
  42931. /**
  42932. * AKA Diffuse Texture in standard nomenclature.
  42933. */
  42934. protected _albedoTexture: BaseTexture;
  42935. /**
  42936. * AKA Occlusion Texture in other nomenclature.
  42937. */
  42938. protected _ambientTexture: BaseTexture;
  42939. /**
  42940. * AKA Occlusion Texture Intensity in other nomenclature.
  42941. */
  42942. protected _ambientTextureStrength: number;
  42943. /**
  42944. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42945. * 1 means it completely occludes it
  42946. * 0 mean it has no impact
  42947. */
  42948. protected _ambientTextureImpactOnAnalyticalLights: number;
  42949. /**
  42950. * Stores the alpha values in a texture.
  42951. */
  42952. protected _opacityTexture: BaseTexture;
  42953. /**
  42954. * Stores the reflection values in a texture.
  42955. */
  42956. protected _reflectionTexture: BaseTexture;
  42957. /**
  42958. * Stores the refraction values in a texture.
  42959. */
  42960. protected _refractionTexture: BaseTexture;
  42961. /**
  42962. * Stores the emissive values in a texture.
  42963. */
  42964. protected _emissiveTexture: BaseTexture;
  42965. /**
  42966. * AKA Specular texture in other nomenclature.
  42967. */
  42968. protected _reflectivityTexture: BaseTexture;
  42969. /**
  42970. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42971. */
  42972. protected _metallicTexture: BaseTexture;
  42973. /**
  42974. * Specifies the metallic scalar of the metallic/roughness workflow.
  42975. * Can also be used to scale the metalness values of the metallic texture.
  42976. */
  42977. protected _metallic: Nullable<number>;
  42978. /**
  42979. * Specifies the roughness scalar of the metallic/roughness workflow.
  42980. * Can also be used to scale the roughness values of the metallic texture.
  42981. */
  42982. protected _roughness: Nullable<number>;
  42983. /**
  42984. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42985. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42986. */
  42987. protected _microSurfaceTexture: BaseTexture;
  42988. /**
  42989. * Stores surface normal data used to displace a mesh in a texture.
  42990. */
  42991. protected _bumpTexture: BaseTexture;
  42992. /**
  42993. * Stores the pre-calculated light information of a mesh in a texture.
  42994. */
  42995. protected _lightmapTexture: BaseTexture;
  42996. /**
  42997. * The color of a material in ambient lighting.
  42998. */
  42999. protected _ambientColor: Color3;
  43000. /**
  43001. * AKA Diffuse Color in other nomenclature.
  43002. */
  43003. protected _albedoColor: Color3;
  43004. /**
  43005. * AKA Specular Color in other nomenclature.
  43006. */
  43007. protected _reflectivityColor: Color3;
  43008. /**
  43009. * The color applied when light is reflected from a material.
  43010. */
  43011. protected _reflectionColor: Color3;
  43012. /**
  43013. * The color applied when light is emitted from a material.
  43014. */
  43015. protected _emissiveColor: Color3;
  43016. /**
  43017. * AKA Glossiness in other nomenclature.
  43018. */
  43019. protected _microSurface: number;
  43020. /**
  43021. * source material index of refraction (IOR)' / 'destination material IOR.
  43022. */
  43023. protected _indexOfRefraction: number;
  43024. /**
  43025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43026. */
  43027. protected _invertRefractionY: boolean;
  43028. /**
  43029. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43030. * Materials half opaque for instance using refraction could benefit from this control.
  43031. */
  43032. protected _linkRefractionWithTransparency: boolean;
  43033. /**
  43034. * Specifies that the material will use the light map as a show map.
  43035. */
  43036. protected _useLightmapAsShadowmap: boolean;
  43037. /**
  43038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43039. * makes the reflect vector face the model (under horizon).
  43040. */
  43041. protected _useHorizonOcclusion: boolean;
  43042. /**
  43043. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43044. * too much the area relying on ambient texture to define their ambient occlusion.
  43045. */
  43046. protected _useRadianceOcclusion: boolean;
  43047. /**
  43048. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43049. */
  43050. protected _useAlphaFromAlbedoTexture: boolean;
  43051. /**
  43052. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43053. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43054. */
  43055. protected _useSpecularOverAlpha: boolean;
  43056. /**
  43057. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43058. */
  43059. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43060. /**
  43061. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43062. */
  43063. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43064. /**
  43065. * Specifies if the metallic texture contains the roughness information in its green channel.
  43066. */
  43067. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43068. /**
  43069. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43070. */
  43071. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43072. /**
  43073. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43074. */
  43075. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43076. /**
  43077. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43078. */
  43079. protected _useAmbientInGrayScale: boolean;
  43080. /**
  43081. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43082. * The material will try to infer what glossiness each pixel should be.
  43083. */
  43084. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43085. /**
  43086. * Defines the falloff type used in this material.
  43087. * It by default is Physical.
  43088. */
  43089. protected _lightFalloff: number;
  43090. /**
  43091. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43092. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43093. */
  43094. protected _useRadianceOverAlpha: boolean;
  43095. /**
  43096. * Allows using an object space normal map (instead of tangent space).
  43097. */
  43098. protected _useObjectSpaceNormalMap: boolean;
  43099. /**
  43100. * Allows using the bump map in parallax mode.
  43101. */
  43102. protected _useParallax: boolean;
  43103. /**
  43104. * Allows using the bump map in parallax occlusion mode.
  43105. */
  43106. protected _useParallaxOcclusion: boolean;
  43107. /**
  43108. * Controls the scale bias of the parallax mode.
  43109. */
  43110. protected _parallaxScaleBias: number;
  43111. /**
  43112. * If sets to true, disables all the lights affecting the material.
  43113. */
  43114. protected _disableLighting: boolean;
  43115. /**
  43116. * Number of Simultaneous lights allowed on the material.
  43117. */
  43118. protected _maxSimultaneousLights: number;
  43119. /**
  43120. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43121. */
  43122. protected _invertNormalMapX: boolean;
  43123. /**
  43124. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43125. */
  43126. protected _invertNormalMapY: boolean;
  43127. /**
  43128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43129. */
  43130. protected _twoSidedLighting: boolean;
  43131. /**
  43132. * Defines the alpha limits in alpha test mode.
  43133. */
  43134. protected _alphaCutOff: number;
  43135. /**
  43136. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43137. */
  43138. protected _forceAlphaTest: boolean;
  43139. /**
  43140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43141. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43142. */
  43143. protected _useAlphaFresnel: boolean;
  43144. /**
  43145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43146. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43147. */
  43148. protected _useLinearAlphaFresnel: boolean;
  43149. /**
  43150. * The transparency mode of the material.
  43151. */
  43152. protected _transparencyMode: Nullable<number>;
  43153. /**
  43154. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43155. * from cos thetav and roughness:
  43156. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43157. */
  43158. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43159. /**
  43160. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43161. */
  43162. protected _forceIrradianceInFragment: boolean;
  43163. /**
  43164. * Force normal to face away from face.
  43165. */
  43166. protected _forceNormalForward: boolean;
  43167. /**
  43168. * Enables specular anti aliasing in the PBR shader.
  43169. * It will both interacts on the Geometry for analytical and IBL lighting.
  43170. * It also prefilter the roughness map based on the bump values.
  43171. */
  43172. protected _enableSpecularAntiAliasing: boolean;
  43173. /**
  43174. * Default configuration related to image processing available in the PBR Material.
  43175. */
  43176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43177. /**
  43178. * Keep track of the image processing observer to allow dispose and replace.
  43179. */
  43180. private _imageProcessingObserver;
  43181. /**
  43182. * Attaches a new image processing configuration to the PBR Material.
  43183. * @param configuration
  43184. */
  43185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43186. /**
  43187. * Stores the available render targets.
  43188. */
  43189. private _renderTargets;
  43190. /**
  43191. * Sets the global ambient color for the material used in lighting calculations.
  43192. */
  43193. private _globalAmbientColor;
  43194. /**
  43195. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  43196. */
  43197. private _useLogarithmicDepth;
  43198. /**
  43199. * If set to true, no lighting calculations will be applied.
  43200. */
  43201. private _unlit;
  43202. /**
  43203. * Defines the clear coat layer parameters for the material.
  43204. */
  43205. readonly clearCoat: PBRClearCoatConfiguration;
  43206. /**
  43207. * Defines the anisotropic parameters for the material.
  43208. */
  43209. readonly anisotropy: PBRAnisotropicConfiguration;
  43210. /**
  43211. * Instantiates a new PBRMaterial instance.
  43212. *
  43213. * @param name The material name
  43214. * @param scene The scene the material will be use in.
  43215. */
  43216. constructor(name: string, scene: Scene);
  43217. /**
  43218. * Gets a boolean indicating that current material needs to register RTT
  43219. */
  43220. readonly hasRenderTargetTextures: boolean;
  43221. /**
  43222. * Gets the name of the material class.
  43223. */
  43224. getClassName(): string;
  43225. /**
  43226. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43227. */
  43228. /**
  43229. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43230. */
  43231. useLogarithmicDepth: boolean;
  43232. /**
  43233. * Gets the current transparency mode.
  43234. */
  43235. /**
  43236. * Sets the transparency mode of the material.
  43237. *
  43238. * | Value | Type | Description |
  43239. * | ----- | ----------------------------------- | ----------- |
  43240. * | 0 | OPAQUE | |
  43241. * | 1 | ALPHATEST | |
  43242. * | 2 | ALPHABLEND | |
  43243. * | 3 | ALPHATESTANDBLEND | |
  43244. *
  43245. */
  43246. transparencyMode: Nullable<number>;
  43247. /**
  43248. * Returns true if alpha blending should be disabled.
  43249. */
  43250. private readonly _disableAlphaBlending;
  43251. /**
  43252. * Specifies whether or not this material should be rendered in alpha blend mode.
  43253. */
  43254. needAlphaBlending(): boolean;
  43255. /**
  43256. * Specifies if the mesh will require alpha blending.
  43257. * @param mesh - BJS mesh.
  43258. */
  43259. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  43260. /**
  43261. * Specifies whether or not this material should be rendered in alpha test mode.
  43262. */
  43263. needAlphaTesting(): boolean;
  43264. /**
  43265. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  43266. */
  43267. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  43268. /**
  43269. * Gets the texture used for the alpha test.
  43270. */
  43271. getAlphaTestTexture(): BaseTexture;
  43272. /**
  43273. * Specifies that the submesh is ready to be used.
  43274. * @param mesh - BJS mesh.
  43275. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  43276. * @param useInstances - Specifies that instances should be used.
  43277. * @returns - boolean indicating that the submesh is ready or not.
  43278. */
  43279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43280. /**
  43281. * Specifies if the material uses metallic roughness workflow.
  43282. * @returns boolean specifiying if the material uses metallic roughness workflow.
  43283. */
  43284. isMetallicWorkflow(): boolean;
  43285. private _prepareEffect;
  43286. private _prepareDefines;
  43287. /**
  43288. * Force shader compilation
  43289. */
  43290. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  43291. clipPlane: boolean;
  43292. }>): void;
  43293. /**
  43294. * Initializes the uniform buffer layout for the shader.
  43295. */
  43296. buildUniformLayout(): void;
  43297. /**
  43298. * Unbinds the textures.
  43299. */
  43300. unbind(): void;
  43301. /**
  43302. * Binds the submesh data.
  43303. * @param world - The world matrix.
  43304. * @param mesh - The BJS mesh.
  43305. * @param subMesh - A submesh of the BJS mesh.
  43306. */
  43307. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43308. /**
  43309. * Returns the animatable textures.
  43310. * @returns - Array of animatable textures.
  43311. */
  43312. getAnimatables(): IAnimatable[];
  43313. /**
  43314. * Returns the texture used for reflections.
  43315. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  43316. */
  43317. private _getReflectionTexture;
  43318. /**
  43319. * Returns the texture used for refraction or null if none is used.
  43320. * @returns - Refection texture if present. If no refraction texture and refraction
  43321. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43322. */
  43323. private _getRefractionTexture;
  43324. /**
  43325. * Returns an array of the actively used textures.
  43326. * @returns - Array of BaseTextures
  43327. */
  43328. getActiveTextures(): BaseTexture[];
  43329. /**
  43330. * Checks to see if a texture is used in the material.
  43331. * @param texture - Base texture to use.
  43332. * @returns - Boolean specifying if a texture is used in the material.
  43333. */
  43334. hasTexture(texture: BaseTexture): boolean;
  43335. /**
  43336. * Disposes the resources of the material.
  43337. * @param forceDisposeEffect - Forces the disposal of effects.
  43338. * @param forceDisposeTextures - Forces the disposal of all textures.
  43339. */
  43340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43341. }
  43342. }
  43343. declare module BABYLON {
  43344. /**
  43345. * The Physically based material of BJS.
  43346. *
  43347. * This offers the main features of a standard PBR material.
  43348. * For more information, please refer to the documentation :
  43349. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43350. */
  43351. export class PBRMaterial extends PBRBaseMaterial {
  43352. /**
  43353. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43354. */
  43355. static readonly PBRMATERIAL_OPAQUE: number;
  43356. /**
  43357. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43358. */
  43359. static readonly PBRMATERIAL_ALPHATEST: number;
  43360. /**
  43361. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43362. */
  43363. static readonly PBRMATERIAL_ALPHABLEND: number;
  43364. /**
  43365. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43366. * They are also discarded below the alpha cutoff threshold to improve performances.
  43367. */
  43368. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43369. /**
  43370. * Defines the default value of how much AO map is occluding the analytical lights
  43371. * (point spot...).
  43372. */
  43373. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43374. /**
  43375. * Intensity of the direct lights e.g. the four lights available in your scene.
  43376. * This impacts both the direct diffuse and specular highlights.
  43377. */
  43378. directIntensity: number;
  43379. /**
  43380. * Intensity of the emissive part of the material.
  43381. * This helps controlling the emissive effect without modifying the emissive color.
  43382. */
  43383. emissiveIntensity: number;
  43384. /**
  43385. * Intensity of the environment e.g. how much the environment will light the object
  43386. * either through harmonics for rough material or through the refelction for shiny ones.
  43387. */
  43388. environmentIntensity: number;
  43389. /**
  43390. * This is a special control allowing the reduction of the specular highlights coming from the
  43391. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43392. */
  43393. specularIntensity: number;
  43394. /**
  43395. * Debug Control allowing disabling the bump map on this material.
  43396. */
  43397. disableBumpMap: boolean;
  43398. /**
  43399. * AKA Diffuse Texture in standard nomenclature.
  43400. */
  43401. albedoTexture: BaseTexture;
  43402. /**
  43403. * AKA Occlusion Texture in other nomenclature.
  43404. */
  43405. ambientTexture: BaseTexture;
  43406. /**
  43407. * AKA Occlusion Texture Intensity in other nomenclature.
  43408. */
  43409. ambientTextureStrength: number;
  43410. /**
  43411. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43412. * 1 means it completely occludes it
  43413. * 0 mean it has no impact
  43414. */
  43415. ambientTextureImpactOnAnalyticalLights: number;
  43416. /**
  43417. * Stores the alpha values in a texture.
  43418. */
  43419. opacityTexture: BaseTexture;
  43420. /**
  43421. * Stores the reflection values in a texture.
  43422. */
  43423. reflectionTexture: Nullable<BaseTexture>;
  43424. /**
  43425. * Stores the emissive values in a texture.
  43426. */
  43427. emissiveTexture: BaseTexture;
  43428. /**
  43429. * AKA Specular texture in other nomenclature.
  43430. */
  43431. reflectivityTexture: BaseTexture;
  43432. /**
  43433. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43434. */
  43435. metallicTexture: BaseTexture;
  43436. /**
  43437. * Specifies the metallic scalar of the metallic/roughness workflow.
  43438. * Can also be used to scale the metalness values of the metallic texture.
  43439. */
  43440. metallic: Nullable<number>;
  43441. /**
  43442. * Specifies the roughness scalar of the metallic/roughness workflow.
  43443. * Can also be used to scale the roughness values of the metallic texture.
  43444. */
  43445. roughness: Nullable<number>;
  43446. /**
  43447. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43448. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43449. */
  43450. microSurfaceTexture: BaseTexture;
  43451. /**
  43452. * Stores surface normal data used to displace a mesh in a texture.
  43453. */
  43454. bumpTexture: BaseTexture;
  43455. /**
  43456. * Stores the pre-calculated light information of a mesh in a texture.
  43457. */
  43458. lightmapTexture: BaseTexture;
  43459. /**
  43460. * Stores the refracted light information in a texture.
  43461. */
  43462. refractionTexture: BaseTexture;
  43463. /**
  43464. * The color of a material in ambient lighting.
  43465. */
  43466. ambientColor: Color3;
  43467. /**
  43468. * AKA Diffuse Color in other nomenclature.
  43469. */
  43470. albedoColor: Color3;
  43471. /**
  43472. * AKA Specular Color in other nomenclature.
  43473. */
  43474. reflectivityColor: Color3;
  43475. /**
  43476. * The color reflected from the material.
  43477. */
  43478. reflectionColor: Color3;
  43479. /**
  43480. * The color emitted from the material.
  43481. */
  43482. emissiveColor: Color3;
  43483. /**
  43484. * AKA Glossiness in other nomenclature.
  43485. */
  43486. microSurface: number;
  43487. /**
  43488. * source material index of refraction (IOR)' / 'destination material IOR.
  43489. */
  43490. indexOfRefraction: number;
  43491. /**
  43492. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43493. */
  43494. invertRefractionY: boolean;
  43495. /**
  43496. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43497. * Materials half opaque for instance using refraction could benefit from this control.
  43498. */
  43499. linkRefractionWithTransparency: boolean;
  43500. /**
  43501. * If true, the light map contains occlusion information instead of lighting info.
  43502. */
  43503. useLightmapAsShadowmap: boolean;
  43504. /**
  43505. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43506. */
  43507. useAlphaFromAlbedoTexture: boolean;
  43508. /**
  43509. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43510. */
  43511. forceAlphaTest: boolean;
  43512. /**
  43513. * Defines the alpha limits in alpha test mode.
  43514. */
  43515. alphaCutOff: number;
  43516. /**
  43517. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43518. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43519. */
  43520. useSpecularOverAlpha: boolean;
  43521. /**
  43522. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43523. */
  43524. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43525. /**
  43526. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43527. */
  43528. useRoughnessFromMetallicTextureAlpha: boolean;
  43529. /**
  43530. * Specifies if the metallic texture contains the roughness information in its green channel.
  43531. */
  43532. useRoughnessFromMetallicTextureGreen: boolean;
  43533. /**
  43534. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43535. */
  43536. useMetallnessFromMetallicTextureBlue: boolean;
  43537. /**
  43538. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43539. */
  43540. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43541. /**
  43542. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43543. */
  43544. useAmbientInGrayScale: boolean;
  43545. /**
  43546. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43547. * The material will try to infer what glossiness each pixel should be.
  43548. */
  43549. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43550. /**
  43551. * BJS is using an harcoded light falloff based on a manually sets up range.
  43552. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43553. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43554. */
  43555. /**
  43556. * BJS is using an harcoded light falloff based on a manually sets up range.
  43557. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43558. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43559. */
  43560. usePhysicalLightFalloff: boolean;
  43561. /**
  43562. * In order to support the falloff compatibility with gltf, a special mode has been added
  43563. * to reproduce the gltf light falloff.
  43564. */
  43565. /**
  43566. * In order to support the falloff compatibility with gltf, a special mode has been added
  43567. * to reproduce the gltf light falloff.
  43568. */
  43569. useGLTFLightFalloff: boolean;
  43570. /**
  43571. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43572. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43573. */
  43574. useRadianceOverAlpha: boolean;
  43575. /**
  43576. * Allows using an object space normal map (instead of tangent space).
  43577. */
  43578. useObjectSpaceNormalMap: boolean;
  43579. /**
  43580. * Allows using the bump map in parallax mode.
  43581. */
  43582. useParallax: boolean;
  43583. /**
  43584. * Allows using the bump map in parallax occlusion mode.
  43585. */
  43586. useParallaxOcclusion: boolean;
  43587. /**
  43588. * Controls the scale bias of the parallax mode.
  43589. */
  43590. parallaxScaleBias: number;
  43591. /**
  43592. * If sets to true, disables all the lights affecting the material.
  43593. */
  43594. disableLighting: boolean;
  43595. /**
  43596. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43597. */
  43598. forceIrradianceInFragment: boolean;
  43599. /**
  43600. * Number of Simultaneous lights allowed on the material.
  43601. */
  43602. maxSimultaneousLights: number;
  43603. /**
  43604. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43605. */
  43606. invertNormalMapX: boolean;
  43607. /**
  43608. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43609. */
  43610. invertNormalMapY: boolean;
  43611. /**
  43612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43613. */
  43614. twoSidedLighting: boolean;
  43615. /**
  43616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43617. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43618. */
  43619. useAlphaFresnel: boolean;
  43620. /**
  43621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43622. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43623. */
  43624. useLinearAlphaFresnel: boolean;
  43625. /**
  43626. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43627. * And/Or occlude the blended part.
  43628. */
  43629. environmentBRDFTexture: Nullable<BaseTexture>;
  43630. /**
  43631. * Force normal to face away from face.
  43632. */
  43633. forceNormalForward: boolean;
  43634. /**
  43635. * Enables specular anti aliasing in the PBR shader.
  43636. * It will both interacts on the Geometry for analytical and IBL lighting.
  43637. * It also prefilter the roughness map based on the bump values.
  43638. */
  43639. enableSpecularAntiAliasing: boolean;
  43640. /**
  43641. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43642. * makes the reflect vector face the model (under horizon).
  43643. */
  43644. useHorizonOcclusion: boolean;
  43645. /**
  43646. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43647. * too much the area relying on ambient texture to define their ambient occlusion.
  43648. */
  43649. useRadianceOcclusion: boolean;
  43650. /**
  43651. * If set to true, no lighting calculations will be applied.
  43652. */
  43653. unlit: boolean;
  43654. /**
  43655. * Gets the image processing configuration used either in this material.
  43656. */
  43657. /**
  43658. * Sets the Default image processing configuration used either in the this material.
  43659. *
  43660. * If sets to null, the scene one is in use.
  43661. */
  43662. imageProcessingConfiguration: ImageProcessingConfiguration;
  43663. /**
  43664. * Gets wether the color curves effect is enabled.
  43665. */
  43666. /**
  43667. * Sets wether the color curves effect is enabled.
  43668. */
  43669. cameraColorCurvesEnabled: boolean;
  43670. /**
  43671. * Gets wether the color grading effect is enabled.
  43672. */
  43673. /**
  43674. * Gets wether the color grading effect is enabled.
  43675. */
  43676. cameraColorGradingEnabled: boolean;
  43677. /**
  43678. * Gets wether tonemapping is enabled or not.
  43679. */
  43680. /**
  43681. * Sets wether tonemapping is enabled or not
  43682. */
  43683. cameraToneMappingEnabled: boolean;
  43684. /**
  43685. * The camera exposure used on this material.
  43686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43687. * This corresponds to a photographic exposure.
  43688. */
  43689. /**
  43690. * The camera exposure used on this material.
  43691. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43692. * This corresponds to a photographic exposure.
  43693. */
  43694. cameraExposure: number;
  43695. /**
  43696. * Gets The camera contrast used on this material.
  43697. */
  43698. /**
  43699. * Sets The camera contrast used on this material.
  43700. */
  43701. cameraContrast: number;
  43702. /**
  43703. * Gets the Color Grading 2D Lookup Texture.
  43704. */
  43705. /**
  43706. * Sets the Color Grading 2D Lookup Texture.
  43707. */
  43708. cameraColorGradingTexture: Nullable<BaseTexture>;
  43709. /**
  43710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43712. * 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;
  43713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43714. */
  43715. /**
  43716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43718. * 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;
  43719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43720. */
  43721. cameraColorCurves: Nullable<ColorCurves>;
  43722. /**
  43723. * Instantiates a new PBRMaterial instance.
  43724. *
  43725. * @param name The material name
  43726. * @param scene The scene the material will be use in.
  43727. */
  43728. constructor(name: string, scene: Scene);
  43729. /**
  43730. * Returns the name of this material class.
  43731. */
  43732. getClassName(): string;
  43733. /**
  43734. * Makes a duplicate of the current material.
  43735. * @param name - name to use for the new material.
  43736. */
  43737. clone(name: string): PBRMaterial;
  43738. /**
  43739. * Serializes this PBR Material.
  43740. * @returns - An object with the serialized material.
  43741. */
  43742. serialize(): any;
  43743. /**
  43744. * Parses a PBR Material from a serialized object.
  43745. * @param source - Serialized object.
  43746. * @param scene - BJS scene instance.
  43747. * @param rootUrl - url for the scene object
  43748. * @returns - PBRMaterial
  43749. */
  43750. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43751. }
  43752. }
  43753. declare module BABYLON {
  43754. /** @hidden */
  43755. export var _forceSceneHelpersToBundle: boolean;
  43756. interface Scene {
  43757. /**
  43758. * Creates a default light for the scene.
  43759. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43760. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43761. */
  43762. createDefaultLight(replace?: boolean): void;
  43763. /**
  43764. * Creates a default camera for the scene.
  43765. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43766. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43767. * @param replace has default false, when true replaces the active camera in the scene
  43768. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43769. */
  43770. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43771. /**
  43772. * Creates a default camera and a default light.
  43773. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43774. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43775. * @param replace has the default false, when true replaces the active camera/light in the scene
  43776. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43777. */
  43778. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43779. /**
  43780. * Creates a new sky box
  43781. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43782. * @param environmentTexture defines the texture to use as environment texture
  43783. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43784. * @param scale defines the overall scale of the skybox
  43785. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43786. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43787. * @returns a new mesh holding the sky box
  43788. */
  43789. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43790. /**
  43791. * Creates a new environment
  43792. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43793. * @param options defines the options you can use to configure the environment
  43794. * @returns the new EnvironmentHelper
  43795. */
  43796. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43797. /**
  43798. * Creates a new VREXperienceHelper
  43799. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43800. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43801. * @returns a new VREXperienceHelper
  43802. */
  43803. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43804. /**
  43805. * Creates a new XREXperienceHelper
  43806. * @see http://doc.babylonjs.com/how_to/webxr
  43807. * @returns a promise for a new XREXperienceHelper
  43808. */
  43809. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43810. }
  43811. }
  43812. declare module BABYLON {
  43813. /**
  43814. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43815. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43816. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43817. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43818. */
  43819. export class VideoDome extends TransformNode {
  43820. private _useDirectMapping;
  43821. /**
  43822. * The video texture being displayed on the sphere
  43823. */
  43824. protected _videoTexture: VideoTexture;
  43825. /**
  43826. * Gets the video texture being displayed on the sphere
  43827. */
  43828. readonly videoTexture: VideoTexture;
  43829. /**
  43830. * The skybox material
  43831. */
  43832. protected _material: BackgroundMaterial;
  43833. /**
  43834. * The surface used for the skybox
  43835. */
  43836. protected _mesh: Mesh;
  43837. /**
  43838. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43839. * Also see the options.resolution property.
  43840. */
  43841. fovMultiplier: number;
  43842. /**
  43843. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43844. * @param name Element's name, child elements will append suffixes for their own names.
  43845. * @param urlsOrVideo defines the url(s) or the video element to use
  43846. * @param options An object containing optional or exposed sub element properties
  43847. */
  43848. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43849. resolution?: number;
  43850. clickToPlay?: boolean;
  43851. autoPlay?: boolean;
  43852. loop?: boolean;
  43853. size?: number;
  43854. poster?: string;
  43855. useDirectMapping?: boolean;
  43856. }, scene: Scene);
  43857. /**
  43858. * Releases resources associated with this node.
  43859. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43860. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43861. */
  43862. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43863. }
  43864. }
  43865. declare module BABYLON {
  43866. /**
  43867. * This class can be used to get instrumentation data from a Babylon engine
  43868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43869. */
  43870. export class EngineInstrumentation implements IDisposable {
  43871. /**
  43872. * Define the instrumented engine.
  43873. */
  43874. engine: Engine;
  43875. private _captureGPUFrameTime;
  43876. private _gpuFrameTimeToken;
  43877. private _gpuFrameTime;
  43878. private _captureShaderCompilationTime;
  43879. private _shaderCompilationTime;
  43880. private _onBeginFrameObserver;
  43881. private _onEndFrameObserver;
  43882. private _onBeforeShaderCompilationObserver;
  43883. private _onAfterShaderCompilationObserver;
  43884. /**
  43885. * Gets the perf counter used for GPU frame time
  43886. */
  43887. readonly gpuFrameTimeCounter: PerfCounter;
  43888. /**
  43889. * Gets the GPU frame time capture status
  43890. */
  43891. /**
  43892. * Enable or disable the GPU frame time capture
  43893. */
  43894. captureGPUFrameTime: boolean;
  43895. /**
  43896. * Gets the perf counter used for shader compilation time
  43897. */
  43898. readonly shaderCompilationTimeCounter: PerfCounter;
  43899. /**
  43900. * Gets the shader compilation time capture status
  43901. */
  43902. /**
  43903. * Enable or disable the shader compilation time capture
  43904. */
  43905. captureShaderCompilationTime: boolean;
  43906. /**
  43907. * Instantiates a new engine instrumentation.
  43908. * This class can be used to get instrumentation data from a Babylon engine
  43909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43910. * @param engine Defines the engine to instrument
  43911. */
  43912. constructor(
  43913. /**
  43914. * Define the instrumented engine.
  43915. */
  43916. engine: Engine);
  43917. /**
  43918. * Dispose and release associated resources.
  43919. */
  43920. dispose(): void;
  43921. }
  43922. }
  43923. declare module BABYLON {
  43924. /**
  43925. * This class can be used to get instrumentation data from a Babylon engine
  43926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43927. */
  43928. export class SceneInstrumentation implements IDisposable {
  43929. /**
  43930. * Defines the scene to instrument
  43931. */
  43932. scene: Scene;
  43933. private _captureActiveMeshesEvaluationTime;
  43934. private _activeMeshesEvaluationTime;
  43935. private _captureRenderTargetsRenderTime;
  43936. private _renderTargetsRenderTime;
  43937. private _captureFrameTime;
  43938. private _frameTime;
  43939. private _captureRenderTime;
  43940. private _renderTime;
  43941. private _captureInterFrameTime;
  43942. private _interFrameTime;
  43943. private _captureParticlesRenderTime;
  43944. private _particlesRenderTime;
  43945. private _captureSpritesRenderTime;
  43946. private _spritesRenderTime;
  43947. private _capturePhysicsTime;
  43948. private _physicsTime;
  43949. private _captureAnimationsTime;
  43950. private _animationsTime;
  43951. private _captureCameraRenderTime;
  43952. private _cameraRenderTime;
  43953. private _onBeforeActiveMeshesEvaluationObserver;
  43954. private _onAfterActiveMeshesEvaluationObserver;
  43955. private _onBeforeRenderTargetsRenderObserver;
  43956. private _onAfterRenderTargetsRenderObserver;
  43957. private _onAfterRenderObserver;
  43958. private _onBeforeDrawPhaseObserver;
  43959. private _onAfterDrawPhaseObserver;
  43960. private _onBeforeAnimationsObserver;
  43961. private _onBeforeParticlesRenderingObserver;
  43962. private _onAfterParticlesRenderingObserver;
  43963. private _onBeforeSpritesRenderingObserver;
  43964. private _onAfterSpritesRenderingObserver;
  43965. private _onBeforePhysicsObserver;
  43966. private _onAfterPhysicsObserver;
  43967. private _onAfterAnimationsObserver;
  43968. private _onBeforeCameraRenderObserver;
  43969. private _onAfterCameraRenderObserver;
  43970. /**
  43971. * Gets the perf counter used for active meshes evaluation time
  43972. */
  43973. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  43974. /**
  43975. * Gets the active meshes evaluation time capture status
  43976. */
  43977. /**
  43978. * Enable or disable the active meshes evaluation time capture
  43979. */
  43980. captureActiveMeshesEvaluationTime: boolean;
  43981. /**
  43982. * Gets the perf counter used for render targets render time
  43983. */
  43984. readonly renderTargetsRenderTimeCounter: PerfCounter;
  43985. /**
  43986. * Gets the render targets render time capture status
  43987. */
  43988. /**
  43989. * Enable or disable the render targets render time capture
  43990. */
  43991. captureRenderTargetsRenderTime: boolean;
  43992. /**
  43993. * Gets the perf counter used for particles render time
  43994. */
  43995. readonly particlesRenderTimeCounter: PerfCounter;
  43996. /**
  43997. * Gets the particles render time capture status
  43998. */
  43999. /**
  44000. * Enable or disable the particles render time capture
  44001. */
  44002. captureParticlesRenderTime: boolean;
  44003. /**
  44004. * Gets the perf counter used for sprites render time
  44005. */
  44006. readonly spritesRenderTimeCounter: PerfCounter;
  44007. /**
  44008. * Gets the sprites render time capture status
  44009. */
  44010. /**
  44011. * Enable or disable the sprites render time capture
  44012. */
  44013. captureSpritesRenderTime: boolean;
  44014. /**
  44015. * Gets the perf counter used for physics time
  44016. */
  44017. readonly physicsTimeCounter: PerfCounter;
  44018. /**
  44019. * Gets the physics time capture status
  44020. */
  44021. /**
  44022. * Enable or disable the physics time capture
  44023. */
  44024. capturePhysicsTime: boolean;
  44025. /**
  44026. * Gets the perf counter used for animations time
  44027. */
  44028. readonly animationsTimeCounter: PerfCounter;
  44029. /**
  44030. * Gets the animations time capture status
  44031. */
  44032. /**
  44033. * Enable or disable the animations time capture
  44034. */
  44035. captureAnimationsTime: boolean;
  44036. /**
  44037. * Gets the perf counter used for frame time capture
  44038. */
  44039. readonly frameTimeCounter: PerfCounter;
  44040. /**
  44041. * Gets the frame time capture status
  44042. */
  44043. /**
  44044. * Enable or disable the frame time capture
  44045. */
  44046. captureFrameTime: boolean;
  44047. /**
  44048. * Gets the perf counter used for inter-frames time capture
  44049. */
  44050. readonly interFrameTimeCounter: PerfCounter;
  44051. /**
  44052. * Gets the inter-frames time capture status
  44053. */
  44054. /**
  44055. * Enable or disable the inter-frames time capture
  44056. */
  44057. captureInterFrameTime: boolean;
  44058. /**
  44059. * Gets the perf counter used for render time capture
  44060. */
  44061. readonly renderTimeCounter: PerfCounter;
  44062. /**
  44063. * Gets the render time capture status
  44064. */
  44065. /**
  44066. * Enable or disable the render time capture
  44067. */
  44068. captureRenderTime: boolean;
  44069. /**
  44070. * Gets the perf counter used for camera render time capture
  44071. */
  44072. readonly cameraRenderTimeCounter: PerfCounter;
  44073. /**
  44074. * Gets the camera render time capture status
  44075. */
  44076. /**
  44077. * Enable or disable the camera render time capture
  44078. */
  44079. captureCameraRenderTime: boolean;
  44080. /**
  44081. * Gets the perf counter used for draw calls
  44082. */
  44083. readonly drawCallsCounter: PerfCounter;
  44084. /**
  44085. * Gets the perf counter used for texture collisions
  44086. */
  44087. readonly textureCollisionsCounter: PerfCounter;
  44088. /**
  44089. * Instantiates a new scene instrumentation.
  44090. * This class can be used to get instrumentation data from a Babylon engine
  44091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44092. * @param scene Defines the scene to instrument
  44093. */
  44094. constructor(
  44095. /**
  44096. * Defines the scene to instrument
  44097. */
  44098. scene: Scene);
  44099. /**
  44100. * Dispose and release associated resources.
  44101. */
  44102. dispose(): void;
  44103. }
  44104. }
  44105. declare module BABYLON {
  44106. /** @hidden */
  44107. export var glowMapGenerationPixelShader: {
  44108. name: string;
  44109. shader: string;
  44110. };
  44111. }
  44112. declare module BABYLON {
  44113. /** @hidden */
  44114. export var glowMapGenerationVertexShader: {
  44115. name: string;
  44116. shader: string;
  44117. };
  44118. }
  44119. declare module BABYLON {
  44120. /**
  44121. * Effect layer options. This helps customizing the behaviour
  44122. * of the effect layer.
  44123. */
  44124. export interface IEffectLayerOptions {
  44125. /**
  44126. * Multiplication factor apply to the canvas size to compute the render target size
  44127. * used to generated the objects (the smaller the faster).
  44128. */
  44129. mainTextureRatio: number;
  44130. /**
  44131. * Enforces a fixed size texture to ensure effect stability across devices.
  44132. */
  44133. mainTextureFixedSize?: number;
  44134. /**
  44135. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  44136. */
  44137. alphaBlendingMode: number;
  44138. /**
  44139. * The camera attached to the layer.
  44140. */
  44141. camera: Nullable<Camera>;
  44142. /**
  44143. * The rendering group to draw the layer in.
  44144. */
  44145. renderingGroupId: number;
  44146. }
  44147. /**
  44148. * The effect layer Helps adding post process effect blended with the main pass.
  44149. *
  44150. * This can be for instance use to generate glow or higlight effects on the scene.
  44151. *
  44152. * The effect layer class can not be used directly and is intented to inherited from to be
  44153. * customized per effects.
  44154. */
  44155. export abstract class EffectLayer {
  44156. private _vertexBuffers;
  44157. private _indexBuffer;
  44158. private _cachedDefines;
  44159. private _effectLayerMapGenerationEffect;
  44160. private _effectLayerOptions;
  44161. private _mergeEffect;
  44162. protected _scene: Scene;
  44163. protected _engine: Engine;
  44164. protected _maxSize: number;
  44165. protected _mainTextureDesiredSize: ISize;
  44166. protected _mainTexture: RenderTargetTexture;
  44167. protected _shouldRender: boolean;
  44168. protected _postProcesses: PostProcess[];
  44169. protected _textures: BaseTexture[];
  44170. protected _emissiveTextureAndColor: {
  44171. texture: Nullable<BaseTexture>;
  44172. color: Color4;
  44173. };
  44174. /**
  44175. * The name of the layer
  44176. */
  44177. name: string;
  44178. /**
  44179. * The clear color of the texture used to generate the glow map.
  44180. */
  44181. neutralColor: Color4;
  44182. /**
  44183. * Specifies wether the highlight layer is enabled or not.
  44184. */
  44185. isEnabled: boolean;
  44186. /**
  44187. * Gets the camera attached to the layer.
  44188. */
  44189. readonly camera: Nullable<Camera>;
  44190. /**
  44191. * Gets the rendering group id the layer should render in.
  44192. */
  44193. readonly renderingGroupId: number;
  44194. /**
  44195. * An event triggered when the effect layer has been disposed.
  44196. */
  44197. onDisposeObservable: Observable<EffectLayer>;
  44198. /**
  44199. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  44200. */
  44201. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  44202. /**
  44203. * An event triggered when the generated texture is being merged in the scene.
  44204. */
  44205. onBeforeComposeObservable: Observable<EffectLayer>;
  44206. /**
  44207. * An event triggered when the generated texture has been merged in the scene.
  44208. */
  44209. onAfterComposeObservable: Observable<EffectLayer>;
  44210. /**
  44211. * An event triggered when the efffect layer changes its size.
  44212. */
  44213. onSizeChangedObservable: Observable<EffectLayer>;
  44214. /** @hidden */
  44215. static _SceneComponentInitialization: (scene: Scene) => void;
  44216. /**
  44217. * Instantiates a new effect Layer and references it in the scene.
  44218. * @param name The name of the layer
  44219. * @param scene The scene to use the layer in
  44220. */
  44221. constructor(
  44222. /** The Friendly of the effect in the scene */
  44223. name: string, scene: Scene);
  44224. /**
  44225. * Get the effect name of the layer.
  44226. * @return The effect name
  44227. */
  44228. abstract getEffectName(): string;
  44229. /**
  44230. * Checks for the readiness of the element composing the layer.
  44231. * @param subMesh the mesh to check for
  44232. * @param useInstances specify wether or not to use instances to render the mesh
  44233. * @return true if ready otherwise, false
  44234. */
  44235. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44236. /**
  44237. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44238. * @returns true if the effect requires stencil during the main canvas render pass.
  44239. */
  44240. abstract needStencil(): boolean;
  44241. /**
  44242. * Create the merge effect. This is the shader use to blit the information back
  44243. * to the main canvas at the end of the scene rendering.
  44244. * @returns The effect containing the shader used to merge the effect on the main canvas
  44245. */
  44246. protected abstract _createMergeEffect(): Effect;
  44247. /**
  44248. * Creates the render target textures and post processes used in the effect layer.
  44249. */
  44250. protected abstract _createTextureAndPostProcesses(): void;
  44251. /**
  44252. * Implementation specific of rendering the generating effect on the main canvas.
  44253. * @param effect The effect used to render through
  44254. */
  44255. protected abstract _internalRender(effect: Effect): void;
  44256. /**
  44257. * Sets the required values for both the emissive texture and and the main color.
  44258. */
  44259. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44260. /**
  44261. * Free any resources and references associated to a mesh.
  44262. * Internal use
  44263. * @param mesh The mesh to free.
  44264. */
  44265. abstract _disposeMesh(mesh: Mesh): void;
  44266. /**
  44267. * Serializes this layer (Glow or Highlight for example)
  44268. * @returns a serialized layer object
  44269. */
  44270. abstract serialize?(): any;
  44271. /**
  44272. * Initializes the effect layer with the required options.
  44273. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  44274. */
  44275. protected _init(options: Partial<IEffectLayerOptions>): void;
  44276. /**
  44277. * Generates the index buffer of the full screen quad blending to the main canvas.
  44278. */
  44279. private _generateIndexBuffer;
  44280. /**
  44281. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  44282. */
  44283. private _genrateVertexBuffer;
  44284. /**
  44285. * Sets the main texture desired size which is the closest power of two
  44286. * of the engine canvas size.
  44287. */
  44288. private _setMainTextureSize;
  44289. /**
  44290. * Creates the main texture for the effect layer.
  44291. */
  44292. protected _createMainTexture(): void;
  44293. /**
  44294. * Adds specific effects defines.
  44295. * @param defines The defines to add specifics to.
  44296. */
  44297. protected _addCustomEffectDefines(defines: string[]): void;
  44298. /**
  44299. * Checks for the readiness of the element composing the layer.
  44300. * @param subMesh the mesh to check for
  44301. * @param useInstances specify wether or not to use instances to render the mesh
  44302. * @param emissiveTexture the associated emissive texture used to generate the glow
  44303. * @return true if ready otherwise, false
  44304. */
  44305. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  44306. /**
  44307. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  44308. */
  44309. render(): void;
  44310. /**
  44311. * Determine if a given mesh will be used in the current effect.
  44312. * @param mesh mesh to test
  44313. * @returns true if the mesh will be used
  44314. */
  44315. hasMesh(mesh: AbstractMesh): boolean;
  44316. /**
  44317. * Returns true if the layer contains information to display, otherwise false.
  44318. * @returns true if the glow layer should be rendered
  44319. */
  44320. shouldRender(): boolean;
  44321. /**
  44322. * Returns true if the mesh should render, otherwise false.
  44323. * @param mesh The mesh to render
  44324. * @returns true if it should render otherwise false
  44325. */
  44326. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  44327. /**
  44328. * Returns true if the mesh can be rendered, otherwise false.
  44329. * @param mesh The mesh to render
  44330. * @param material The material used on the mesh
  44331. * @returns true if it can be rendered otherwise false
  44332. */
  44333. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44334. /**
  44335. * Returns true if the mesh should render, otherwise false.
  44336. * @param mesh The mesh to render
  44337. * @returns true if it should render otherwise false
  44338. */
  44339. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  44340. /**
  44341. * Renders the submesh passed in parameter to the generation map.
  44342. */
  44343. protected _renderSubMesh(subMesh: SubMesh): void;
  44344. /**
  44345. * Rebuild the required buffers.
  44346. * @hidden Internal use only.
  44347. */
  44348. _rebuild(): void;
  44349. /**
  44350. * Dispose only the render target textures and post process.
  44351. */
  44352. private _disposeTextureAndPostProcesses;
  44353. /**
  44354. * Dispose the highlight layer and free resources.
  44355. */
  44356. dispose(): void;
  44357. /**
  44358. * Gets the class name of the effect layer
  44359. * @returns the string with the class name of the effect layer
  44360. */
  44361. getClassName(): string;
  44362. /**
  44363. * Creates an effect layer from parsed effect layer data
  44364. * @param parsedEffectLayer defines effect layer data
  44365. * @param scene defines the current scene
  44366. * @param rootUrl defines the root URL containing the effect layer information
  44367. * @returns a parsed effect Layer
  44368. */
  44369. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. interface AbstractScene {
  44374. /**
  44375. * The list of effect layers (highlights/glow) added to the scene
  44376. * @see http://doc.babylonjs.com/how_to/highlight_layer
  44377. * @see http://doc.babylonjs.com/how_to/glow_layer
  44378. */
  44379. effectLayers: Array<EffectLayer>;
  44380. /**
  44381. * Removes the given effect layer from this scene.
  44382. * @param toRemove defines the effect layer to remove
  44383. * @returns the index of the removed effect layer
  44384. */
  44385. removeEffectLayer(toRemove: EffectLayer): number;
  44386. /**
  44387. * Adds the given effect layer to this scene
  44388. * @param newEffectLayer defines the effect layer to add
  44389. */
  44390. addEffectLayer(newEffectLayer: EffectLayer): void;
  44391. }
  44392. /**
  44393. * Defines the layer scene component responsible to manage any effect layers
  44394. * in a given scene.
  44395. */
  44396. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  44397. /**
  44398. * The component name helpfull to identify the component in the list of scene components.
  44399. */
  44400. readonly name: string;
  44401. /**
  44402. * The scene the component belongs to.
  44403. */
  44404. scene: Scene;
  44405. private _engine;
  44406. private _renderEffects;
  44407. private _needStencil;
  44408. private _previousStencilState;
  44409. /**
  44410. * Creates a new instance of the component for the given scene
  44411. * @param scene Defines the scene to register the component in
  44412. */
  44413. constructor(scene: Scene);
  44414. /**
  44415. * Registers the component in a given scene
  44416. */
  44417. register(): void;
  44418. /**
  44419. * Rebuilds the elements related to this component in case of
  44420. * context lost for instance.
  44421. */
  44422. rebuild(): void;
  44423. /**
  44424. * Serializes the component data to the specified json object
  44425. * @param serializationObject The object to serialize to
  44426. */
  44427. serialize(serializationObject: any): void;
  44428. /**
  44429. * Adds all the element from the container to the scene
  44430. * @param container the container holding the elements
  44431. */
  44432. addFromContainer(container: AbstractScene): void;
  44433. /**
  44434. * Removes all the elements in the container from the scene
  44435. * @param container contains the elements to remove
  44436. */
  44437. removeFromContainer(container: AbstractScene): void;
  44438. /**
  44439. * Disposes the component and the associated ressources.
  44440. */
  44441. dispose(): void;
  44442. private _isReadyForMesh;
  44443. private _renderMainTexture;
  44444. private _setStencil;
  44445. private _setStencilBack;
  44446. private _draw;
  44447. private _drawCamera;
  44448. private _drawRenderingGroup;
  44449. }
  44450. }
  44451. declare module BABYLON {
  44452. /** @hidden */
  44453. export var glowMapMergePixelShader: {
  44454. name: string;
  44455. shader: string;
  44456. };
  44457. }
  44458. declare module BABYLON {
  44459. /** @hidden */
  44460. export var glowMapMergeVertexShader: {
  44461. name: string;
  44462. shader: string;
  44463. };
  44464. }
  44465. declare module BABYLON {
  44466. interface AbstractScene {
  44467. /**
  44468. * Return a the first highlight layer of the scene with a given name.
  44469. * @param name The name of the highlight layer to look for.
  44470. * @return The highlight layer if found otherwise null.
  44471. */
  44472. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  44473. }
  44474. /**
  44475. * Glow layer options. This helps customizing the behaviour
  44476. * of the glow layer.
  44477. */
  44478. export interface IGlowLayerOptions {
  44479. /**
  44480. * Multiplication factor apply to the canvas size to compute the render target size
  44481. * used to generated the glowing objects (the smaller the faster).
  44482. */
  44483. mainTextureRatio: number;
  44484. /**
  44485. * Enforces a fixed size texture to ensure resize independant blur.
  44486. */
  44487. mainTextureFixedSize?: number;
  44488. /**
  44489. * How big is the kernel of the blur texture.
  44490. */
  44491. blurKernelSize: number;
  44492. /**
  44493. * The camera attached to the layer.
  44494. */
  44495. camera: Nullable<Camera>;
  44496. /**
  44497. * Enable MSAA by chosing the number of samples.
  44498. */
  44499. mainTextureSamples?: number;
  44500. /**
  44501. * The rendering group to draw the layer in.
  44502. */
  44503. renderingGroupId: number;
  44504. }
  44505. /**
  44506. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  44507. *
  44508. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44509. * glowy meshes to your scene.
  44510. *
  44511. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  44512. */
  44513. export class GlowLayer extends EffectLayer {
  44514. /**
  44515. * Effect Name of the layer.
  44516. */
  44517. static readonly EffectName: string;
  44518. /**
  44519. * The default blur kernel size used for the glow.
  44520. */
  44521. static DefaultBlurKernelSize: number;
  44522. /**
  44523. * The default texture size ratio used for the glow.
  44524. */
  44525. static DefaultTextureRatio: number;
  44526. /**
  44527. * Sets the kernel size of the blur.
  44528. */
  44529. /**
  44530. * Gets the kernel size of the blur.
  44531. */
  44532. blurKernelSize: number;
  44533. /**
  44534. * Sets the glow intensity.
  44535. */
  44536. /**
  44537. * Gets the glow intensity.
  44538. */
  44539. intensity: number;
  44540. private _options;
  44541. private _intensity;
  44542. private _horizontalBlurPostprocess1;
  44543. private _verticalBlurPostprocess1;
  44544. private _horizontalBlurPostprocess2;
  44545. private _verticalBlurPostprocess2;
  44546. private _blurTexture1;
  44547. private _blurTexture2;
  44548. private _postProcesses1;
  44549. private _postProcesses2;
  44550. private _includedOnlyMeshes;
  44551. private _excludedMeshes;
  44552. /**
  44553. * Callback used to let the user override the color selection on a per mesh basis
  44554. */
  44555. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  44556. /**
  44557. * Callback used to let the user override the texture selection on a per mesh basis
  44558. */
  44559. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  44560. /**
  44561. * Instantiates a new glow Layer and references it to the scene.
  44562. * @param name The name of the layer
  44563. * @param scene The scene to use the layer in
  44564. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  44565. */
  44566. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  44567. /**
  44568. * Get the effect name of the layer.
  44569. * @return The effect name
  44570. */
  44571. getEffectName(): string;
  44572. /**
  44573. * Create the merge effect. This is the shader use to blit the information back
  44574. * to the main canvas at the end of the scene rendering.
  44575. */
  44576. protected _createMergeEffect(): Effect;
  44577. /**
  44578. * Creates the render target textures and post processes used in the glow layer.
  44579. */
  44580. protected _createTextureAndPostProcesses(): void;
  44581. /**
  44582. * Checks for the readiness of the element composing the layer.
  44583. * @param subMesh the mesh to check for
  44584. * @param useInstances specify wether or not to use instances to render the mesh
  44585. * @param emissiveTexture the associated emissive texture used to generate the glow
  44586. * @return true if ready otherwise, false
  44587. */
  44588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44589. /**
  44590. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44591. */
  44592. needStencil(): boolean;
  44593. /**
  44594. * Returns true if the mesh can be rendered, otherwise false.
  44595. * @param mesh The mesh to render
  44596. * @param material The material used on the mesh
  44597. * @returns true if it can be rendered otherwise false
  44598. */
  44599. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44600. /**
  44601. * Implementation specific of rendering the generating effect on the main canvas.
  44602. * @param effect The effect used to render through
  44603. */
  44604. protected _internalRender(effect: Effect): void;
  44605. /**
  44606. * Sets the required values for both the emissive texture and and the main color.
  44607. */
  44608. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44609. /**
  44610. * Returns true if the mesh should render, otherwise false.
  44611. * @param mesh The mesh to render
  44612. * @returns true if it should render otherwise false
  44613. */
  44614. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44615. /**
  44616. * Adds specific effects defines.
  44617. * @param defines The defines to add specifics to.
  44618. */
  44619. protected _addCustomEffectDefines(defines: string[]): void;
  44620. /**
  44621. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44622. * @param mesh The mesh to exclude from the glow layer
  44623. */
  44624. addExcludedMesh(mesh: Mesh): void;
  44625. /**
  44626. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44627. * @param mesh The mesh to remove
  44628. */
  44629. removeExcludedMesh(mesh: Mesh): void;
  44630. /**
  44631. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44632. * @param mesh The mesh to include in the glow layer
  44633. */
  44634. addIncludedOnlyMesh(mesh: Mesh): void;
  44635. /**
  44636. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44637. * @param mesh The mesh to remove
  44638. */
  44639. removeIncludedOnlyMesh(mesh: Mesh): void;
  44640. /**
  44641. * Determine if a given mesh will be used in the glow layer
  44642. * @param mesh The mesh to test
  44643. * @returns true if the mesh will be highlighted by the current glow layer
  44644. */
  44645. hasMesh(mesh: AbstractMesh): boolean;
  44646. /**
  44647. * Free any resources and references associated to a mesh.
  44648. * Internal use
  44649. * @param mesh The mesh to free.
  44650. * @hidden
  44651. */
  44652. _disposeMesh(mesh: Mesh): void;
  44653. /**
  44654. * Gets the class name of the effect layer
  44655. * @returns the string with the class name of the effect layer
  44656. */
  44657. getClassName(): string;
  44658. /**
  44659. * Serializes this glow layer
  44660. * @returns a serialized glow layer object
  44661. */
  44662. serialize(): any;
  44663. /**
  44664. * Creates a Glow Layer from parsed glow layer data
  44665. * @param parsedGlowLayer defines glow layer data
  44666. * @param scene defines the current scene
  44667. * @param rootUrl defines the root URL containing the glow layer information
  44668. * @returns a parsed Glow Layer
  44669. */
  44670. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44671. }
  44672. }
  44673. declare module BABYLON {
  44674. /** @hidden */
  44675. export var glowBlurPostProcessPixelShader: {
  44676. name: string;
  44677. shader: string;
  44678. };
  44679. }
  44680. declare module BABYLON {
  44681. interface AbstractScene {
  44682. /**
  44683. * Return a the first highlight layer of the scene with a given name.
  44684. * @param name The name of the highlight layer to look for.
  44685. * @return The highlight layer if found otherwise null.
  44686. */
  44687. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44688. }
  44689. /**
  44690. * Highlight layer options. This helps customizing the behaviour
  44691. * of the highlight layer.
  44692. */
  44693. export interface IHighlightLayerOptions {
  44694. /**
  44695. * Multiplication factor apply to the canvas size to compute the render target size
  44696. * used to generated the glowing objects (the smaller the faster).
  44697. */
  44698. mainTextureRatio: number;
  44699. /**
  44700. * Enforces a fixed size texture to ensure resize independant blur.
  44701. */
  44702. mainTextureFixedSize?: number;
  44703. /**
  44704. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44705. * of the picture to blur (the smaller the faster).
  44706. */
  44707. blurTextureSizeRatio: number;
  44708. /**
  44709. * How big in texel of the blur texture is the vertical blur.
  44710. */
  44711. blurVerticalSize: number;
  44712. /**
  44713. * How big in texel of the blur texture is the horizontal blur.
  44714. */
  44715. blurHorizontalSize: number;
  44716. /**
  44717. * Alpha blending mode used to apply the blur. Default is combine.
  44718. */
  44719. alphaBlendingMode: number;
  44720. /**
  44721. * The camera attached to the layer.
  44722. */
  44723. camera: Nullable<Camera>;
  44724. /**
  44725. * Should we display highlight as a solid stroke?
  44726. */
  44727. isStroke?: boolean;
  44728. /**
  44729. * The rendering group to draw the layer in.
  44730. */
  44731. renderingGroupId: number;
  44732. }
  44733. /**
  44734. * The highlight layer Helps adding a glow effect around a mesh.
  44735. *
  44736. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44737. * glowy meshes to your scene.
  44738. *
  44739. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44740. */
  44741. export class HighlightLayer extends EffectLayer {
  44742. name: string;
  44743. /**
  44744. * Effect Name of the highlight layer.
  44745. */
  44746. static readonly EffectName: string;
  44747. /**
  44748. * The neutral color used during the preparation of the glow effect.
  44749. * This is black by default as the blend operation is a blend operation.
  44750. */
  44751. static NeutralColor: Color4;
  44752. /**
  44753. * Stencil value used for glowing meshes.
  44754. */
  44755. static GlowingMeshStencilReference: number;
  44756. /**
  44757. * Stencil value used for the other meshes in the scene.
  44758. */
  44759. static NormalMeshStencilReference: number;
  44760. /**
  44761. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44762. */
  44763. innerGlow: boolean;
  44764. /**
  44765. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44766. */
  44767. outerGlow: boolean;
  44768. /**
  44769. * Specifies the horizontal size of the blur.
  44770. */
  44771. /**
  44772. * Gets the horizontal size of the blur.
  44773. */
  44774. blurHorizontalSize: number;
  44775. /**
  44776. * Specifies the vertical size of the blur.
  44777. */
  44778. /**
  44779. * Gets the vertical size of the blur.
  44780. */
  44781. blurVerticalSize: number;
  44782. /**
  44783. * An event triggered when the highlight layer is being blurred.
  44784. */
  44785. onBeforeBlurObservable: Observable<HighlightLayer>;
  44786. /**
  44787. * An event triggered when the highlight layer has been blurred.
  44788. */
  44789. onAfterBlurObservable: Observable<HighlightLayer>;
  44790. private _instanceGlowingMeshStencilReference;
  44791. private _options;
  44792. private _downSamplePostprocess;
  44793. private _horizontalBlurPostprocess;
  44794. private _verticalBlurPostprocess;
  44795. private _blurTexture;
  44796. private _meshes;
  44797. private _excludedMeshes;
  44798. /**
  44799. * Instantiates a new highlight Layer and references it to the scene..
  44800. * @param name The name of the layer
  44801. * @param scene The scene to use the layer in
  44802. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44803. */
  44804. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44805. /**
  44806. * Get the effect name of the layer.
  44807. * @return The effect name
  44808. */
  44809. getEffectName(): string;
  44810. /**
  44811. * Create the merge effect. This is the shader use to blit the information back
  44812. * to the main canvas at the end of the scene rendering.
  44813. */
  44814. protected _createMergeEffect(): Effect;
  44815. /**
  44816. * Creates the render target textures and post processes used in the highlight layer.
  44817. */
  44818. protected _createTextureAndPostProcesses(): void;
  44819. /**
  44820. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44821. */
  44822. needStencil(): boolean;
  44823. /**
  44824. * Checks for the readiness of the element composing the layer.
  44825. * @param subMesh the mesh to check for
  44826. * @param useInstances specify wether or not to use instances to render the mesh
  44827. * @param emissiveTexture the associated emissive texture used to generate the glow
  44828. * @return true if ready otherwise, false
  44829. */
  44830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44831. /**
  44832. * Implementation specific of rendering the generating effect on the main canvas.
  44833. * @param effect The effect used to render through
  44834. */
  44835. protected _internalRender(effect: Effect): void;
  44836. /**
  44837. * Returns true if the layer contains information to display, otherwise false.
  44838. */
  44839. shouldRender(): boolean;
  44840. /**
  44841. * Returns true if the mesh should render, otherwise false.
  44842. * @param mesh The mesh to render
  44843. * @returns true if it should render otherwise false
  44844. */
  44845. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44846. /**
  44847. * Sets the required values for both the emissive texture and and the main color.
  44848. */
  44849. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44850. /**
  44851. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44852. * @param mesh The mesh to exclude from the highlight layer
  44853. */
  44854. addExcludedMesh(mesh: Mesh): void;
  44855. /**
  44856. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44857. * @param mesh The mesh to highlight
  44858. */
  44859. removeExcludedMesh(mesh: Mesh): void;
  44860. /**
  44861. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44862. * @param mesh mesh to test
  44863. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44864. */
  44865. hasMesh(mesh: AbstractMesh): boolean;
  44866. /**
  44867. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44868. * @param mesh The mesh to highlight
  44869. * @param color The color of the highlight
  44870. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44871. */
  44872. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44873. /**
  44874. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44875. * @param mesh The mesh to highlight
  44876. */
  44877. removeMesh(mesh: Mesh): void;
  44878. /**
  44879. * Force the stencil to the normal expected value for none glowing parts
  44880. */
  44881. private _defaultStencilReference;
  44882. /**
  44883. * Free any resources and references associated to a mesh.
  44884. * Internal use
  44885. * @param mesh The mesh to free.
  44886. * @hidden
  44887. */
  44888. _disposeMesh(mesh: Mesh): void;
  44889. /**
  44890. * Dispose the highlight layer and free resources.
  44891. */
  44892. dispose(): void;
  44893. /**
  44894. * Gets the class name of the effect layer
  44895. * @returns the string with the class name of the effect layer
  44896. */
  44897. getClassName(): string;
  44898. /**
  44899. * Serializes this Highlight layer
  44900. * @returns a serialized Highlight layer object
  44901. */
  44902. serialize(): any;
  44903. /**
  44904. * Creates a Highlight layer from parsed Highlight layer data
  44905. * @param parsedHightlightLayer defines the Highlight layer data
  44906. * @param scene defines the current scene
  44907. * @param rootUrl defines the root URL containing the Highlight layer information
  44908. * @returns a parsed Highlight layer
  44909. */
  44910. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44911. }
  44912. }
  44913. declare module BABYLON {
  44914. /** @hidden */
  44915. export var lensFlarePixelShader: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module BABYLON {
  44921. /** @hidden */
  44922. export var lensFlareVertexShader: {
  44923. name: string;
  44924. shader: string;
  44925. };
  44926. }
  44927. declare module BABYLON {
  44928. /**
  44929. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44930. * It is usually composed of several `lensFlare`.
  44931. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44932. */
  44933. export class LensFlareSystem {
  44934. /**
  44935. * Define the name of the lens flare system
  44936. */
  44937. name: string;
  44938. /**
  44939. * List of lens flares used in this system.
  44940. */
  44941. lensFlares: LensFlare[];
  44942. /**
  44943. * Define a limit from the border the lens flare can be visible.
  44944. */
  44945. borderLimit: number;
  44946. /**
  44947. * Define a viewport border we do not want to see the lens flare in.
  44948. */
  44949. viewportBorder: number;
  44950. /**
  44951. * Define a predicate which could limit the list of meshes able to occlude the effect.
  44952. */
  44953. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44954. /**
  44955. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44956. */
  44957. layerMask: number;
  44958. /**
  44959. * Define the id of the lens flare system in the scene.
  44960. * (equal to name by default)
  44961. */
  44962. id: string;
  44963. private _scene;
  44964. private _emitter;
  44965. private _vertexBuffers;
  44966. private _indexBuffer;
  44967. private _effect;
  44968. private _positionX;
  44969. private _positionY;
  44970. private _isEnabled;
  44971. /** @hidden */
  44972. static _SceneComponentInitialization: (scene: Scene) => void;
  44973. /**
  44974. * Instantiates a lens flare system.
  44975. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44976. * It is usually composed of several `lensFlare`.
  44977. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44978. * @param name Define the name of the lens flare system in the scene
  44979. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44980. * @param scene Define the scene the lens flare system belongs to
  44981. */
  44982. constructor(
  44983. /**
  44984. * Define the name of the lens flare system
  44985. */
  44986. name: string, emitter: any, scene: Scene);
  44987. /**
  44988. * Define if the lens flare system is enabled.
  44989. */
  44990. isEnabled: boolean;
  44991. /**
  44992. * Get the scene the effects belongs to.
  44993. * @returns the scene holding the lens flare system
  44994. */
  44995. getScene(): Scene;
  44996. /**
  44997. * Get the emitter of the lens flare system.
  44998. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44999. * @returns the emitter of the lens flare system
  45000. */
  45001. getEmitter(): any;
  45002. /**
  45003. * Set the emitter of the lens flare system.
  45004. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45005. * @param newEmitter Define the new emitter of the system
  45006. */
  45007. setEmitter(newEmitter: any): void;
  45008. /**
  45009. * Get the lens flare system emitter position.
  45010. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45011. * @returns the position
  45012. */
  45013. getEmitterPosition(): Vector3;
  45014. /**
  45015. * @hidden
  45016. */
  45017. computeEffectivePosition(globalViewport: Viewport): boolean;
  45018. /** @hidden */
  45019. _isVisible(): boolean;
  45020. /**
  45021. * @hidden
  45022. */
  45023. render(): boolean;
  45024. /**
  45025. * Dispose and release the lens flare with its associated resources.
  45026. */
  45027. dispose(): void;
  45028. /**
  45029. * Parse a lens flare system from a JSON repressentation
  45030. * @param parsedLensFlareSystem Define the JSON to parse
  45031. * @param scene Define the scene the parsed system should be instantiated in
  45032. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45033. * @returns the parsed system
  45034. */
  45035. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  45036. /**
  45037. * Serialize the current Lens Flare System into a JSON representation.
  45038. * @returns the serialized JSON
  45039. */
  45040. serialize(): any;
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. /**
  45045. * This represents one of the lens effect in a `lensFlareSystem`.
  45046. * It controls one of the indiviual texture used in the effect.
  45047. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45048. */
  45049. export class LensFlare {
  45050. /**
  45051. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45052. */
  45053. size: number;
  45054. /**
  45055. * 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.
  45056. */
  45057. position: number;
  45058. /**
  45059. * Define the lens color.
  45060. */
  45061. color: Color3;
  45062. /**
  45063. * Define the lens texture.
  45064. */
  45065. texture: Nullable<Texture>;
  45066. /**
  45067. * Define the alpha mode to render this particular lens.
  45068. */
  45069. alphaMode: number;
  45070. private _system;
  45071. /**
  45072. * Creates a new Lens Flare.
  45073. * This represents one of the lens effect in a `lensFlareSystem`.
  45074. * It controls one of the indiviual texture used in the effect.
  45075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45076. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  45077. * @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.
  45078. * @param color Define the lens color
  45079. * @param imgUrl Define the lens texture url
  45080. * @param system Define the `lensFlareSystem` this flare is part of
  45081. * @returns The newly created Lens Flare
  45082. */
  45083. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  45084. /**
  45085. * Instantiates a new Lens Flare.
  45086. * This represents one of the lens effect in a `lensFlareSystem`.
  45087. * It controls one of the indiviual texture used in the effect.
  45088. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45089. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  45090. * @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.
  45091. * @param color Define the lens color
  45092. * @param imgUrl Define the lens texture url
  45093. * @param system Define the `lensFlareSystem` this flare is part of
  45094. */
  45095. constructor(
  45096. /**
  45097. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45098. */
  45099. size: number,
  45100. /**
  45101. * 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.
  45102. */
  45103. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  45104. /**
  45105. * Dispose and release the lens flare with its associated resources.
  45106. */
  45107. dispose(): void;
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. interface AbstractScene {
  45112. /**
  45113. * The list of lens flare system added to the scene
  45114. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45115. */
  45116. lensFlareSystems: Array<LensFlareSystem>;
  45117. /**
  45118. * Removes the given lens flare system from this scene.
  45119. * @param toRemove The lens flare system to remove
  45120. * @returns The index of the removed lens flare system
  45121. */
  45122. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  45123. /**
  45124. * Adds the given lens flare system to this scene
  45125. * @param newLensFlareSystem The lens flare system to add
  45126. */
  45127. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  45128. /**
  45129. * Gets a lens flare system using its name
  45130. * @param name defines the name to look for
  45131. * @returns the lens flare system or null if not found
  45132. */
  45133. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  45134. /**
  45135. * Gets a lens flare system using its id
  45136. * @param id defines the id to look for
  45137. * @returns the lens flare system or null if not found
  45138. */
  45139. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  45140. }
  45141. /**
  45142. * Defines the lens flare scene component responsible to manage any lens flares
  45143. * in a given scene.
  45144. */
  45145. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  45146. /**
  45147. * The component name helpfull to identify the component in the list of scene components.
  45148. */
  45149. readonly name: string;
  45150. /**
  45151. * The scene the component belongs to.
  45152. */
  45153. scene: Scene;
  45154. /**
  45155. * Creates a new instance of the component for the given scene
  45156. * @param scene Defines the scene to register the component in
  45157. */
  45158. constructor(scene: Scene);
  45159. /**
  45160. * Registers the component in a given scene
  45161. */
  45162. register(): void;
  45163. /**
  45164. * Rebuilds the elements related to this component in case of
  45165. * context lost for instance.
  45166. */
  45167. rebuild(): void;
  45168. /**
  45169. * Adds all the element from the container to the scene
  45170. * @param container the container holding the elements
  45171. */
  45172. addFromContainer(container: AbstractScene): void;
  45173. /**
  45174. * Removes all the elements in the container from the scene
  45175. * @param container contains the elements to remove
  45176. */
  45177. removeFromContainer(container: AbstractScene): void;
  45178. /**
  45179. * Serializes the component data to the specified json object
  45180. * @param serializationObject The object to serialize to
  45181. */
  45182. serialize(serializationObject: any): void;
  45183. /**
  45184. * Disposes the component and the associated ressources.
  45185. */
  45186. dispose(): void;
  45187. private _draw;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /**
  45192. * Defines the shadow generator component responsible to manage any shadow generators
  45193. * in a given scene.
  45194. */
  45195. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  45196. /**
  45197. * The component name helpfull to identify the component in the list of scene components.
  45198. */
  45199. readonly name: string;
  45200. /**
  45201. * The scene the component belongs to.
  45202. */
  45203. scene: Scene;
  45204. /**
  45205. * Creates a new instance of the component for the given scene
  45206. * @param scene Defines the scene to register the component in
  45207. */
  45208. constructor(scene: Scene);
  45209. /**
  45210. * Registers the component in a given scene
  45211. */
  45212. register(): void;
  45213. /**
  45214. * Rebuilds the elements related to this component in case of
  45215. * context lost for instance.
  45216. */
  45217. rebuild(): void;
  45218. /**
  45219. * Serializes the component data to the specified json object
  45220. * @param serializationObject The object to serialize to
  45221. */
  45222. serialize(serializationObject: any): void;
  45223. /**
  45224. * Adds all the element from the container to the scene
  45225. * @param container the container holding the elements
  45226. */
  45227. addFromContainer(container: AbstractScene): void;
  45228. /**
  45229. * Removes all the elements in the container from the scene
  45230. * @param container contains the elements to remove
  45231. */
  45232. removeFromContainer(container: AbstractScene): void;
  45233. /**
  45234. * Rebuilds the elements related to this component in case of
  45235. * context lost for instance.
  45236. */
  45237. dispose(): void;
  45238. private _gatherRenderTargets;
  45239. }
  45240. }
  45241. declare module BABYLON {
  45242. /**
  45243. * A directional light is defined by a direction (what a surprise!).
  45244. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45245. * 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.
  45246. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45247. */
  45248. export class DirectionalLight extends ShadowLight {
  45249. private _shadowFrustumSize;
  45250. /**
  45251. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45252. */
  45253. /**
  45254. * Specifies a fix frustum size for the shadow generation.
  45255. */
  45256. shadowFrustumSize: number;
  45257. private _shadowOrthoScale;
  45258. /**
  45259. * Gets the shadow projection scale against the optimal computed one.
  45260. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45261. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45262. */
  45263. /**
  45264. * Sets the shadow projection scale against the optimal computed one.
  45265. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45266. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45267. */
  45268. shadowOrthoScale: number;
  45269. /**
  45270. * Automatically compute the projection matrix to best fit (including all the casters)
  45271. * on each frame.
  45272. */
  45273. autoUpdateExtends: boolean;
  45274. private _orthoLeft;
  45275. private _orthoRight;
  45276. private _orthoTop;
  45277. private _orthoBottom;
  45278. /**
  45279. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45280. * The directional light is emitted from everywhere in the given direction.
  45281. * It can cast shadows.
  45282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45283. * @param name The friendly name of the light
  45284. * @param direction The direction of the light
  45285. * @param scene The scene the light belongs to
  45286. */
  45287. constructor(name: string, direction: Vector3, scene: Scene);
  45288. /**
  45289. * Returns the string "DirectionalLight".
  45290. * @return The class name
  45291. */
  45292. getClassName(): string;
  45293. /**
  45294. * Returns the integer 1.
  45295. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45296. */
  45297. getTypeID(): number;
  45298. /**
  45299. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45300. * Returns the DirectionalLight Shadow projection matrix.
  45301. */
  45302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45303. /**
  45304. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45305. * Returns the DirectionalLight Shadow projection matrix.
  45306. */
  45307. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45308. /**
  45309. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45310. * Returns the DirectionalLight Shadow projection matrix.
  45311. */
  45312. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45313. protected _buildUniformLayout(): void;
  45314. /**
  45315. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45316. * @param effect The effect to update
  45317. * @param lightIndex The index of the light in the effect to update
  45318. * @returns The directional light
  45319. */
  45320. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45321. /**
  45322. * Gets the minZ used for shadow according to both the scene and the light.
  45323. *
  45324. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45325. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45326. * @param activeCamera The camera we are returning the min for
  45327. * @returns the depth min z
  45328. */
  45329. getDepthMinZ(activeCamera: Camera): number;
  45330. /**
  45331. * Gets the maxZ used for shadow according to both the scene and the light.
  45332. *
  45333. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45334. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45335. * @param activeCamera The camera we are returning the max for
  45336. * @returns the depth max z
  45337. */
  45338. getDepthMaxZ(activeCamera: Camera): number;
  45339. /**
  45340. * Prepares the list of defines specific to the light type.
  45341. * @param defines the list of defines
  45342. * @param lightIndex defines the index of the light for the effect
  45343. */
  45344. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45345. }
  45346. }
  45347. declare module BABYLON {
  45348. /**
  45349. * A point light is a light defined by an unique point in world space.
  45350. * The light is emitted in every direction from this point.
  45351. * A good example of a point light is a standard light bulb.
  45352. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45353. */
  45354. export class PointLight extends ShadowLight {
  45355. private _shadowAngle;
  45356. /**
  45357. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45358. * This specifies what angle the shadow will use to be created.
  45359. *
  45360. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45361. */
  45362. /**
  45363. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45364. * This specifies what angle the shadow will use to be created.
  45365. *
  45366. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45367. */
  45368. shadowAngle: number;
  45369. /**
  45370. * Gets the direction if it has been set.
  45371. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45372. */
  45373. /**
  45374. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45375. */
  45376. direction: Vector3;
  45377. /**
  45378. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45379. * A PointLight emits the light in every direction.
  45380. * It can cast shadows.
  45381. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45382. * ```javascript
  45383. * var pointLight = new PointLight("pl", camera.position, scene);
  45384. * ```
  45385. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45386. * @param name The light friendly name
  45387. * @param position The position of the point light in the scene
  45388. * @param scene The scene the lights belongs to
  45389. */
  45390. constructor(name: string, position: Vector3, scene: Scene);
  45391. /**
  45392. * Returns the string "PointLight"
  45393. * @returns the class name
  45394. */
  45395. getClassName(): string;
  45396. /**
  45397. * Returns the integer 0.
  45398. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45399. */
  45400. getTypeID(): number;
  45401. /**
  45402. * Specifies wether or not the shadowmap should be a cube texture.
  45403. * @returns true if the shadowmap needs to be a cube texture.
  45404. */
  45405. needCube(): boolean;
  45406. /**
  45407. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  45408. * @param faceIndex The index of the face we are computed the direction to generate shadow
  45409. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  45410. */
  45411. getShadowDirection(faceIndex?: number): Vector3;
  45412. /**
  45413. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  45414. * - fov = PI / 2
  45415. * - aspect ratio : 1.0
  45416. * - z-near and far equal to the active camera minZ and maxZ.
  45417. * Returns the PointLight.
  45418. */
  45419. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45420. protected _buildUniformLayout(): void;
  45421. /**
  45422. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  45423. * @param effect The effect to update
  45424. * @param lightIndex The index of the light in the effect to update
  45425. * @returns The point light
  45426. */
  45427. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  45428. /**
  45429. * Prepares the list of defines specific to the light type.
  45430. * @param defines the list of defines
  45431. * @param lightIndex defines the index of the light for the effect
  45432. */
  45433. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45434. }
  45435. }
  45436. declare module BABYLON {
  45437. /**
  45438. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45439. * These values define a cone of light starting from the position, emitting toward the direction.
  45440. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45441. * and the exponent defines the speed of the decay of the light with distance (reach).
  45442. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45443. */
  45444. export class SpotLight extends ShadowLight {
  45445. private _angle;
  45446. private _innerAngle;
  45447. private _cosHalfAngle;
  45448. private _lightAngleScale;
  45449. private _lightAngleOffset;
  45450. /**
  45451. * Gets the cone angle of the spot light in Radians.
  45452. */
  45453. /**
  45454. * Sets the cone angle of the spot light in Radians.
  45455. */
  45456. angle: number;
  45457. /**
  45458. * Only used in gltf falloff mode, this defines the angle where
  45459. * the directional falloff will start before cutting at angle which could be seen
  45460. * as outer angle.
  45461. */
  45462. /**
  45463. * Only used in gltf falloff mode, this defines the angle where
  45464. * the directional falloff will start before cutting at angle which could be seen
  45465. * as outer angle.
  45466. */
  45467. innerAngle: number;
  45468. private _shadowAngleScale;
  45469. /**
  45470. * Allows scaling the angle of the light for shadow generation only.
  45471. */
  45472. /**
  45473. * Allows scaling the angle of the light for shadow generation only.
  45474. */
  45475. shadowAngleScale: number;
  45476. /**
  45477. * The light decay speed with the distance from the emission spot.
  45478. */
  45479. exponent: number;
  45480. private _projectionTextureMatrix;
  45481. /**
  45482. * Allows reading the projecton texture
  45483. */
  45484. readonly projectionTextureMatrix: Matrix;
  45485. protected _projectionTextureLightNear: number;
  45486. /**
  45487. * Gets the near clip of the Spotlight for texture projection.
  45488. */
  45489. /**
  45490. * Sets the near clip of the Spotlight for texture projection.
  45491. */
  45492. projectionTextureLightNear: number;
  45493. protected _projectionTextureLightFar: number;
  45494. /**
  45495. * Gets the far clip of the Spotlight for texture projection.
  45496. */
  45497. /**
  45498. * Sets the far clip of the Spotlight for texture projection.
  45499. */
  45500. projectionTextureLightFar: number;
  45501. protected _projectionTextureUpDirection: Vector3;
  45502. /**
  45503. * Gets the Up vector of the Spotlight for texture projection.
  45504. */
  45505. /**
  45506. * Sets the Up vector of the Spotlight for texture projection.
  45507. */
  45508. projectionTextureUpDirection: Vector3;
  45509. private _projectionTexture;
  45510. /**
  45511. * Gets the projection texture of the light.
  45512. */
  45513. /**
  45514. * Sets the projection texture of the light.
  45515. */
  45516. projectionTexture: Nullable<BaseTexture>;
  45517. private _projectionTextureViewLightDirty;
  45518. private _projectionTextureProjectionLightDirty;
  45519. private _projectionTextureDirty;
  45520. private _projectionTextureViewTargetVector;
  45521. private _projectionTextureViewLightMatrix;
  45522. private _projectionTextureProjectionLightMatrix;
  45523. private _projectionTextureScalingMatrix;
  45524. /**
  45525. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45526. * It can cast shadows.
  45527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45528. * @param name The light friendly name
  45529. * @param position The position of the spot light in the scene
  45530. * @param direction The direction of the light in the scene
  45531. * @param angle The cone angle of the light in Radians
  45532. * @param exponent The light decay speed with the distance from the emission spot
  45533. * @param scene The scene the lights belongs to
  45534. */
  45535. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45536. /**
  45537. * Returns the string "SpotLight".
  45538. * @returns the class name
  45539. */
  45540. getClassName(): string;
  45541. /**
  45542. * Returns the integer 2.
  45543. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45544. */
  45545. getTypeID(): number;
  45546. /**
  45547. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45548. */
  45549. protected _setDirection(value: Vector3): void;
  45550. /**
  45551. * Overrides the position setter to recompute the projection texture view light Matrix.
  45552. */
  45553. protected _setPosition(value: Vector3): void;
  45554. /**
  45555. * 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.
  45556. * Returns the SpotLight.
  45557. */
  45558. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45559. protected _computeProjectionTextureViewLightMatrix(): void;
  45560. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45561. /**
  45562. * Main function for light texture projection matrix computing.
  45563. */
  45564. protected _computeProjectionTextureMatrix(): void;
  45565. protected _buildUniformLayout(): void;
  45566. private _computeAngleValues;
  45567. /**
  45568. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45569. * @param effect The effect to update
  45570. * @param lightIndex The index of the light in the effect to update
  45571. * @returns The spot light
  45572. */
  45573. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45574. /**
  45575. * Disposes the light and the associated resources.
  45576. */
  45577. dispose(): void;
  45578. /**
  45579. * Prepares the list of defines specific to the light type.
  45580. * @param defines the list of defines
  45581. * @param lightIndex defines the index of the light for the effect
  45582. */
  45583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45584. }
  45585. }
  45586. declare module BABYLON {
  45587. /**
  45588. * Header information of HDR texture files.
  45589. */
  45590. export interface HDRInfo {
  45591. /**
  45592. * The height of the texture in pixels.
  45593. */
  45594. height: number;
  45595. /**
  45596. * The width of the texture in pixels.
  45597. */
  45598. width: number;
  45599. /**
  45600. * The index of the beginning of the data in the binary file.
  45601. */
  45602. dataPosition: number;
  45603. }
  45604. /**
  45605. * This groups tools to convert HDR texture to native colors array.
  45606. */
  45607. export class HDRTools {
  45608. private static Ldexp;
  45609. private static Rgbe2float;
  45610. private static readStringLine;
  45611. /**
  45612. * Reads header information from an RGBE texture stored in a native array.
  45613. * More information on this format are available here:
  45614. * https://en.wikipedia.org/wiki/RGBE_image_format
  45615. *
  45616. * @param uint8array The binary file stored in native array.
  45617. * @return The header information.
  45618. */
  45619. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45620. /**
  45621. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45622. * This RGBE texture needs to store the information as a panorama.
  45623. *
  45624. * More information on this format are available here:
  45625. * https://en.wikipedia.org/wiki/RGBE_image_format
  45626. *
  45627. * @param buffer The binary file stored in an array buffer.
  45628. * @param size The expected size of the extracted cubemap.
  45629. * @return The Cube Map information.
  45630. */
  45631. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45632. /**
  45633. * Returns the pixels data extracted from an RGBE texture.
  45634. * This pixels will be stored left to right up to down in the R G B order in one array.
  45635. *
  45636. * More information on this format are available here:
  45637. * https://en.wikipedia.org/wiki/RGBE_image_format
  45638. *
  45639. * @param uint8array The binary file stored in an array buffer.
  45640. * @param hdrInfo The header information of the file.
  45641. * @return The pixels data in RGB right to left up to down order.
  45642. */
  45643. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45644. private static RGBE_ReadPixels_RLE;
  45645. }
  45646. }
  45647. declare module BABYLON {
  45648. /**
  45649. * This represents a texture coming from an HDR input.
  45650. *
  45651. * The only supported format is currently panorama picture stored in RGBE format.
  45652. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45653. */
  45654. export class HDRCubeTexture extends BaseTexture {
  45655. private static _facesMapping;
  45656. private _generateHarmonics;
  45657. private _noMipmap;
  45658. private _textureMatrix;
  45659. private _size;
  45660. private _onLoad;
  45661. private _onError;
  45662. /**
  45663. * The texture URL.
  45664. */
  45665. url: string;
  45666. /**
  45667. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45668. */
  45669. coordinatesMode: number;
  45670. protected _isBlocking: boolean;
  45671. /**
  45672. * Sets wether or not the texture is blocking during loading.
  45673. */
  45674. /**
  45675. * Gets wether or not the texture is blocking during loading.
  45676. */
  45677. isBlocking: boolean;
  45678. protected _rotationY: number;
  45679. /**
  45680. * Sets texture matrix rotation angle around Y axis in radians.
  45681. */
  45682. /**
  45683. * Gets texture matrix rotation angle around Y axis radians.
  45684. */
  45685. rotationY: number;
  45686. /**
  45687. * Gets or sets the center of the bounding box associated with the cube texture
  45688. * It must define where the camera used to render the texture was set
  45689. */
  45690. boundingBoxPosition: Vector3;
  45691. private _boundingBoxSize;
  45692. /**
  45693. * Gets or sets the size of the bounding box associated with the cube texture
  45694. * When defined, the cubemap will switch to local mode
  45695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45696. * @example https://www.babylonjs-playground.com/#RNASML
  45697. */
  45698. boundingBoxSize: Vector3;
  45699. /**
  45700. * Instantiates an HDRTexture from the following parameters.
  45701. *
  45702. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45703. * @param scene The scene the texture will be used in
  45704. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45705. * @param noMipmap Forces to not generate the mipmap if true
  45706. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45707. * @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)
  45708. * @param reserved Reserved flag for internal use.
  45709. */
  45710. 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>);
  45711. /**
  45712. * Get the current class name of the texture useful for serialization or dynamic coding.
  45713. * @returns "HDRCubeTexture"
  45714. */
  45715. getClassName(): string;
  45716. /**
  45717. * Occurs when the file is raw .hdr file.
  45718. */
  45719. private loadTexture;
  45720. clone(): HDRCubeTexture;
  45721. delayLoad(): void;
  45722. /**
  45723. * Get the texture reflection matrix used to rotate/transform the reflection.
  45724. * @returns the reflection matrix
  45725. */
  45726. getReflectionTextureMatrix(): Matrix;
  45727. /**
  45728. * Set the texture reflection matrix used to rotate/transform the reflection.
  45729. * @param value Define the reflection matrix to set
  45730. */
  45731. setReflectionTextureMatrix(value: Matrix): void;
  45732. /**
  45733. * Parses a JSON representation of an HDR Texture in order to create the texture
  45734. * @param parsedTexture Define the JSON representation
  45735. * @param scene Define the scene the texture should be created in
  45736. * @param rootUrl Define the root url in case we need to load relative dependencies
  45737. * @returns the newly created texture after parsing
  45738. */
  45739. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45740. serialize(): any;
  45741. }
  45742. }
  45743. declare module BABYLON {
  45744. /**
  45745. * Class used to control physics engine
  45746. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45747. */
  45748. export class PhysicsEngine implements IPhysicsEngine {
  45749. private _physicsPlugin;
  45750. /**
  45751. * Global value used to control the smallest number supported by the simulation
  45752. */
  45753. static Epsilon: number;
  45754. private _impostors;
  45755. private _joints;
  45756. /**
  45757. * Gets the gravity vector used by the simulation
  45758. */
  45759. gravity: Vector3;
  45760. /**
  45761. * Factory used to create the default physics plugin.
  45762. * @returns The default physics plugin
  45763. */
  45764. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45765. /**
  45766. * Creates a new Physics Engine
  45767. * @param gravity defines the gravity vector used by the simulation
  45768. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45769. */
  45770. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45771. /**
  45772. * Sets the gravity vector used by the simulation
  45773. * @param gravity defines the gravity vector to use
  45774. */
  45775. setGravity(gravity: Vector3): void;
  45776. /**
  45777. * Set the time step of the physics engine.
  45778. * Default is 1/60.
  45779. * To slow it down, enter 1/600 for example.
  45780. * To speed it up, 1/30
  45781. * @param newTimeStep defines the new timestep to apply to this world.
  45782. */
  45783. setTimeStep(newTimeStep?: number): void;
  45784. /**
  45785. * Get the time step of the physics engine.
  45786. * @returns the current time step
  45787. */
  45788. getTimeStep(): number;
  45789. /**
  45790. * Release all resources
  45791. */
  45792. dispose(): void;
  45793. /**
  45794. * Gets the name of the current physics plugin
  45795. * @returns the name of the plugin
  45796. */
  45797. getPhysicsPluginName(): string;
  45798. /**
  45799. * Adding a new impostor for the impostor tracking.
  45800. * This will be done by the impostor itself.
  45801. * @param impostor the impostor to add
  45802. */
  45803. addImpostor(impostor: PhysicsImpostor): void;
  45804. /**
  45805. * Remove an impostor from the engine.
  45806. * This impostor and its mesh will not longer be updated by the physics engine.
  45807. * @param impostor the impostor to remove
  45808. */
  45809. removeImpostor(impostor: PhysicsImpostor): void;
  45810. /**
  45811. * Add a joint to the physics engine
  45812. * @param mainImpostor defines the main impostor to which the joint is added.
  45813. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45814. * @param joint defines the joint that will connect both impostors.
  45815. */
  45816. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45817. /**
  45818. * Removes a joint from the simulation
  45819. * @param mainImpostor defines the impostor used with the joint
  45820. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45821. * @param joint defines the joint to remove
  45822. */
  45823. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45824. /**
  45825. * Called by the scene. No need to call it.
  45826. * @param delta defines the timespam between frames
  45827. */
  45828. _step(delta: number): void;
  45829. /**
  45830. * Gets the current plugin used to run the simulation
  45831. * @returns current plugin
  45832. */
  45833. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45834. /**
  45835. * Gets the list of physic impostors
  45836. * @returns an array of PhysicsImpostor
  45837. */
  45838. getImpostors(): Array<PhysicsImpostor>;
  45839. /**
  45840. * Gets the impostor for a physics enabled object
  45841. * @param object defines the object impersonated by the impostor
  45842. * @returns the PhysicsImpostor or null if not found
  45843. */
  45844. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45845. /**
  45846. * Gets the impostor for a physics body object
  45847. * @param body defines physics body used by the impostor
  45848. * @returns the PhysicsImpostor or null if not found
  45849. */
  45850. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45851. }
  45852. }
  45853. declare module BABYLON {
  45854. /** @hidden */
  45855. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45856. private _useDeltaForWorldStep;
  45857. world: any;
  45858. name: string;
  45859. private _physicsMaterials;
  45860. private _fixedTimeStep;
  45861. BJSCANNON: any;
  45862. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45863. setGravity(gravity: Vector3): void;
  45864. setTimeStep(timeStep: number): void;
  45865. getTimeStep(): number;
  45866. executeStep(delta: number): void;
  45867. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45868. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45869. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45870. private _processChildMeshes;
  45871. removePhysicsBody(impostor: PhysicsImpostor): void;
  45872. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45873. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45874. private _addMaterial;
  45875. private _checkWithEpsilon;
  45876. private _createShape;
  45877. private _createHeightmap;
  45878. private _minus90X;
  45879. private _plus90X;
  45880. private _tmpPosition;
  45881. private _tmpDeltaPosition;
  45882. private _tmpUnityRotation;
  45883. private _updatePhysicsBodyTransformation;
  45884. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45885. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45886. isSupported(): boolean;
  45887. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45888. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45889. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45890. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45891. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45892. getBodyMass(impostor: PhysicsImpostor): number;
  45893. getBodyFriction(impostor: PhysicsImpostor): number;
  45894. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45895. getBodyRestitution(impostor: PhysicsImpostor): number;
  45896. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45897. sleepBody(impostor: PhysicsImpostor): void;
  45898. wakeUpBody(impostor: PhysicsImpostor): void;
  45899. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45900. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45901. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45902. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45903. getRadius(impostor: PhysicsImpostor): number;
  45904. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45905. dispose(): void;
  45906. private _extendNamespace;
  45907. }
  45908. }
  45909. declare module BABYLON {
  45910. /** @hidden */
  45911. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45912. world: any;
  45913. name: string;
  45914. BJSOIMO: any;
  45915. constructor(iterations?: number, oimoInjection?: any);
  45916. setGravity(gravity: Vector3): void;
  45917. setTimeStep(timeStep: number): void;
  45918. getTimeStep(): number;
  45919. private _tmpImpostorsArray;
  45920. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45921. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45922. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45923. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45924. private _tmpPositionVector;
  45925. removePhysicsBody(impostor: PhysicsImpostor): void;
  45926. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45927. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45928. isSupported(): boolean;
  45929. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45930. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45931. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45932. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45933. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45934. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45935. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45936. getBodyMass(impostor: PhysicsImpostor): number;
  45937. getBodyFriction(impostor: PhysicsImpostor): number;
  45938. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45939. getBodyRestitution(impostor: PhysicsImpostor): number;
  45940. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45941. sleepBody(impostor: PhysicsImpostor): void;
  45942. wakeUpBody(impostor: PhysicsImpostor): void;
  45943. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  45944. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  45945. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  45946. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45947. getRadius(impostor: PhysicsImpostor): number;
  45948. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45949. dispose(): void;
  45950. }
  45951. }
  45952. declare module BABYLON {
  45953. interface AbstractScene {
  45954. /**
  45955. * The list of reflection probes added to the scene
  45956. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45957. */
  45958. reflectionProbes: Array<ReflectionProbe>;
  45959. /**
  45960. * Removes the given reflection probe from this scene.
  45961. * @param toRemove The reflection probe to remove
  45962. * @returns The index of the removed reflection probe
  45963. */
  45964. removeReflectionProbe(toRemove: ReflectionProbe): number;
  45965. /**
  45966. * Adds the given reflection probe to this scene.
  45967. * @param newReflectionProbe The reflection probe to add
  45968. */
  45969. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  45970. }
  45971. /**
  45972. * Class used to generate realtime reflection / refraction cube textures
  45973. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45974. */
  45975. export class ReflectionProbe {
  45976. /** defines the name of the probe */
  45977. name: string;
  45978. private _scene;
  45979. private _renderTargetTexture;
  45980. private _projectionMatrix;
  45981. private _viewMatrix;
  45982. private _target;
  45983. private _add;
  45984. private _attachedMesh;
  45985. private _invertYAxis;
  45986. /** Gets or sets probe position (center of the cube map) */
  45987. position: Vector3;
  45988. /**
  45989. * Creates a new reflection probe
  45990. * @param name defines the name of the probe
  45991. * @param size defines the texture resolution (for each face)
  45992. * @param scene defines the hosting scene
  45993. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  45994. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  45995. */
  45996. constructor(
  45997. /** defines the name of the probe */
  45998. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  45999. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  46000. samples: number;
  46001. /** Gets or sets the refresh rate to use (on every frame by default) */
  46002. refreshRate: number;
  46003. /**
  46004. * Gets the hosting scene
  46005. * @returns a Scene
  46006. */
  46007. getScene(): Scene;
  46008. /** Gets the internal CubeTexture used to render to */
  46009. readonly cubeTexture: RenderTargetTexture;
  46010. /** Gets the list of meshes to render */
  46011. readonly renderList: Nullable<AbstractMesh[]>;
  46012. /**
  46013. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  46014. * @param mesh defines the mesh to attach to
  46015. */
  46016. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46017. /**
  46018. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  46019. * @param renderingGroupId The rendering group id corresponding to its index
  46020. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46021. */
  46022. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46023. /**
  46024. * Clean all associated resources
  46025. */
  46026. dispose(): void;
  46027. /**
  46028. * Converts the reflection probe information to a readable string for debug purpose.
  46029. * @param fullDetails Supports for multiple levels of logging within scene loading
  46030. * @returns the human readable reflection probe info
  46031. */
  46032. toString(fullDetails?: boolean): string;
  46033. /**
  46034. * Get the class name of the relfection probe.
  46035. * @returns "ReflectionProbe"
  46036. */
  46037. getClassName(): string;
  46038. /**
  46039. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  46040. * @returns The JSON representation of the texture
  46041. */
  46042. serialize(): any;
  46043. /**
  46044. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  46045. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  46046. * @param scene Define the scene the parsed reflection probe should be instantiated in
  46047. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46048. * @returns The parsed reflection probe if successful
  46049. */
  46050. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  46051. }
  46052. }
  46053. declare module BABYLON {
  46054. /** @hidden */
  46055. export var _BabylonLoaderRegistered: boolean;
  46056. }
  46057. declare module BABYLON {
  46058. /**
  46059. * The Physically based simple base material of BJS.
  46060. *
  46061. * This enables better naming and convention enforcements on top of the pbrMaterial.
  46062. * It is used as the base class for both the specGloss and metalRough conventions.
  46063. */
  46064. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  46065. /**
  46066. * Number of Simultaneous lights allowed on the material.
  46067. */
  46068. maxSimultaneousLights: number;
  46069. /**
  46070. * If sets to true, disables all the lights affecting the material.
  46071. */
  46072. disableLighting: boolean;
  46073. /**
  46074. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  46075. */
  46076. environmentTexture: BaseTexture;
  46077. /**
  46078. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46079. */
  46080. invertNormalMapX: boolean;
  46081. /**
  46082. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46083. */
  46084. invertNormalMapY: boolean;
  46085. /**
  46086. * Normal map used in the model.
  46087. */
  46088. normalTexture: BaseTexture;
  46089. /**
  46090. * Emissivie color used to self-illuminate the model.
  46091. */
  46092. emissiveColor: Color3;
  46093. /**
  46094. * Emissivie texture used to self-illuminate the model.
  46095. */
  46096. emissiveTexture: BaseTexture;
  46097. /**
  46098. * Occlusion Channel Strenght.
  46099. */
  46100. occlusionStrength: number;
  46101. /**
  46102. * Occlusion Texture of the material (adding extra occlusion effects).
  46103. */
  46104. occlusionTexture: BaseTexture;
  46105. /**
  46106. * Defines the alpha limits in alpha test mode.
  46107. */
  46108. alphaCutOff: number;
  46109. /**
  46110. * Gets the current double sided mode.
  46111. */
  46112. /**
  46113. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46114. */
  46115. doubleSided: boolean;
  46116. /**
  46117. * Stores the pre-calculated light information of a mesh in a texture.
  46118. */
  46119. lightmapTexture: BaseTexture;
  46120. /**
  46121. * If true, the light map contains occlusion information instead of lighting info.
  46122. */
  46123. useLightmapAsShadowmap: boolean;
  46124. /**
  46125. * Instantiates a new PBRMaterial instance.
  46126. *
  46127. * @param name The material name
  46128. * @param scene The scene the material will be use in.
  46129. */
  46130. constructor(name: string, scene: Scene);
  46131. getClassName(): string;
  46132. }
  46133. }
  46134. declare module BABYLON {
  46135. /**
  46136. * The PBR material of BJS following the metal roughness convention.
  46137. *
  46138. * This fits to the PBR convention in the GLTF definition:
  46139. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46140. */
  46141. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46142. /**
  46143. * The base color has two different interpretations depending on the value of metalness.
  46144. * When the material is a metal, the base color is the specific measured reflectance value
  46145. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46146. * of the material.
  46147. */
  46148. baseColor: Color3;
  46149. /**
  46150. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46151. * well as opacity information in the alpha channel.
  46152. */
  46153. baseTexture: BaseTexture;
  46154. /**
  46155. * Specifies the metallic scalar value of the material.
  46156. * Can also be used to scale the metalness values of the metallic texture.
  46157. */
  46158. metallic: number;
  46159. /**
  46160. * Specifies the roughness scalar value of the material.
  46161. * Can also be used to scale the roughness values of the metallic texture.
  46162. */
  46163. roughness: number;
  46164. /**
  46165. * Texture containing both the metallic value in the B channel and the
  46166. * roughness value in the G channel to keep better precision.
  46167. */
  46168. metallicRoughnessTexture: BaseTexture;
  46169. /**
  46170. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46171. *
  46172. * @param name The material name
  46173. * @param scene The scene the material will be use in.
  46174. */
  46175. constructor(name: string, scene: Scene);
  46176. /**
  46177. * Return the currrent class name of the material.
  46178. */
  46179. getClassName(): string;
  46180. /**
  46181. * Makes a duplicate of the current material.
  46182. * @param name - name to use for the new material.
  46183. */
  46184. clone(name: string): PBRMetallicRoughnessMaterial;
  46185. /**
  46186. * Serialize the material to a parsable JSON object.
  46187. */
  46188. serialize(): any;
  46189. /**
  46190. * Parses a JSON object correponding to the serialize function.
  46191. */
  46192. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * The PBR material of BJS following the specular glossiness convention.
  46198. *
  46199. * This fits to the PBR convention in the GLTF definition:
  46200. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46201. */
  46202. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46203. /**
  46204. * Specifies the diffuse color of the material.
  46205. */
  46206. diffuseColor: Color3;
  46207. /**
  46208. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46209. * channel.
  46210. */
  46211. diffuseTexture: BaseTexture;
  46212. /**
  46213. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46214. */
  46215. specularColor: Color3;
  46216. /**
  46217. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46218. */
  46219. glossiness: number;
  46220. /**
  46221. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46222. */
  46223. specularGlossinessTexture: BaseTexture;
  46224. /**
  46225. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46226. *
  46227. * @param name The material name
  46228. * @param scene The scene the material will be use in.
  46229. */
  46230. constructor(name: string, scene: Scene);
  46231. /**
  46232. * Return the currrent class name of the material.
  46233. */
  46234. getClassName(): string;
  46235. /**
  46236. * Makes a duplicate of the current material.
  46237. * @param name - name to use for the new material.
  46238. */
  46239. clone(name: string): PBRSpecularGlossinessMaterial;
  46240. /**
  46241. * Serialize the material to a parsable JSON object.
  46242. */
  46243. serialize(): any;
  46244. /**
  46245. * Parses a JSON object correponding to the serialize function.
  46246. */
  46247. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46248. }
  46249. }
  46250. declare module BABYLON {
  46251. /**
  46252. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46253. * It can help converting any input color in a desired output one. This can then be used to create effects
  46254. * from sepia, black and white to sixties or futuristic rendering...
  46255. *
  46256. * The only supported format is currently 3dl.
  46257. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46258. */
  46259. export class ColorGradingTexture extends BaseTexture {
  46260. /**
  46261. * The current texture matrix. (will always be identity in color grading texture)
  46262. */
  46263. private _textureMatrix;
  46264. /**
  46265. * The texture URL.
  46266. */
  46267. url: string;
  46268. /**
  46269. * Empty line regex stored for GC.
  46270. */
  46271. private static _noneEmptyLineRegex;
  46272. private _engine;
  46273. /**
  46274. * Instantiates a ColorGradingTexture from the following parameters.
  46275. *
  46276. * @param url The location of the color gradind data (currently only supporting 3dl)
  46277. * @param scene The scene the texture will be used in
  46278. */
  46279. constructor(url: string, scene: Scene);
  46280. /**
  46281. * Returns the texture matrix used in most of the material.
  46282. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46283. */
  46284. getTextureMatrix(): Matrix;
  46285. /**
  46286. * Occurs when the file being loaded is a .3dl LUT file.
  46287. */
  46288. private load3dlTexture;
  46289. /**
  46290. * Starts the loading process of the texture.
  46291. */
  46292. private loadTexture;
  46293. /**
  46294. * Clones the color gradind texture.
  46295. */
  46296. clone(): ColorGradingTexture;
  46297. /**
  46298. * Called during delayed load for textures.
  46299. */
  46300. delayLoad(): void;
  46301. /**
  46302. * Parses a color grading texture serialized by Babylon.
  46303. * @param parsedTexture The texture information being parsedTexture
  46304. * @param scene The scene to load the texture in
  46305. * @param rootUrl The root url of the data assets to load
  46306. * @return A color gradind texture
  46307. */
  46308. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  46309. /**
  46310. * Serializes the LUT texture to json format.
  46311. */
  46312. serialize(): any;
  46313. }
  46314. }
  46315. declare module BABYLON {
  46316. /**
  46317. * Direct draw surface info
  46318. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46319. */
  46320. export interface DDSInfo {
  46321. /**
  46322. * Width of the texture
  46323. */
  46324. width: number;
  46325. /**
  46326. * Width of the texture
  46327. */
  46328. height: number;
  46329. /**
  46330. * Number of Mipmaps for the texture
  46331. * @see https://en.wikipedia.org/wiki/Mipmap
  46332. */
  46333. mipmapCount: number;
  46334. /**
  46335. * If the textures format is a known fourCC format
  46336. * @see https://www.fourcc.org/
  46337. */
  46338. isFourCC: boolean;
  46339. /**
  46340. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46341. */
  46342. isRGB: boolean;
  46343. /**
  46344. * If the texture is a lumincance format
  46345. */
  46346. isLuminance: boolean;
  46347. /**
  46348. * If this is a cube texture
  46349. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46350. */
  46351. isCube: boolean;
  46352. /**
  46353. * If the texture is a compressed format eg. FOURCC_DXT1
  46354. */
  46355. isCompressed: boolean;
  46356. /**
  46357. * The dxgiFormat of the texture
  46358. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46359. */
  46360. dxgiFormat: number;
  46361. /**
  46362. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46363. */
  46364. textureType: number;
  46365. /**
  46366. * Sphericle polynomial created for the dds texture
  46367. */
  46368. sphericalPolynomial?: SphericalPolynomial;
  46369. }
  46370. /**
  46371. * Class used to provide DDS decompression tools
  46372. */
  46373. export class DDSTools {
  46374. /**
  46375. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46376. */
  46377. static StoreLODInAlphaChannel: boolean;
  46378. /**
  46379. * Gets DDS information from an array buffer
  46380. * @param arrayBuffer defines the array buffer to read data from
  46381. * @returns the DDS information
  46382. */
  46383. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46384. private static _FloatView;
  46385. private static _Int32View;
  46386. private static _ToHalfFloat;
  46387. private static _FromHalfFloat;
  46388. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46389. private static _GetHalfFloatRGBAArrayBuffer;
  46390. private static _GetFloatRGBAArrayBuffer;
  46391. private static _GetFloatAsUIntRGBAArrayBuffer;
  46392. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46393. private static _GetRGBAArrayBuffer;
  46394. private static _ExtractLongWordOrder;
  46395. private static _GetRGBArrayBuffer;
  46396. private static _GetLuminanceArrayBuffer;
  46397. /**
  46398. * Uploads DDS Levels to a Babylon Texture
  46399. * @hidden
  46400. */
  46401. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46402. }
  46403. interface Engine {
  46404. /**
  46405. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46406. * @param rootUrl defines the url where the file to load is located
  46407. * @param scene defines the current scene
  46408. * @param lodScale defines scale to apply to the mip map selection
  46409. * @param lodOffset defines offset to apply to the mip map selection
  46410. * @param onLoad defines an optional callback raised when the texture is loaded
  46411. * @param onError defines an optional callback raised if there is an issue to load the texture
  46412. * @param format defines the format of the data
  46413. * @param forcedExtension defines the extension to use to pick the right loader
  46414. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46415. * @returns the cube texture as an InternalTexture
  46416. */
  46417. 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;
  46418. }
  46419. }
  46420. declare module BABYLON {
  46421. /**
  46422. * Implementation of the DDS Texture Loader.
  46423. * @hidden
  46424. */
  46425. export class _DDSTextureLoader implements IInternalTextureLoader {
  46426. /**
  46427. * Defines wether the loader supports cascade loading the different faces.
  46428. */
  46429. readonly supportCascades: boolean;
  46430. /**
  46431. * This returns if the loader support the current file information.
  46432. * @param extension defines the file extension of the file being loaded
  46433. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46434. * @param fallback defines the fallback internal texture if any
  46435. * @param isBase64 defines whether the texture is encoded as a base64
  46436. * @param isBuffer defines whether the texture data are stored as a buffer
  46437. * @returns true if the loader can load the specified file
  46438. */
  46439. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46440. /**
  46441. * Transform the url before loading if required.
  46442. * @param rootUrl the url of the texture
  46443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46444. * @returns the transformed texture
  46445. */
  46446. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46447. /**
  46448. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46449. * @param rootUrl the url of the texture
  46450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46451. * @returns the fallback texture
  46452. */
  46453. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46454. /**
  46455. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46456. * @param data contains the texture data
  46457. * @param texture defines the BabylonJS internal texture
  46458. * @param createPolynomials will be true if polynomials have been requested
  46459. * @param onLoad defines the callback to trigger once the texture is ready
  46460. * @param onError defines the callback to trigger in case of error
  46461. */
  46462. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46463. /**
  46464. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46465. * @param data contains the texture data
  46466. * @param texture defines the BabylonJS internal texture
  46467. * @param callback defines the method to call once ready to upload
  46468. */
  46469. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46470. }
  46471. }
  46472. declare module BABYLON {
  46473. /** @hidden */
  46474. export var rgbdEncodePixelShader: {
  46475. name: string;
  46476. shader: string;
  46477. };
  46478. }
  46479. declare module BABYLON {
  46480. /** @hidden */
  46481. export var rgbdDecodePixelShader: {
  46482. name: string;
  46483. shader: string;
  46484. };
  46485. }
  46486. declare module BABYLON {
  46487. /**
  46488. * Raw texture data and descriptor sufficient for WebGL texture upload
  46489. */
  46490. export interface EnvironmentTextureInfo {
  46491. /**
  46492. * Version of the environment map
  46493. */
  46494. version: number;
  46495. /**
  46496. * Width of image
  46497. */
  46498. width: number;
  46499. /**
  46500. * Irradiance information stored in the file.
  46501. */
  46502. irradiance: any;
  46503. /**
  46504. * Specular information stored in the file.
  46505. */
  46506. specular: any;
  46507. }
  46508. /**
  46509. * Sets of helpers addressing the serialization and deserialization of environment texture
  46510. * stored in a BabylonJS env file.
  46511. * Those files are usually stored as .env files.
  46512. */
  46513. export class EnvironmentTextureTools {
  46514. /**
  46515. * Magic number identifying the env file.
  46516. */
  46517. private static _MagicBytes;
  46518. /**
  46519. * Gets the environment info from an env file.
  46520. * @param data The array buffer containing the .env bytes.
  46521. * @returns the environment file info (the json header) if successfully parsed.
  46522. */
  46523. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46524. /**
  46525. * Creates an environment texture from a loaded cube texture.
  46526. * @param texture defines the cube texture to convert in env file
  46527. * @return a promise containing the environment data if succesfull.
  46528. */
  46529. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46530. /**
  46531. * Creates a JSON representation of the spherical data.
  46532. * @param texture defines the texture containing the polynomials
  46533. * @return the JSON representation of the spherical info
  46534. */
  46535. private static _CreateEnvTextureIrradiance;
  46536. /**
  46537. * Uploads the texture info contained in the env file to the GPU.
  46538. * @param texture defines the internal texture to upload to
  46539. * @param arrayBuffer defines the buffer cotaining the data to load
  46540. * @param info defines the texture info retrieved through the GetEnvInfo method
  46541. * @returns a promise
  46542. */
  46543. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46544. /**
  46545. * Uploads the levels of image data to the GPU.
  46546. * @param texture defines the internal texture to upload to
  46547. * @param imageData defines the array buffer views of image data [mipmap][face]
  46548. * @returns a promise
  46549. */
  46550. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46551. /**
  46552. * Uploads spherical polynomials information to the texture.
  46553. * @param texture defines the texture we are trying to upload the information to
  46554. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46555. */
  46556. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46557. /** @hidden */
  46558. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46559. }
  46560. }
  46561. declare module BABYLON {
  46562. /**
  46563. * Implementation of the ENV Texture Loader.
  46564. * @hidden
  46565. */
  46566. export class _ENVTextureLoader implements IInternalTextureLoader {
  46567. /**
  46568. * Defines wether the loader supports cascade loading the different faces.
  46569. */
  46570. readonly supportCascades: boolean;
  46571. /**
  46572. * This returns if the loader support the current file information.
  46573. * @param extension defines the file extension of the file being loaded
  46574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46575. * @param fallback defines the fallback internal texture if any
  46576. * @param isBase64 defines whether the texture is encoded as a base64
  46577. * @param isBuffer defines whether the texture data are stored as a buffer
  46578. * @returns true if the loader can load the specified file
  46579. */
  46580. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46581. /**
  46582. * Transform the url before loading if required.
  46583. * @param rootUrl the url of the texture
  46584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46585. * @returns the transformed texture
  46586. */
  46587. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46588. /**
  46589. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46590. * @param rootUrl the url of the texture
  46591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46592. * @returns the fallback texture
  46593. */
  46594. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46595. /**
  46596. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46597. * @param data contains the texture data
  46598. * @param texture defines the BabylonJS internal texture
  46599. * @param createPolynomials will be true if polynomials have been requested
  46600. * @param onLoad defines the callback to trigger once the texture is ready
  46601. * @param onError defines the callback to trigger in case of error
  46602. */
  46603. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46604. /**
  46605. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46606. * @param data contains the texture data
  46607. * @param texture defines the BabylonJS internal texture
  46608. * @param callback defines the method to call once ready to upload
  46609. */
  46610. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46611. }
  46612. }
  46613. declare module BABYLON {
  46614. /**
  46615. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46616. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46617. */
  46618. export class KhronosTextureContainer {
  46619. /** contents of the KTX container file */
  46620. arrayBuffer: any;
  46621. private static HEADER_LEN;
  46622. private static COMPRESSED_2D;
  46623. private static COMPRESSED_3D;
  46624. private static TEX_2D;
  46625. private static TEX_3D;
  46626. /**
  46627. * Gets the openGL type
  46628. */
  46629. glType: number;
  46630. /**
  46631. * Gets the openGL type size
  46632. */
  46633. glTypeSize: number;
  46634. /**
  46635. * Gets the openGL format
  46636. */
  46637. glFormat: number;
  46638. /**
  46639. * Gets the openGL internal format
  46640. */
  46641. glInternalFormat: number;
  46642. /**
  46643. * Gets the base internal format
  46644. */
  46645. glBaseInternalFormat: number;
  46646. /**
  46647. * Gets image width in pixel
  46648. */
  46649. pixelWidth: number;
  46650. /**
  46651. * Gets image height in pixel
  46652. */
  46653. pixelHeight: number;
  46654. /**
  46655. * Gets image depth in pixels
  46656. */
  46657. pixelDepth: number;
  46658. /**
  46659. * Gets the number of array elements
  46660. */
  46661. numberOfArrayElements: number;
  46662. /**
  46663. * Gets the number of faces
  46664. */
  46665. numberOfFaces: number;
  46666. /**
  46667. * Gets the number of mipmap levels
  46668. */
  46669. numberOfMipmapLevels: number;
  46670. /**
  46671. * Gets the bytes of key value data
  46672. */
  46673. bytesOfKeyValueData: number;
  46674. /**
  46675. * Gets the load type
  46676. */
  46677. loadType: number;
  46678. /**
  46679. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46680. */
  46681. isInvalid: boolean;
  46682. /**
  46683. * Creates a new KhronosTextureContainer
  46684. * @param arrayBuffer contents of the KTX container file
  46685. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46686. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46687. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46688. */
  46689. constructor(
  46690. /** contents of the KTX container file */
  46691. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46692. /**
  46693. * Uploads KTX content to a Babylon Texture.
  46694. * It is assumed that the texture has already been created & is currently bound
  46695. * @hidden
  46696. */
  46697. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46698. private _upload2DCompressedLevels;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. /**
  46703. * Implementation of the KTX Texture Loader.
  46704. * @hidden
  46705. */
  46706. export class _KTXTextureLoader implements IInternalTextureLoader {
  46707. /**
  46708. * Defines wether the loader supports cascade loading the different faces.
  46709. */
  46710. readonly supportCascades: boolean;
  46711. /**
  46712. * This returns if the loader support the current file information.
  46713. * @param extension defines the file extension of the file being loaded
  46714. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46715. * @param fallback defines the fallback internal texture if any
  46716. * @param isBase64 defines whether the texture is encoded as a base64
  46717. * @param isBuffer defines whether the texture data are stored as a buffer
  46718. * @returns true if the loader can load the specified file
  46719. */
  46720. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46721. /**
  46722. * Transform the url before loading if required.
  46723. * @param rootUrl the url of the texture
  46724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46725. * @returns the transformed texture
  46726. */
  46727. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46728. /**
  46729. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46730. * @param rootUrl the url of the texture
  46731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46732. * @returns the fallback texture
  46733. */
  46734. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46735. /**
  46736. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46737. * @param data contains the texture data
  46738. * @param texture defines the BabylonJS internal texture
  46739. * @param createPolynomials will be true if polynomials have been requested
  46740. * @param onLoad defines the callback to trigger once the texture is ready
  46741. * @param onError defines the callback to trigger in case of error
  46742. */
  46743. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46744. /**
  46745. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46746. * @param data contains the texture data
  46747. * @param texture defines the BabylonJS internal texture
  46748. * @param callback defines the method to call once ready to upload
  46749. */
  46750. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46751. }
  46752. }
  46753. declare module BABYLON {
  46754. /**
  46755. * Based on jsTGALoader - Javascript loader for TGA file
  46756. * By Vincent Thibault
  46757. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46758. */
  46759. export class TGATools {
  46760. private static _TYPE_INDEXED;
  46761. private static _TYPE_RGB;
  46762. private static _TYPE_GREY;
  46763. private static _TYPE_RLE_INDEXED;
  46764. private static _TYPE_RLE_RGB;
  46765. private static _TYPE_RLE_GREY;
  46766. private static _ORIGIN_MASK;
  46767. private static _ORIGIN_SHIFT;
  46768. private static _ORIGIN_BL;
  46769. private static _ORIGIN_BR;
  46770. private static _ORIGIN_UL;
  46771. private static _ORIGIN_UR;
  46772. /**
  46773. * Gets the header of a TGA file
  46774. * @param data defines the TGA data
  46775. * @returns the header
  46776. */
  46777. static GetTGAHeader(data: Uint8Array): any;
  46778. /**
  46779. * Uploads TGA content to a Babylon Texture
  46780. * @hidden
  46781. */
  46782. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46783. /** @hidden */
  46784. 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;
  46785. /** @hidden */
  46786. 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;
  46787. /** @hidden */
  46788. 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;
  46789. /** @hidden */
  46790. 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;
  46791. /** @hidden */
  46792. 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;
  46793. /** @hidden */
  46794. 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;
  46795. }
  46796. }
  46797. declare module BABYLON {
  46798. /**
  46799. * Implementation of the TGA Texture Loader.
  46800. * @hidden
  46801. */
  46802. export class _TGATextureLoader implements IInternalTextureLoader {
  46803. /**
  46804. * Defines wether the loader supports cascade loading the different faces.
  46805. */
  46806. readonly supportCascades: boolean;
  46807. /**
  46808. * This returns if the loader support the current file information.
  46809. * @param extension defines the file extension of the file being loaded
  46810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46811. * @param fallback defines the fallback internal texture if any
  46812. * @param isBase64 defines whether the texture is encoded as a base64
  46813. * @param isBuffer defines whether the texture data are stored as a buffer
  46814. * @returns true if the loader can load the specified file
  46815. */
  46816. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46817. /**
  46818. * Transform the url before loading if required.
  46819. * @param rootUrl the url of the texture
  46820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46821. * @returns the transformed texture
  46822. */
  46823. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46824. /**
  46825. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46826. * @param rootUrl the url of the texture
  46827. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46828. * @returns the fallback texture
  46829. */
  46830. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46831. /**
  46832. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46833. * @param data contains the texture data
  46834. * @param texture defines the BabylonJS internal texture
  46835. * @param createPolynomials will be true if polynomials have been requested
  46836. * @param onLoad defines the callback to trigger once the texture is ready
  46837. * @param onError defines the callback to trigger in case of error
  46838. */
  46839. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46840. /**
  46841. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46842. * @param data contains the texture data
  46843. * @param texture defines the BabylonJS internal texture
  46844. * @param callback defines the method to call once ready to upload
  46845. */
  46846. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46847. }
  46848. }
  46849. declare module BABYLON {
  46850. /**
  46851. * 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.
  46852. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46854. */
  46855. export class CustomProceduralTexture extends ProceduralTexture {
  46856. private _animate;
  46857. private _time;
  46858. private _config;
  46859. private _texturePath;
  46860. /**
  46861. * Instantiates a new Custom Procedural Texture.
  46862. * 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.
  46863. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46864. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46865. * @param name Define the name of the texture
  46866. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46867. * @param size Define the size of the texture to create
  46868. * @param scene Define the scene the texture belongs to
  46869. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46870. * @param generateMipMaps Define if the texture should creates mip maps or not
  46871. */
  46872. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46873. private _loadJson;
  46874. /**
  46875. * Is the texture ready to be used ? (rendered at least once)
  46876. * @returns true if ready, otherwise, false.
  46877. */
  46878. isReady(): boolean;
  46879. /**
  46880. * Render the texture to its associated render target.
  46881. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46882. */
  46883. render(useCameraPostProcess?: boolean): void;
  46884. /**
  46885. * Update the list of dependant textures samplers in the shader.
  46886. */
  46887. updateTextures(): void;
  46888. /**
  46889. * Update the uniform values of the procedural texture in the shader.
  46890. */
  46891. updateShaderUniforms(): void;
  46892. /**
  46893. * Define if the texture animates or not.
  46894. */
  46895. animate: boolean;
  46896. }
  46897. }
  46898. declare module BABYLON {
  46899. /** @hidden */
  46900. export var noisePixelShader: {
  46901. name: string;
  46902. shader: string;
  46903. };
  46904. }
  46905. declare module BABYLON {
  46906. /**
  46907. * Class used to generate noise procedural textures
  46908. */
  46909. export class NoiseProceduralTexture extends ProceduralTexture {
  46910. private _time;
  46911. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46912. brightness: number;
  46913. /** Defines the number of octaves to process */
  46914. octaves: number;
  46915. /** Defines the level of persistence (0.8 by default) */
  46916. persistence: number;
  46917. /** Gets or sets animation speed factor (default is 1) */
  46918. animationSpeedFactor: number;
  46919. /**
  46920. * Creates a new NoiseProceduralTexture
  46921. * @param name defines the name fo the texture
  46922. * @param size defines the size of the texture (default is 256)
  46923. * @param scene defines the hosting scene
  46924. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46925. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46926. */
  46927. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46928. private _updateShaderUniforms;
  46929. protected _getDefines(): string;
  46930. /** Generate the current state of the procedural texture */
  46931. render(useCameraPostProcess?: boolean): void;
  46932. /**
  46933. * Serializes this noise procedural texture
  46934. * @returns a serialized noise procedural texture object
  46935. */
  46936. serialize(): any;
  46937. /**
  46938. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46939. * @param parsedTexture defines parsed texture data
  46940. * @param scene defines the current scene
  46941. * @param rootUrl defines the root URL containing noise procedural texture information
  46942. * @returns a parsed NoiseProceduralTexture
  46943. */
  46944. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  46945. }
  46946. }
  46947. declare module BABYLON {
  46948. /**
  46949. * Raw cube texture where the raw buffers are passed in
  46950. */
  46951. export class RawCubeTexture extends CubeTexture {
  46952. /**
  46953. * Creates a cube texture where the raw buffers are passed in.
  46954. * @param scene defines the scene the texture is attached to
  46955. * @param data defines the array of data to use to create each face
  46956. * @param size defines the size of the textures
  46957. * @param format defines the format of the data
  46958. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46959. * @param generateMipMaps defines if the engine should generate the mip levels
  46960. * @param invertY defines if data must be stored with Y axis inverted
  46961. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46962. * @param compression defines the compression used (null by default)
  46963. */
  46964. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46965. /**
  46966. * Updates the raw cube texture.
  46967. * @param data defines the data to store
  46968. * @param format defines the data format
  46969. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46970. * @param invertY defines if data must be stored with Y axis inverted
  46971. * @param compression defines the compression used (null by default)
  46972. * @param level defines which level of the texture to update
  46973. */
  46974. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  46975. /**
  46976. * Updates a raw cube texture with RGBD encoded data.
  46977. * @param data defines the array of data [mipmap][face] to use to create each face
  46978. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46979. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46980. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46981. * @returns a promsie that resolves when the operation is complete
  46982. */
  46983. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46984. /**
  46985. * Clones the raw cube texture.
  46986. * @return a new cube texture
  46987. */
  46988. clone(): CubeTexture;
  46989. /** @hidden */
  46990. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46991. }
  46992. }
  46993. declare module BABYLON {
  46994. /**
  46995. * Class used to store 3D textures containing user data
  46996. */
  46997. export class RawTexture3D extends Texture {
  46998. /** Gets or sets the texture format to use */
  46999. format: number;
  47000. private _engine;
  47001. /**
  47002. * Create a new RawTexture3D
  47003. * @param data defines the data of the texture
  47004. * @param width defines the width of the texture
  47005. * @param height defines the height of the texture
  47006. * @param depth defines the depth of the texture
  47007. * @param format defines the texture format to use
  47008. * @param scene defines the hosting scene
  47009. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47010. * @param invertY defines if texture must be stored with Y axis inverted
  47011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  47012. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47013. */
  47014. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47015. /** Gets or sets the texture format to use */
  47016. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47017. /**
  47018. * Update the texture with new data
  47019. * @param data defines the data to store in the texture
  47020. */
  47021. update(data: ArrayBufferView): void;
  47022. }
  47023. }
  47024. declare module BABYLON {
  47025. /**
  47026. * Creates a refraction texture used by refraction channel of the standard material.
  47027. * It is like a mirror but to see through a material.
  47028. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47029. */
  47030. export class RefractionTexture extends RenderTargetTexture {
  47031. /**
  47032. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47033. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  47034. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47035. */
  47036. refractionPlane: Plane;
  47037. /**
  47038. * Define how deep under the surface we should see.
  47039. */
  47040. depth: number;
  47041. /**
  47042. * Creates a refraction texture used by refraction channel of the standard material.
  47043. * It is like a mirror but to see through a material.
  47044. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47045. * @param name Define the texture name
  47046. * @param size Define the size of the underlying texture
  47047. * @param scene Define the scene the refraction belongs to
  47048. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47049. */
  47050. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47051. /**
  47052. * Clone the refraction texture.
  47053. * @returns the cloned texture
  47054. */
  47055. clone(): RefractionTexture;
  47056. /**
  47057. * Serialize the texture to a JSON representation you could use in Parse later on
  47058. * @returns the serialized JSON representation
  47059. */
  47060. serialize(): any;
  47061. }
  47062. }
  47063. declare module BABYLON {
  47064. /**
  47065. * Configuration for Draco compression
  47066. */
  47067. export interface IDracoCompressionConfiguration {
  47068. /**
  47069. * Configuration for the decoder.
  47070. */
  47071. decoder?: {
  47072. /**
  47073. * The url to the WebAssembly module.
  47074. */
  47075. wasmUrl?: string;
  47076. /**
  47077. * The url to the WebAssembly binary.
  47078. */
  47079. wasmBinaryUrl?: string;
  47080. /**
  47081. * The url to the fallback JavaScript module.
  47082. */
  47083. fallbackUrl?: string;
  47084. };
  47085. }
  47086. /**
  47087. * Draco compression (https://google.github.io/draco/)
  47088. *
  47089. * This class wraps the Draco module.
  47090. *
  47091. * **Encoder**
  47092. *
  47093. * The encoder is not currently implemented.
  47094. *
  47095. * **Decoder**
  47096. *
  47097. * 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.
  47098. *
  47099. * To update the configuration, use the following code:
  47100. * ```javascript
  47101. * DracoCompression.Configuration = {
  47102. * decoder: {
  47103. * wasmUrl: "<url to the WebAssembly library>",
  47104. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47105. * fallbackUrl: "<url to the fallback JavaScript library>",
  47106. * }
  47107. * };
  47108. * ```
  47109. *
  47110. * 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.
  47111. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47112. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47113. *
  47114. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47115. * ```javascript
  47116. * var dracoCompression = new DracoCompression();
  47117. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47118. * [VertexBuffer.PositionKind]: 0
  47119. * });
  47120. * ```
  47121. *
  47122. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47123. */
  47124. export class DracoCompression implements IDisposable {
  47125. private static _DecoderModulePromise;
  47126. /**
  47127. * The configuration. Defaults to the following urls:
  47128. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47129. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47130. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47131. */
  47132. static Configuration: IDracoCompressionConfiguration;
  47133. /**
  47134. * Returns true if the decoder is available.
  47135. */
  47136. static readonly DecoderAvailable: boolean;
  47137. /**
  47138. * Constructor
  47139. */
  47140. constructor();
  47141. /**
  47142. * Stop all async operations and release resources.
  47143. */
  47144. dispose(): void;
  47145. /**
  47146. * Decode Draco compressed mesh data to vertex data.
  47147. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47148. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47149. * @returns A promise that resolves with the decoded vertex data
  47150. */
  47151. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47152. [kind: string]: number;
  47153. }): Promise<VertexData>;
  47154. private static _GetDecoderModule;
  47155. private static _LoadScriptAsync;
  47156. private static _LoadFileAsync;
  47157. }
  47158. }
  47159. declare module BABYLON {
  47160. /**
  47161. * Class for building Constructive Solid Geometry
  47162. */
  47163. export class CSG {
  47164. private polygons;
  47165. /**
  47166. * The world matrix
  47167. */
  47168. matrix: Matrix;
  47169. /**
  47170. * Stores the position
  47171. */
  47172. position: Vector3;
  47173. /**
  47174. * Stores the rotation
  47175. */
  47176. rotation: Vector3;
  47177. /**
  47178. * Stores the rotation quaternion
  47179. */
  47180. rotationQuaternion: Nullable<Quaternion>;
  47181. /**
  47182. * Stores the scaling vector
  47183. */
  47184. scaling: Vector3;
  47185. /**
  47186. * Convert the Mesh to CSG
  47187. * @param mesh The Mesh to convert to CSG
  47188. * @returns A new CSG from the Mesh
  47189. */
  47190. static FromMesh(mesh: Mesh): CSG;
  47191. /**
  47192. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  47193. * @param polygons Polygons used to construct a CSG solid
  47194. */
  47195. private static FromPolygons;
  47196. /**
  47197. * Clones, or makes a deep copy, of the CSG
  47198. * @returns A new CSG
  47199. */
  47200. clone(): CSG;
  47201. /**
  47202. * Unions this CSG with another CSG
  47203. * @param csg The CSG to union against this CSG
  47204. * @returns The unioned CSG
  47205. */
  47206. union(csg: CSG): CSG;
  47207. /**
  47208. * Unions this CSG with another CSG in place
  47209. * @param csg The CSG to union against this CSG
  47210. */
  47211. unionInPlace(csg: CSG): void;
  47212. /**
  47213. * Subtracts this CSG with another CSG
  47214. * @param csg The CSG to subtract against this CSG
  47215. * @returns A new CSG
  47216. */
  47217. subtract(csg: CSG): CSG;
  47218. /**
  47219. * Subtracts this CSG with another CSG in place
  47220. * @param csg The CSG to subtact against this CSG
  47221. */
  47222. subtractInPlace(csg: CSG): void;
  47223. /**
  47224. * Intersect this CSG with another CSG
  47225. * @param csg The CSG to intersect against this CSG
  47226. * @returns A new CSG
  47227. */
  47228. intersect(csg: CSG): CSG;
  47229. /**
  47230. * Intersects this CSG with another CSG in place
  47231. * @param csg The CSG to intersect against this CSG
  47232. */
  47233. intersectInPlace(csg: CSG): void;
  47234. /**
  47235. * Return a new CSG solid with solid and empty space switched. This solid is
  47236. * not modified.
  47237. * @returns A new CSG solid with solid and empty space switched
  47238. */
  47239. inverse(): CSG;
  47240. /**
  47241. * Inverses the CSG in place
  47242. */
  47243. inverseInPlace(): void;
  47244. /**
  47245. * This is used to keep meshes transformations so they can be restored
  47246. * when we build back a Babylon Mesh
  47247. * NB : All CSG operations are performed in world coordinates
  47248. * @param csg The CSG to copy the transform attributes from
  47249. * @returns This CSG
  47250. */
  47251. copyTransformAttributes(csg: CSG): CSG;
  47252. /**
  47253. * Build Raw mesh from CSG
  47254. * Coordinates here are in world space
  47255. * @param name The name of the mesh geometry
  47256. * @param scene The Scene
  47257. * @param keepSubMeshes Specifies if the submeshes should be kept
  47258. * @returns A new Mesh
  47259. */
  47260. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  47261. /**
  47262. * Build Mesh from CSG taking material and transforms into account
  47263. * @param name The name of the Mesh
  47264. * @param material The material of the Mesh
  47265. * @param scene The Scene
  47266. * @param keepSubMeshes Specifies if submeshes should be kept
  47267. * @returns The new Mesh
  47268. */
  47269. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  47270. }
  47271. }
  47272. declare module BABYLON {
  47273. /**
  47274. * Class used to create a trail following a mesh
  47275. */
  47276. export class TrailMesh extends Mesh {
  47277. private _generator;
  47278. private _autoStart;
  47279. private _running;
  47280. private _diameter;
  47281. private _length;
  47282. private _sectionPolygonPointsCount;
  47283. private _sectionVectors;
  47284. private _sectionNormalVectors;
  47285. private _beforeRenderObserver;
  47286. /**
  47287. * @constructor
  47288. * @param name The value used by scene.getMeshByName() to do a lookup.
  47289. * @param generator The mesh to generate a trail.
  47290. * @param scene The scene to add this mesh to.
  47291. * @param diameter Diameter of trailing mesh. Default is 1.
  47292. * @param length Length of trailing mesh. Default is 60.
  47293. * @param autoStart Automatically start trailing mesh. Default true.
  47294. */
  47295. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  47296. /**
  47297. * "TrailMesh"
  47298. * @returns "TrailMesh"
  47299. */
  47300. getClassName(): string;
  47301. private _createMesh;
  47302. /**
  47303. * Start trailing mesh.
  47304. */
  47305. start(): void;
  47306. /**
  47307. * Stop trailing mesh.
  47308. */
  47309. stop(): void;
  47310. /**
  47311. * Update trailing mesh geometry.
  47312. */
  47313. update(): void;
  47314. /**
  47315. * Returns a new TrailMesh object.
  47316. * @param name is a string, the name given to the new mesh
  47317. * @param newGenerator use new generator object for cloned trail mesh
  47318. * @returns a new mesh
  47319. */
  47320. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  47321. /**
  47322. * Serializes this trail mesh
  47323. * @param serializationObject object to write serialization to
  47324. */
  47325. serialize(serializationObject: any): void;
  47326. /**
  47327. * Parses a serialized trail mesh
  47328. * @param parsedMesh the serialized mesh
  47329. * @param scene the scene to create the trail mesh in
  47330. * @returns the created trail mesh
  47331. */
  47332. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  47333. }
  47334. }
  47335. declare module BABYLON {
  47336. /**
  47337. * Class containing static functions to help procedurally build meshes
  47338. */
  47339. export class RibbonBuilder {
  47340. /**
  47341. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47342. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47343. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47344. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47345. * * 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
  47346. * * 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
  47347. * * 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
  47348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47349. * * 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
  47350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47351. * * 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
  47352. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47353. * * 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
  47354. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47356. * @param name defines the name of the mesh
  47357. * @param options defines the options used to create the mesh
  47358. * @param scene defines the hosting scene
  47359. * @returns the ribbon mesh
  47360. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47362. */
  47363. static CreateRibbon(name: string, options: {
  47364. pathArray: Vector3[][];
  47365. closeArray?: boolean;
  47366. closePath?: boolean;
  47367. offset?: number;
  47368. updatable?: boolean;
  47369. sideOrientation?: number;
  47370. frontUVs?: Vector4;
  47371. backUVs?: Vector4;
  47372. instance?: Mesh;
  47373. invertUV?: boolean;
  47374. uvs?: Vector2[];
  47375. colors?: Color4[];
  47376. }, scene?: Nullable<Scene>): Mesh;
  47377. }
  47378. }
  47379. declare module BABYLON {
  47380. /**
  47381. * Class containing static functions to help procedurally build meshes
  47382. */
  47383. export class TorusKnotBuilder {
  47384. /**
  47385. * Creates a torus knot mesh
  47386. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47387. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47388. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47389. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47391. * * 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
  47392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47393. * @param name defines the name of the mesh
  47394. * @param options defines the options used to create the mesh
  47395. * @param scene defines the hosting scene
  47396. * @returns the torus knot mesh
  47397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47398. */
  47399. static CreateTorusKnot(name: string, options: {
  47400. radius?: number;
  47401. tube?: number;
  47402. radialSegments?: number;
  47403. tubularSegments?: number;
  47404. p?: number;
  47405. q?: number;
  47406. updatable?: boolean;
  47407. sideOrientation?: number;
  47408. frontUVs?: Vector4;
  47409. backUVs?: Vector4;
  47410. }, scene: any): Mesh;
  47411. }
  47412. }
  47413. declare module BABYLON {
  47414. /**
  47415. * Polygon
  47416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  47417. */
  47418. export class Polygon {
  47419. /**
  47420. * Creates a rectangle
  47421. * @param xmin bottom X coord
  47422. * @param ymin bottom Y coord
  47423. * @param xmax top X coord
  47424. * @param ymax top Y coord
  47425. * @returns points that make the resulting rectation
  47426. */
  47427. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  47428. /**
  47429. * Creates a circle
  47430. * @param radius radius of circle
  47431. * @param cx scale in x
  47432. * @param cy scale in y
  47433. * @param numberOfSides number of sides that make up the circle
  47434. * @returns points that make the resulting circle
  47435. */
  47436. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  47437. /**
  47438. * Creates a polygon from input string
  47439. * @param input Input polygon data
  47440. * @returns the parsed points
  47441. */
  47442. static Parse(input: string): Vector2[];
  47443. /**
  47444. * Starts building a polygon from x and y coordinates
  47445. * @param x x coordinate
  47446. * @param y y coordinate
  47447. * @returns the started path2
  47448. */
  47449. static StartingAt(x: number, y: number): Path2;
  47450. }
  47451. /**
  47452. * Builds a polygon
  47453. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  47454. */
  47455. export class PolygonMeshBuilder {
  47456. private _points;
  47457. private _outlinepoints;
  47458. private _holes;
  47459. private _name;
  47460. private _scene;
  47461. private _epoints;
  47462. private _eholes;
  47463. private _addToepoint;
  47464. /**
  47465. * Babylon reference to the earcut plugin.
  47466. */
  47467. bjsEarcut: any;
  47468. /**
  47469. * Creates a PolygonMeshBuilder
  47470. * @param name name of the builder
  47471. * @param contours Path of the polygon
  47472. * @param scene scene to add to
  47473. * @param earcutInjection can be used to inject your own earcut reference
  47474. */
  47475. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  47476. /**
  47477. * Adds a whole within the polygon
  47478. * @param hole Array of points defining the hole
  47479. * @returns this
  47480. */
  47481. addHole(hole: Vector2[]): PolygonMeshBuilder;
  47482. /**
  47483. * Creates the polygon
  47484. * @param updatable If the mesh should be updatable
  47485. * @param depth The depth of the mesh created
  47486. * @returns the created mesh
  47487. */
  47488. build(updatable?: boolean, depth?: number): Mesh;
  47489. /**
  47490. * Adds a side to the polygon
  47491. * @param positions points that make the polygon
  47492. * @param normals normals of the polygon
  47493. * @param uvs uvs of the polygon
  47494. * @param indices indices of the polygon
  47495. * @param bounds bounds of the polygon
  47496. * @param points points of the polygon
  47497. * @param depth depth of the polygon
  47498. * @param flip flip of the polygon
  47499. */
  47500. private addSide;
  47501. }
  47502. }
  47503. declare module BABYLON {
  47504. /**
  47505. * Class containing static functions to help procedurally build meshes
  47506. */
  47507. export class PolygonBuilder {
  47508. /**
  47509. * Creates a polygon mesh
  47510. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47511. * * 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
  47512. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47514. * * 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)
  47515. * * Remember you can only change the shape positions, not their number when updating a polygon
  47516. * @param name defines the name of the mesh
  47517. * @param options defines the options used to create the mesh
  47518. * @param scene defines the hosting scene
  47519. * @param earcutInjection can be used to inject your own earcut reference
  47520. * @returns the polygon mesh
  47521. */
  47522. static CreatePolygon(name: string, options: {
  47523. shape: Vector3[];
  47524. holes?: Vector3[][];
  47525. depth?: number;
  47526. faceUV?: Vector4[];
  47527. faceColors?: Color4[];
  47528. updatable?: boolean;
  47529. sideOrientation?: number;
  47530. frontUVs?: Vector4;
  47531. backUVs?: Vector4;
  47532. }, scene: Scene, earcutInjection?: any): Mesh;
  47533. /**
  47534. * Creates an extruded polygon mesh, with depth in the Y direction.
  47535. * * 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)
  47536. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47537. * @param name defines the name of the mesh
  47538. * @param options defines the options used to create the mesh
  47539. * @param scene defines the hosting scene
  47540. * @param earcutInjection can be used to inject your own earcut reference
  47541. * @returns the polygon mesh
  47542. */
  47543. static ExtrudePolygon(name: string, options: {
  47544. shape: Vector3[];
  47545. holes?: Vector3[][];
  47546. depth?: number;
  47547. faceUV?: Vector4[];
  47548. faceColors?: Color4[];
  47549. updatable?: boolean;
  47550. sideOrientation?: number;
  47551. frontUVs?: Vector4;
  47552. backUVs?: Vector4;
  47553. }, scene: Scene, earcutInjection?: any): Mesh;
  47554. }
  47555. }
  47556. declare module BABYLON {
  47557. /**
  47558. * Class containing static functions to help procedurally build meshes
  47559. */
  47560. export class ShapeBuilder {
  47561. /**
  47562. * 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.
  47563. * * 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.
  47564. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47565. * * 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.
  47566. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47567. * * 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
  47568. * * 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
  47569. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47571. * * 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
  47572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47574. * @param name defines the name of the mesh
  47575. * @param options defines the options used to create the mesh
  47576. * @param scene defines the hosting scene
  47577. * @returns the extruded shape mesh
  47578. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47580. */
  47581. static ExtrudeShape(name: string, options: {
  47582. shape: Vector3[];
  47583. path: Vector3[];
  47584. scale?: number;
  47585. rotation?: number;
  47586. cap?: number;
  47587. updatable?: boolean;
  47588. sideOrientation?: number;
  47589. frontUVs?: Vector4;
  47590. backUVs?: Vector4;
  47591. instance?: Mesh;
  47592. invertUV?: boolean;
  47593. }, scene?: Nullable<Scene>): Mesh;
  47594. /**
  47595. * Creates an custom extruded shape mesh.
  47596. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47597. * * 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.
  47598. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47599. * * 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
  47600. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47601. * * 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
  47602. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47603. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47604. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47605. * * 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
  47606. * * 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
  47607. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47609. * * 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
  47610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47612. * @param name defines the name of the mesh
  47613. * @param options defines the options used to create the mesh
  47614. * @param scene defines the hosting scene
  47615. * @returns the custom extruded shape mesh
  47616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47617. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47619. */
  47620. static ExtrudeShapeCustom(name: string, options: {
  47621. shape: Vector3[];
  47622. path: Vector3[];
  47623. scaleFunction?: any;
  47624. rotationFunction?: any;
  47625. ribbonCloseArray?: boolean;
  47626. ribbonClosePath?: boolean;
  47627. cap?: number;
  47628. updatable?: boolean;
  47629. sideOrientation?: number;
  47630. frontUVs?: Vector4;
  47631. backUVs?: Vector4;
  47632. instance?: Mesh;
  47633. invertUV?: boolean;
  47634. }, scene: Scene): Mesh;
  47635. private static _ExtrudeShapeGeneric;
  47636. }
  47637. }
  47638. declare module BABYLON {
  47639. /**
  47640. * Class containing static functions to help procedurally build meshes
  47641. */
  47642. export class LatheBuilder {
  47643. /**
  47644. * Creates lathe mesh.
  47645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47646. * * 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
  47647. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47648. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47649. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47650. * * 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
  47651. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47652. * * 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
  47653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47654. * * 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
  47655. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47657. * @param name defines the name of the mesh
  47658. * @param options defines the options used to create the mesh
  47659. * @param scene defines the hosting scene
  47660. * @returns the lathe mesh
  47661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47662. */
  47663. static CreateLathe(name: string, options: {
  47664. shape: Vector3[];
  47665. radius?: number;
  47666. tessellation?: number;
  47667. clip?: number;
  47668. arc?: number;
  47669. closed?: boolean;
  47670. updatable?: boolean;
  47671. sideOrientation?: number;
  47672. frontUVs?: Vector4;
  47673. backUVs?: Vector4;
  47674. cap?: number;
  47675. invertUV?: boolean;
  47676. }, scene: Scene): Mesh;
  47677. }
  47678. }
  47679. declare module BABYLON {
  47680. /**
  47681. * Class containing static functions to help procedurally build meshes
  47682. */
  47683. export class TubeBuilder {
  47684. /**
  47685. * Creates a tube mesh.
  47686. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47687. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47688. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47689. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47690. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47691. * * 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)
  47692. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47693. * * 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
  47694. * * 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
  47695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47696. * * 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
  47697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47699. * @param name defines the name of the mesh
  47700. * @param options defines the options used to create the mesh
  47701. * @param scene defines the hosting scene
  47702. * @returns the tube mesh
  47703. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47704. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47705. */
  47706. static CreateTube(name: string, options: {
  47707. path: Vector3[];
  47708. radius?: number;
  47709. tessellation?: number;
  47710. radiusFunction?: {
  47711. (i: number, distance: number): number;
  47712. };
  47713. cap?: number;
  47714. arc?: number;
  47715. updatable?: boolean;
  47716. sideOrientation?: number;
  47717. frontUVs?: Vector4;
  47718. backUVs?: Vector4;
  47719. instance?: Mesh;
  47720. invertUV?: boolean;
  47721. }, scene: Scene): Mesh;
  47722. }
  47723. }
  47724. declare module BABYLON {
  47725. /**
  47726. * Class containing static functions to help procedurally build meshes
  47727. */
  47728. export class IcoSphereBuilder {
  47729. /**
  47730. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47731. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47732. * * 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`)
  47733. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47734. * * 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
  47735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47736. * * 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
  47737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47738. * @param name defines the name of the mesh
  47739. * @param options defines the options used to create the mesh
  47740. * @param scene defines the hosting scene
  47741. * @returns the icosahedron mesh
  47742. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47743. */
  47744. static CreateIcoSphere(name: string, options: {
  47745. radius?: number;
  47746. radiusX?: number;
  47747. radiusY?: number;
  47748. radiusZ?: number;
  47749. flat?: boolean;
  47750. subdivisions?: number;
  47751. sideOrientation?: number;
  47752. frontUVs?: Vector4;
  47753. backUVs?: Vector4;
  47754. updatable?: boolean;
  47755. }, scene: Scene): Mesh;
  47756. }
  47757. }
  47758. declare module BABYLON {
  47759. /**
  47760. * Class containing static functions to help procedurally build meshes
  47761. */
  47762. export class DecalBuilder {
  47763. /**
  47764. * Creates a decal mesh.
  47765. * 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
  47766. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47767. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47768. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47769. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47770. * @param name defines the name of the mesh
  47771. * @param sourceMesh defines the mesh where the decal must be applied
  47772. * @param options defines the options used to create the mesh
  47773. * @param scene defines the hosting scene
  47774. * @returns the decal mesh
  47775. * @see https://doc.babylonjs.com/how_to/decals
  47776. */
  47777. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47778. position?: Vector3;
  47779. normal?: Vector3;
  47780. size?: Vector3;
  47781. angle?: number;
  47782. }): Mesh;
  47783. }
  47784. }
  47785. declare module BABYLON {
  47786. /**
  47787. * Class containing static functions to help procedurally build meshes
  47788. */
  47789. export class MeshBuilder {
  47790. /**
  47791. * Creates a box mesh
  47792. * * The parameter `size` sets the size (float) of each box side (default 1)
  47793. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47794. * * 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)
  47795. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47797. * * 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
  47798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47799. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47800. * @param name defines the name of the mesh
  47801. * @param options defines the options used to create the mesh
  47802. * @param scene defines the hosting scene
  47803. * @returns the box mesh
  47804. */
  47805. static CreateBox(name: string, options: {
  47806. size?: number;
  47807. width?: number;
  47808. height?: number;
  47809. depth?: number;
  47810. faceUV?: Vector4[];
  47811. faceColors?: Color4[];
  47812. sideOrientation?: number;
  47813. frontUVs?: Vector4;
  47814. backUVs?: Vector4;
  47815. updatable?: boolean;
  47816. }, scene?: Nullable<Scene>): Mesh;
  47817. /**
  47818. * Creates a sphere mesh
  47819. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47820. * * 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`)
  47821. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47822. * * 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
  47823. * * 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)
  47824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47825. * * 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
  47826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47827. * @param name defines the name of the mesh
  47828. * @param options defines the options used to create the mesh
  47829. * @param scene defines the hosting scene
  47830. * @returns the sphere mesh
  47831. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47832. */
  47833. static CreateSphere(name: string, options: {
  47834. segments?: number;
  47835. diameter?: number;
  47836. diameterX?: number;
  47837. diameterY?: number;
  47838. diameterZ?: number;
  47839. arc?: number;
  47840. slice?: number;
  47841. sideOrientation?: number;
  47842. frontUVs?: Vector4;
  47843. backUVs?: Vector4;
  47844. updatable?: boolean;
  47845. }, scene: any): Mesh;
  47846. /**
  47847. * Creates a plane polygonal mesh. By default, this is a disc
  47848. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  47849. * * 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
  47850. * * 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
  47851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47852. * * 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
  47853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47854. * @param name defines the name of the mesh
  47855. * @param options defines the options used to create the mesh
  47856. * @param scene defines the hosting scene
  47857. * @returns the plane polygonal mesh
  47858. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  47859. */
  47860. static CreateDisc(name: string, options: {
  47861. radius?: number;
  47862. tessellation?: number;
  47863. arc?: number;
  47864. updatable?: boolean;
  47865. sideOrientation?: number;
  47866. frontUVs?: Vector4;
  47867. backUVs?: Vector4;
  47868. }, scene?: Nullable<Scene>): Mesh;
  47869. /**
  47870. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47871. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47872. * * 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`)
  47873. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47874. * * 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
  47875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47876. * * 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
  47877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47878. * @param name defines the name of the mesh
  47879. * @param options defines the options used to create the mesh
  47880. * @param scene defines the hosting scene
  47881. * @returns the icosahedron mesh
  47882. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47883. */
  47884. static CreateIcoSphere(name: string, options: {
  47885. radius?: number;
  47886. radiusX?: number;
  47887. radiusY?: number;
  47888. radiusZ?: number;
  47889. flat?: boolean;
  47890. subdivisions?: number;
  47891. sideOrientation?: number;
  47892. frontUVs?: Vector4;
  47893. backUVs?: Vector4;
  47894. updatable?: boolean;
  47895. }, scene: Scene): Mesh;
  47896. /**
  47897. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47898. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47899. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47900. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47901. * * 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
  47902. * * 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
  47903. * * 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
  47904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47905. * * 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
  47906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47907. * * 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
  47908. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47909. * * 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
  47910. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47912. * @param name defines the name of the mesh
  47913. * @param options defines the options used to create the mesh
  47914. * @param scene defines the hosting scene
  47915. * @returns the ribbon mesh
  47916. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47918. */
  47919. static CreateRibbon(name: string, options: {
  47920. pathArray: Vector3[][];
  47921. closeArray?: boolean;
  47922. closePath?: boolean;
  47923. offset?: number;
  47924. updatable?: boolean;
  47925. sideOrientation?: number;
  47926. frontUVs?: Vector4;
  47927. backUVs?: Vector4;
  47928. instance?: Mesh;
  47929. invertUV?: boolean;
  47930. uvs?: Vector2[];
  47931. colors?: Color4[];
  47932. }, scene?: Nullable<Scene>): Mesh;
  47933. /**
  47934. * Creates a cylinder or a cone mesh
  47935. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47936. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47937. * * 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.
  47938. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47939. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47940. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47941. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47942. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47943. * * 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).
  47944. * * 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
  47945. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47946. * * 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
  47947. * * 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.
  47948. * * If `enclose` is false, a ring surface is one element.
  47949. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47950. * * 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
  47951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47952. * * 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
  47953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47954. * @param name defines the name of the mesh
  47955. * @param options defines the options used to create the mesh
  47956. * @param scene defines the hosting scene
  47957. * @returns the cylinder mesh
  47958. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47959. */
  47960. static CreateCylinder(name: string, options: {
  47961. height?: number;
  47962. diameterTop?: number;
  47963. diameterBottom?: number;
  47964. diameter?: number;
  47965. tessellation?: number;
  47966. subdivisions?: number;
  47967. arc?: number;
  47968. faceColors?: Color4[];
  47969. faceUV?: Vector4[];
  47970. updatable?: boolean;
  47971. hasRings?: boolean;
  47972. enclose?: boolean;
  47973. sideOrientation?: number;
  47974. frontUVs?: Vector4;
  47975. backUVs?: Vector4;
  47976. }, scene: any): Mesh;
  47977. /**
  47978. * Creates a torus mesh
  47979. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47980. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47981. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47983. * * 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
  47984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47985. * @param name defines the name of the mesh
  47986. * @param options defines the options used to create the mesh
  47987. * @param scene defines the hosting scene
  47988. * @returns the torus mesh
  47989. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47990. */
  47991. static CreateTorus(name: string, options: {
  47992. diameter?: number;
  47993. thickness?: number;
  47994. tessellation?: number;
  47995. updatable?: boolean;
  47996. sideOrientation?: number;
  47997. frontUVs?: Vector4;
  47998. backUVs?: Vector4;
  47999. }, scene: any): Mesh;
  48000. /**
  48001. * Creates a torus knot mesh
  48002. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48003. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48004. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48005. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48007. * * 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
  48008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48009. * @param name defines the name of the mesh
  48010. * @param options defines the options used to create the mesh
  48011. * @param scene defines the hosting scene
  48012. * @returns the torus knot mesh
  48013. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48014. */
  48015. static CreateTorusKnot(name: string, options: {
  48016. radius?: number;
  48017. tube?: number;
  48018. radialSegments?: number;
  48019. tubularSegments?: number;
  48020. p?: number;
  48021. q?: number;
  48022. updatable?: boolean;
  48023. sideOrientation?: number;
  48024. frontUVs?: Vector4;
  48025. backUVs?: Vector4;
  48026. }, scene: any): Mesh;
  48027. /**
  48028. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48029. * * 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
  48030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48031. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48032. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48033. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48034. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48035. * * 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
  48036. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48039. * @param name defines the name of the new line system
  48040. * @param options defines the options used to create the line system
  48041. * @param scene defines the hosting scene
  48042. * @returns a new line system mesh
  48043. */
  48044. static CreateLineSystem(name: string, options: {
  48045. lines: Vector3[][];
  48046. updatable?: boolean;
  48047. instance?: Nullable<LinesMesh>;
  48048. colors?: Nullable<Color4[][]>;
  48049. useVertexAlpha?: boolean;
  48050. }, scene: Nullable<Scene>): LinesMesh;
  48051. /**
  48052. * Creates a line mesh
  48053. * 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
  48054. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48055. * * The parameter `points` is an array successive Vector3
  48056. * * 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
  48057. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48058. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48059. * * When updating an instance, remember that only point positions can change, not the number of points
  48060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48062. * @param name defines the name of the new line system
  48063. * @param options defines the options used to create the line system
  48064. * @param scene defines the hosting scene
  48065. * @returns a new line mesh
  48066. */
  48067. static CreateLines(name: string, options: {
  48068. points: Vector3[];
  48069. updatable?: boolean;
  48070. instance?: Nullable<LinesMesh>;
  48071. colors?: Color4[];
  48072. useVertexAlpha?: boolean;
  48073. }, scene?: Nullable<Scene>): LinesMesh;
  48074. /**
  48075. * Creates a dashed line mesh
  48076. * * 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
  48077. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48078. * * The parameter `points` is an array successive Vector3
  48079. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48080. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48081. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48082. * * 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
  48083. * * When updating an instance, remember that only point positions can change, not the number of points
  48084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48085. * @param name defines the name of the mesh
  48086. * @param options defines the options used to create the mesh
  48087. * @param scene defines the hosting scene
  48088. * @returns the dashed line mesh
  48089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48090. */
  48091. static CreateDashedLines(name: string, options: {
  48092. points: Vector3[];
  48093. dashSize?: number;
  48094. gapSize?: number;
  48095. dashNb?: number;
  48096. updatable?: boolean;
  48097. instance?: LinesMesh;
  48098. }, scene?: Nullable<Scene>): LinesMesh;
  48099. /**
  48100. * 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.
  48101. * * 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.
  48102. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48103. * * 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.
  48104. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48105. * * 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
  48106. * * 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
  48107. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48109. * * 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
  48110. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48112. * @param name defines the name of the mesh
  48113. * @param options defines the options used to create the mesh
  48114. * @param scene defines the hosting scene
  48115. * @returns the extruded shape mesh
  48116. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48118. */
  48119. static ExtrudeShape(name: string, options: {
  48120. shape: Vector3[];
  48121. path: Vector3[];
  48122. scale?: number;
  48123. rotation?: number;
  48124. cap?: number;
  48125. updatable?: boolean;
  48126. sideOrientation?: number;
  48127. frontUVs?: Vector4;
  48128. backUVs?: Vector4;
  48129. instance?: Mesh;
  48130. invertUV?: boolean;
  48131. }, scene?: Nullable<Scene>): Mesh;
  48132. /**
  48133. * Creates an custom extruded shape mesh.
  48134. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48135. * * 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.
  48136. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48137. * * 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
  48138. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48139. * * 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
  48140. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48141. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48142. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48143. * * 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
  48144. * * 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
  48145. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48147. * * 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
  48148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48150. * @param name defines the name of the mesh
  48151. * @param options defines the options used to create the mesh
  48152. * @param scene defines the hosting scene
  48153. * @returns the custom extruded shape mesh
  48154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48157. */
  48158. static ExtrudeShapeCustom(name: string, options: {
  48159. shape: Vector3[];
  48160. path: Vector3[];
  48161. scaleFunction?: any;
  48162. rotationFunction?: any;
  48163. ribbonCloseArray?: boolean;
  48164. ribbonClosePath?: boolean;
  48165. cap?: number;
  48166. updatable?: boolean;
  48167. sideOrientation?: number;
  48168. frontUVs?: Vector4;
  48169. backUVs?: Vector4;
  48170. instance?: Mesh;
  48171. invertUV?: boolean;
  48172. }, scene: Scene): Mesh;
  48173. /**
  48174. * Creates lathe mesh.
  48175. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48176. * * 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
  48177. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48178. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  48179. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  48180. * * 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
  48181. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  48182. * * 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
  48183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48184. * * 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
  48185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48187. * @param name defines the name of the mesh
  48188. * @param options defines the options used to create the mesh
  48189. * @param scene defines the hosting scene
  48190. * @returns the lathe mesh
  48191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  48192. */
  48193. static CreateLathe(name: string, options: {
  48194. shape: Vector3[];
  48195. radius?: number;
  48196. tessellation?: number;
  48197. clip?: number;
  48198. arc?: number;
  48199. closed?: boolean;
  48200. updatable?: boolean;
  48201. sideOrientation?: number;
  48202. frontUVs?: Vector4;
  48203. backUVs?: Vector4;
  48204. cap?: number;
  48205. invertUV?: boolean;
  48206. }, scene: Scene): Mesh;
  48207. /**
  48208. * Creates a plane mesh
  48209. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48210. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48211. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48213. * * 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
  48214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48215. * @param name defines the name of the mesh
  48216. * @param options defines the options used to create the mesh
  48217. * @param scene defines the hosting scene
  48218. * @returns the plane mesh
  48219. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48220. */
  48221. static CreatePlane(name: string, options: {
  48222. size?: number;
  48223. width?: number;
  48224. height?: number;
  48225. sideOrientation?: number;
  48226. frontUVs?: Vector4;
  48227. backUVs?: Vector4;
  48228. updatable?: boolean;
  48229. sourcePlane?: Plane;
  48230. }, scene: Scene): Mesh;
  48231. /**
  48232. * Creates a ground mesh
  48233. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48234. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48236. * @param name defines the name of the mesh
  48237. * @param options defines the options used to create the mesh
  48238. * @param scene defines the hosting scene
  48239. * @returns the ground mesh
  48240. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48241. */
  48242. static CreateGround(name: string, options: {
  48243. width?: number;
  48244. height?: number;
  48245. subdivisions?: number;
  48246. subdivisionsX?: number;
  48247. subdivisionsY?: number;
  48248. updatable?: boolean;
  48249. }, scene: any): Mesh;
  48250. /**
  48251. * Creates a tiled ground mesh
  48252. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48253. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48254. * * 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
  48255. * * 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
  48256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48257. * @param name defines the name of the mesh
  48258. * @param options defines the options used to create the mesh
  48259. * @param scene defines the hosting scene
  48260. * @returns the tiled ground mesh
  48261. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48262. */
  48263. static CreateTiledGround(name: string, options: {
  48264. xmin: number;
  48265. zmin: number;
  48266. xmax: number;
  48267. zmax: number;
  48268. subdivisions?: {
  48269. w: number;
  48270. h: number;
  48271. };
  48272. precision?: {
  48273. w: number;
  48274. h: number;
  48275. };
  48276. updatable?: boolean;
  48277. }, scene: Scene): Mesh;
  48278. /**
  48279. * Creates a ground mesh from a height map
  48280. * * The parameter `url` sets the URL of the height map image resource.
  48281. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48282. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48283. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48284. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48285. * * 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.
  48286. * * 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).
  48287. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48289. * @param name defines the name of the mesh
  48290. * @param url defines the url to the height map
  48291. * @param options defines the options used to create the mesh
  48292. * @param scene defines the hosting scene
  48293. * @returns the ground mesh
  48294. * @see https://doc.babylonjs.com/babylon101/height_map
  48295. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48296. */
  48297. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48298. width?: number;
  48299. height?: number;
  48300. subdivisions?: number;
  48301. minHeight?: number;
  48302. maxHeight?: number;
  48303. colorFilter?: Color3;
  48304. alphaFilter?: number;
  48305. updatable?: boolean;
  48306. onReady?: (mesh: GroundMesh) => void;
  48307. }, scene: Scene): GroundMesh;
  48308. /**
  48309. * Creates a polygon mesh
  48310. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48311. * * 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
  48312. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48314. * * 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)
  48315. * * Remember you can only change the shape positions, not their number when updating a polygon
  48316. * @param name defines the name of the mesh
  48317. * @param options defines the options used to create the mesh
  48318. * @param scene defines the hosting scene
  48319. * @param earcutInjection can be used to inject your own earcut reference
  48320. * @returns the polygon mesh
  48321. */
  48322. static CreatePolygon(name: string, options: {
  48323. shape: Vector3[];
  48324. holes?: Vector3[][];
  48325. depth?: number;
  48326. faceUV?: Vector4[];
  48327. faceColors?: Color4[];
  48328. updatable?: boolean;
  48329. sideOrientation?: number;
  48330. frontUVs?: Vector4;
  48331. backUVs?: Vector4;
  48332. }, scene: Scene, earcutInjection?: any): Mesh;
  48333. /**
  48334. * Creates an extruded polygon mesh, with depth in the Y direction.
  48335. * * 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)
  48336. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48337. * @param name defines the name of the mesh
  48338. * @param options defines the options used to create the mesh
  48339. * @param scene defines the hosting scene
  48340. * @param earcutInjection can be used to inject your own earcut reference
  48341. * @returns the polygon mesh
  48342. */
  48343. static ExtrudePolygon(name: string, options: {
  48344. shape: Vector3[];
  48345. holes?: Vector3[][];
  48346. depth?: number;
  48347. faceUV?: Vector4[];
  48348. faceColors?: Color4[];
  48349. updatable?: boolean;
  48350. sideOrientation?: number;
  48351. frontUVs?: Vector4;
  48352. backUVs?: Vector4;
  48353. }, scene: Scene, earcutInjection?: any): Mesh;
  48354. /**
  48355. * Creates a tube mesh.
  48356. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48357. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  48358. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  48359. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  48360. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  48361. * * 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)
  48362. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  48363. * * 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
  48364. * * 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
  48365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48366. * * 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
  48367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48369. * @param name defines the name of the mesh
  48370. * @param options defines the options used to create the mesh
  48371. * @param scene defines the hosting scene
  48372. * @returns the tube mesh
  48373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48374. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  48375. */
  48376. static CreateTube(name: string, options: {
  48377. path: Vector3[];
  48378. radius?: number;
  48379. tessellation?: number;
  48380. radiusFunction?: {
  48381. (i: number, distance: number): number;
  48382. };
  48383. cap?: number;
  48384. arc?: number;
  48385. updatable?: boolean;
  48386. sideOrientation?: number;
  48387. frontUVs?: Vector4;
  48388. backUVs?: Vector4;
  48389. instance?: Mesh;
  48390. invertUV?: boolean;
  48391. }, scene: Scene): Mesh;
  48392. /**
  48393. * Creates a polyhedron mesh
  48394. * * 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
  48395. * * The parameter `size` (positive float, default 1) sets the polygon size
  48396. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48397. * * 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`
  48398. * * 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
  48399. * * 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)`)
  48400. * * 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
  48401. * * 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
  48402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48403. * * 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
  48404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48405. * @param name defines the name of the mesh
  48406. * @param options defines the options used to create the mesh
  48407. * @param scene defines the hosting scene
  48408. * @returns the polyhedron mesh
  48409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48410. */
  48411. static CreatePolyhedron(name: string, options: {
  48412. type?: number;
  48413. size?: number;
  48414. sizeX?: number;
  48415. sizeY?: number;
  48416. sizeZ?: number;
  48417. custom?: any;
  48418. faceUV?: Vector4[];
  48419. faceColors?: Color4[];
  48420. flat?: boolean;
  48421. updatable?: boolean;
  48422. sideOrientation?: number;
  48423. frontUVs?: Vector4;
  48424. backUVs?: Vector4;
  48425. }, scene: Scene): Mesh;
  48426. /**
  48427. * Creates a decal mesh.
  48428. * 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
  48429. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  48430. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  48431. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  48432. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  48433. * @param name defines the name of the mesh
  48434. * @param sourceMesh defines the mesh where the decal must be applied
  48435. * @param options defines the options used to create the mesh
  48436. * @param scene defines the hosting scene
  48437. * @returns the decal mesh
  48438. * @see https://doc.babylonjs.com/how_to/decals
  48439. */
  48440. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  48441. position?: Vector3;
  48442. normal?: Vector3;
  48443. size?: Vector3;
  48444. angle?: number;
  48445. }): Mesh;
  48446. }
  48447. }
  48448. declare module BABYLON {
  48449. /**
  48450. * A simplifier interface for future simplification implementations
  48451. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48452. */
  48453. export interface ISimplifier {
  48454. /**
  48455. * Simplification of a given mesh according to the given settings.
  48456. * Since this requires computation, it is assumed that the function runs async.
  48457. * @param settings The settings of the simplification, including quality and distance
  48458. * @param successCallback A callback that will be called after the mesh was simplified.
  48459. * @param errorCallback in case of an error, this callback will be called. optional.
  48460. */
  48461. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  48462. }
  48463. /**
  48464. * Expected simplification settings.
  48465. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  48466. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48467. */
  48468. export interface ISimplificationSettings {
  48469. /**
  48470. * Gets or sets the expected quality
  48471. */
  48472. quality: number;
  48473. /**
  48474. * Gets or sets the distance when this optimized version should be used
  48475. */
  48476. distance: number;
  48477. /**
  48478. * Gets an already optimized mesh
  48479. */
  48480. optimizeMesh?: boolean;
  48481. }
  48482. /**
  48483. * Class used to specify simplification options
  48484. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48485. */
  48486. export class SimplificationSettings implements ISimplificationSettings {
  48487. /** expected quality */
  48488. quality: number;
  48489. /** distance when this optimized version should be used */
  48490. distance: number;
  48491. /** already optimized mesh */
  48492. optimizeMesh?: boolean | undefined;
  48493. /**
  48494. * Creates a SimplificationSettings
  48495. * @param quality expected quality
  48496. * @param distance distance when this optimized version should be used
  48497. * @param optimizeMesh already optimized mesh
  48498. */
  48499. constructor(
  48500. /** expected quality */
  48501. quality: number,
  48502. /** distance when this optimized version should be used */
  48503. distance: number,
  48504. /** already optimized mesh */
  48505. optimizeMesh?: boolean | undefined);
  48506. }
  48507. /**
  48508. * Interface used to define a simplification task
  48509. */
  48510. export interface ISimplificationTask {
  48511. /**
  48512. * Array of settings
  48513. */
  48514. settings: Array<ISimplificationSettings>;
  48515. /**
  48516. * Simplification type
  48517. */
  48518. simplificationType: SimplificationType;
  48519. /**
  48520. * Mesh to simplify
  48521. */
  48522. mesh: Mesh;
  48523. /**
  48524. * Callback called on success
  48525. */
  48526. successCallback?: () => void;
  48527. /**
  48528. * Defines if parallel processing can be used
  48529. */
  48530. parallelProcessing: boolean;
  48531. }
  48532. /**
  48533. * Queue used to order the simplification tasks
  48534. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48535. */
  48536. export class SimplificationQueue {
  48537. private _simplificationArray;
  48538. /**
  48539. * Gets a boolean indicating that the process is still running
  48540. */
  48541. running: boolean;
  48542. /**
  48543. * Creates a new queue
  48544. */
  48545. constructor();
  48546. /**
  48547. * Adds a new simplification task
  48548. * @param task defines a task to add
  48549. */
  48550. addTask(task: ISimplificationTask): void;
  48551. /**
  48552. * Execute next task
  48553. */
  48554. executeNext(): void;
  48555. /**
  48556. * Execute a simplification task
  48557. * @param task defines the task to run
  48558. */
  48559. runSimplification(task: ISimplificationTask): void;
  48560. private getSimplifier;
  48561. }
  48562. /**
  48563. * The implemented types of simplification
  48564. * At the moment only Quadratic Error Decimation is implemented
  48565. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48566. */
  48567. export enum SimplificationType {
  48568. /** Quadratic error decimation */
  48569. QUADRATIC = 0
  48570. }
  48571. }
  48572. declare module BABYLON {
  48573. interface Scene {
  48574. /** @hidden (Backing field) */
  48575. _simplificationQueue: SimplificationQueue;
  48576. /**
  48577. * Gets or sets the simplification queue attached to the scene
  48578. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  48579. */
  48580. simplificationQueue: SimplificationQueue;
  48581. }
  48582. interface Mesh {
  48583. /**
  48584. * Simplify the mesh according to the given array of settings.
  48585. * Function will return immediately and will simplify async
  48586. * @param settings a collection of simplification settings
  48587. * @param parallelProcessing should all levels calculate parallel or one after the other
  48588. * @param simplificationType the type of simplification to run
  48589. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  48590. * @returns the current mesh
  48591. */
  48592. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  48593. }
  48594. /**
  48595. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  48596. * created in a scene
  48597. */
  48598. export class SimplicationQueueSceneComponent implements ISceneComponent {
  48599. /**
  48600. * The component name helpfull to identify the component in the list of scene components.
  48601. */
  48602. readonly name: string;
  48603. /**
  48604. * The scene the component belongs to.
  48605. */
  48606. scene: Scene;
  48607. /**
  48608. * Creates a new instance of the component for the given scene
  48609. * @param scene Defines the scene to register the component in
  48610. */
  48611. constructor(scene: Scene);
  48612. /**
  48613. * Registers the component in a given scene
  48614. */
  48615. register(): void;
  48616. /**
  48617. * Rebuilds the elements related to this component in case of
  48618. * context lost for instance.
  48619. */
  48620. rebuild(): void;
  48621. /**
  48622. * Disposes the component and the associated ressources
  48623. */
  48624. dispose(): void;
  48625. private _beforeCameraUpdate;
  48626. }
  48627. }
  48628. declare module BABYLON {
  48629. /**
  48630. * Class used to enable access to IndexedDB
  48631. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48632. */
  48633. export class Database implements IOfflineProvider {
  48634. private _callbackManifestChecked;
  48635. private _currentSceneUrl;
  48636. private _db;
  48637. private _enableSceneOffline;
  48638. private _enableTexturesOffline;
  48639. private _manifestVersionFound;
  48640. private _mustUpdateRessources;
  48641. private _hasReachedQuota;
  48642. private _isSupported;
  48643. private _idbFactory;
  48644. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  48645. private static IsUASupportingBlobStorage;
  48646. /**
  48647. * Gets a boolean indicating if Database storate is enabled (off by default)
  48648. */
  48649. static IDBStorageEnabled: boolean;
  48650. /**
  48651. * Gets a boolean indicating if scene must be saved in the database
  48652. */
  48653. readonly enableSceneOffline: boolean;
  48654. /**
  48655. * Gets a boolean indicating if textures must be saved in the database
  48656. */
  48657. readonly enableTexturesOffline: boolean;
  48658. /**
  48659. * Creates a new Database
  48660. * @param urlToScene defines the url to load the scene
  48661. * @param callbackManifestChecked defines the callback to use when manifest is checked
  48662. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  48663. */
  48664. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  48665. private static _ParseURL;
  48666. private static _ReturnFullUrlLocation;
  48667. private _checkManifestFile;
  48668. /**
  48669. * Open the database and make it available
  48670. * @param successCallback defines the callback to call on success
  48671. * @param errorCallback defines the callback to call on error
  48672. */
  48673. open(successCallback: () => void, errorCallback: () => void): void;
  48674. /**
  48675. * Loads an image from the database
  48676. * @param url defines the url to load from
  48677. * @param image defines the target DOM image
  48678. */
  48679. loadImage(url: string, image: HTMLImageElement): void;
  48680. private _loadImageFromDBAsync;
  48681. private _saveImageIntoDBAsync;
  48682. private _checkVersionFromDB;
  48683. private _loadVersionFromDBAsync;
  48684. private _saveVersionIntoDBAsync;
  48685. /**
  48686. * Loads a file from database
  48687. * @param url defines the URL to load from
  48688. * @param sceneLoaded defines a callback to call on success
  48689. * @param progressCallBack defines a callback to call when progress changed
  48690. * @param errorCallback defines a callback to call on error
  48691. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48692. */
  48693. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48694. private _loadFileAsync;
  48695. private _saveFileAsync;
  48696. /**
  48697. * Validates if xhr data is correct
  48698. * @param xhr defines the request to validate
  48699. * @param dataType defines the expected data type
  48700. * @returns true if data is correct
  48701. */
  48702. private static _ValidateXHRData;
  48703. }
  48704. }
  48705. declare module BABYLON {
  48706. /** @hidden */
  48707. export var gpuUpdateParticlesPixelShader: {
  48708. name: string;
  48709. shader: string;
  48710. };
  48711. }
  48712. declare module BABYLON {
  48713. /** @hidden */
  48714. export var gpuUpdateParticlesVertexShader: {
  48715. name: string;
  48716. shader: string;
  48717. };
  48718. }
  48719. declare module BABYLON {
  48720. /** @hidden */
  48721. export var clipPlaneFragmentDeclaration2: {
  48722. name: string;
  48723. shader: string;
  48724. };
  48725. }
  48726. declare module BABYLON {
  48727. /** @hidden */
  48728. export var gpuRenderParticlesPixelShader: {
  48729. name: string;
  48730. shader: string;
  48731. };
  48732. }
  48733. declare module BABYLON {
  48734. /** @hidden */
  48735. export var clipPlaneVertexDeclaration2: {
  48736. name: string;
  48737. shader: string;
  48738. };
  48739. }
  48740. declare module BABYLON {
  48741. /** @hidden */
  48742. export var gpuRenderParticlesVertexShader: {
  48743. name: string;
  48744. shader: string;
  48745. };
  48746. }
  48747. declare module BABYLON {
  48748. /**
  48749. * This represents a GPU particle system in Babylon
  48750. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48751. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48752. */
  48753. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48754. /**
  48755. * The layer mask we are rendering the particles through.
  48756. */
  48757. layerMask: number;
  48758. private _capacity;
  48759. private _activeCount;
  48760. private _currentActiveCount;
  48761. private _accumulatedCount;
  48762. private _renderEffect;
  48763. private _updateEffect;
  48764. private _buffer0;
  48765. private _buffer1;
  48766. private _spriteBuffer;
  48767. private _updateVAO;
  48768. private _renderVAO;
  48769. private _targetIndex;
  48770. private _sourceBuffer;
  48771. private _targetBuffer;
  48772. private _engine;
  48773. private _currentRenderId;
  48774. private _started;
  48775. private _stopped;
  48776. private _timeDelta;
  48777. private _randomTexture;
  48778. private _randomTexture2;
  48779. private _attributesStrideSize;
  48780. private _updateEffectOptions;
  48781. private _randomTextureSize;
  48782. private _actualFrame;
  48783. private readonly _rawTextureWidth;
  48784. /**
  48785. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48786. */
  48787. static readonly IsSupported: boolean;
  48788. /**
  48789. * An event triggered when the system is disposed.
  48790. */
  48791. onDisposeObservable: Observable<GPUParticleSystem>;
  48792. /**
  48793. * Gets the maximum number of particles active at the same time.
  48794. * @returns The max number of active particles.
  48795. */
  48796. getCapacity(): number;
  48797. /**
  48798. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48799. * to override the particles.
  48800. */
  48801. forceDepthWrite: boolean;
  48802. /**
  48803. * Gets or set the number of active particles
  48804. */
  48805. activeParticleCount: number;
  48806. private _preWarmDone;
  48807. /**
  48808. * Is this system ready to be used/rendered
  48809. * @return true if the system is ready
  48810. */
  48811. isReady(): boolean;
  48812. /**
  48813. * Gets if the system has been started. (Note: this will still be true after stop is called)
  48814. * @returns True if it has been started, otherwise false.
  48815. */
  48816. isStarted(): boolean;
  48817. /**
  48818. * Starts the particle system and begins to emit
  48819. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  48820. */
  48821. start(delay?: number): void;
  48822. /**
  48823. * Stops the particle system.
  48824. */
  48825. stop(): void;
  48826. /**
  48827. * Remove all active particles
  48828. */
  48829. reset(): void;
  48830. /**
  48831. * Returns the string "GPUParticleSystem"
  48832. * @returns a string containing the class name
  48833. */
  48834. getClassName(): string;
  48835. private _colorGradientsTexture;
  48836. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  48837. /**
  48838. * Adds a new color gradient
  48839. * @param gradient defines the gradient to use (between 0 and 1)
  48840. * @param color1 defines the color to affect to the specified gradient
  48841. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  48842. * @returns the current particle system
  48843. */
  48844. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  48845. /**
  48846. * Remove a specific color gradient
  48847. * @param gradient defines the gradient to remove
  48848. * @returns the current particle system
  48849. */
  48850. removeColorGradient(gradient: number): GPUParticleSystem;
  48851. private _angularSpeedGradientsTexture;
  48852. private _sizeGradientsTexture;
  48853. private _velocityGradientsTexture;
  48854. private _limitVelocityGradientsTexture;
  48855. private _dragGradientsTexture;
  48856. private _addFactorGradient;
  48857. /**
  48858. * Adds a new size gradient
  48859. * @param gradient defines the gradient to use (between 0 and 1)
  48860. * @param factor defines the size factor to affect to the specified gradient
  48861. * @returns the current particle system
  48862. */
  48863. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  48864. /**
  48865. * Remove a specific size gradient
  48866. * @param gradient defines the gradient to remove
  48867. * @returns the current particle system
  48868. */
  48869. removeSizeGradient(gradient: number): GPUParticleSystem;
  48870. /**
  48871. * Adds a new angular speed gradient
  48872. * @param gradient defines the gradient to use (between 0 and 1)
  48873. * @param factor defines the angular speed to affect to the specified gradient
  48874. * @returns the current particle system
  48875. */
  48876. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  48877. /**
  48878. * Remove a specific angular speed gradient
  48879. * @param gradient defines the gradient to remove
  48880. * @returns the current particle system
  48881. */
  48882. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  48883. /**
  48884. * Adds a new velocity gradient
  48885. * @param gradient defines the gradient to use (between 0 and 1)
  48886. * @param factor defines the velocity to affect to the specified gradient
  48887. * @returns the current particle system
  48888. */
  48889. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48890. /**
  48891. * Remove a specific velocity gradient
  48892. * @param gradient defines the gradient to remove
  48893. * @returns the current particle system
  48894. */
  48895. removeVelocityGradient(gradient: number): GPUParticleSystem;
  48896. /**
  48897. * Adds a new limit velocity gradient
  48898. * @param gradient defines the gradient to use (between 0 and 1)
  48899. * @param factor defines the limit velocity value to affect to the specified gradient
  48900. * @returns the current particle system
  48901. */
  48902. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48903. /**
  48904. * Remove a specific limit velocity gradient
  48905. * @param gradient defines the gradient to remove
  48906. * @returns the current particle system
  48907. */
  48908. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  48909. /**
  48910. * Adds a new drag gradient
  48911. * @param gradient defines the gradient to use (between 0 and 1)
  48912. * @param factor defines the drag value to affect to the specified gradient
  48913. * @returns the current particle system
  48914. */
  48915. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  48916. /**
  48917. * Remove a specific drag gradient
  48918. * @param gradient defines the gradient to remove
  48919. * @returns the current particle system
  48920. */
  48921. removeDragGradient(gradient: number): GPUParticleSystem;
  48922. /**
  48923. * Not supported by GPUParticleSystem
  48924. * @param gradient defines the gradient to use (between 0 and 1)
  48925. * @param factor defines the emit rate value to affect to the specified gradient
  48926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48927. * @returns the current particle system
  48928. */
  48929. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48930. /**
  48931. * Not supported by GPUParticleSystem
  48932. * @param gradient defines the gradient to remove
  48933. * @returns the current particle system
  48934. */
  48935. removeEmitRateGradient(gradient: number): IParticleSystem;
  48936. /**
  48937. * Not supported by GPUParticleSystem
  48938. * @param gradient defines the gradient to use (between 0 and 1)
  48939. * @param factor defines the start size value to affect to the specified gradient
  48940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48941. * @returns the current particle system
  48942. */
  48943. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48944. /**
  48945. * Not supported by GPUParticleSystem
  48946. * @param gradient defines the gradient to remove
  48947. * @returns the current particle system
  48948. */
  48949. removeStartSizeGradient(gradient: number): IParticleSystem;
  48950. /**
  48951. * Not supported by GPUParticleSystem
  48952. * @param gradient defines the gradient to use (between 0 and 1)
  48953. * @param min defines the color remap minimal range
  48954. * @param max defines the color remap maximal range
  48955. * @returns the current particle system
  48956. */
  48957. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48958. /**
  48959. * Not supported by GPUParticleSystem
  48960. * @param gradient defines the gradient to remove
  48961. * @returns the current particle system
  48962. */
  48963. removeColorRemapGradient(): IParticleSystem;
  48964. /**
  48965. * Not supported by GPUParticleSystem
  48966. * @param gradient defines the gradient to use (between 0 and 1)
  48967. * @param min defines the alpha remap minimal range
  48968. * @param max defines the alpha remap maximal range
  48969. * @returns the current particle system
  48970. */
  48971. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48972. /**
  48973. * Not supported by GPUParticleSystem
  48974. * @param gradient defines the gradient to remove
  48975. * @returns the current particle system
  48976. */
  48977. removeAlphaRemapGradient(): IParticleSystem;
  48978. /**
  48979. * Not supported by GPUParticleSystem
  48980. * @param gradient defines the gradient to use (between 0 and 1)
  48981. * @param color defines the color to affect to the specified gradient
  48982. * @returns the current particle system
  48983. */
  48984. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  48985. /**
  48986. * Not supported by GPUParticleSystem
  48987. * @param gradient defines the gradient to remove
  48988. * @returns the current particle system
  48989. */
  48990. removeRampGradient(): IParticleSystem;
  48991. /**
  48992. * Not supported by GPUParticleSystem
  48993. * @returns the list of ramp gradients
  48994. */
  48995. getRampGradients(): Nullable<Array<Color3Gradient>>;
  48996. /**
  48997. * Not supported by GPUParticleSystem
  48998. * Gets or sets a boolean indicating that ramp gradients must be used
  48999. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  49000. */
  49001. useRampGradients: boolean;
  49002. /**
  49003. * Not supported by GPUParticleSystem
  49004. * @param gradient defines the gradient to use (between 0 and 1)
  49005. * @param factor defines the life time factor to affect to the specified gradient
  49006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49007. * @returns the current particle system
  49008. */
  49009. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49010. /**
  49011. * Not supported by GPUParticleSystem
  49012. * @param gradient defines the gradient to remove
  49013. * @returns the current particle system
  49014. */
  49015. removeLifeTimeGradient(gradient: number): IParticleSystem;
  49016. /**
  49017. * Instantiates a GPU particle system.
  49018. * 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.
  49019. * @param name The name of the particle system
  49020. * @param options The options used to create the system
  49021. * @param scene The scene the particle system belongs to
  49022. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  49023. */
  49024. constructor(name: string, options: Partial<{
  49025. capacity: number;
  49026. randomTextureSize: number;
  49027. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  49028. protected _reset(): void;
  49029. private _createUpdateVAO;
  49030. private _createRenderVAO;
  49031. private _initialize;
  49032. /** @hidden */
  49033. _recreateUpdateEffect(): void;
  49034. /** @hidden */
  49035. _recreateRenderEffect(): void;
  49036. /**
  49037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  49038. * @param preWarm defines if we are in the pre-warmimg phase
  49039. */
  49040. animate(preWarm?: boolean): void;
  49041. private _createFactorGradientTexture;
  49042. private _createSizeGradientTexture;
  49043. private _createAngularSpeedGradientTexture;
  49044. private _createVelocityGradientTexture;
  49045. private _createLimitVelocityGradientTexture;
  49046. private _createDragGradientTexture;
  49047. private _createColorGradientTexture;
  49048. /**
  49049. * Renders the particle system in its current state
  49050. * @param preWarm defines if the system should only update the particles but not render them
  49051. * @returns the current number of particles
  49052. */
  49053. render(preWarm?: boolean): number;
  49054. /**
  49055. * Rebuilds the particle system
  49056. */
  49057. rebuild(): void;
  49058. private _releaseBuffers;
  49059. private _releaseVAOs;
  49060. /**
  49061. * Disposes the particle system and free the associated resources
  49062. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  49063. */
  49064. dispose(disposeTexture?: boolean): void;
  49065. /**
  49066. * Clones the particle system.
  49067. * @param name The name of the cloned object
  49068. * @param newEmitter The new emitter to use
  49069. * @returns the cloned particle system
  49070. */
  49071. clone(name: string, newEmitter: any): GPUParticleSystem;
  49072. /**
  49073. * Serializes the particle system to a JSON object.
  49074. * @returns the JSON object
  49075. */
  49076. serialize(): any;
  49077. /**
  49078. * Parses a JSON object to create a GPU particle system.
  49079. * @param parsedParticleSystem The JSON object to parse
  49080. * @param scene The scene to create the particle system in
  49081. * @param rootUrl The root url to use to load external dependencies like texture
  49082. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  49083. * @returns the parsed GPU particle system
  49084. */
  49085. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  49086. }
  49087. }
  49088. declare module BABYLON {
  49089. /**
  49090. * Represents a set of particle systems working together to create a specific effect
  49091. */
  49092. export class ParticleSystemSet implements IDisposable {
  49093. private _emitterCreationOptions;
  49094. private _emitterNode;
  49095. /**
  49096. * Gets the particle system list
  49097. */
  49098. systems: IParticleSystem[];
  49099. /**
  49100. * Gets the emitter node used with this set
  49101. */
  49102. readonly emitterNode: Nullable<TransformNode>;
  49103. /**
  49104. * Creates a new emitter mesh as a sphere
  49105. * @param options defines the options used to create the sphere
  49106. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  49107. * @param scene defines the hosting scene
  49108. */
  49109. setEmitterAsSphere(options: {
  49110. diameter: number;
  49111. segments: number;
  49112. color: Color3;
  49113. }, renderingGroupId: number, scene: Scene): void;
  49114. /**
  49115. * Starts all particle systems of the set
  49116. * @param emitter defines an optional mesh to use as emitter for the particle systems
  49117. */
  49118. start(emitter?: AbstractMesh): void;
  49119. /**
  49120. * Release all associated resources
  49121. */
  49122. dispose(): void;
  49123. /**
  49124. * Serialize the set into a JSON compatible object
  49125. * @returns a JSON compatible representation of the set
  49126. */
  49127. serialize(): any;
  49128. /**
  49129. * Parse a new ParticleSystemSet from a serialized source
  49130. * @param data defines a JSON compatible representation of the set
  49131. * @param scene defines the hosting scene
  49132. * @param gpu defines if we want GPU particles or CPU particles
  49133. * @returns a new ParticleSystemSet
  49134. */
  49135. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  49136. }
  49137. }
  49138. declare module BABYLON {
  49139. /**
  49140. * This class is made for on one-liner static method to help creating particle system set.
  49141. */
  49142. export class ParticleHelper {
  49143. /**
  49144. * Gets or sets base Assets URL
  49145. */
  49146. static BaseAssetsUrl: string;
  49147. /**
  49148. * Create a default particle system that you can tweak
  49149. * @param emitter defines the emitter to use
  49150. * @param capacity defines the system capacity (default is 500 particles)
  49151. * @param scene defines the hosting scene
  49152. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  49153. * @returns the new Particle system
  49154. */
  49155. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  49156. /**
  49157. * This is the main static method (one-liner) of this helper to create different particle systems
  49158. * @param type This string represents the type to the particle system to create
  49159. * @param scene The scene where the particle system should live
  49160. * @param gpu If the system will use gpu
  49161. * @returns the ParticleSystemSet created
  49162. */
  49163. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  49164. /**
  49165. * Static function used to export a particle system to a ParticleSystemSet variable.
  49166. * Please note that the emitter shape is not exported
  49167. * @param systems defines the particle systems to export
  49168. * @returns the created particle system set
  49169. */
  49170. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  49171. }
  49172. }
  49173. declare module BABYLON {
  49174. interface Engine {
  49175. /**
  49176. * Create an effect to use with particle systems.
  49177. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  49178. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  49179. * @param uniformsNames defines a list of attribute names
  49180. * @param samplers defines an array of string used to represent textures
  49181. * @param defines defines the string containing the defines to use to compile the shaders
  49182. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  49183. * @param onCompiled defines a function to call when the effect creation is successful
  49184. * @param onError defines a function to call when the effect creation has failed
  49185. * @returns the new Effect
  49186. */
  49187. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  49188. }
  49189. interface Mesh {
  49190. /**
  49191. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  49192. * @returns an array of IParticleSystem
  49193. */
  49194. getEmittedParticleSystems(): IParticleSystem[];
  49195. /**
  49196. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  49197. * @returns an array of IParticleSystem
  49198. */
  49199. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  49200. }
  49201. /**
  49202. * @hidden
  49203. */
  49204. export var _IDoNeedToBeInTheBuild: number;
  49205. }
  49206. declare module BABYLON {
  49207. interface Scene {
  49208. /** @hidden (Backing field) */
  49209. _physicsEngine: Nullable<IPhysicsEngine>;
  49210. /**
  49211. * Gets the current physics engine
  49212. * @returns a IPhysicsEngine or null if none attached
  49213. */
  49214. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  49215. /**
  49216. * Enables physics to the current scene
  49217. * @param gravity defines the scene's gravity for the physics engine
  49218. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  49219. * @return a boolean indicating if the physics engine was initialized
  49220. */
  49221. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  49222. /**
  49223. * Disables and disposes the physics engine associated with the scene
  49224. */
  49225. disablePhysicsEngine(): void;
  49226. /**
  49227. * Gets a boolean indicating if there is an active physics engine
  49228. * @returns a boolean indicating if there is an active physics engine
  49229. */
  49230. isPhysicsEnabled(): boolean;
  49231. /**
  49232. * Deletes a physics compound impostor
  49233. * @param compound defines the compound to delete
  49234. */
  49235. deleteCompoundImpostor(compound: any): void;
  49236. /**
  49237. * An event triggered when physic simulation is about to be run
  49238. */
  49239. onBeforePhysicsObservable: Observable<Scene>;
  49240. /**
  49241. * An event triggered when physic simulation has been done
  49242. */
  49243. onAfterPhysicsObservable: Observable<Scene>;
  49244. }
  49245. interface AbstractMesh {
  49246. /** @hidden */
  49247. _physicsImpostor: Nullable<PhysicsImpostor>;
  49248. /**
  49249. * Gets or sets impostor used for physic simulation
  49250. * @see http://doc.babylonjs.com/features/physics_engine
  49251. */
  49252. physicsImpostor: Nullable<PhysicsImpostor>;
  49253. /**
  49254. * Gets the current physics impostor
  49255. * @see http://doc.babylonjs.com/features/physics_engine
  49256. * @returns a physics impostor or null
  49257. */
  49258. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  49259. /** Apply a physic impulse to the mesh
  49260. * @param force defines the force to apply
  49261. * @param contactPoint defines where to apply the force
  49262. * @returns the current mesh
  49263. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49264. */
  49265. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  49266. /**
  49267. * Creates a physic joint between two meshes
  49268. * @param otherMesh defines the other mesh to use
  49269. * @param pivot1 defines the pivot to use on this mesh
  49270. * @param pivot2 defines the pivot to use on the other mesh
  49271. * @param options defines additional options (can be plugin dependent)
  49272. * @returns the current mesh
  49273. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  49274. */
  49275. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  49276. /** @hidden */
  49277. _disposePhysicsObserver: Nullable<Observer<Node>>;
  49278. }
  49279. /**
  49280. * Defines the physics engine scene component responsible to manage a physics engine
  49281. */
  49282. export class PhysicsEngineSceneComponent implements ISceneComponent {
  49283. /**
  49284. * The component name helpful to identify the component in the list of scene components.
  49285. */
  49286. readonly name: string;
  49287. /**
  49288. * The scene the component belongs to.
  49289. */
  49290. scene: Scene;
  49291. /**
  49292. * Creates a new instance of the component for the given scene
  49293. * @param scene Defines the scene to register the component in
  49294. */
  49295. constructor(scene: Scene);
  49296. /**
  49297. * Registers the component in a given scene
  49298. */
  49299. register(): void;
  49300. /**
  49301. * Rebuilds the elements related to this component in case of
  49302. * context lost for instance.
  49303. */
  49304. rebuild(): void;
  49305. /**
  49306. * Disposes the component and the associated ressources
  49307. */
  49308. dispose(): void;
  49309. }
  49310. }
  49311. declare module BABYLON {
  49312. /**
  49313. * A helper for physics simulations
  49314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49315. */
  49316. export class PhysicsHelper {
  49317. private _scene;
  49318. private _physicsEngine;
  49319. /**
  49320. * Initializes the Physics helper
  49321. * @param scene Babylon.js scene
  49322. */
  49323. constructor(scene: Scene);
  49324. /**
  49325. * Applies a radial explosion impulse
  49326. * @param origin the origin of the explosion
  49327. * @param radius the explosion radius
  49328. * @param strength the explosion strength
  49329. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49330. * @returns A physics radial explosion event, or null
  49331. */
  49332. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49333. /**
  49334. * Applies a radial explosion force
  49335. * @param origin the origin of the explosion
  49336. * @param radius the explosion radius
  49337. * @param strength the explosion strength
  49338. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49339. * @returns A physics radial explosion event, or null
  49340. */
  49341. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  49342. /**
  49343. * Creates a gravitational field
  49344. * @param origin the origin of the explosion
  49345. * @param radius the explosion radius
  49346. * @param strength the explosion strength
  49347. * @param falloff possible options: Constant & Linear. Defaults to Constant
  49348. * @returns A physics gravitational field event, or null
  49349. */
  49350. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  49351. /**
  49352. * Creates a physics updraft event
  49353. * @param origin the origin of the updraft
  49354. * @param radius the radius of the updraft
  49355. * @param strength the strength of the updraft
  49356. * @param height the height of the updraft
  49357. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  49358. * @returns A physics updraft event, or null
  49359. */
  49360. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  49361. /**
  49362. * Creates a physics vortex event
  49363. * @param origin the of the vortex
  49364. * @param radius the radius of the vortex
  49365. * @param strength the strength of the vortex
  49366. * @param height the height of the vortex
  49367. * @returns a Physics vortex event, or null
  49368. * A physics vortex event or null
  49369. */
  49370. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  49371. }
  49372. /**
  49373. * Represents a physics radial explosion event
  49374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49375. */
  49376. export class PhysicsRadialExplosionEvent {
  49377. private _scene;
  49378. private _sphere;
  49379. private _sphereOptions;
  49380. private _rays;
  49381. private _dataFetched;
  49382. /**
  49383. * Initializes a radial explosioin event
  49384. * @param scene BabylonJS scene
  49385. */
  49386. constructor(scene: Scene);
  49387. /**
  49388. * Returns the data related to the radial explosion event (sphere & rays).
  49389. * @returns The radial explosion event data
  49390. */
  49391. getData(): PhysicsRadialExplosionEventData;
  49392. /**
  49393. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  49394. * @param impostor A physics imposter
  49395. * @param origin the origin of the explosion
  49396. * @param radius the explosion radius
  49397. * @param strength the explosion strength
  49398. * @param falloff possible options: Constant & Linear
  49399. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  49400. */
  49401. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  49402. /**
  49403. * Disposes the sphere.
  49404. * @param force Specifies if the sphere should be disposed by force
  49405. */
  49406. dispose(force?: boolean): void;
  49407. /*** Helpers ***/
  49408. private _prepareSphere;
  49409. private _intersectsWithSphere;
  49410. }
  49411. /**
  49412. * Represents a gravitational field event
  49413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49414. */
  49415. export class PhysicsGravitationalFieldEvent {
  49416. private _physicsHelper;
  49417. private _scene;
  49418. private _origin;
  49419. private _radius;
  49420. private _strength;
  49421. private _falloff;
  49422. private _tickCallback;
  49423. private _sphere;
  49424. private _dataFetched;
  49425. /**
  49426. * Initializes the physics gravitational field event
  49427. * @param physicsHelper A physics helper
  49428. * @param scene BabylonJS scene
  49429. * @param origin The origin position of the gravitational field event
  49430. * @param radius The radius of the gravitational field event
  49431. * @param strength The strength of the gravitational field event
  49432. * @param falloff The falloff for the gravitational field event
  49433. */
  49434. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  49435. /**
  49436. * Returns the data related to the gravitational field event (sphere).
  49437. * @returns A gravitational field event
  49438. */
  49439. getData(): PhysicsGravitationalFieldEventData;
  49440. /**
  49441. * Enables the gravitational field.
  49442. */
  49443. enable(): void;
  49444. /**
  49445. * Disables the gravitational field.
  49446. */
  49447. disable(): void;
  49448. /**
  49449. * Disposes the sphere.
  49450. * @param force The force to dispose from the gravitational field event
  49451. */
  49452. dispose(force?: boolean): void;
  49453. private _tick;
  49454. }
  49455. /**
  49456. * Represents a physics updraft event
  49457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49458. */
  49459. export class PhysicsUpdraftEvent {
  49460. private _scene;
  49461. private _origin;
  49462. private _radius;
  49463. private _strength;
  49464. private _height;
  49465. private _updraftMode;
  49466. private _physicsEngine;
  49467. private _originTop;
  49468. private _originDirection;
  49469. private _tickCallback;
  49470. private _cylinder;
  49471. private _cylinderPosition;
  49472. private _dataFetched;
  49473. /**
  49474. * Initializes the physics updraft event
  49475. * @param _scene BabylonJS scene
  49476. * @param _origin The origin position of the updraft
  49477. * @param _radius The radius of the updraft
  49478. * @param _strength The strength of the updraft
  49479. * @param _height The height of the updraft
  49480. * @param _updraftMode The mode of the updraft
  49481. */
  49482. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  49483. /**
  49484. * Returns the data related to the updraft event (cylinder).
  49485. * @returns A physics updraft event
  49486. */
  49487. getData(): PhysicsUpdraftEventData;
  49488. /**
  49489. * Enables the updraft.
  49490. */
  49491. enable(): void;
  49492. /**
  49493. * Disables the cortex.
  49494. */
  49495. disable(): void;
  49496. /**
  49497. * Disposes the sphere.
  49498. * @param force Specifies if the updraft should be disposed by force
  49499. */
  49500. dispose(force?: boolean): void;
  49501. private getImpostorForceAndContactPoint;
  49502. private _tick;
  49503. /*** Helpers ***/
  49504. private _prepareCylinder;
  49505. private _intersectsWithCylinder;
  49506. }
  49507. /**
  49508. * Represents a physics vortex event
  49509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49510. */
  49511. export class PhysicsVortexEvent {
  49512. private _scene;
  49513. private _origin;
  49514. private _radius;
  49515. private _strength;
  49516. private _height;
  49517. private _physicsEngine;
  49518. private _originTop;
  49519. private _centripetalForceThreshold;
  49520. private _updraftMultiplier;
  49521. private _tickCallback;
  49522. private _cylinder;
  49523. private _cylinderPosition;
  49524. private _dataFetched;
  49525. /**
  49526. * Initializes the physics vortex event
  49527. * @param _scene The BabylonJS scene
  49528. * @param _origin The origin position of the vortex
  49529. * @param _radius The radius of the vortex
  49530. * @param _strength The strength of the vortex
  49531. * @param _height The height of the vortex
  49532. */
  49533. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  49534. /**
  49535. * Returns the data related to the vortex event (cylinder).
  49536. * @returns The physics vortex event data
  49537. */
  49538. getData(): PhysicsVortexEventData;
  49539. /**
  49540. * Enables the vortex.
  49541. */
  49542. enable(): void;
  49543. /**
  49544. * Disables the cortex.
  49545. */
  49546. disable(): void;
  49547. /**
  49548. * Disposes the sphere.
  49549. * @param force
  49550. */
  49551. dispose(force?: boolean): void;
  49552. private getImpostorForceAndContactPoint;
  49553. private _tick;
  49554. /*** Helpers ***/
  49555. private _prepareCylinder;
  49556. private _intersectsWithCylinder;
  49557. }
  49558. /**
  49559. * The strenght of the force in correspondence to the distance of the affected object
  49560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49561. */
  49562. export enum PhysicsRadialImpulseFalloff {
  49563. /** Defines that impulse is constant in strength across it's whole radius */
  49564. Constant = 0,
  49565. /** DEfines that impulse gets weaker if it's further from the origin */
  49566. Linear = 1
  49567. }
  49568. /**
  49569. * The strength of the force in correspondence to the distance of the affected object
  49570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49571. */
  49572. export enum PhysicsUpdraftMode {
  49573. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  49574. Center = 0,
  49575. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  49576. Perpendicular = 1
  49577. }
  49578. /**
  49579. * Interface for a physics force and contact point
  49580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49581. */
  49582. export interface PhysicsForceAndContactPoint {
  49583. /**
  49584. * The force applied at the contact point
  49585. */
  49586. force: Vector3;
  49587. /**
  49588. * The contact point
  49589. */
  49590. contactPoint: Vector3;
  49591. }
  49592. /**
  49593. * Interface for radial explosion event data
  49594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49595. */
  49596. export interface PhysicsRadialExplosionEventData {
  49597. /**
  49598. * A sphere used for the radial explosion event
  49599. */
  49600. sphere: Mesh;
  49601. /**
  49602. * An array of rays for the radial explosion event
  49603. */
  49604. rays: Array<Ray>;
  49605. }
  49606. /**
  49607. * Interface for gravitational field event data
  49608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49609. */
  49610. export interface PhysicsGravitationalFieldEventData {
  49611. /**
  49612. * A sphere mesh used for the gravitational field event
  49613. */
  49614. sphere: Mesh;
  49615. }
  49616. /**
  49617. * Interface for updraft event data
  49618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49619. */
  49620. export interface PhysicsUpdraftEventData {
  49621. /**
  49622. * A cylinder used for the updraft event
  49623. */
  49624. cylinder: Mesh;
  49625. }
  49626. /**
  49627. * Interface for vortex event data
  49628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49629. */
  49630. export interface PhysicsVortexEventData {
  49631. /**
  49632. * A cylinder used for the vortex event
  49633. */
  49634. cylinder: Mesh;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * AmmoJS Physics plugin
  49640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49641. * @see https://github.com/kripken/ammo.js/
  49642. */
  49643. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49644. private _useDeltaForWorldStep;
  49645. /**
  49646. * Reference to the Ammo library
  49647. */
  49648. bjsAMMO: any;
  49649. /**
  49650. * Created ammoJS world which physics bodies are added to
  49651. */
  49652. world: any;
  49653. /**
  49654. * Name of the plugin
  49655. */
  49656. name: string;
  49657. private _timeStep;
  49658. private _fixedTimeStep;
  49659. private _maxSteps;
  49660. private _tmpQuaternion;
  49661. private _tmpAmmoTransform;
  49662. private _tmpAmmoQuaternion;
  49663. private _tmpAmmoConcreteContactResultCallback;
  49664. private _collisionConfiguration;
  49665. private _dispatcher;
  49666. private _overlappingPairCache;
  49667. private _solver;
  49668. private _tmpAmmoVectorA;
  49669. private _tmpAmmoVectorB;
  49670. private _tmpAmmoVectorC;
  49671. private _tmpContactCallbackResult;
  49672. private static readonly DISABLE_COLLISION_FLAG;
  49673. private static readonly KINEMATIC_FLAG;
  49674. private static readonly DISABLE_DEACTIVATION_FLAG;
  49675. /**
  49676. * Initializes the ammoJS plugin
  49677. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49678. * @param ammoInjection can be used to inject your own ammo reference
  49679. */
  49680. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49681. /**
  49682. * Sets the gravity of the physics world (m/(s^2))
  49683. * @param gravity Gravity to set
  49684. */
  49685. setGravity(gravity: Vector3): void;
  49686. /**
  49687. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49688. * @param timeStep timestep to use in seconds
  49689. */
  49690. setTimeStep(timeStep: number): void;
  49691. /**
  49692. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  49693. * @param fixedTimeStep fixedTimeStep to use in seconds
  49694. */
  49695. setFixedTimeStep(fixedTimeStep: number): void;
  49696. /**
  49697. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49698. * @param maxSteps the maximum number of steps by the physics engine per frame
  49699. */
  49700. setMaxSteps(maxSteps: number): void;
  49701. /**
  49702. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49703. * @returns the current timestep in seconds
  49704. */
  49705. getTimeStep(): number;
  49706. private _isImpostorInContact;
  49707. private _isImpostorPairInContact;
  49708. private _stepSimulation;
  49709. /**
  49710. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49711. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49712. * After the step the babylon meshes are set to the position of the physics imposters
  49713. * @param delta amount of time to step forward
  49714. * @param impostors array of imposters to update before/after the step
  49715. */
  49716. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49717. private _tmpVector;
  49718. private _tmpMatrix;
  49719. /**
  49720. * Applies an implulse on the imposter
  49721. * @param impostor imposter to apply impulse
  49722. * @param force amount of force to be applied to the imposter
  49723. * @param contactPoint the location to apply the impulse on the imposter
  49724. */
  49725. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49726. /**
  49727. * Applies a force on the imposter
  49728. * @param impostor imposter to apply force
  49729. * @param force amount of force to be applied to the imposter
  49730. * @param contactPoint the location to apply the force on the imposter
  49731. */
  49732. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49733. /**
  49734. * Creates a physics body using the plugin
  49735. * @param impostor the imposter to create the physics body on
  49736. */
  49737. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49738. /**
  49739. * Removes the physics body from the imposter and disposes of the body's memory
  49740. * @param impostor imposter to remove the physics body from
  49741. */
  49742. removePhysicsBody(impostor: PhysicsImpostor): void;
  49743. /**
  49744. * Generates a joint
  49745. * @param impostorJoint the imposter joint to create the joint with
  49746. */
  49747. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49748. /**
  49749. * Removes a joint
  49750. * @param impostorJoint the imposter joint to remove the joint from
  49751. */
  49752. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49753. private _addMeshVerts;
  49754. private _createShape;
  49755. /**
  49756. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49757. * @param impostor imposter containing the physics body and babylon object
  49758. */
  49759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49760. /**
  49761. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49762. * @param impostor imposter containing the physics body and babylon object
  49763. * @param newPosition new position
  49764. * @param newRotation new rotation
  49765. */
  49766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49767. /**
  49768. * If this plugin is supported
  49769. * @returns true if its supported
  49770. */
  49771. isSupported(): boolean;
  49772. /**
  49773. * Sets the linear velocity of the physics body
  49774. * @param impostor imposter to set the velocity on
  49775. * @param velocity velocity to set
  49776. */
  49777. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49778. /**
  49779. * Sets the angular velocity of the physics body
  49780. * @param impostor imposter to set the velocity on
  49781. * @param velocity velocity to set
  49782. */
  49783. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49784. /**
  49785. * gets the linear velocity
  49786. * @param impostor imposter to get linear velocity from
  49787. * @returns linear velocity
  49788. */
  49789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49790. /**
  49791. * gets the angular velocity
  49792. * @param impostor imposter to get angular velocity from
  49793. * @returns angular velocity
  49794. */
  49795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49796. /**
  49797. * Sets the mass of physics body
  49798. * @param impostor imposter to set the mass on
  49799. * @param mass mass to set
  49800. */
  49801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49802. /**
  49803. * Gets the mass of the physics body
  49804. * @param impostor imposter to get the mass from
  49805. * @returns mass
  49806. */
  49807. getBodyMass(impostor: PhysicsImpostor): number;
  49808. /**
  49809. * Gets friction of the impostor
  49810. * @param impostor impostor to get friction from
  49811. * @returns friction value
  49812. */
  49813. getBodyFriction(impostor: PhysicsImpostor): number;
  49814. /**
  49815. * Sets friction of the impostor
  49816. * @param impostor impostor to set friction on
  49817. * @param friction friction value
  49818. */
  49819. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49820. /**
  49821. * Gets restitution of the impostor
  49822. * @param impostor impostor to get restitution from
  49823. * @returns restitution value
  49824. */
  49825. getBodyRestitution(impostor: PhysicsImpostor): number;
  49826. /**
  49827. * Sets resitution of the impostor
  49828. * @param impostor impostor to set resitution on
  49829. * @param restitution resitution value
  49830. */
  49831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49832. /**
  49833. * Sleeps the physics body and stops it from being active
  49834. * @param impostor impostor to sleep
  49835. */
  49836. sleepBody(impostor: PhysicsImpostor): void;
  49837. /**
  49838. * Activates the physics body
  49839. * @param impostor impostor to activate
  49840. */
  49841. wakeUpBody(impostor: PhysicsImpostor): void;
  49842. /**
  49843. * Updates the distance parameters of the joint
  49844. * @param joint joint to update
  49845. * @param maxDistance maximum distance of the joint
  49846. * @param minDistance minimum distance of the joint
  49847. */
  49848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49849. /**
  49850. * Sets a motor on the joint
  49851. * @param joint joint to set motor on
  49852. * @param speed speed of the motor
  49853. * @param maxForce maximum force of the motor
  49854. * @param motorIndex index of the motor
  49855. */
  49856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49857. /**
  49858. * Sets the motors limit
  49859. * @param joint joint to set limit on
  49860. * @param upperLimit upper limit
  49861. * @param lowerLimit lower limit
  49862. */
  49863. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49864. /**
  49865. * Syncs the position and rotation of a mesh with the impostor
  49866. * @param mesh mesh to sync
  49867. * @param impostor impostor to update the mesh with
  49868. */
  49869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49870. /**
  49871. * Gets the radius of the impostor
  49872. * @param impostor impostor to get radius from
  49873. * @returns the radius
  49874. */
  49875. getRadius(impostor: PhysicsImpostor): number;
  49876. /**
  49877. * Gets the box size of the impostor
  49878. * @param impostor impostor to get box size from
  49879. * @param result the resulting box size
  49880. */
  49881. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49882. /**
  49883. * Disposes of the impostor
  49884. */
  49885. dispose(): void;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /** @hidden */
  49890. export var blackAndWhitePixelShader: {
  49891. name: string;
  49892. shader: string;
  49893. };
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * Post process used to render in black and white
  49898. */
  49899. export class BlackAndWhitePostProcess extends PostProcess {
  49900. /**
  49901. * Linear about to convert he result to black and white (default: 1)
  49902. */
  49903. degree: number;
  49904. /**
  49905. * Creates a black and white post process
  49906. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49907. * @param name The name of the effect.
  49908. * @param options The required width/height ratio to downsize to before computing the render pass.
  49909. * @param camera The camera to apply the render pass to.
  49910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49911. * @param engine The engine which the post process will be applied. (default: current engine)
  49912. * @param reusable If the post process can be reused on the same frame. (default: false)
  49913. */
  49914. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49915. }
  49916. }
  49917. declare module BABYLON {
  49918. /**
  49919. * This represents a set of one or more post processes in Babylon.
  49920. * A post process can be used to apply a shader to a texture after it is rendered.
  49921. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49922. */
  49923. export class PostProcessRenderEffect {
  49924. private _postProcesses;
  49925. private _getPostProcesses;
  49926. private _singleInstance;
  49927. private _cameras;
  49928. private _indicesForCamera;
  49929. /**
  49930. * Name of the effect
  49931. * @hidden
  49932. */
  49933. _name: string;
  49934. /**
  49935. * Instantiates a post process render effect.
  49936. * A post process can be used to apply a shader to a texture after it is rendered.
  49937. * @param engine The engine the effect is tied to
  49938. * @param name The name of the effect
  49939. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49940. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49941. */
  49942. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49943. /**
  49944. * Checks if all the post processes in the effect are supported.
  49945. */
  49946. readonly isSupported: boolean;
  49947. /**
  49948. * Updates the current state of the effect
  49949. * @hidden
  49950. */
  49951. _update(): void;
  49952. /**
  49953. * Attaches the effect on cameras
  49954. * @param cameras The camera to attach to.
  49955. * @hidden
  49956. */
  49957. _attachCameras(cameras: Camera): void;
  49958. /**
  49959. * Attaches the effect on cameras
  49960. * @param cameras The camera to attach to.
  49961. * @hidden
  49962. */
  49963. _attachCameras(cameras: Camera[]): void;
  49964. /**
  49965. * Detatches the effect on cameras
  49966. * @param cameras The camera to detatch from.
  49967. * @hidden
  49968. */
  49969. _detachCameras(cameras: Camera): void;
  49970. /**
  49971. * Detatches the effect on cameras
  49972. * @param cameras The camera to detatch from.
  49973. * @hidden
  49974. */
  49975. _detachCameras(cameras: Camera[]): void;
  49976. /**
  49977. * Enables the effect on given cameras
  49978. * @param cameras The camera to enable.
  49979. * @hidden
  49980. */
  49981. _enable(cameras: Camera): void;
  49982. /**
  49983. * Enables the effect on given cameras
  49984. * @param cameras The camera to enable.
  49985. * @hidden
  49986. */
  49987. _enable(cameras: Nullable<Camera[]>): void;
  49988. /**
  49989. * Disables the effect on the given cameras
  49990. * @param cameras The camera to disable.
  49991. * @hidden
  49992. */
  49993. _disable(cameras: Camera): void;
  49994. /**
  49995. * Disables the effect on the given cameras
  49996. * @param cameras The camera to disable.
  49997. * @hidden
  49998. */
  49999. _disable(cameras: Nullable<Camera[]>): void;
  50000. /**
  50001. * Gets a list of the post processes contained in the effect.
  50002. * @param camera The camera to get the post processes on.
  50003. * @returns The list of the post processes in the effect.
  50004. */
  50005. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  50006. }
  50007. }
  50008. declare module BABYLON {
  50009. /** @hidden */
  50010. export var extractHighlightsPixelShader: {
  50011. name: string;
  50012. shader: string;
  50013. };
  50014. }
  50015. declare module BABYLON {
  50016. /**
  50017. * 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.
  50018. */
  50019. export class ExtractHighlightsPostProcess extends PostProcess {
  50020. /**
  50021. * The luminance threshold, pixels below this value will be set to black.
  50022. */
  50023. threshold: number;
  50024. /** @hidden */
  50025. _exposure: number;
  50026. /**
  50027. * Post process which has the input texture to be used when performing highlight extraction
  50028. * @hidden
  50029. */
  50030. _inputPostProcess: Nullable<PostProcess>;
  50031. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50032. }
  50033. }
  50034. declare module BABYLON {
  50035. /** @hidden */
  50036. export var bloomMergePixelShader: {
  50037. name: string;
  50038. shader: string;
  50039. };
  50040. }
  50041. declare module BABYLON {
  50042. /**
  50043. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50044. */
  50045. export class BloomMergePostProcess extends PostProcess {
  50046. /** Weight of the bloom to be added to the original input. */
  50047. weight: number;
  50048. /**
  50049. * Creates a new instance of @see BloomMergePostProcess
  50050. * @param name The name of the effect.
  50051. * @param originalFromInput Post process which's input will be used for the merge.
  50052. * @param blurred Blurred highlights post process which's output will be used.
  50053. * @param weight Weight of the bloom to be added to the original input.
  50054. * @param options The required width/height ratio to downsize to before computing the render pass.
  50055. * @param camera The camera to apply the render pass to.
  50056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50057. * @param engine The engine which the post process will be applied. (default: current engine)
  50058. * @param reusable If the post process can be reused on the same frame. (default: false)
  50059. * @param textureType Type of textures used when performing the post process. (default: 0)
  50060. * @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)
  50061. */
  50062. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  50063. /** Weight of the bloom to be added to the original input. */
  50064. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50065. }
  50066. }
  50067. declare module BABYLON {
  50068. /**
  50069. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  50070. */
  50071. export class BloomEffect extends PostProcessRenderEffect {
  50072. private bloomScale;
  50073. /**
  50074. * @hidden Internal
  50075. */
  50076. _effects: Array<PostProcess>;
  50077. /**
  50078. * @hidden Internal
  50079. */
  50080. _downscale: ExtractHighlightsPostProcess;
  50081. private _blurX;
  50082. private _blurY;
  50083. private _merge;
  50084. /**
  50085. * The luminance threshold to find bright areas of the image to bloom.
  50086. */
  50087. threshold: number;
  50088. /**
  50089. * The strength of the bloom.
  50090. */
  50091. weight: number;
  50092. /**
  50093. * Specifies the size of the bloom blur kernel, relative to the final output size
  50094. */
  50095. kernel: number;
  50096. /**
  50097. * Creates a new instance of @see BloomEffect
  50098. * @param scene The scene the effect belongs to.
  50099. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  50100. * @param bloomKernel The size of the kernel to be used when applying the blur.
  50101. * @param bloomWeight The the strength of bloom.
  50102. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  50103. * @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)
  50104. */
  50105. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  50106. /**
  50107. * Disposes each of the internal effects for a given camera.
  50108. * @param camera The camera to dispose the effect on.
  50109. */
  50110. disposeEffects(camera: Camera): void;
  50111. /**
  50112. * @hidden Internal
  50113. */
  50114. _updateEffects(): void;
  50115. /**
  50116. * Internal
  50117. * @returns if all the contained post processes are ready.
  50118. * @hidden
  50119. */
  50120. _isReady(): boolean;
  50121. }
  50122. }
  50123. declare module BABYLON {
  50124. /** @hidden */
  50125. export var chromaticAberrationPixelShader: {
  50126. name: string;
  50127. shader: string;
  50128. };
  50129. }
  50130. declare module BABYLON {
  50131. /**
  50132. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  50133. */
  50134. export class ChromaticAberrationPostProcess extends PostProcess {
  50135. /**
  50136. * The amount of seperation of rgb channels (default: 30)
  50137. */
  50138. aberrationAmount: number;
  50139. /**
  50140. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  50141. */
  50142. radialIntensity: number;
  50143. /**
  50144. * 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))
  50145. */
  50146. direction: Vector2;
  50147. /**
  50148. * 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))
  50149. */
  50150. centerPosition: Vector2;
  50151. /**
  50152. * Creates a new instance ChromaticAberrationPostProcess
  50153. * @param name The name of the effect.
  50154. * @param screenWidth The width of the screen to apply the effect on.
  50155. * @param screenHeight The height of the screen to apply the effect on.
  50156. * @param options The required width/height ratio to downsize to before computing the render pass.
  50157. * @param camera The camera to apply the render pass to.
  50158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50159. * @param engine The engine which the post process will be applied. (default: current engine)
  50160. * @param reusable If the post process can be reused on the same frame. (default: false)
  50161. * @param textureType Type of textures used when performing the post process. (default: 0)
  50162. * @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)
  50163. */
  50164. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50165. }
  50166. }
  50167. declare module BABYLON {
  50168. /** @hidden */
  50169. export var circleOfConfusionPixelShader: {
  50170. name: string;
  50171. shader: string;
  50172. };
  50173. }
  50174. declare module BABYLON {
  50175. /**
  50176. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  50177. */
  50178. export class CircleOfConfusionPostProcess extends PostProcess {
  50179. /**
  50180. * 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.
  50181. */
  50182. lensSize: number;
  50183. /**
  50184. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  50185. */
  50186. fStop: number;
  50187. /**
  50188. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  50189. */
  50190. focusDistance: number;
  50191. /**
  50192. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  50193. */
  50194. focalLength: number;
  50195. private _depthTexture;
  50196. /**
  50197. * Creates a new instance CircleOfConfusionPostProcess
  50198. * @param name The name of the effect.
  50199. * @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.
  50200. * @param options The required width/height ratio to downsize to before computing the render pass.
  50201. * @param camera The camera to apply the render pass to.
  50202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50203. * @param engine The engine which the post process will be applied. (default: current engine)
  50204. * @param reusable If the post process can be reused on the same frame. (default: false)
  50205. * @param textureType Type of textures used when performing the post process. (default: 0)
  50206. * @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)
  50207. */
  50208. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50209. /**
  50210. * 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.
  50211. */
  50212. depthTexture: RenderTargetTexture;
  50213. }
  50214. }
  50215. declare module BABYLON {
  50216. /** @hidden */
  50217. export var colorCorrectionPixelShader: {
  50218. name: string;
  50219. shader: string;
  50220. };
  50221. }
  50222. declare module BABYLON {
  50223. /**
  50224. *
  50225. * This post-process allows the modification of rendered colors by using
  50226. * a 'look-up table' (LUT). This effect is also called Color Grading.
  50227. *
  50228. * The object needs to be provided an url to a texture containing the color
  50229. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  50230. * Use an image editing software to tweak the LUT to match your needs.
  50231. *
  50232. * For an example of a color LUT, see here:
  50233. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  50234. * For explanations on color grading, see here:
  50235. * @see http://udn.epicgames.com/Three/ColorGrading.html
  50236. *
  50237. */
  50238. export class ColorCorrectionPostProcess extends PostProcess {
  50239. private _colorTableTexture;
  50240. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50241. }
  50242. }
  50243. declare module BABYLON {
  50244. /** @hidden */
  50245. export var convolutionPixelShader: {
  50246. name: string;
  50247. shader: string;
  50248. };
  50249. }
  50250. declare module BABYLON {
  50251. /**
  50252. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  50253. * input texture to perform effects such as edge detection or sharpening
  50254. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50255. */
  50256. export class ConvolutionPostProcess extends PostProcess {
  50257. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50258. kernel: number[];
  50259. /**
  50260. * Creates a new instance ConvolutionPostProcess
  50261. * @param name The name of the effect.
  50262. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  50263. * @param options The required width/height ratio to downsize to before computing the render pass.
  50264. * @param camera The camera to apply the render pass to.
  50265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50266. * @param engine The engine which the post process will be applied. (default: current engine)
  50267. * @param reusable If the post process can be reused on the same frame. (default: false)
  50268. * @param textureType Type of textures used when performing the post process. (default: 0)
  50269. */
  50270. constructor(name: string,
  50271. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  50272. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50273. /**
  50274. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50275. */
  50276. static EdgeDetect0Kernel: number[];
  50277. /**
  50278. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50279. */
  50280. static EdgeDetect1Kernel: number[];
  50281. /**
  50282. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50283. */
  50284. static EdgeDetect2Kernel: number[];
  50285. /**
  50286. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50287. */
  50288. static SharpenKernel: number[];
  50289. /**
  50290. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50291. */
  50292. static EmbossKernel: number[];
  50293. /**
  50294. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  50295. */
  50296. static GaussianKernel: number[];
  50297. }
  50298. }
  50299. declare module BABYLON {
  50300. /**
  50301. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  50302. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  50303. * based on samples that have a large difference in distance than the center pixel.
  50304. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  50305. */
  50306. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  50307. direction: Vector2;
  50308. /**
  50309. * Creates a new instance CircleOfConfusionPostProcess
  50310. * @param name The name of the effect.
  50311. * @param scene The scene the effect belongs to.
  50312. * @param direction The direction the blur should be applied.
  50313. * @param kernel The size of the kernel used to blur.
  50314. * @param options The required width/height ratio to downsize to before computing the render pass.
  50315. * @param camera The camera to apply the render pass to.
  50316. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  50317. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  50318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50319. * @param engine The engine which the post process will be applied. (default: current engine)
  50320. * @param reusable If the post process can be reused on the same frame. (default: false)
  50321. * @param textureType Type of textures used when performing the post process. (default: 0)
  50322. * @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)
  50323. */
  50324. 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);
  50325. }
  50326. }
  50327. declare module BABYLON {
  50328. /** @hidden */
  50329. export var depthOfFieldMergePixelShader: {
  50330. name: string;
  50331. shader: string;
  50332. };
  50333. }
  50334. declare module BABYLON {
  50335. /**
  50336. * Options to be set when merging outputs from the default pipeline.
  50337. */
  50338. export class DepthOfFieldMergePostProcessOptions {
  50339. /**
  50340. * The original image to merge on top of
  50341. */
  50342. originalFromInput: PostProcess;
  50343. /**
  50344. * Parameters to perform the merge of the depth of field effect
  50345. */
  50346. depthOfField?: {
  50347. circleOfConfusion: PostProcess;
  50348. blurSteps: Array<PostProcess>;
  50349. };
  50350. /**
  50351. * Parameters to perform the merge of bloom effect
  50352. */
  50353. bloom?: {
  50354. blurred: PostProcess;
  50355. weight: number;
  50356. };
  50357. }
  50358. /**
  50359. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50360. */
  50361. export class DepthOfFieldMergePostProcess extends PostProcess {
  50362. private blurSteps;
  50363. /**
  50364. * Creates a new instance of DepthOfFieldMergePostProcess
  50365. * @param name The name of the effect.
  50366. * @param originalFromInput Post process which's input will be used for the merge.
  50367. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  50368. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  50369. * @param options The required width/height ratio to downsize to before computing the render pass.
  50370. * @param camera The camera to apply the render pass to.
  50371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50372. * @param engine The engine which the post process will be applied. (default: current engine)
  50373. * @param reusable If the post process can be reused on the same frame. (default: false)
  50374. * @param textureType Type of textures used when performing the post process. (default: 0)
  50375. * @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)
  50376. */
  50377. 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);
  50378. /**
  50379. * Updates the effect with the current post process compile time values and recompiles the shader.
  50380. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  50381. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  50382. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  50383. * @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
  50384. * @param onCompiled Called when the shader has been compiled.
  50385. * @param onError Called if there is an error when compiling a shader.
  50386. */
  50387. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  50388. }
  50389. }
  50390. declare module BABYLON {
  50391. /**
  50392. * Specifies the level of max blur that should be applied when using the depth of field effect
  50393. */
  50394. export enum DepthOfFieldEffectBlurLevel {
  50395. /**
  50396. * Subtle blur
  50397. */
  50398. Low = 0,
  50399. /**
  50400. * Medium blur
  50401. */
  50402. Medium = 1,
  50403. /**
  50404. * Large blur
  50405. */
  50406. High = 2
  50407. }
  50408. /**
  50409. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  50410. */
  50411. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  50412. private _circleOfConfusion;
  50413. /**
  50414. * @hidden Internal, blurs from high to low
  50415. */
  50416. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  50417. private _depthOfFieldBlurY;
  50418. private _dofMerge;
  50419. /**
  50420. * @hidden Internal post processes in depth of field effect
  50421. */
  50422. _effects: Array<PostProcess>;
  50423. /**
  50424. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  50425. */
  50426. focalLength: number;
  50427. /**
  50428. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  50429. */
  50430. fStop: number;
  50431. /**
  50432. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  50433. */
  50434. focusDistance: number;
  50435. /**
  50436. * 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.
  50437. */
  50438. lensSize: number;
  50439. /**
  50440. * Creates a new instance DepthOfFieldEffect
  50441. * @param scene The scene the effect belongs to.
  50442. * @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.
  50443. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  50444. * @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)
  50445. */
  50446. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  50447. /**
  50448. * 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.
  50449. */
  50450. depthTexture: RenderTargetTexture;
  50451. /**
  50452. * Disposes each of the internal effects for a given camera.
  50453. * @param camera The camera to dispose the effect on.
  50454. */
  50455. disposeEffects(camera: Camera): void;
  50456. /**
  50457. * @hidden Internal
  50458. */
  50459. _updateEffects(): void;
  50460. /**
  50461. * Internal
  50462. * @returns if all the contained post processes are ready.
  50463. * @hidden
  50464. */
  50465. _isReady(): boolean;
  50466. }
  50467. }
  50468. declare module BABYLON {
  50469. /** @hidden */
  50470. export var displayPassPixelShader: {
  50471. name: string;
  50472. shader: string;
  50473. };
  50474. }
  50475. declare module BABYLON {
  50476. /**
  50477. * DisplayPassPostProcess which produces an output the same as it's input
  50478. */
  50479. export class DisplayPassPostProcess extends PostProcess {
  50480. /**
  50481. * Creates the DisplayPassPostProcess
  50482. * @param name The name of the effect.
  50483. * @param options The required width/height ratio to downsize to before computing the render pass.
  50484. * @param camera The camera to apply the render pass to.
  50485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50486. * @param engine The engine which the post process will be applied. (default: current engine)
  50487. * @param reusable If the post process can be reused on the same frame. (default: false)
  50488. */
  50489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50490. }
  50491. }
  50492. declare module BABYLON {
  50493. /** @hidden */
  50494. export var filterPixelShader: {
  50495. name: string;
  50496. shader: string;
  50497. };
  50498. }
  50499. declare module BABYLON {
  50500. /**
  50501. * Applies a kernel filter to the image
  50502. */
  50503. export class FilterPostProcess extends PostProcess {
  50504. /** The matrix to be applied to the image */
  50505. kernelMatrix: Matrix;
  50506. /**
  50507. *
  50508. * @param name The name of the effect.
  50509. * @param kernelMatrix The matrix to be applied to the image
  50510. * @param options The required width/height ratio to downsize to before computing the render pass.
  50511. * @param camera The camera to apply the render pass to.
  50512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50513. * @param engine The engine which the post process will be applied. (default: current engine)
  50514. * @param reusable If the post process can be reused on the same frame. (default: false)
  50515. */
  50516. constructor(name: string,
  50517. /** The matrix to be applied to the image */
  50518. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50519. }
  50520. }
  50521. declare module BABYLON {
  50522. /** @hidden */
  50523. export var fxaaPixelShader: {
  50524. name: string;
  50525. shader: string;
  50526. };
  50527. }
  50528. declare module BABYLON {
  50529. /** @hidden */
  50530. export var fxaaVertexShader: {
  50531. name: string;
  50532. shader: string;
  50533. };
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * Fxaa post process
  50538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  50539. */
  50540. export class FxaaPostProcess extends PostProcess {
  50541. /** @hidden */
  50542. texelWidth: number;
  50543. /** @hidden */
  50544. texelHeight: number;
  50545. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50546. private _getDefines;
  50547. }
  50548. }
  50549. declare module BABYLON {
  50550. /** @hidden */
  50551. export var grainPixelShader: {
  50552. name: string;
  50553. shader: string;
  50554. };
  50555. }
  50556. declare module BABYLON {
  50557. /**
  50558. * The GrainPostProcess adds noise to the image at mid luminance levels
  50559. */
  50560. export class GrainPostProcess extends PostProcess {
  50561. /**
  50562. * The intensity of the grain added (default: 30)
  50563. */
  50564. intensity: number;
  50565. /**
  50566. * If the grain should be randomized on every frame
  50567. */
  50568. animated: boolean;
  50569. /**
  50570. * Creates a new instance of @see GrainPostProcess
  50571. * @param name The name of the effect.
  50572. * @param options The required width/height ratio to downsize to before computing the render pass.
  50573. * @param camera The camera to apply the render pass to.
  50574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50575. * @param engine The engine which the post process will be applied. (default: current engine)
  50576. * @param reusable If the post process can be reused on the same frame. (default: false)
  50577. * @param textureType Type of textures used when performing the post process. (default: 0)
  50578. * @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)
  50579. */
  50580. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50581. }
  50582. }
  50583. declare module BABYLON {
  50584. /** @hidden */
  50585. export var highlightsPixelShader: {
  50586. name: string;
  50587. shader: string;
  50588. };
  50589. }
  50590. declare module BABYLON {
  50591. /**
  50592. * Extracts highlights from the image
  50593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50594. */
  50595. export class HighlightsPostProcess extends PostProcess {
  50596. /**
  50597. * Extracts highlights from the image
  50598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  50599. * @param name The name of the effect.
  50600. * @param options The required width/height ratio to downsize to before computing the render pass.
  50601. * @param camera The camera to apply the render pass to.
  50602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50603. * @param engine The engine which the post process will be applied. (default: current engine)
  50604. * @param reusable If the post process can be reused on the same frame. (default: false)
  50605. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  50606. */
  50607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  50608. }
  50609. }
  50610. declare module BABYLON {
  50611. /** @hidden */
  50612. export var mrtFragmentDeclaration: {
  50613. name: string;
  50614. shader: string;
  50615. };
  50616. }
  50617. declare module BABYLON {
  50618. /** @hidden */
  50619. export var geometryPixelShader: {
  50620. name: string;
  50621. shader: string;
  50622. };
  50623. }
  50624. declare module BABYLON {
  50625. /** @hidden */
  50626. export var geometryVertexShader: {
  50627. name: string;
  50628. shader: string;
  50629. };
  50630. }
  50631. declare module BABYLON {
  50632. /**
  50633. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  50634. */
  50635. export class GeometryBufferRenderer {
  50636. /**
  50637. * Constant used to retrieve the position texture index in the G-Buffer textures array
  50638. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  50639. */
  50640. static readonly POSITION_TEXTURE_TYPE: number;
  50641. /**
  50642. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  50643. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  50644. */
  50645. static readonly VELOCITY_TEXTURE_TYPE: number;
  50646. /**
  50647. * Dictionary used to store the previous transformation matrices of each rendered mesh
  50648. * in order to compute objects velocities when enableVelocity is set to "true"
  50649. * @hidden
  50650. */
  50651. _previousTransformationMatrices: {
  50652. [index: number]: Matrix;
  50653. };
  50654. private _scene;
  50655. private _multiRenderTarget;
  50656. private _ratio;
  50657. private _enablePosition;
  50658. private _enableVelocity;
  50659. private _positionIndex;
  50660. private _velocityIndex;
  50661. protected _effect: Effect;
  50662. protected _cachedDefines: string;
  50663. /**
  50664. * Set the render list (meshes to be rendered) used in the G buffer.
  50665. */
  50666. renderList: Mesh[];
  50667. /**
  50668. * Gets wether or not G buffer are supported by the running hardware.
  50669. * This requires draw buffer supports
  50670. */
  50671. readonly isSupported: boolean;
  50672. /**
  50673. * Returns the index of the given texture type in the G-Buffer textures array
  50674. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  50675. * @returns the index of the given texture type in the G-Buffer textures array
  50676. */
  50677. getTextureIndex(textureType: number): number;
  50678. /**
  50679. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  50680. */
  50681. /**
  50682. * Sets whether or not objects positions are enabled for the G buffer.
  50683. */
  50684. enablePosition: boolean;
  50685. /**
  50686. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  50687. */
  50688. /**
  50689. * Sets wether or not objects velocities are enabled for the G buffer.
  50690. */
  50691. enableVelocity: boolean;
  50692. /**
  50693. * Gets the scene associated with the buffer.
  50694. */
  50695. readonly scene: Scene;
  50696. /**
  50697. * Gets the ratio used by the buffer during its creation.
  50698. * How big is the buffer related to the main canvas.
  50699. */
  50700. readonly ratio: number;
  50701. /** @hidden */
  50702. static _SceneComponentInitialization: (scene: Scene) => void;
  50703. /**
  50704. * Creates a new G Buffer for the scene
  50705. * @param scene The scene the buffer belongs to
  50706. * @param ratio How big is the buffer related to the main canvas.
  50707. */
  50708. constructor(scene: Scene, ratio?: number);
  50709. /**
  50710. * Checks wether everything is ready to render a submesh to the G buffer.
  50711. * @param subMesh the submesh to check readiness for
  50712. * @param useInstances is the mesh drawn using instance or not
  50713. * @returns true if ready otherwise false
  50714. */
  50715. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50716. /**
  50717. * Gets the current underlying G Buffer.
  50718. * @returns the buffer
  50719. */
  50720. getGBuffer(): MultiRenderTarget;
  50721. /**
  50722. * Gets the number of samples used to render the buffer (anti aliasing).
  50723. */
  50724. /**
  50725. * Sets the number of samples used to render the buffer (anti aliasing).
  50726. */
  50727. samples: number;
  50728. /**
  50729. * Disposes the renderer and frees up associated resources.
  50730. */
  50731. dispose(): void;
  50732. protected _createRenderTargets(): void;
  50733. }
  50734. }
  50735. declare module BABYLON {
  50736. /** @hidden */
  50737. export var motionBlurPixelShader: {
  50738. name: string;
  50739. shader: string;
  50740. };
  50741. }
  50742. declare module BABYLON {
  50743. /**
  50744. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50745. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50746. * As an example, all you have to do is to create the post-process:
  50747. * var mb = new BABYLON.MotionBlurPostProcess(
  50748. * 'mb', // The name of the effect.
  50749. * scene, // The scene containing the objects to blur according to their velocity.
  50750. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50751. * camera // The camera to apply the render pass to.
  50752. * );
  50753. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50754. */
  50755. export class MotionBlurPostProcess extends PostProcess {
  50756. /**
  50757. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50758. */
  50759. motionStrength: number;
  50760. /**
  50761. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50762. */
  50763. /**
  50764. * Sets the number of iterations to be used for motion blur quality
  50765. */
  50766. motionBlurSamples: number;
  50767. private _motionBlurSamples;
  50768. private _geometryBufferRenderer;
  50769. /**
  50770. * Creates a new instance MotionBlurPostProcess
  50771. * @param name The name of the effect.
  50772. * @param scene The scene containing the objects to blur according to their velocity.
  50773. * @param options The required width/height ratio to downsize to before computing the render pass.
  50774. * @param camera The camera to apply the render pass to.
  50775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50776. * @param engine The engine which the post process will be applied. (default: current engine)
  50777. * @param reusable If the post process can be reused on the same frame. (default: false)
  50778. * @param textureType Type of textures used when performing the post process. (default: 0)
  50779. * @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)
  50780. */
  50781. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50782. /**
  50783. * Disposes the post process.
  50784. * @param camera The camera to dispose the post process on.
  50785. */
  50786. dispose(camera?: Camera): void;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. /** @hidden */
  50791. export var refractionPixelShader: {
  50792. name: string;
  50793. shader: string;
  50794. };
  50795. }
  50796. declare module BABYLON {
  50797. /**
  50798. * Post process which applies a refractin texture
  50799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50800. */
  50801. export class RefractionPostProcess extends PostProcess {
  50802. /** the base color of the refraction (used to taint the rendering) */
  50803. color: Color3;
  50804. /** simulated refraction depth */
  50805. depth: number;
  50806. /** the coefficient of the base color (0 to remove base color tainting) */
  50807. colorLevel: number;
  50808. private _refTexture;
  50809. private _ownRefractionTexture;
  50810. /**
  50811. * Gets or sets the refraction texture
  50812. * Please note that you are responsible for disposing the texture if you set it manually
  50813. */
  50814. refractionTexture: Texture;
  50815. /**
  50816. * Initializes the RefractionPostProcess
  50817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50818. * @param name The name of the effect.
  50819. * @param refractionTextureUrl Url of the refraction texture to use
  50820. * @param color the base color of the refraction (used to taint the rendering)
  50821. * @param depth simulated refraction depth
  50822. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50823. * @param camera The camera to apply the render pass to.
  50824. * @param options The required width/height ratio to downsize to before computing the render pass.
  50825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50826. * @param engine The engine which the post process will be applied. (default: current engine)
  50827. * @param reusable If the post process can be reused on the same frame. (default: false)
  50828. */
  50829. constructor(name: string, refractionTextureUrl: string,
  50830. /** the base color of the refraction (used to taint the rendering) */
  50831. color: Color3,
  50832. /** simulated refraction depth */
  50833. depth: number,
  50834. /** the coefficient of the base color (0 to remove base color tainting) */
  50835. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50836. /**
  50837. * Disposes of the post process
  50838. * @param camera Camera to dispose post process on
  50839. */
  50840. dispose(camera: Camera): void;
  50841. }
  50842. }
  50843. declare module BABYLON {
  50844. /** @hidden */
  50845. export var sharpenPixelShader: {
  50846. name: string;
  50847. shader: string;
  50848. };
  50849. }
  50850. declare module BABYLON {
  50851. /**
  50852. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50853. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50854. */
  50855. export class SharpenPostProcess extends PostProcess {
  50856. /**
  50857. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50858. */
  50859. colorAmount: number;
  50860. /**
  50861. * How much sharpness should be applied (default: 0.3)
  50862. */
  50863. edgeAmount: number;
  50864. /**
  50865. * Creates a new instance ConvolutionPostProcess
  50866. * @param name The name of the effect.
  50867. * @param options The required width/height ratio to downsize to before computing the render pass.
  50868. * @param camera The camera to apply the render pass to.
  50869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50870. * @param engine The engine which the post process will be applied. (default: current engine)
  50871. * @param reusable If the post process can be reused on the same frame. (default: false)
  50872. * @param textureType Type of textures used when performing the post process. (default: 0)
  50873. * @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)
  50874. */
  50875. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50876. }
  50877. }
  50878. declare module BABYLON {
  50879. /**
  50880. * PostProcessRenderPipeline
  50881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50882. */
  50883. export class PostProcessRenderPipeline {
  50884. private engine;
  50885. private _renderEffects;
  50886. private _renderEffectsForIsolatedPass;
  50887. /**
  50888. * @hidden
  50889. */
  50890. protected _cameras: Camera[];
  50891. /** @hidden */
  50892. _name: string;
  50893. /**
  50894. * Gets pipeline name
  50895. */
  50896. readonly name: string;
  50897. /**
  50898. * Initializes a PostProcessRenderPipeline
  50899. * @param engine engine to add the pipeline to
  50900. * @param name name of the pipeline
  50901. */
  50902. constructor(engine: Engine, name: string);
  50903. /**
  50904. * Gets the class name
  50905. * @returns "PostProcessRenderPipeline"
  50906. */
  50907. getClassName(): string;
  50908. /**
  50909. * If all the render effects in the pipeline are supported
  50910. */
  50911. readonly isSupported: boolean;
  50912. /**
  50913. * Adds an effect to the pipeline
  50914. * @param renderEffect the effect to add
  50915. */
  50916. addEffect(renderEffect: PostProcessRenderEffect): void;
  50917. /** @hidden */
  50918. _rebuild(): void;
  50919. /** @hidden */
  50920. _enableEffect(renderEffectName: string, cameras: Camera): void;
  50921. /** @hidden */
  50922. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  50923. /** @hidden */
  50924. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50925. /** @hidden */
  50926. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50927. /** @hidden */
  50928. _attachCameras(cameras: Camera, unique: boolean): void;
  50929. /** @hidden */
  50930. _attachCameras(cameras: Camera[], unique: boolean): void;
  50931. /** @hidden */
  50932. _detachCameras(cameras: Camera): void;
  50933. /** @hidden */
  50934. _detachCameras(cameras: Nullable<Camera[]>): void;
  50935. /** @hidden */
  50936. _update(): void;
  50937. /** @hidden */
  50938. _reset(): void;
  50939. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  50940. /**
  50941. * Disposes of the pipeline
  50942. */
  50943. dispose(): void;
  50944. }
  50945. }
  50946. declare module BABYLON {
  50947. /**
  50948. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50949. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50950. */
  50951. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50952. private _scene;
  50953. private _camerasToBeAttached;
  50954. /**
  50955. * ID of the sharpen post process,
  50956. */
  50957. private readonly SharpenPostProcessId;
  50958. /**
  50959. * @ignore
  50960. * ID of the image processing post process;
  50961. */
  50962. readonly ImageProcessingPostProcessId: string;
  50963. /**
  50964. * @ignore
  50965. * ID of the Fast Approximate Anti-Aliasing post process;
  50966. */
  50967. readonly FxaaPostProcessId: string;
  50968. /**
  50969. * ID of the chromatic aberration post process,
  50970. */
  50971. private readonly ChromaticAberrationPostProcessId;
  50972. /**
  50973. * ID of the grain post process
  50974. */
  50975. private readonly GrainPostProcessId;
  50976. /**
  50977. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50978. */
  50979. sharpen: SharpenPostProcess;
  50980. private _sharpenEffect;
  50981. private bloom;
  50982. /**
  50983. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50984. */
  50985. depthOfField: DepthOfFieldEffect;
  50986. /**
  50987. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50988. */
  50989. fxaa: FxaaPostProcess;
  50990. /**
  50991. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50992. */
  50993. imageProcessing: ImageProcessingPostProcess;
  50994. /**
  50995. * Chromatic aberration post process which will shift rgb colors in the image
  50996. */
  50997. chromaticAberration: ChromaticAberrationPostProcess;
  50998. private _chromaticAberrationEffect;
  50999. /**
  51000. * Grain post process which add noise to the image
  51001. */
  51002. grain: GrainPostProcess;
  51003. private _grainEffect;
  51004. /**
  51005. * Glow post process which adds a glow to emissive areas of the image
  51006. */
  51007. private _glowLayer;
  51008. /**
  51009. * Animations which can be used to tweak settings over a period of time
  51010. */
  51011. animations: Animation[];
  51012. private _imageProcessingConfigurationObserver;
  51013. private _sharpenEnabled;
  51014. private _bloomEnabled;
  51015. private _depthOfFieldEnabled;
  51016. private _depthOfFieldBlurLevel;
  51017. private _fxaaEnabled;
  51018. private _imageProcessingEnabled;
  51019. private _defaultPipelineTextureType;
  51020. private _bloomScale;
  51021. private _chromaticAberrationEnabled;
  51022. private _grainEnabled;
  51023. private _buildAllowed;
  51024. /**
  51025. * Gets active scene
  51026. */
  51027. readonly scene: Scene;
  51028. /**
  51029. * Enable or disable the sharpen process from the pipeline
  51030. */
  51031. sharpenEnabled: boolean;
  51032. private _resizeObserver;
  51033. private _hardwareScaleLevel;
  51034. private _bloomKernel;
  51035. /**
  51036. * Specifies the size of the bloom blur kernel, relative to the final output size
  51037. */
  51038. bloomKernel: number;
  51039. /**
  51040. * Specifies the weight of the bloom in the final rendering
  51041. */
  51042. private _bloomWeight;
  51043. /**
  51044. * Specifies the luma threshold for the area that will be blurred by the bloom
  51045. */
  51046. private _bloomThreshold;
  51047. private _hdr;
  51048. /**
  51049. * The strength of the bloom.
  51050. */
  51051. bloomWeight: number;
  51052. /**
  51053. * The strength of the bloom.
  51054. */
  51055. bloomThreshold: number;
  51056. /**
  51057. * The scale of the bloom, lower value will provide better performance.
  51058. */
  51059. bloomScale: number;
  51060. /**
  51061. * Enable or disable the bloom from the pipeline
  51062. */
  51063. bloomEnabled: boolean;
  51064. private _rebuildBloom;
  51065. /**
  51066. * If the depth of field is enabled.
  51067. */
  51068. depthOfFieldEnabled: boolean;
  51069. /**
  51070. * Blur level of the depth of field effect. (Higher blur will effect performance)
  51071. */
  51072. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  51073. /**
  51074. * If the anti aliasing is enabled.
  51075. */
  51076. fxaaEnabled: boolean;
  51077. private _samples;
  51078. /**
  51079. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51080. */
  51081. samples: number;
  51082. /**
  51083. * If image processing is enabled.
  51084. */
  51085. imageProcessingEnabled: boolean;
  51086. /**
  51087. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  51088. */
  51089. glowLayerEnabled: boolean;
  51090. /**
  51091. * Enable or disable the chromaticAberration process from the pipeline
  51092. */
  51093. chromaticAberrationEnabled: boolean;
  51094. /**
  51095. * Enable or disable the grain process from the pipeline
  51096. */
  51097. grainEnabled: boolean;
  51098. /**
  51099. * @constructor
  51100. * @param name - The rendering pipeline name (default: "")
  51101. * @param hdr - If high dynamic range textures should be used (default: true)
  51102. * @param scene - The scene linked to this pipeline (default: the last created scene)
  51103. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  51104. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  51105. */
  51106. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  51107. /**
  51108. * Get the class name
  51109. * @returns "DefaultRenderingPipeline"
  51110. */
  51111. getClassName(): string;
  51112. /**
  51113. * Force the compilation of the entire pipeline.
  51114. */
  51115. prepare(): void;
  51116. private _hasCleared;
  51117. private _prevPostProcess;
  51118. private _prevPrevPostProcess;
  51119. private _setAutoClearAndTextureSharing;
  51120. private _depthOfFieldSceneObserver;
  51121. private _buildPipeline;
  51122. private _disposePostProcesses;
  51123. /**
  51124. * Adds a camera to the pipeline
  51125. * @param camera the camera to be added
  51126. */
  51127. addCamera(camera: Camera): void;
  51128. /**
  51129. * Removes a camera from the pipeline
  51130. * @param camera the camera to remove
  51131. */
  51132. removeCamera(camera: Camera): void;
  51133. /**
  51134. * Dispose of the pipeline and stop all post processes
  51135. */
  51136. dispose(): void;
  51137. /**
  51138. * Serialize the rendering pipeline (Used when exporting)
  51139. * @returns the serialized object
  51140. */
  51141. serialize(): any;
  51142. /**
  51143. * Parse the serialized pipeline
  51144. * @param source Source pipeline.
  51145. * @param scene The scene to load the pipeline to.
  51146. * @param rootUrl The URL of the serialized pipeline.
  51147. * @returns An instantiated pipeline from the serialized object.
  51148. */
  51149. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  51150. }
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export var lensHighlightsPixelShader: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module BABYLON {
  51160. /** @hidden */
  51161. export var depthOfFieldPixelShader: {
  51162. name: string;
  51163. shader: string;
  51164. };
  51165. }
  51166. declare module BABYLON {
  51167. /**
  51168. * BABYLON.JS Chromatic Aberration GLSL Shader
  51169. * Author: Olivier Guyot
  51170. * Separates very slightly R, G and B colors on the edges of the screen
  51171. * Inspired by Francois Tarlier & Martins Upitis
  51172. */
  51173. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  51174. /**
  51175. * @ignore
  51176. * The chromatic aberration PostProcess id in the pipeline
  51177. */
  51178. LensChromaticAberrationEffect: string;
  51179. /**
  51180. * @ignore
  51181. * The highlights enhancing PostProcess id in the pipeline
  51182. */
  51183. HighlightsEnhancingEffect: string;
  51184. /**
  51185. * @ignore
  51186. * The depth-of-field PostProcess id in the pipeline
  51187. */
  51188. LensDepthOfFieldEffect: string;
  51189. private _scene;
  51190. private _depthTexture;
  51191. private _grainTexture;
  51192. private _chromaticAberrationPostProcess;
  51193. private _highlightsPostProcess;
  51194. private _depthOfFieldPostProcess;
  51195. private _edgeBlur;
  51196. private _grainAmount;
  51197. private _chromaticAberration;
  51198. private _distortion;
  51199. private _highlightsGain;
  51200. private _highlightsThreshold;
  51201. private _dofDistance;
  51202. private _dofAperture;
  51203. private _dofDarken;
  51204. private _dofPentagon;
  51205. private _blurNoise;
  51206. /**
  51207. * @constructor
  51208. *
  51209. * Effect parameters are as follow:
  51210. * {
  51211. * chromatic_aberration: number; // from 0 to x (1 for realism)
  51212. * edge_blur: number; // from 0 to x (1 for realism)
  51213. * distortion: number; // from 0 to x (1 for realism)
  51214. * grain_amount: number; // from 0 to 1
  51215. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  51216. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  51217. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  51218. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  51219. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  51220. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  51221. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  51222. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  51223. * }
  51224. * Note: if an effect parameter is unset, effect is disabled
  51225. *
  51226. * @param name The rendering pipeline name
  51227. * @param parameters - An object containing all parameters (see above)
  51228. * @param scene The scene linked to this pipeline
  51229. * @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)
  51230. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51231. */
  51232. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  51233. /**
  51234. * Sets the amount of blur at the edges
  51235. * @param amount blur amount
  51236. */
  51237. setEdgeBlur(amount: number): void;
  51238. /**
  51239. * Sets edge blur to 0
  51240. */
  51241. disableEdgeBlur(): void;
  51242. /**
  51243. * Sets the amout of grain
  51244. * @param amount Amount of grain
  51245. */
  51246. setGrainAmount(amount: number): void;
  51247. /**
  51248. * Set grain amount to 0
  51249. */
  51250. disableGrain(): void;
  51251. /**
  51252. * Sets the chromatic aberration amount
  51253. * @param amount amount of chromatic aberration
  51254. */
  51255. setChromaticAberration(amount: number): void;
  51256. /**
  51257. * Sets chromatic aberration amount to 0
  51258. */
  51259. disableChromaticAberration(): void;
  51260. /**
  51261. * Sets the EdgeDistortion amount
  51262. * @param amount amount of EdgeDistortion
  51263. */
  51264. setEdgeDistortion(amount: number): void;
  51265. /**
  51266. * Sets edge distortion to 0
  51267. */
  51268. disableEdgeDistortion(): void;
  51269. /**
  51270. * Sets the FocusDistance amount
  51271. * @param amount amount of FocusDistance
  51272. */
  51273. setFocusDistance(amount: number): void;
  51274. /**
  51275. * Disables depth of field
  51276. */
  51277. disableDepthOfField(): void;
  51278. /**
  51279. * Sets the Aperture amount
  51280. * @param amount amount of Aperture
  51281. */
  51282. setAperture(amount: number): void;
  51283. /**
  51284. * Sets the DarkenOutOfFocus amount
  51285. * @param amount amount of DarkenOutOfFocus
  51286. */
  51287. setDarkenOutOfFocus(amount: number): void;
  51288. /**
  51289. * Creates a pentagon bokeh effect
  51290. */
  51291. enablePentagonBokeh(): void;
  51292. /**
  51293. * Disables the pentagon bokeh effect
  51294. */
  51295. disablePentagonBokeh(): void;
  51296. /**
  51297. * Enables noise blur
  51298. */
  51299. enableNoiseBlur(): void;
  51300. /**
  51301. * Disables noise blur
  51302. */
  51303. disableNoiseBlur(): void;
  51304. /**
  51305. * Sets the HighlightsGain amount
  51306. * @param amount amount of HighlightsGain
  51307. */
  51308. setHighlightsGain(amount: number): void;
  51309. /**
  51310. * Sets the HighlightsThreshold amount
  51311. * @param amount amount of HighlightsThreshold
  51312. */
  51313. setHighlightsThreshold(amount: number): void;
  51314. /**
  51315. * Disables highlights
  51316. */
  51317. disableHighlights(): void;
  51318. /**
  51319. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  51320. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  51321. */
  51322. dispose(disableDepthRender?: boolean): void;
  51323. private _createChromaticAberrationPostProcess;
  51324. private _createHighlightsPostProcess;
  51325. private _createDepthOfFieldPostProcess;
  51326. private _createGrainTexture;
  51327. }
  51328. }
  51329. declare module BABYLON {
  51330. /** @hidden */
  51331. export var ssao2PixelShader: {
  51332. name: string;
  51333. shader: string;
  51334. };
  51335. }
  51336. declare module BABYLON {
  51337. /** @hidden */
  51338. export var ssaoCombinePixelShader: {
  51339. name: string;
  51340. shader: string;
  51341. };
  51342. }
  51343. declare module BABYLON {
  51344. /**
  51345. * Render pipeline to produce ssao effect
  51346. */
  51347. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  51348. /**
  51349. * @ignore
  51350. * The PassPostProcess id in the pipeline that contains the original scene color
  51351. */
  51352. SSAOOriginalSceneColorEffect: string;
  51353. /**
  51354. * @ignore
  51355. * The SSAO PostProcess id in the pipeline
  51356. */
  51357. SSAORenderEffect: string;
  51358. /**
  51359. * @ignore
  51360. * The horizontal blur PostProcess id in the pipeline
  51361. */
  51362. SSAOBlurHRenderEffect: string;
  51363. /**
  51364. * @ignore
  51365. * The vertical blur PostProcess id in the pipeline
  51366. */
  51367. SSAOBlurVRenderEffect: string;
  51368. /**
  51369. * @ignore
  51370. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51371. */
  51372. SSAOCombineRenderEffect: string;
  51373. /**
  51374. * The output strength of the SSAO post-process. Default value is 1.0.
  51375. */
  51376. totalStrength: number;
  51377. /**
  51378. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  51379. */
  51380. maxZ: number;
  51381. /**
  51382. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  51383. */
  51384. minZAspect: number;
  51385. private _samples;
  51386. /**
  51387. * Number of samples used for the SSAO calculations. Default value is 8
  51388. */
  51389. samples: number;
  51390. private _textureSamples;
  51391. /**
  51392. * Number of samples to use for antialiasing
  51393. */
  51394. textureSamples: number;
  51395. /**
  51396. * Ratio object used for SSAO ratio and blur ratio
  51397. */
  51398. private _ratio;
  51399. /**
  51400. * Dynamically generated sphere sampler.
  51401. */
  51402. private _sampleSphere;
  51403. /**
  51404. * Blur filter offsets
  51405. */
  51406. private _samplerOffsets;
  51407. private _expensiveBlur;
  51408. /**
  51409. * If bilateral blur should be used
  51410. */
  51411. expensiveBlur: boolean;
  51412. /**
  51413. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  51414. */
  51415. radius: number;
  51416. /**
  51417. * The base color of the SSAO post-process
  51418. * The final result is "base + ssao" between [0, 1]
  51419. */
  51420. base: number;
  51421. /**
  51422. * Support test.
  51423. */
  51424. static readonly IsSupported: boolean;
  51425. private _scene;
  51426. private _depthTexture;
  51427. private _normalTexture;
  51428. private _randomTexture;
  51429. private _originalColorPostProcess;
  51430. private _ssaoPostProcess;
  51431. private _blurHPostProcess;
  51432. private _blurVPostProcess;
  51433. private _ssaoCombinePostProcess;
  51434. private _firstUpdate;
  51435. /**
  51436. * Gets active scene
  51437. */
  51438. readonly scene: Scene;
  51439. /**
  51440. * @constructor
  51441. * @param name The rendering pipeline name
  51442. * @param scene The scene linked to this pipeline
  51443. * @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 }
  51444. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51445. */
  51446. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51447. /**
  51448. * Get the class name
  51449. * @returns "SSAO2RenderingPipeline"
  51450. */
  51451. getClassName(): string;
  51452. /**
  51453. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51454. */
  51455. dispose(disableGeometryBufferRenderer?: boolean): void;
  51456. private _createBlurPostProcess;
  51457. /** @hidden */
  51458. _rebuild(): void;
  51459. private _bits;
  51460. private _radicalInverse_VdC;
  51461. private _hammersley;
  51462. private _hemisphereSample_uniform;
  51463. private _generateHemisphere;
  51464. private _createSSAOPostProcess;
  51465. private _createSSAOCombinePostProcess;
  51466. private _createRandomTexture;
  51467. /**
  51468. * Serialize the rendering pipeline (Used when exporting)
  51469. * @returns the serialized object
  51470. */
  51471. serialize(): any;
  51472. /**
  51473. * Parse the serialized pipeline
  51474. * @param source Source pipeline.
  51475. * @param scene The scene to load the pipeline to.
  51476. * @param rootUrl The URL of the serialized pipeline.
  51477. * @returns An instantiated pipeline from the serialized object.
  51478. */
  51479. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  51480. }
  51481. }
  51482. declare module BABYLON {
  51483. /** @hidden */
  51484. export var ssaoPixelShader: {
  51485. name: string;
  51486. shader: string;
  51487. };
  51488. }
  51489. declare module BABYLON {
  51490. /**
  51491. * Render pipeline to produce ssao effect
  51492. */
  51493. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  51494. /**
  51495. * @ignore
  51496. * The PassPostProcess id in the pipeline that contains the original scene color
  51497. */
  51498. SSAOOriginalSceneColorEffect: string;
  51499. /**
  51500. * @ignore
  51501. * The SSAO PostProcess id in the pipeline
  51502. */
  51503. SSAORenderEffect: string;
  51504. /**
  51505. * @ignore
  51506. * The horizontal blur PostProcess id in the pipeline
  51507. */
  51508. SSAOBlurHRenderEffect: string;
  51509. /**
  51510. * @ignore
  51511. * The vertical blur PostProcess id in the pipeline
  51512. */
  51513. SSAOBlurVRenderEffect: string;
  51514. /**
  51515. * @ignore
  51516. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  51517. */
  51518. SSAOCombineRenderEffect: string;
  51519. /**
  51520. * The output strength of the SSAO post-process. Default value is 1.0.
  51521. */
  51522. totalStrength: number;
  51523. /**
  51524. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  51525. */
  51526. radius: number;
  51527. /**
  51528. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  51529. * Must not be equal to fallOff and superior to fallOff.
  51530. * Default value is 0.0075
  51531. */
  51532. area: number;
  51533. /**
  51534. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  51535. * Must not be equal to area and inferior to area.
  51536. * Default value is 0.000001
  51537. */
  51538. fallOff: number;
  51539. /**
  51540. * The base color of the SSAO post-process
  51541. * The final result is "base + ssao" between [0, 1]
  51542. */
  51543. base: number;
  51544. private _scene;
  51545. private _depthTexture;
  51546. private _randomTexture;
  51547. private _originalColorPostProcess;
  51548. private _ssaoPostProcess;
  51549. private _blurHPostProcess;
  51550. private _blurVPostProcess;
  51551. private _ssaoCombinePostProcess;
  51552. private _firstUpdate;
  51553. /**
  51554. * Gets active scene
  51555. */
  51556. readonly scene: Scene;
  51557. /**
  51558. * @constructor
  51559. * @param name - The rendering pipeline name
  51560. * @param scene - The scene linked to this pipeline
  51561. * @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 }
  51562. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  51563. */
  51564. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  51565. /**
  51566. * Get the class name
  51567. * @returns "SSAORenderingPipeline"
  51568. */
  51569. getClassName(): string;
  51570. /**
  51571. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  51572. */
  51573. dispose(disableDepthRender?: boolean): void;
  51574. private _createBlurPostProcess;
  51575. /** @hidden */
  51576. _rebuild(): void;
  51577. private _createSSAOPostProcess;
  51578. private _createSSAOCombinePostProcess;
  51579. private _createRandomTexture;
  51580. }
  51581. }
  51582. declare module BABYLON {
  51583. /** @hidden */
  51584. export var standardPixelShader: {
  51585. name: string;
  51586. shader: string;
  51587. };
  51588. }
  51589. declare module BABYLON {
  51590. /**
  51591. * Standard rendering pipeline
  51592. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51593. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  51594. */
  51595. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  51596. /**
  51597. * Public members
  51598. */
  51599. /**
  51600. * Post-process which contains the original scene color before the pipeline applies all the effects
  51601. */
  51602. originalPostProcess: Nullable<PostProcess>;
  51603. /**
  51604. * Post-process used to down scale an image x4
  51605. */
  51606. downSampleX4PostProcess: Nullable<PostProcess>;
  51607. /**
  51608. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  51609. */
  51610. brightPassPostProcess: Nullable<PostProcess>;
  51611. /**
  51612. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  51613. */
  51614. blurHPostProcesses: PostProcess[];
  51615. /**
  51616. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51617. */
  51618. blurVPostProcesses: PostProcess[];
  51619. /**
  51620. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51621. */
  51622. textureAdderPostProcess: Nullable<PostProcess>;
  51623. /**
  51624. * Post-process used to create volumetric lighting effect
  51625. */
  51626. volumetricLightPostProcess: Nullable<PostProcess>;
  51627. /**
  51628. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51629. */
  51630. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51631. /**
  51632. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51633. */
  51634. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51635. /**
  51636. * Post-process used to merge the volumetric light effect and the real scene color
  51637. */
  51638. volumetricLightMergePostProces: Nullable<PostProcess>;
  51639. /**
  51640. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51641. */
  51642. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51643. /**
  51644. * Base post-process used to calculate the average luminance of the final image for HDR
  51645. */
  51646. luminancePostProcess: Nullable<PostProcess>;
  51647. /**
  51648. * Post-processes used to create down sample post-processes in order to get
  51649. * the average luminance of the final image for HDR
  51650. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51651. */
  51652. luminanceDownSamplePostProcesses: PostProcess[];
  51653. /**
  51654. * Post-process used to create a HDR effect (light adaptation)
  51655. */
  51656. hdrPostProcess: Nullable<PostProcess>;
  51657. /**
  51658. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51659. */
  51660. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51661. /**
  51662. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51663. */
  51664. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51665. /**
  51666. * Post-process used to merge the final HDR post-process and the real scene color
  51667. */
  51668. hdrFinalPostProcess: Nullable<PostProcess>;
  51669. /**
  51670. * Post-process used to create a lens flare effect
  51671. */
  51672. lensFlarePostProcess: Nullable<PostProcess>;
  51673. /**
  51674. * Post-process that merges the result of the lens flare post-process and the real scene color
  51675. */
  51676. lensFlareComposePostProcess: Nullable<PostProcess>;
  51677. /**
  51678. * Post-process used to create a motion blur effect
  51679. */
  51680. motionBlurPostProcess: Nullable<PostProcess>;
  51681. /**
  51682. * Post-process used to create a depth of field effect
  51683. */
  51684. depthOfFieldPostProcess: Nullable<PostProcess>;
  51685. /**
  51686. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51687. */
  51688. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51689. /**
  51690. * Represents the brightness threshold in order to configure the illuminated surfaces
  51691. */
  51692. brightThreshold: number;
  51693. /**
  51694. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51695. */
  51696. blurWidth: number;
  51697. /**
  51698. * Sets if the blur for highlighted surfaces must be only horizontal
  51699. */
  51700. horizontalBlur: boolean;
  51701. /**
  51702. * Sets the overall exposure used by the pipeline
  51703. */
  51704. exposure: number;
  51705. /**
  51706. * Texture used typically to simulate "dirty" on camera lens
  51707. */
  51708. lensTexture: Nullable<Texture>;
  51709. /**
  51710. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51711. */
  51712. volumetricLightCoefficient: number;
  51713. /**
  51714. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51715. */
  51716. volumetricLightPower: number;
  51717. /**
  51718. * Used the set the blur intensity to smooth the volumetric lights
  51719. */
  51720. volumetricLightBlurScale: number;
  51721. /**
  51722. * Light (spot or directional) used to generate the volumetric lights rays
  51723. * The source light must have a shadow generate so the pipeline can get its
  51724. * depth map
  51725. */
  51726. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51727. /**
  51728. * For eye adaptation, represents the minimum luminance the eye can see
  51729. */
  51730. hdrMinimumLuminance: number;
  51731. /**
  51732. * For eye adaptation, represents the decrease luminance speed
  51733. */
  51734. hdrDecreaseRate: number;
  51735. /**
  51736. * For eye adaptation, represents the increase luminance speed
  51737. */
  51738. hdrIncreaseRate: number;
  51739. /**
  51740. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51741. */
  51742. lensColorTexture: Nullable<Texture>;
  51743. /**
  51744. * The overall strengh for the lens flare effect
  51745. */
  51746. lensFlareStrength: number;
  51747. /**
  51748. * Dispersion coefficient for lens flare ghosts
  51749. */
  51750. lensFlareGhostDispersal: number;
  51751. /**
  51752. * Main lens flare halo width
  51753. */
  51754. lensFlareHaloWidth: number;
  51755. /**
  51756. * Based on the lens distortion effect, defines how much the lens flare result
  51757. * is distorted
  51758. */
  51759. lensFlareDistortionStrength: number;
  51760. /**
  51761. * Lens star texture must be used to simulate rays on the flares and is available
  51762. * in the documentation
  51763. */
  51764. lensStarTexture: Nullable<Texture>;
  51765. /**
  51766. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51767. * flare effect by taking account of the dirt texture
  51768. */
  51769. lensFlareDirtTexture: Nullable<Texture>;
  51770. /**
  51771. * Represents the focal length for the depth of field effect
  51772. */
  51773. depthOfFieldDistance: number;
  51774. /**
  51775. * Represents the blur intensity for the blurred part of the depth of field effect
  51776. */
  51777. depthOfFieldBlurWidth: number;
  51778. /**
  51779. * For motion blur, defines how much the image is blurred by the movement
  51780. */
  51781. motionStrength: number;
  51782. /**
  51783. * List of animations for the pipeline (IAnimatable implementation)
  51784. */
  51785. animations: Animation[];
  51786. /**
  51787. * Private members
  51788. */
  51789. private _scene;
  51790. private _currentDepthOfFieldSource;
  51791. private _basePostProcess;
  51792. private _hdrCurrentLuminance;
  51793. private _floatTextureType;
  51794. private _ratio;
  51795. private _bloomEnabled;
  51796. private _depthOfFieldEnabled;
  51797. private _vlsEnabled;
  51798. private _lensFlareEnabled;
  51799. private _hdrEnabled;
  51800. private _motionBlurEnabled;
  51801. private _fxaaEnabled;
  51802. private _motionBlurSamples;
  51803. private _volumetricLightStepsCount;
  51804. private _samples;
  51805. /**
  51806. * @ignore
  51807. * Specifies if the bloom pipeline is enabled
  51808. */
  51809. BloomEnabled: boolean;
  51810. /**
  51811. * @ignore
  51812. * Specifies if the depth of field pipeline is enabed
  51813. */
  51814. DepthOfFieldEnabled: boolean;
  51815. /**
  51816. * @ignore
  51817. * Specifies if the lens flare pipeline is enabed
  51818. */
  51819. LensFlareEnabled: boolean;
  51820. /**
  51821. * @ignore
  51822. * Specifies if the HDR pipeline is enabled
  51823. */
  51824. HDREnabled: boolean;
  51825. /**
  51826. * @ignore
  51827. * Specifies if the volumetric lights scattering effect is enabled
  51828. */
  51829. VLSEnabled: boolean;
  51830. /**
  51831. * @ignore
  51832. * Specifies if the motion blur effect is enabled
  51833. */
  51834. MotionBlurEnabled: boolean;
  51835. /**
  51836. * Specifies if anti-aliasing is enabled
  51837. */
  51838. fxaaEnabled: boolean;
  51839. /**
  51840. * Specifies the number of steps used to calculate the volumetric lights
  51841. * Typically in interval [50, 200]
  51842. */
  51843. volumetricLightStepsCount: number;
  51844. /**
  51845. * Specifies the number of samples used for the motion blur effect
  51846. * Typically in interval [16, 64]
  51847. */
  51848. motionBlurSamples: number;
  51849. /**
  51850. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51851. */
  51852. samples: number;
  51853. /**
  51854. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51855. * @constructor
  51856. * @param name The rendering pipeline name
  51857. * @param scene The scene linked to this pipeline
  51858. * @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)
  51859. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51860. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51861. */
  51862. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51863. private _buildPipeline;
  51864. private _createDownSampleX4PostProcess;
  51865. private _createBrightPassPostProcess;
  51866. private _createBlurPostProcesses;
  51867. private _createTextureAdderPostProcess;
  51868. private _createVolumetricLightPostProcess;
  51869. private _createLuminancePostProcesses;
  51870. private _createHdrPostProcess;
  51871. private _createLensFlarePostProcess;
  51872. private _createDepthOfFieldPostProcess;
  51873. private _createMotionBlurPostProcess;
  51874. private _getDepthTexture;
  51875. private _disposePostProcesses;
  51876. /**
  51877. * Dispose of the pipeline and stop all post processes
  51878. */
  51879. dispose(): void;
  51880. /**
  51881. * Serialize the rendering pipeline (Used when exporting)
  51882. * @returns the serialized object
  51883. */
  51884. serialize(): any;
  51885. /**
  51886. * Parse the serialized pipeline
  51887. * @param source Source pipeline.
  51888. * @param scene The scene to load the pipeline to.
  51889. * @param rootUrl The URL of the serialized pipeline.
  51890. * @returns An instantiated pipeline from the serialized object.
  51891. */
  51892. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51893. /**
  51894. * Luminance steps
  51895. */
  51896. static LuminanceSteps: number;
  51897. }
  51898. }
  51899. declare module BABYLON {
  51900. /**
  51901. * PostProcessRenderPipelineManager class
  51902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51903. */
  51904. export class PostProcessRenderPipelineManager {
  51905. private _renderPipelines;
  51906. /**
  51907. * Initializes a PostProcessRenderPipelineManager
  51908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51909. */
  51910. constructor();
  51911. /**
  51912. * Gets the list of supported render pipelines
  51913. */
  51914. readonly supportedPipelines: PostProcessRenderPipeline[];
  51915. /**
  51916. * Adds a pipeline to the manager
  51917. * @param renderPipeline The pipeline to add
  51918. */
  51919. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51920. /**
  51921. * Attaches a camera to the pipeline
  51922. * @param renderPipelineName The name of the pipeline to attach to
  51923. * @param cameras the camera to attach
  51924. * @param unique if the camera can be attached multiple times to the pipeline
  51925. */
  51926. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51927. /**
  51928. * Detaches a camera from the pipeline
  51929. * @param renderPipelineName The name of the pipeline to detach from
  51930. * @param cameras the camera to detach
  51931. */
  51932. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51933. /**
  51934. * Enables an effect by name on a pipeline
  51935. * @param renderPipelineName the name of the pipeline to enable the effect in
  51936. * @param renderEffectName the name of the effect to enable
  51937. * @param cameras the cameras that the effect should be enabled on
  51938. */
  51939. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51940. /**
  51941. * Disables an effect by name on a pipeline
  51942. * @param renderPipelineName the name of the pipeline to disable the effect in
  51943. * @param renderEffectName the name of the effect to disable
  51944. * @param cameras the cameras that the effect should be disabled on
  51945. */
  51946. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51947. /**
  51948. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51949. */
  51950. update(): void;
  51951. /** @hidden */
  51952. _rebuild(): void;
  51953. /**
  51954. * Disposes of the manager and pipelines
  51955. */
  51956. dispose(): void;
  51957. }
  51958. }
  51959. declare module BABYLON {
  51960. interface Scene {
  51961. /** @hidden (Backing field) */
  51962. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51963. /**
  51964. * Gets the postprocess render pipeline manager
  51965. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51966. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51967. */
  51968. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51969. }
  51970. /**
  51971. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51972. */
  51973. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51974. /**
  51975. * The component name helpfull to identify the component in the list of scene components.
  51976. */
  51977. readonly name: string;
  51978. /**
  51979. * The scene the component belongs to.
  51980. */
  51981. scene: Scene;
  51982. /**
  51983. * Creates a new instance of the component for the given scene
  51984. * @param scene Defines the scene to register the component in
  51985. */
  51986. constructor(scene: Scene);
  51987. /**
  51988. * Registers the component in a given scene
  51989. */
  51990. register(): void;
  51991. /**
  51992. * Rebuilds the elements related to this component in case of
  51993. * context lost for instance.
  51994. */
  51995. rebuild(): void;
  51996. /**
  51997. * Disposes the component and the associated ressources
  51998. */
  51999. dispose(): void;
  52000. private _gatherRenderTargets;
  52001. }
  52002. }
  52003. declare module BABYLON {
  52004. /** @hidden */
  52005. export var tonemapPixelShader: {
  52006. name: string;
  52007. shader: string;
  52008. };
  52009. }
  52010. declare module BABYLON {
  52011. /** Defines operator used for tonemapping */
  52012. export enum TonemappingOperator {
  52013. /** Hable */
  52014. Hable = 0,
  52015. /** Reinhard */
  52016. Reinhard = 1,
  52017. /** HejiDawson */
  52018. HejiDawson = 2,
  52019. /** Photographic */
  52020. Photographic = 3
  52021. }
  52022. /**
  52023. * Defines a post process to apply tone mapping
  52024. */
  52025. export class TonemapPostProcess extends PostProcess {
  52026. private _operator;
  52027. /** Defines the required exposure adjustement */
  52028. exposureAdjustment: number;
  52029. /**
  52030. * Creates a new TonemapPostProcess
  52031. * @param name defines the name of the postprocess
  52032. * @param _operator defines the operator to use
  52033. * @param exposureAdjustment defines the required exposure adjustement
  52034. * @param camera defines the camera to use (can be null)
  52035. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  52036. * @param engine defines the hosting engine (can be ignore if camera is set)
  52037. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52038. */
  52039. constructor(name: string, _operator: TonemappingOperator,
  52040. /** Defines the required exposure adjustement */
  52041. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  52042. }
  52043. }
  52044. declare module BABYLON {
  52045. /** @hidden */
  52046. export var depthVertexShader: {
  52047. name: string;
  52048. shader: string;
  52049. };
  52050. }
  52051. declare module BABYLON {
  52052. /** @hidden */
  52053. export var volumetricLightScatteringPixelShader: {
  52054. name: string;
  52055. shader: string;
  52056. };
  52057. }
  52058. declare module BABYLON {
  52059. /** @hidden */
  52060. export var volumetricLightScatteringPassPixelShader: {
  52061. name: string;
  52062. shader: string;
  52063. };
  52064. }
  52065. declare module BABYLON {
  52066. /**
  52067. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  52068. */
  52069. export class VolumetricLightScatteringPostProcess extends PostProcess {
  52070. private _volumetricLightScatteringPass;
  52071. private _volumetricLightScatteringRTT;
  52072. private _viewPort;
  52073. private _screenCoordinates;
  52074. private _cachedDefines;
  52075. /**
  52076. * If not undefined, the mesh position is computed from the attached node position
  52077. */
  52078. attachedNode: {
  52079. position: Vector3;
  52080. };
  52081. /**
  52082. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  52083. */
  52084. customMeshPosition: Vector3;
  52085. /**
  52086. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  52087. */
  52088. useCustomMeshPosition: boolean;
  52089. /**
  52090. * If the post-process should inverse the light scattering direction
  52091. */
  52092. invert: boolean;
  52093. /**
  52094. * The internal mesh used by the post-process
  52095. */
  52096. mesh: Mesh;
  52097. /**
  52098. * @hidden
  52099. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  52100. */
  52101. useDiffuseColor: boolean;
  52102. /**
  52103. * Array containing the excluded meshes not rendered in the internal pass
  52104. */
  52105. excludedMeshes: AbstractMesh[];
  52106. /**
  52107. * Controls the overall intensity of the post-process
  52108. */
  52109. exposure: number;
  52110. /**
  52111. * Dissipates each sample's contribution in range [0, 1]
  52112. */
  52113. decay: number;
  52114. /**
  52115. * Controls the overall intensity of each sample
  52116. */
  52117. weight: number;
  52118. /**
  52119. * Controls the density of each sample
  52120. */
  52121. density: number;
  52122. /**
  52123. * @constructor
  52124. * @param name The post-process name
  52125. * @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)
  52126. * @param camera The camera that the post-process will be attached to
  52127. * @param mesh The mesh used to create the light scattering
  52128. * @param samples The post-process quality, default 100
  52129. * @param samplingModeThe post-process filtering mode
  52130. * @param engine The babylon engine
  52131. * @param reusable If the post-process is reusable
  52132. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  52133. */
  52134. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  52135. /**
  52136. * Returns the string "VolumetricLightScatteringPostProcess"
  52137. * @returns "VolumetricLightScatteringPostProcess"
  52138. */
  52139. getClassName(): string;
  52140. private _isReady;
  52141. /**
  52142. * Sets the new light position for light scattering effect
  52143. * @param position The new custom light position
  52144. */
  52145. setCustomMeshPosition(position: Vector3): void;
  52146. /**
  52147. * Returns the light position for light scattering effect
  52148. * @return Vector3 The custom light position
  52149. */
  52150. getCustomMeshPosition(): Vector3;
  52151. /**
  52152. * Disposes the internal assets and detaches the post-process from the camera
  52153. */
  52154. dispose(camera: Camera): void;
  52155. /**
  52156. * Returns the render target texture used by the post-process
  52157. * @return the render target texture used by the post-process
  52158. */
  52159. getPass(): RenderTargetTexture;
  52160. private _meshExcluded;
  52161. private _createPass;
  52162. private _updateMeshScreenCoordinates;
  52163. /**
  52164. * Creates a default mesh for the Volumeric Light Scattering post-process
  52165. * @param name The mesh name
  52166. * @param scene The scene where to create the mesh
  52167. * @return the default mesh
  52168. */
  52169. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  52170. }
  52171. }
  52172. declare module BABYLON {
  52173. interface Scene {
  52174. /** @hidden (Backing field) */
  52175. _boundingBoxRenderer: BoundingBoxRenderer;
  52176. /** @hidden (Backing field) */
  52177. _forceShowBoundingBoxes: boolean;
  52178. /**
  52179. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  52180. */
  52181. forceShowBoundingBoxes: boolean;
  52182. /**
  52183. * Gets the bounding box renderer associated with the scene
  52184. * @returns a BoundingBoxRenderer
  52185. */
  52186. getBoundingBoxRenderer(): BoundingBoxRenderer;
  52187. }
  52188. interface AbstractMesh {
  52189. /** @hidden (Backing field) */
  52190. _showBoundingBox: boolean;
  52191. /**
  52192. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  52193. */
  52194. showBoundingBox: boolean;
  52195. }
  52196. /**
  52197. * Component responsible of rendering the bounding box of the meshes in a scene.
  52198. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  52199. */
  52200. export class BoundingBoxRenderer implements ISceneComponent {
  52201. /**
  52202. * The component name helpfull to identify the component in the list of scene components.
  52203. */
  52204. readonly name: string;
  52205. /**
  52206. * The scene the component belongs to.
  52207. */
  52208. scene: Scene;
  52209. /**
  52210. * Color of the bounding box lines placed in front of an object
  52211. */
  52212. frontColor: Color3;
  52213. /**
  52214. * Color of the bounding box lines placed behind an object
  52215. */
  52216. backColor: Color3;
  52217. /**
  52218. * Defines if the renderer should show the back lines or not
  52219. */
  52220. showBackLines: boolean;
  52221. /**
  52222. * @hidden
  52223. */
  52224. renderList: SmartArray<BoundingBox>;
  52225. private _colorShader;
  52226. private _vertexBuffers;
  52227. private _indexBuffer;
  52228. /**
  52229. * Instantiates a new bounding box renderer in a scene.
  52230. * @param scene the scene the renderer renders in
  52231. */
  52232. constructor(scene: Scene);
  52233. /**
  52234. * Registers the component in a given scene
  52235. */
  52236. register(): void;
  52237. private _evaluateSubMesh;
  52238. private _activeMesh;
  52239. private _prepareRessources;
  52240. private _createIndexBuffer;
  52241. /**
  52242. * Rebuilds the elements related to this component in case of
  52243. * context lost for instance.
  52244. */
  52245. rebuild(): void;
  52246. /**
  52247. * @hidden
  52248. */
  52249. reset(): void;
  52250. /**
  52251. * Render the bounding boxes of a specific rendering group
  52252. * @param renderingGroupId defines the rendering group to render
  52253. */
  52254. render(renderingGroupId: number): void;
  52255. /**
  52256. * In case of occlusion queries, we can render the occlusion bounding box through this method
  52257. * @param mesh Define the mesh to render the occlusion bounding box for
  52258. */
  52259. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  52260. /**
  52261. * Dispose and release the resources attached to this renderer.
  52262. */
  52263. dispose(): void;
  52264. }
  52265. }
  52266. declare module BABYLON {
  52267. /** @hidden */
  52268. export var depthPixelShader: {
  52269. name: string;
  52270. shader: string;
  52271. };
  52272. }
  52273. declare module BABYLON {
  52274. /**
  52275. * This represents a depth renderer in Babylon.
  52276. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  52277. */
  52278. export class DepthRenderer {
  52279. private _scene;
  52280. private _depthMap;
  52281. private _effect;
  52282. private _cachedDefines;
  52283. private _camera;
  52284. /**
  52285. * Specifiess that the depth renderer will only be used within
  52286. * the camera it is created for.
  52287. * This can help forcing its rendering during the camera processing.
  52288. */
  52289. useOnlyInActiveCamera: boolean;
  52290. /** @hidden */
  52291. static _SceneComponentInitialization: (scene: Scene) => void;
  52292. /**
  52293. * Instantiates a depth renderer
  52294. * @param scene The scene the renderer belongs to
  52295. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  52296. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  52297. */
  52298. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  52299. /**
  52300. * Creates the depth rendering effect and checks if the effect is ready.
  52301. * @param subMesh The submesh to be used to render the depth map of
  52302. * @param useInstances If multiple world instances should be used
  52303. * @returns if the depth renderer is ready to render the depth map
  52304. */
  52305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52306. /**
  52307. * Gets the texture which the depth map will be written to.
  52308. * @returns The depth map texture
  52309. */
  52310. getDepthMap(): RenderTargetTexture;
  52311. /**
  52312. * Disposes of the depth renderer.
  52313. */
  52314. dispose(): void;
  52315. }
  52316. }
  52317. declare module BABYLON {
  52318. interface Scene {
  52319. /** @hidden (Backing field) */
  52320. _depthRenderer: {
  52321. [id: string]: DepthRenderer;
  52322. };
  52323. /**
  52324. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  52325. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  52326. * @returns the created depth renderer
  52327. */
  52328. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  52329. /**
  52330. * Disables a depth renderer for a given camera
  52331. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  52332. */
  52333. disableDepthRenderer(camera?: Nullable<Camera>): void;
  52334. }
  52335. /**
  52336. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  52337. * in several rendering techniques.
  52338. */
  52339. export class DepthRendererSceneComponent implements ISceneComponent {
  52340. /**
  52341. * The component name helpfull to identify the component in the list of scene components.
  52342. */
  52343. readonly name: string;
  52344. /**
  52345. * The scene the component belongs to.
  52346. */
  52347. scene: Scene;
  52348. /**
  52349. * Creates a new instance of the component for the given scene
  52350. * @param scene Defines the scene to register the component in
  52351. */
  52352. constructor(scene: Scene);
  52353. /**
  52354. * Registers the component in a given scene
  52355. */
  52356. register(): void;
  52357. /**
  52358. * Rebuilds the elements related to this component in case of
  52359. * context lost for instance.
  52360. */
  52361. rebuild(): void;
  52362. /**
  52363. * Disposes the component and the associated ressources
  52364. */
  52365. dispose(): void;
  52366. private _gatherRenderTargets;
  52367. private _gatherActiveCameraRenderTargets;
  52368. }
  52369. }
  52370. declare module BABYLON {
  52371. interface Scene {
  52372. /** @hidden (Backing field) */
  52373. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52374. /**
  52375. * Gets or Sets the current geometry buffer associated to the scene.
  52376. */
  52377. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52378. /**
  52379. * Enables a GeometryBufferRender and associates it with the scene
  52380. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52381. * @returns the GeometryBufferRenderer
  52382. */
  52383. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52384. /**
  52385. * Disables the GeometryBufferRender associated with the scene
  52386. */
  52387. disableGeometryBufferRenderer(): void;
  52388. }
  52389. /**
  52390. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52391. * in several rendering techniques.
  52392. */
  52393. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52394. /**
  52395. * The component name helpful to identify the component in the list of scene components.
  52396. */
  52397. readonly name: string;
  52398. /**
  52399. * The scene the component belongs to.
  52400. */
  52401. scene: Scene;
  52402. /**
  52403. * Creates a new instance of the component for the given scene
  52404. * @param scene Defines the scene to register the component in
  52405. */
  52406. constructor(scene: Scene);
  52407. /**
  52408. * Registers the component in a given scene
  52409. */
  52410. register(): void;
  52411. /**
  52412. * Rebuilds the elements related to this component in case of
  52413. * context lost for instance.
  52414. */
  52415. rebuild(): void;
  52416. /**
  52417. * Disposes the component and the associated ressources
  52418. */
  52419. dispose(): void;
  52420. private _gatherRenderTargets;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /** @hidden */
  52425. export var outlinePixelShader: {
  52426. name: string;
  52427. shader: string;
  52428. };
  52429. }
  52430. declare module BABYLON {
  52431. /** @hidden */
  52432. export var outlineVertexShader: {
  52433. name: string;
  52434. shader: string;
  52435. };
  52436. }
  52437. declare module BABYLON {
  52438. interface Scene {
  52439. /** @hidden */
  52440. _outlineRenderer: OutlineRenderer;
  52441. /**
  52442. * Gets the outline renderer associated with the scene
  52443. * @returns a OutlineRenderer
  52444. */
  52445. getOutlineRenderer(): OutlineRenderer;
  52446. }
  52447. interface AbstractMesh {
  52448. /** @hidden (Backing field) */
  52449. _renderOutline: boolean;
  52450. /**
  52451. * Gets or sets a boolean indicating if the outline must be rendered as well
  52452. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  52453. */
  52454. renderOutline: boolean;
  52455. /** @hidden (Backing field) */
  52456. _renderOverlay: boolean;
  52457. /**
  52458. * Gets or sets a boolean indicating if the overlay must be rendered as well
  52459. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  52460. */
  52461. renderOverlay: boolean;
  52462. }
  52463. /**
  52464. * This class is responsible to draw bothe outline/overlay of meshes.
  52465. * It should not be used directly but through the available method on mesh.
  52466. */
  52467. export class OutlineRenderer implements ISceneComponent {
  52468. /**
  52469. * The name of the component. Each component must have a unique name.
  52470. */
  52471. name: string;
  52472. /**
  52473. * The scene the component belongs to.
  52474. */
  52475. scene: Scene;
  52476. /**
  52477. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  52478. */
  52479. zOffset: number;
  52480. private _engine;
  52481. private _effect;
  52482. private _cachedDefines;
  52483. private _savedDepthWrite;
  52484. /**
  52485. * Instantiates a new outline renderer. (There could be only one per scene).
  52486. * @param scene Defines the scene it belongs to
  52487. */
  52488. constructor(scene: Scene);
  52489. /**
  52490. * Register the component to one instance of a scene.
  52491. */
  52492. register(): void;
  52493. /**
  52494. * Rebuilds the elements related to this component in case of
  52495. * context lost for instance.
  52496. */
  52497. rebuild(): void;
  52498. /**
  52499. * Disposes the component and the associated ressources.
  52500. */
  52501. dispose(): void;
  52502. /**
  52503. * Renders the outline in the canvas.
  52504. * @param subMesh Defines the sumesh to render
  52505. * @param batch Defines the batch of meshes in case of instances
  52506. * @param useOverlay Defines if the rendering is for the overlay or the outline
  52507. */
  52508. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  52509. /**
  52510. * Returns whether or not the outline renderer is ready for a given submesh.
  52511. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  52512. * @param subMesh Defines the submesh to check readyness for
  52513. * @param useInstances Defines wheter wee are trying to render instances or not
  52514. * @returns true if ready otherwise false
  52515. */
  52516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52517. private _beforeRenderingMesh;
  52518. private _afterRenderingMesh;
  52519. }
  52520. }
  52521. declare module BABYLON {
  52522. /**
  52523. * Defines the list of states available for a task inside a AssetsManager
  52524. */
  52525. export enum AssetTaskState {
  52526. /**
  52527. * Initialization
  52528. */
  52529. INIT = 0,
  52530. /**
  52531. * Running
  52532. */
  52533. RUNNING = 1,
  52534. /**
  52535. * Done
  52536. */
  52537. DONE = 2,
  52538. /**
  52539. * Error
  52540. */
  52541. ERROR = 3
  52542. }
  52543. /**
  52544. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  52545. */
  52546. export abstract class AbstractAssetTask {
  52547. /**
  52548. * Task name
  52549. */ name: string;
  52550. /**
  52551. * Callback called when the task is successful
  52552. */
  52553. onSuccess: (task: any) => void;
  52554. /**
  52555. * Callback called when the task is not successful
  52556. */
  52557. onError: (task: any, message?: string, exception?: any) => void;
  52558. /**
  52559. * Creates a new AssetsManager
  52560. * @param name defines the name of the task
  52561. */
  52562. constructor(
  52563. /**
  52564. * Task name
  52565. */ name: string);
  52566. private _isCompleted;
  52567. private _taskState;
  52568. private _errorObject;
  52569. /**
  52570. * Get if the task is completed
  52571. */
  52572. readonly isCompleted: boolean;
  52573. /**
  52574. * Gets the current state of the task
  52575. */
  52576. readonly taskState: AssetTaskState;
  52577. /**
  52578. * Gets the current error object (if task is in error)
  52579. */
  52580. readonly errorObject: {
  52581. message?: string;
  52582. exception?: any;
  52583. };
  52584. /**
  52585. * Internal only
  52586. * @hidden
  52587. */
  52588. _setErrorObject(message?: string, exception?: any): void;
  52589. /**
  52590. * Execute the current task
  52591. * @param scene defines the scene where you want your assets to be loaded
  52592. * @param onSuccess is a callback called when the task is successfully executed
  52593. * @param onError is a callback called if an error occurs
  52594. */
  52595. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52596. /**
  52597. * Execute the current task
  52598. * @param scene defines the scene where you want your assets to be loaded
  52599. * @param onSuccess is a callback called when the task is successfully executed
  52600. * @param onError is a callback called if an error occurs
  52601. */
  52602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52603. /**
  52604. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  52605. * This can be used with failed tasks that have the reason for failure fixed.
  52606. */
  52607. reset(): void;
  52608. private onErrorCallback;
  52609. private onDoneCallback;
  52610. }
  52611. /**
  52612. * Define the interface used by progress events raised during assets loading
  52613. */
  52614. export interface IAssetsProgressEvent {
  52615. /**
  52616. * Defines the number of remaining tasks to process
  52617. */
  52618. remainingCount: number;
  52619. /**
  52620. * Defines the total number of tasks
  52621. */
  52622. totalCount: number;
  52623. /**
  52624. * Defines the task that was just processed
  52625. */
  52626. task: AbstractAssetTask;
  52627. }
  52628. /**
  52629. * Class used to share progress information about assets loading
  52630. */
  52631. export class AssetsProgressEvent implements IAssetsProgressEvent {
  52632. /**
  52633. * Defines the number of remaining tasks to process
  52634. */
  52635. remainingCount: number;
  52636. /**
  52637. * Defines the total number of tasks
  52638. */
  52639. totalCount: number;
  52640. /**
  52641. * Defines the task that was just processed
  52642. */
  52643. task: AbstractAssetTask;
  52644. /**
  52645. * Creates a AssetsProgressEvent
  52646. * @param remainingCount defines the number of remaining tasks to process
  52647. * @param totalCount defines the total number of tasks
  52648. * @param task defines the task that was just processed
  52649. */
  52650. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  52651. }
  52652. /**
  52653. * Define a task used by AssetsManager to load meshes
  52654. */
  52655. export class MeshAssetTask extends AbstractAssetTask {
  52656. /**
  52657. * Defines the name of the task
  52658. */
  52659. name: string;
  52660. /**
  52661. * Defines the list of mesh's names you want to load
  52662. */
  52663. meshesNames: any;
  52664. /**
  52665. * Defines the root url to use as a base to load your meshes and associated resources
  52666. */
  52667. rootUrl: string;
  52668. /**
  52669. * Defines the filename of the scene to load from
  52670. */
  52671. sceneFilename: string;
  52672. /**
  52673. * Gets the list of loaded meshes
  52674. */
  52675. loadedMeshes: Array<AbstractMesh>;
  52676. /**
  52677. * Gets the list of loaded particle systems
  52678. */
  52679. loadedParticleSystems: Array<IParticleSystem>;
  52680. /**
  52681. * Gets the list of loaded skeletons
  52682. */
  52683. loadedSkeletons: Array<Skeleton>;
  52684. /**
  52685. * Gets the list of loaded animation groups
  52686. */
  52687. loadedAnimationGroups: Array<AnimationGroup>;
  52688. /**
  52689. * Callback called when the task is successful
  52690. */
  52691. onSuccess: (task: MeshAssetTask) => void;
  52692. /**
  52693. * Callback called when the task is successful
  52694. */
  52695. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  52696. /**
  52697. * Creates a new MeshAssetTask
  52698. * @param name defines the name of the task
  52699. * @param meshesNames defines the list of mesh's names you want to load
  52700. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  52701. * @param sceneFilename defines the filename of the scene to load from
  52702. */
  52703. constructor(
  52704. /**
  52705. * Defines the name of the task
  52706. */
  52707. name: string,
  52708. /**
  52709. * Defines the list of mesh's names you want to load
  52710. */
  52711. meshesNames: any,
  52712. /**
  52713. * Defines the root url to use as a base to load your meshes and associated resources
  52714. */
  52715. rootUrl: string,
  52716. /**
  52717. * Defines the filename of the scene to load from
  52718. */
  52719. sceneFilename: string);
  52720. /**
  52721. * Execute the current task
  52722. * @param scene defines the scene where you want your assets to be loaded
  52723. * @param onSuccess is a callback called when the task is successfully executed
  52724. * @param onError is a callback called if an error occurs
  52725. */
  52726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52727. }
  52728. /**
  52729. * Define a task used by AssetsManager to load text content
  52730. */
  52731. export class TextFileAssetTask extends AbstractAssetTask {
  52732. /**
  52733. * Defines the name of the task
  52734. */
  52735. name: string;
  52736. /**
  52737. * Defines the location of the file to load
  52738. */
  52739. url: string;
  52740. /**
  52741. * Gets the loaded text string
  52742. */
  52743. text: string;
  52744. /**
  52745. * Callback called when the task is successful
  52746. */
  52747. onSuccess: (task: TextFileAssetTask) => void;
  52748. /**
  52749. * Callback called when the task is successful
  52750. */
  52751. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52752. /**
  52753. * Creates a new TextFileAssetTask object
  52754. * @param name defines the name of the task
  52755. * @param url defines the location of the file to load
  52756. */
  52757. constructor(
  52758. /**
  52759. * Defines the name of the task
  52760. */
  52761. name: string,
  52762. /**
  52763. * Defines the location of the file to load
  52764. */
  52765. url: string);
  52766. /**
  52767. * Execute the current task
  52768. * @param scene defines the scene where you want your assets to be loaded
  52769. * @param onSuccess is a callback called when the task is successfully executed
  52770. * @param onError is a callback called if an error occurs
  52771. */
  52772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52773. }
  52774. /**
  52775. * Define a task used by AssetsManager to load binary data
  52776. */
  52777. export class BinaryFileAssetTask extends AbstractAssetTask {
  52778. /**
  52779. * Defines the name of the task
  52780. */
  52781. name: string;
  52782. /**
  52783. * Defines the location of the file to load
  52784. */
  52785. url: string;
  52786. /**
  52787. * Gets the lodaded data (as an array buffer)
  52788. */
  52789. data: ArrayBuffer;
  52790. /**
  52791. * Callback called when the task is successful
  52792. */
  52793. onSuccess: (task: BinaryFileAssetTask) => void;
  52794. /**
  52795. * Callback called when the task is successful
  52796. */
  52797. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  52798. /**
  52799. * Creates a new BinaryFileAssetTask object
  52800. * @param name defines the name of the new task
  52801. * @param url defines the location of the file to load
  52802. */
  52803. constructor(
  52804. /**
  52805. * Defines the name of the task
  52806. */
  52807. name: string,
  52808. /**
  52809. * Defines the location of the file to load
  52810. */
  52811. url: string);
  52812. /**
  52813. * Execute the current task
  52814. * @param scene defines the scene where you want your assets to be loaded
  52815. * @param onSuccess is a callback called when the task is successfully executed
  52816. * @param onError is a callback called if an error occurs
  52817. */
  52818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52819. }
  52820. /**
  52821. * Define a task used by AssetsManager to load images
  52822. */
  52823. export class ImageAssetTask extends AbstractAssetTask {
  52824. /**
  52825. * Defines the name of the task
  52826. */
  52827. name: string;
  52828. /**
  52829. * Defines the location of the image to load
  52830. */
  52831. url: string;
  52832. /**
  52833. * Gets the loaded images
  52834. */
  52835. image: HTMLImageElement;
  52836. /**
  52837. * Callback called when the task is successful
  52838. */
  52839. onSuccess: (task: ImageAssetTask) => void;
  52840. /**
  52841. * Callback called when the task is successful
  52842. */
  52843. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  52844. /**
  52845. * Creates a new ImageAssetTask
  52846. * @param name defines the name of the task
  52847. * @param url defines the location of the image to load
  52848. */
  52849. constructor(
  52850. /**
  52851. * Defines the name of the task
  52852. */
  52853. name: string,
  52854. /**
  52855. * Defines the location of the image to load
  52856. */
  52857. url: string);
  52858. /**
  52859. * Execute the current task
  52860. * @param scene defines the scene where you want your assets to be loaded
  52861. * @param onSuccess is a callback called when the task is successfully executed
  52862. * @param onError is a callback called if an error occurs
  52863. */
  52864. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52865. }
  52866. /**
  52867. * Defines the interface used by texture loading tasks
  52868. */
  52869. export interface ITextureAssetTask<TEX extends BaseTexture> {
  52870. /**
  52871. * Gets the loaded texture
  52872. */
  52873. texture: TEX;
  52874. }
  52875. /**
  52876. * Define a task used by AssetsManager to load 2D textures
  52877. */
  52878. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  52879. /**
  52880. * Defines the name of the task
  52881. */
  52882. name: string;
  52883. /**
  52884. * Defines the location of the file to load
  52885. */
  52886. url: string;
  52887. /**
  52888. * Defines if mipmap should not be generated (default is false)
  52889. */
  52890. noMipmap?: boolean | undefined;
  52891. /**
  52892. * Defines if texture must be inverted on Y axis (default is false)
  52893. */
  52894. invertY?: boolean | undefined;
  52895. /**
  52896. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52897. */
  52898. samplingMode: number;
  52899. /**
  52900. * Gets the loaded texture
  52901. */
  52902. texture: Texture;
  52903. /**
  52904. * Callback called when the task is successful
  52905. */
  52906. onSuccess: (task: TextureAssetTask) => void;
  52907. /**
  52908. * Callback called when the task is successful
  52909. */
  52910. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  52911. /**
  52912. * Creates a new TextureAssetTask object
  52913. * @param name defines the name of the task
  52914. * @param url defines the location of the file to load
  52915. * @param noMipmap defines if mipmap should not be generated (default is false)
  52916. * @param invertY defines if texture must be inverted on Y axis (default is false)
  52917. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52918. */
  52919. constructor(
  52920. /**
  52921. * Defines the name of the task
  52922. */
  52923. name: string,
  52924. /**
  52925. * Defines the location of the file to load
  52926. */
  52927. url: string,
  52928. /**
  52929. * Defines if mipmap should not be generated (default is false)
  52930. */
  52931. noMipmap?: boolean | undefined,
  52932. /**
  52933. * Defines if texture must be inverted on Y axis (default is false)
  52934. */
  52935. invertY?: boolean | undefined,
  52936. /**
  52937. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52938. */
  52939. samplingMode?: number);
  52940. /**
  52941. * Execute the current task
  52942. * @param scene defines the scene where you want your assets to be loaded
  52943. * @param onSuccess is a callback called when the task is successfully executed
  52944. * @param onError is a callback called if an error occurs
  52945. */
  52946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52947. }
  52948. /**
  52949. * Define a task used by AssetsManager to load cube textures
  52950. */
  52951. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  52952. /**
  52953. * Defines the name of the task
  52954. */
  52955. name: string;
  52956. /**
  52957. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52958. */
  52959. url: string;
  52960. /**
  52961. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52962. */
  52963. extensions?: string[] | undefined;
  52964. /**
  52965. * Defines if mipmaps should not be generated (default is false)
  52966. */
  52967. noMipmap?: boolean | undefined;
  52968. /**
  52969. * Defines the explicit list of files (undefined by default)
  52970. */
  52971. files?: string[] | undefined;
  52972. /**
  52973. * Gets the loaded texture
  52974. */
  52975. texture: CubeTexture;
  52976. /**
  52977. * Callback called when the task is successful
  52978. */
  52979. onSuccess: (task: CubeTextureAssetTask) => void;
  52980. /**
  52981. * Callback called when the task is successful
  52982. */
  52983. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  52984. /**
  52985. * Creates a new CubeTextureAssetTask
  52986. * @param name defines the name of the task
  52987. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52988. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52989. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52990. * @param files defines the explicit list of files (undefined by default)
  52991. */
  52992. constructor(
  52993. /**
  52994. * Defines the name of the task
  52995. */
  52996. name: string,
  52997. /**
  52998. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52999. */
  53000. url: string,
  53001. /**
  53002. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53003. */
  53004. extensions?: string[] | undefined,
  53005. /**
  53006. * Defines if mipmaps should not be generated (default is false)
  53007. */
  53008. noMipmap?: boolean | undefined,
  53009. /**
  53010. * Defines the explicit list of files (undefined by default)
  53011. */
  53012. files?: string[] | undefined);
  53013. /**
  53014. * Execute the current task
  53015. * @param scene defines the scene where you want your assets to be loaded
  53016. * @param onSuccess is a callback called when the task is successfully executed
  53017. * @param onError is a callback called if an error occurs
  53018. */
  53019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53020. }
  53021. /**
  53022. * Define a task used by AssetsManager to load HDR cube textures
  53023. */
  53024. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  53025. /**
  53026. * Defines the name of the task
  53027. */
  53028. name: string;
  53029. /**
  53030. * Defines the location of the file to load
  53031. */
  53032. url: string;
  53033. /**
  53034. * Defines the desired size (the more it increases the longer the generation will be)
  53035. */
  53036. size: number;
  53037. /**
  53038. * Defines if mipmaps should not be generated (default is false)
  53039. */
  53040. noMipmap: boolean;
  53041. /**
  53042. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53043. */
  53044. generateHarmonics: boolean;
  53045. /**
  53046. * 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)
  53047. */
  53048. gammaSpace: boolean;
  53049. /**
  53050. * Internal Use Only
  53051. */
  53052. reserved: boolean;
  53053. /**
  53054. * Gets the loaded texture
  53055. */
  53056. texture: HDRCubeTexture;
  53057. /**
  53058. * Callback called when the task is successful
  53059. */
  53060. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  53061. /**
  53062. * Callback called when the task is successful
  53063. */
  53064. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  53065. /**
  53066. * Creates a new HDRCubeTextureAssetTask object
  53067. * @param name defines the name of the task
  53068. * @param url defines the location of the file to load
  53069. * @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.
  53070. * @param noMipmap defines if mipmaps should not be generated (default is false)
  53071. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53072. * @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)
  53073. * @param reserved Internal use only
  53074. */
  53075. constructor(
  53076. /**
  53077. * Defines the name of the task
  53078. */
  53079. name: string,
  53080. /**
  53081. * Defines the location of the file to load
  53082. */
  53083. url: string,
  53084. /**
  53085. * Defines the desired size (the more it increases the longer the generation will be)
  53086. */
  53087. size: number,
  53088. /**
  53089. * Defines if mipmaps should not be generated (default is false)
  53090. */
  53091. noMipmap?: boolean,
  53092. /**
  53093. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53094. */
  53095. generateHarmonics?: boolean,
  53096. /**
  53097. * 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)
  53098. */
  53099. gammaSpace?: boolean,
  53100. /**
  53101. * Internal Use Only
  53102. */
  53103. reserved?: boolean);
  53104. /**
  53105. * Execute the current task
  53106. * @param scene defines the scene where you want your assets to be loaded
  53107. * @param onSuccess is a callback called when the task is successfully executed
  53108. * @param onError is a callback called if an error occurs
  53109. */
  53110. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53111. }
  53112. /**
  53113. * This class can be used to easily import assets into a scene
  53114. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  53115. */
  53116. export class AssetsManager {
  53117. private _scene;
  53118. private _isLoading;
  53119. protected _tasks: AbstractAssetTask[];
  53120. protected _waitingTasksCount: number;
  53121. protected _totalTasksCount: number;
  53122. /**
  53123. * Callback called when all tasks are processed
  53124. */
  53125. onFinish: (tasks: AbstractAssetTask[]) => void;
  53126. /**
  53127. * Callback called when a task is successful
  53128. */
  53129. onTaskSuccess: (task: AbstractAssetTask) => void;
  53130. /**
  53131. * Callback called when a task had an error
  53132. */
  53133. onTaskError: (task: AbstractAssetTask) => void;
  53134. /**
  53135. * Callback called when a task is done (whatever the result is)
  53136. */
  53137. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  53138. /**
  53139. * Observable called when all tasks are processed
  53140. */
  53141. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  53142. /**
  53143. * Observable called when a task had an error
  53144. */
  53145. onTaskErrorObservable: Observable<AbstractAssetTask>;
  53146. /**
  53147. * Observable called when a task is successful
  53148. */
  53149. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  53150. /**
  53151. * Observable called when a task is done (whatever the result is)
  53152. */
  53153. onProgressObservable: Observable<IAssetsProgressEvent>;
  53154. /**
  53155. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  53156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  53157. */
  53158. useDefaultLoadingScreen: boolean;
  53159. /**
  53160. * Creates a new AssetsManager
  53161. * @param scene defines the scene to work on
  53162. */
  53163. constructor(scene: Scene);
  53164. /**
  53165. * Add a MeshAssetTask to the list of active tasks
  53166. * @param taskName defines the name of the new task
  53167. * @param meshesNames defines the name of meshes to load
  53168. * @param rootUrl defines the root url to use to locate files
  53169. * @param sceneFilename defines the filename of the scene file
  53170. * @returns a new MeshAssetTask object
  53171. */
  53172. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  53173. /**
  53174. * Add a TextFileAssetTask to the list of active tasks
  53175. * @param taskName defines the name of the new task
  53176. * @param url defines the url of the file to load
  53177. * @returns a new TextFileAssetTask object
  53178. */
  53179. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  53180. /**
  53181. * Add a BinaryFileAssetTask to the list of active tasks
  53182. * @param taskName defines the name of the new task
  53183. * @param url defines the url of the file to load
  53184. * @returns a new BinaryFileAssetTask object
  53185. */
  53186. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  53187. /**
  53188. * Add a ImageAssetTask to the list of active tasks
  53189. * @param taskName defines the name of the new task
  53190. * @param url defines the url of the file to load
  53191. * @returns a new ImageAssetTask object
  53192. */
  53193. addImageTask(taskName: string, url: string): ImageAssetTask;
  53194. /**
  53195. * Add a TextureAssetTask to the list of active tasks
  53196. * @param taskName defines the name of the new task
  53197. * @param url defines the url of the file to load
  53198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53199. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  53200. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53201. * @returns a new TextureAssetTask object
  53202. */
  53203. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  53204. /**
  53205. * Add a CubeTextureAssetTask to the list of active tasks
  53206. * @param taskName defines the name of the new task
  53207. * @param url defines the url of the file to load
  53208. * @param extensions defines the extension to use to load the cube map (can be null)
  53209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53210. * @param files defines the list of files to load (can be null)
  53211. * @returns a new CubeTextureAssetTask object
  53212. */
  53213. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  53214. /**
  53215. *
  53216. * Add a HDRCubeTextureAssetTask to the list of active tasks
  53217. * @param taskName defines the name of the new task
  53218. * @param url defines the url of the file to load
  53219. * @param size defines the size you want for the cubemap (can be null)
  53220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  53221. * @param generateHarmonics defines if you want to automatically generate (true by default)
  53222. * @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)
  53223. * @param reserved Internal use only
  53224. * @returns a new HDRCubeTextureAssetTask object
  53225. */
  53226. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  53227. /**
  53228. * Remove a task from the assets manager.
  53229. * @param task the task to remove
  53230. */
  53231. removeTask(task: AbstractAssetTask): void;
  53232. private _decreaseWaitingTasksCount;
  53233. private _runTask;
  53234. /**
  53235. * Reset the AssetsManager and remove all tasks
  53236. * @return the current instance of the AssetsManager
  53237. */
  53238. reset(): AssetsManager;
  53239. /**
  53240. * Start the loading process
  53241. * @return the current instance of the AssetsManager
  53242. */
  53243. load(): AssetsManager;
  53244. }
  53245. }
  53246. declare module BABYLON {
  53247. /**
  53248. * Wrapper class for promise with external resolve and reject.
  53249. */
  53250. export class Deferred<T> {
  53251. /**
  53252. * The promise associated with this deferred object.
  53253. */
  53254. readonly promise: Promise<T>;
  53255. private _resolve;
  53256. private _reject;
  53257. /**
  53258. * The resolve method of the promise associated with this deferred object.
  53259. */
  53260. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  53261. /**
  53262. * The reject method of the promise associated with this deferred object.
  53263. */
  53264. readonly reject: (reason?: any) => void;
  53265. /**
  53266. * Constructor for this deferred object.
  53267. */
  53268. constructor();
  53269. }
  53270. }
  53271. declare module BABYLON {
  53272. /**
  53273. * Class used to help managing file picking and drag'n'drop
  53274. */
  53275. export class FilesInput {
  53276. /**
  53277. * List of files ready to be loaded
  53278. */
  53279. static readonly FilesToLoad: {
  53280. [key: string]: File;
  53281. };
  53282. /**
  53283. * Callback called when a file is processed
  53284. */
  53285. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  53286. private _engine;
  53287. private _currentScene;
  53288. private _sceneLoadedCallback;
  53289. private _progressCallback;
  53290. private _additionalRenderLoopLogicCallback;
  53291. private _textureLoadingCallback;
  53292. private _startingProcessingFilesCallback;
  53293. private _onReloadCallback;
  53294. private _errorCallback;
  53295. private _elementToMonitor;
  53296. private _sceneFileToLoad;
  53297. private _filesToLoad;
  53298. /**
  53299. * Creates a new FilesInput
  53300. * @param engine defines the rendering engine
  53301. * @param scene defines the hosting scene
  53302. * @param sceneLoadedCallback callback called when scene is loaded
  53303. * @param progressCallback callback called to track progress
  53304. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  53305. * @param textureLoadingCallback callback called when a texture is loading
  53306. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  53307. * @param onReloadCallback callback called when a reload is requested
  53308. * @param errorCallback callback call if an error occurs
  53309. */
  53310. 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);
  53311. private _dragEnterHandler;
  53312. private _dragOverHandler;
  53313. private _dropHandler;
  53314. /**
  53315. * Calls this function to listen to drag'n'drop events on a specific DOM element
  53316. * @param elementToMonitor defines the DOM element to track
  53317. */
  53318. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  53319. /**
  53320. * Release all associated resources
  53321. */
  53322. dispose(): void;
  53323. private renderFunction;
  53324. private drag;
  53325. private drop;
  53326. private _traverseFolder;
  53327. private _processFiles;
  53328. /**
  53329. * Load files from a drop event
  53330. * @param event defines the drop event to use as source
  53331. */
  53332. loadFiles(event: any): void;
  53333. private _processReload;
  53334. /**
  53335. * Reload the current scene from the loaded files
  53336. */
  53337. reload(): void;
  53338. }
  53339. }
  53340. declare module BABYLON {
  53341. /**
  53342. * Defines the root class used to create scene optimization to use with SceneOptimizer
  53343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53344. */
  53345. export class SceneOptimization {
  53346. /**
  53347. * Defines the priority of this optimization (0 by default which means first in the list)
  53348. */
  53349. priority: number;
  53350. /**
  53351. * Gets a string describing the action executed by the current optimization
  53352. * @returns description string
  53353. */
  53354. getDescription(): string;
  53355. /**
  53356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53357. * @param scene defines the current scene where to apply this optimization
  53358. * @param optimizer defines the current optimizer
  53359. * @returns true if everything that can be done was applied
  53360. */
  53361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53362. /**
  53363. * Creates the SceneOptimization object
  53364. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53365. * @param desc defines the description associated with the optimization
  53366. */
  53367. constructor(
  53368. /**
  53369. * Defines the priority of this optimization (0 by default which means first in the list)
  53370. */
  53371. priority?: number);
  53372. }
  53373. /**
  53374. * Defines an optimization used to reduce the size of render target textures
  53375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53376. */
  53377. export class TextureOptimization extends SceneOptimization {
  53378. /**
  53379. * Defines the priority of this optimization (0 by default which means first in the list)
  53380. */
  53381. priority: number;
  53382. /**
  53383. * 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
  53384. */
  53385. maximumSize: number;
  53386. /**
  53387. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53388. */
  53389. step: number;
  53390. /**
  53391. * Gets a string describing the action executed by the current optimization
  53392. * @returns description string
  53393. */
  53394. getDescription(): string;
  53395. /**
  53396. * Creates the TextureOptimization object
  53397. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53398. * @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
  53399. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53400. */
  53401. constructor(
  53402. /**
  53403. * Defines the priority of this optimization (0 by default which means first in the list)
  53404. */
  53405. priority?: number,
  53406. /**
  53407. * 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
  53408. */
  53409. maximumSize?: number,
  53410. /**
  53411. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  53412. */
  53413. step?: number);
  53414. /**
  53415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53416. * @param scene defines the current scene where to apply this optimization
  53417. * @param optimizer defines the current optimizer
  53418. * @returns true if everything that can be done was applied
  53419. */
  53420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53421. }
  53422. /**
  53423. * Defines an optimization used to increase or decrease the rendering resolution
  53424. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53425. */
  53426. export class HardwareScalingOptimization extends SceneOptimization {
  53427. /**
  53428. * Defines the priority of this optimization (0 by default which means first in the list)
  53429. */
  53430. priority: number;
  53431. /**
  53432. * Defines the maximum scale to use (2 by default)
  53433. */
  53434. maximumScale: number;
  53435. /**
  53436. * Defines the step to use between two passes (0.5 by default)
  53437. */
  53438. step: number;
  53439. private _currentScale;
  53440. private _directionOffset;
  53441. /**
  53442. * Gets a string describing the action executed by the current optimization
  53443. * @return description string
  53444. */
  53445. getDescription(): string;
  53446. /**
  53447. * Creates the HardwareScalingOptimization object
  53448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53449. * @param maximumScale defines the maximum scale to use (2 by default)
  53450. * @param step defines the step to use between two passes (0.5 by default)
  53451. */
  53452. constructor(
  53453. /**
  53454. * Defines the priority of this optimization (0 by default which means first in the list)
  53455. */
  53456. priority?: number,
  53457. /**
  53458. * Defines the maximum scale to use (2 by default)
  53459. */
  53460. maximumScale?: number,
  53461. /**
  53462. * Defines the step to use between two passes (0.5 by default)
  53463. */
  53464. step?: number);
  53465. /**
  53466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53467. * @param scene defines the current scene where to apply this optimization
  53468. * @param optimizer defines the current optimizer
  53469. * @returns true if everything that can be done was applied
  53470. */
  53471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53472. }
  53473. /**
  53474. * Defines an optimization used to remove shadows
  53475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53476. */
  53477. export class ShadowsOptimization extends SceneOptimization {
  53478. /**
  53479. * Gets a string describing the action executed by the current optimization
  53480. * @return description string
  53481. */
  53482. getDescription(): string;
  53483. /**
  53484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53485. * @param scene defines the current scene where to apply this optimization
  53486. * @param optimizer defines the current optimizer
  53487. * @returns true if everything that can be done was applied
  53488. */
  53489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53490. }
  53491. /**
  53492. * Defines an optimization used to turn post-processes off
  53493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53494. */
  53495. export class PostProcessesOptimization extends SceneOptimization {
  53496. /**
  53497. * Gets a string describing the action executed by the current optimization
  53498. * @return description string
  53499. */
  53500. getDescription(): string;
  53501. /**
  53502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53503. * @param scene defines the current scene where to apply this optimization
  53504. * @param optimizer defines the current optimizer
  53505. * @returns true if everything that can be done was applied
  53506. */
  53507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53508. }
  53509. /**
  53510. * Defines an optimization used to turn lens flares off
  53511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53512. */
  53513. export class LensFlaresOptimization extends SceneOptimization {
  53514. /**
  53515. * Gets a string describing the action executed by the current optimization
  53516. * @return description string
  53517. */
  53518. getDescription(): string;
  53519. /**
  53520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53521. * @param scene defines the current scene where to apply this optimization
  53522. * @param optimizer defines the current optimizer
  53523. * @returns true if everything that can be done was applied
  53524. */
  53525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53526. }
  53527. /**
  53528. * Defines an optimization based on user defined callback.
  53529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53530. */
  53531. export class CustomOptimization extends SceneOptimization {
  53532. /**
  53533. * Callback called to apply the custom optimization.
  53534. */
  53535. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  53536. /**
  53537. * Callback called to get custom description
  53538. */
  53539. onGetDescription: () => string;
  53540. /**
  53541. * Gets a string describing the action executed by the current optimization
  53542. * @returns description string
  53543. */
  53544. getDescription(): string;
  53545. /**
  53546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53547. * @param scene defines the current scene where to apply this optimization
  53548. * @param optimizer defines the current optimizer
  53549. * @returns true if everything that can be done was applied
  53550. */
  53551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53552. }
  53553. /**
  53554. * Defines an optimization used to turn particles off
  53555. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53556. */
  53557. export class ParticlesOptimization extends SceneOptimization {
  53558. /**
  53559. * Gets a string describing the action executed by the current optimization
  53560. * @return description string
  53561. */
  53562. getDescription(): string;
  53563. /**
  53564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53565. * @param scene defines the current scene where to apply this optimization
  53566. * @param optimizer defines the current optimizer
  53567. * @returns true if everything that can be done was applied
  53568. */
  53569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53570. }
  53571. /**
  53572. * Defines an optimization used to turn render targets off
  53573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53574. */
  53575. export class RenderTargetsOptimization extends SceneOptimization {
  53576. /**
  53577. * Gets a string describing the action executed by the current optimization
  53578. * @return description string
  53579. */
  53580. getDescription(): string;
  53581. /**
  53582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53583. * @param scene defines the current scene where to apply this optimization
  53584. * @param optimizer defines the current optimizer
  53585. * @returns true if everything that can be done was applied
  53586. */
  53587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  53588. }
  53589. /**
  53590. * Defines an optimization used to merge meshes with compatible materials
  53591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53592. */
  53593. export class MergeMeshesOptimization extends SceneOptimization {
  53594. private static _UpdateSelectionTree;
  53595. /**
  53596. * Gets or sets a boolean which defines if optimization octree has to be updated
  53597. */
  53598. /**
  53599. * Gets or sets a boolean which defines if optimization octree has to be updated
  53600. */
  53601. static UpdateSelectionTree: boolean;
  53602. /**
  53603. * Gets a string describing the action executed by the current optimization
  53604. * @return description string
  53605. */
  53606. getDescription(): string;
  53607. private _canBeMerged;
  53608. /**
  53609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  53610. * @param scene defines the current scene where to apply this optimization
  53611. * @param optimizer defines the current optimizer
  53612. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  53613. * @returns true if everything that can be done was applied
  53614. */
  53615. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  53616. }
  53617. /**
  53618. * Defines a list of options used by SceneOptimizer
  53619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53620. */
  53621. export class SceneOptimizerOptions {
  53622. /**
  53623. * Defines the target frame rate to reach (60 by default)
  53624. */
  53625. targetFrameRate: number;
  53626. /**
  53627. * Defines the interval between two checkes (2000ms by default)
  53628. */
  53629. trackerDuration: number;
  53630. /**
  53631. * Gets the list of optimizations to apply
  53632. */
  53633. optimizations: SceneOptimization[];
  53634. /**
  53635. * Creates a new list of options used by SceneOptimizer
  53636. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  53637. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  53638. */
  53639. constructor(
  53640. /**
  53641. * Defines the target frame rate to reach (60 by default)
  53642. */
  53643. targetFrameRate?: number,
  53644. /**
  53645. * Defines the interval between two checkes (2000ms by default)
  53646. */
  53647. trackerDuration?: number);
  53648. /**
  53649. * Add a new optimization
  53650. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  53651. * @returns the current SceneOptimizerOptions
  53652. */
  53653. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  53654. /**
  53655. * Add a new custom optimization
  53656. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  53657. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  53658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53659. * @returns the current SceneOptimizerOptions
  53660. */
  53661. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  53662. /**
  53663. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  53664. * @param targetFrameRate defines the target frame rate (60 by default)
  53665. * @returns a SceneOptimizerOptions object
  53666. */
  53667. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53668. /**
  53669. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  53670. * @param targetFrameRate defines the target frame rate (60 by default)
  53671. * @returns a SceneOptimizerOptions object
  53672. */
  53673. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53674. /**
  53675. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  53676. * @param targetFrameRate defines the target frame rate (60 by default)
  53677. * @returns a SceneOptimizerOptions object
  53678. */
  53679. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53680. }
  53681. /**
  53682. * Class used to run optimizations in order to reach a target frame rate
  53683. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53684. */
  53685. export class SceneOptimizer implements IDisposable {
  53686. private _isRunning;
  53687. private _options;
  53688. private _scene;
  53689. private _currentPriorityLevel;
  53690. private _targetFrameRate;
  53691. private _trackerDuration;
  53692. private _currentFrameRate;
  53693. private _sceneDisposeObserver;
  53694. private _improvementMode;
  53695. /**
  53696. * Defines an observable called when the optimizer reaches the target frame rate
  53697. */
  53698. onSuccessObservable: Observable<SceneOptimizer>;
  53699. /**
  53700. * Defines an observable called when the optimizer enables an optimization
  53701. */
  53702. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  53703. /**
  53704. * Defines an observable called when the optimizer is not able to reach the target frame rate
  53705. */
  53706. onFailureObservable: Observable<SceneOptimizer>;
  53707. /**
  53708. * Gets a boolean indicating if the optimizer is in improvement mode
  53709. */
  53710. readonly isInImprovementMode: boolean;
  53711. /**
  53712. * Gets the current priority level (0 at start)
  53713. */
  53714. readonly currentPriorityLevel: number;
  53715. /**
  53716. * Gets the current frame rate checked by the SceneOptimizer
  53717. */
  53718. readonly currentFrameRate: number;
  53719. /**
  53720. * Gets or sets the current target frame rate (60 by default)
  53721. */
  53722. /**
  53723. * Gets or sets the current target frame rate (60 by default)
  53724. */
  53725. targetFrameRate: number;
  53726. /**
  53727. * Gets or sets the current interval between two checks (every 2000ms by default)
  53728. */
  53729. /**
  53730. * Gets or sets the current interval between two checks (every 2000ms by default)
  53731. */
  53732. trackerDuration: number;
  53733. /**
  53734. * Gets the list of active optimizations
  53735. */
  53736. readonly optimizations: SceneOptimization[];
  53737. /**
  53738. * Creates a new SceneOptimizer
  53739. * @param scene defines the scene to work on
  53740. * @param options defines the options to use with the SceneOptimizer
  53741. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53742. * @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)
  53743. */
  53744. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53745. /**
  53746. * Stops the current optimizer
  53747. */
  53748. stop(): void;
  53749. /**
  53750. * Reset the optimizer to initial step (current priority level = 0)
  53751. */
  53752. reset(): void;
  53753. /**
  53754. * Start the optimizer. By default it will try to reach a specific framerate
  53755. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53756. */
  53757. start(): void;
  53758. private _checkCurrentState;
  53759. /**
  53760. * Release all resources
  53761. */
  53762. dispose(): void;
  53763. /**
  53764. * Helper function to create a SceneOptimizer with one single line of code
  53765. * @param scene defines the scene to work on
  53766. * @param options defines the options to use with the SceneOptimizer
  53767. * @param onSuccess defines a callback to call on success
  53768. * @param onFailure defines a callback to call on failure
  53769. * @returns the new SceneOptimizer object
  53770. */
  53771. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53772. }
  53773. }
  53774. declare module BABYLON {
  53775. /**
  53776. * Class used to serialize a scene into a string
  53777. */
  53778. export class SceneSerializer {
  53779. /**
  53780. * Clear cache used by a previous serialization
  53781. */
  53782. static ClearCache(): void;
  53783. /**
  53784. * Serialize a scene into a JSON compatible object
  53785. * @param scene defines the scene to serialize
  53786. * @returns a JSON compatible object
  53787. */
  53788. static Serialize(scene: Scene): any;
  53789. /**
  53790. * Serialize a mesh into a JSON compatible object
  53791. * @param toSerialize defines the mesh to serialize
  53792. * @param withParents defines if parents must be serialized as well
  53793. * @param withChildren defines if children must be serialized as well
  53794. * @returns a JSON compatible object
  53795. */
  53796. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53797. }
  53798. }
  53799. declare module BABYLON {
  53800. /**
  53801. * This represents the different options avilable for the video capture.
  53802. */
  53803. export interface VideoRecorderOptions {
  53804. /** Defines the mime type of the video */
  53805. mimeType: string;
  53806. /** Defines the video the video should be recorded at */
  53807. fps: number;
  53808. /** Defines the chunk size for the recording data */
  53809. recordChunckSize: number;
  53810. /** The audio tracks to attach to the record */
  53811. audioTracks?: MediaStreamTrack[];
  53812. }
  53813. /**
  53814. * This can helps recording videos from BabylonJS.
  53815. * This is based on the available WebRTC functionalities of the browser.
  53816. *
  53817. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53818. */
  53819. export class VideoRecorder {
  53820. private static readonly _defaultOptions;
  53821. /**
  53822. * Returns wehther or not the VideoRecorder is available in your browser.
  53823. * @param engine Defines the Babylon Engine to check the support for
  53824. * @returns true if supported otherwise false
  53825. */
  53826. static IsSupported(engine: Engine): boolean;
  53827. private readonly _options;
  53828. private _canvas;
  53829. private _mediaRecorder;
  53830. private _recordedChunks;
  53831. private _fileName;
  53832. private _resolve;
  53833. private _reject;
  53834. /**
  53835. * True wether a recording is already in progress.
  53836. */
  53837. readonly isRecording: boolean;
  53838. /**
  53839. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53840. * a video file.
  53841. * @param engine Defines the BabylonJS Engine you wish to record
  53842. * @param options Defines options that can be used to customized the capture
  53843. */
  53844. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53845. /**
  53846. * Stops the current recording before the default capture timeout passed in the startRecording
  53847. * functions.
  53848. */
  53849. stopRecording(): void;
  53850. /**
  53851. * Starts recording the canvas for a max duration specified in parameters.
  53852. * @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.
  53853. * @param maxDuration Defines the maximum recording time in seconds.
  53854. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  53855. * @return a promise callback at the end of the recording with the video data in Blob.
  53856. */
  53857. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  53858. /**
  53859. * Releases internal resources used during the recording.
  53860. */
  53861. dispose(): void;
  53862. private _handleDataAvailable;
  53863. private _handleError;
  53864. private _handleStop;
  53865. }
  53866. }
  53867. declare module BABYLON {
  53868. /**
  53869. * Helper class to push actions to a pool of workers.
  53870. */
  53871. export class WorkerPool implements IDisposable {
  53872. private _workerInfos;
  53873. private _pendingActions;
  53874. /**
  53875. * Constructor
  53876. * @param workers Array of workers to use for actions
  53877. */
  53878. constructor(workers: Array<Worker>);
  53879. /**
  53880. * Terminates all workers and clears any pending actions.
  53881. */
  53882. dispose(): void;
  53883. /**
  53884. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53885. * pended until a worker has completed its action.
  53886. * @param action The action to perform. Call onComplete when the action is complete.
  53887. */
  53888. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53889. private _execute;
  53890. }
  53891. }
  53892. declare module BABYLON {
  53893. /**
  53894. * Class containing a set of static utilities functions for screenshots
  53895. */
  53896. export class ScreenshotTools {
  53897. /**
  53898. * Captures a screenshot of the current rendering
  53899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53900. * @param engine defines the rendering engine
  53901. * @param camera defines the source camera
  53902. * @param size This parameter can be set to a single number or to an object with the
  53903. * following (optional) properties: precision, width, height. If a single number is passed,
  53904. * it will be used for both width and height. If an object is passed, the screenshot size
  53905. * will be derived from the parameters. The precision property is a multiplier allowing
  53906. * rendering at a higher or lower resolution
  53907. * @param successCallback defines the callback receives a single parameter which contains the
  53908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53909. * src parameter of an <img> to display it
  53910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  53911. * Check your browser for supported MIME types
  53912. */
  53913. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  53914. /**
  53915. * Generates an image screenshot from the specified camera.
  53916. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53917. * @param engine The engine to use for rendering
  53918. * @param camera The camera to use for rendering
  53919. * @param size This parameter can be set to a single number or to an object with the
  53920. * following (optional) properties: precision, width, height. If a single number is passed,
  53921. * it will be used for both width and height. If an object is passed, the screenshot size
  53922. * will be derived from the parameters. The precision property is a multiplier allowing
  53923. * rendering at a higher or lower resolution
  53924. * @param successCallback The callback receives a single parameter which contains the
  53925. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53926. * src parameter of an <img> to display it
  53927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  53928. * Check your browser for supported MIME types
  53929. * @param samples Texture samples (default: 1)
  53930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  53931. * @param fileName A name for for the downloaded file.
  53932. */
  53933. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /**
  53938. * A cursor which tracks a point on a path
  53939. */
  53940. export class PathCursor {
  53941. private path;
  53942. /**
  53943. * Stores path cursor callbacks for when an onchange event is triggered
  53944. */
  53945. private _onchange;
  53946. /**
  53947. * The value of the path cursor
  53948. */
  53949. value: number;
  53950. /**
  53951. * The animation array of the path cursor
  53952. */
  53953. animations: Animation[];
  53954. /**
  53955. * Initializes the path cursor
  53956. * @param path The path to track
  53957. */
  53958. constructor(path: Path2);
  53959. /**
  53960. * Gets the cursor point on the path
  53961. * @returns A point on the path cursor at the cursor location
  53962. */
  53963. getPoint(): Vector3;
  53964. /**
  53965. * Moves the cursor ahead by the step amount
  53966. * @param step The amount to move the cursor forward
  53967. * @returns This path cursor
  53968. */
  53969. moveAhead(step?: number): PathCursor;
  53970. /**
  53971. * Moves the cursor behind by the step amount
  53972. * @param step The amount to move the cursor back
  53973. * @returns This path cursor
  53974. */
  53975. moveBack(step?: number): PathCursor;
  53976. /**
  53977. * Moves the cursor by the step amount
  53978. * If the step amount is greater than one, an exception is thrown
  53979. * @param step The amount to move the cursor
  53980. * @returns This path cursor
  53981. */
  53982. move(step: number): PathCursor;
  53983. /**
  53984. * Ensures that the value is limited between zero and one
  53985. * @returns This path cursor
  53986. */
  53987. private ensureLimits;
  53988. /**
  53989. * Runs onchange callbacks on change (used by the animation engine)
  53990. * @returns This path cursor
  53991. */
  53992. private raiseOnChange;
  53993. /**
  53994. * Executes a function on change
  53995. * @param f A path cursor onchange callback
  53996. * @returns This path cursor
  53997. */
  53998. onchange(f: (cursor: PathCursor) => void): PathCursor;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /** @hidden */
  54003. export var blurPixelShader: {
  54004. name: string;
  54005. shader: string;
  54006. };
  54007. }
  54008. declare module BABYLON {
  54009. /** @hidden */
  54010. export var bones300Declaration: {
  54011. name: string;
  54012. shader: string;
  54013. };
  54014. }
  54015. declare module BABYLON {
  54016. /** @hidden */
  54017. export var instances300Declaration: {
  54018. name: string;
  54019. shader: string;
  54020. };
  54021. }
  54022. declare module BABYLON {
  54023. /** @hidden */
  54024. export var pointCloudVertexDeclaration: {
  54025. name: string;
  54026. shader: string;
  54027. };
  54028. }
  54029. // Mixins
  54030. interface Window {
  54031. mozIndexedDB: IDBFactory;
  54032. webkitIndexedDB: IDBFactory;
  54033. msIndexedDB: IDBFactory;
  54034. webkitURL: typeof URL;
  54035. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  54036. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  54037. WebGLRenderingContext: WebGLRenderingContext;
  54038. MSGesture: MSGesture;
  54039. CANNON: any;
  54040. AudioContext: AudioContext;
  54041. webkitAudioContext: AudioContext;
  54042. PointerEvent: any;
  54043. Math: Math;
  54044. Uint8Array: Uint8ArrayConstructor;
  54045. Float32Array: Float32ArrayConstructor;
  54046. mozURL: typeof URL;
  54047. msURL: typeof URL;
  54048. VRFrameData: any; // WebVR, from specs 1.1
  54049. DracoDecoderModule: any;
  54050. setImmediate(handler: (...args: any[]) => void): number;
  54051. }
  54052. interface Document {
  54053. mozCancelFullScreen(): void;
  54054. msCancelFullScreen(): void;
  54055. webkitCancelFullScreen(): void;
  54056. requestPointerLock(): void;
  54057. exitPointerLock(): void;
  54058. mozFullScreen: boolean;
  54059. msIsFullScreen: boolean;
  54060. readonly webkitIsFullScreen: boolean;
  54061. readonly pointerLockElement: Element;
  54062. mozPointerLockElement: HTMLElement;
  54063. msPointerLockElement: HTMLElement;
  54064. webkitPointerLockElement: HTMLElement;
  54065. }
  54066. interface HTMLCanvasElement {
  54067. requestPointerLock(): void;
  54068. msRequestPointerLock?(): void;
  54069. mozRequestPointerLock?(): void;
  54070. webkitRequestPointerLock?(): void;
  54071. /** Track wether a record is in progress */
  54072. isRecording: boolean;
  54073. /** Capture Stream method defined by some browsers */
  54074. captureStream(fps?: number): MediaStream;
  54075. }
  54076. interface CanvasRenderingContext2D {
  54077. msImageSmoothingEnabled: boolean;
  54078. }
  54079. interface MouseEvent {
  54080. mozMovementX: number;
  54081. mozMovementY: number;
  54082. webkitMovementX: number;
  54083. webkitMovementY: number;
  54084. msMovementX: number;
  54085. msMovementY: number;
  54086. }
  54087. interface Navigator {
  54088. mozGetVRDevices: (any: any) => any;
  54089. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54090. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54091. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  54092. webkitGetGamepads(): Gamepad[];
  54093. msGetGamepads(): Gamepad[];
  54094. webkitGamepads(): Gamepad[];
  54095. }
  54096. interface HTMLVideoElement {
  54097. mozSrcObject: any;
  54098. }
  54099. interface Math {
  54100. fround(x: number): number;
  54101. imul(a: number, b: number): number;
  54102. }
  54103. interface WebGLProgram {
  54104. context?: WebGLRenderingContext;
  54105. vertexShader?: WebGLShader;
  54106. fragmentShader?: WebGLShader;
  54107. isParallelCompiled: boolean;
  54108. onCompiled?: () => void;
  54109. }
  54110. interface WebGLRenderingContext {
  54111. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  54112. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  54113. vertexAttribDivisor(index: number, divisor: number): void;
  54114. createVertexArray(): any;
  54115. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  54116. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  54117. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  54118. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  54119. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  54120. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  54121. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  54122. // Queries
  54123. createQuery(): WebGLQuery;
  54124. deleteQuery(query: WebGLQuery): void;
  54125. beginQuery(target: number, query: WebGLQuery): void;
  54126. endQuery(target: number): void;
  54127. getQueryParameter(query: WebGLQuery, pname: number): any;
  54128. getQuery(target: number, pname: number): any;
  54129. MAX_SAMPLES: number;
  54130. RGBA8: number;
  54131. READ_FRAMEBUFFER: number;
  54132. DRAW_FRAMEBUFFER: number;
  54133. UNIFORM_BUFFER: number;
  54134. HALF_FLOAT_OES: number;
  54135. RGBA16F: number;
  54136. RGBA32F: number;
  54137. R32F: number;
  54138. RG32F: number;
  54139. RGB32F: number;
  54140. R16F: number;
  54141. RG16F: number;
  54142. RGB16F: number;
  54143. RED: number;
  54144. RG: number;
  54145. R8: number;
  54146. RG8: number;
  54147. UNSIGNED_INT_24_8: number;
  54148. DEPTH24_STENCIL8: number;
  54149. /* Multiple Render Targets */
  54150. drawBuffers(buffers: number[]): void;
  54151. readBuffer(src: number): void;
  54152. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  54153. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  54154. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  54155. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  54156. // Occlusion Query
  54157. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  54158. ANY_SAMPLES_PASSED: number;
  54159. QUERY_RESULT_AVAILABLE: number;
  54160. QUERY_RESULT: number;
  54161. }
  54162. interface WebGLBuffer {
  54163. references: number;
  54164. capacity: number;
  54165. is32Bits: boolean;
  54166. }
  54167. interface WebGLProgram {
  54168. transformFeedback?: WebGLTransformFeedback | null;
  54169. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  54170. }
  54171. interface EXT_disjoint_timer_query {
  54172. QUERY_COUNTER_BITS_EXT: number;
  54173. TIME_ELAPSED_EXT: number;
  54174. TIMESTAMP_EXT: number;
  54175. GPU_DISJOINT_EXT: number;
  54176. QUERY_RESULT_EXT: number;
  54177. QUERY_RESULT_AVAILABLE_EXT: number;
  54178. queryCounterEXT(query: WebGLQuery, target: number): void;
  54179. createQueryEXT(): WebGLQuery;
  54180. beginQueryEXT(target: number, query: WebGLQuery): void;
  54181. endQueryEXT(target: number): void;
  54182. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  54183. deleteQueryEXT(query: WebGLQuery): void;
  54184. }
  54185. interface WebGLUniformLocation {
  54186. _currentState: any;
  54187. }
  54188. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  54189. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  54190. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  54191. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  54192. interface WebGLRenderingContext {
  54193. readonly RASTERIZER_DISCARD: number;
  54194. readonly DEPTH_COMPONENT24: number;
  54195. readonly TEXTURE_3D: number;
  54196. readonly TEXTURE_2D_ARRAY: number;
  54197. readonly TEXTURE_COMPARE_FUNC: number;
  54198. readonly TEXTURE_COMPARE_MODE: number;
  54199. readonly COMPARE_REF_TO_TEXTURE: number;
  54200. readonly TEXTURE_WRAP_R: number;
  54201. readonly HALF_FLOAT: number;
  54202. readonly RGB8: number;
  54203. readonly RED_INTEGER: number;
  54204. readonly RG_INTEGER: number;
  54205. readonly RGB_INTEGER: number;
  54206. readonly RGBA_INTEGER: number;
  54207. readonly R8_SNORM: number;
  54208. readonly RG8_SNORM: number;
  54209. readonly RGB8_SNORM: number;
  54210. readonly RGBA8_SNORM: number;
  54211. readonly R8I: number;
  54212. readonly RG8I: number;
  54213. readonly RGB8I: number;
  54214. readonly RGBA8I: number;
  54215. readonly R8UI: number;
  54216. readonly RG8UI: number;
  54217. readonly RGB8UI: number;
  54218. readonly RGBA8UI: number;
  54219. readonly R16I: number;
  54220. readonly RG16I: number;
  54221. readonly RGB16I: number;
  54222. readonly RGBA16I: number;
  54223. readonly R16UI: number;
  54224. readonly RG16UI: number;
  54225. readonly RGB16UI: number;
  54226. readonly RGBA16UI: number;
  54227. readonly R32I: number;
  54228. readonly RG32I: number;
  54229. readonly RGB32I: number;
  54230. readonly RGBA32I: number;
  54231. readonly R32UI: number;
  54232. readonly RG32UI: number;
  54233. readonly RGB32UI: number;
  54234. readonly RGBA32UI: number;
  54235. readonly RGB10_A2UI: number;
  54236. readonly R11F_G11F_B10F: number;
  54237. readonly RGB9_E5: number;
  54238. readonly RGB10_A2: number;
  54239. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  54240. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  54241. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  54242. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  54243. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  54244. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  54245. 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;
  54246. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  54247. readonly TRANSFORM_FEEDBACK: number;
  54248. readonly INTERLEAVED_ATTRIBS: number;
  54249. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  54250. createTransformFeedback(): WebGLTransformFeedback;
  54251. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  54252. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  54253. beginTransformFeedback(primitiveMode: number): void;
  54254. endTransformFeedback(): void;
  54255. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  54256. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54257. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54258. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  54259. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  54260. }
  54261. interface ImageBitmap {
  54262. readonly width: number;
  54263. readonly height: number;
  54264. close(): void;
  54265. }
  54266. interface WebGLQuery extends WebGLObject {
  54267. }
  54268. declare var WebGLQuery: {
  54269. prototype: WebGLQuery;
  54270. new(): WebGLQuery;
  54271. };
  54272. interface WebGLSampler extends WebGLObject {
  54273. }
  54274. declare var WebGLSampler: {
  54275. prototype: WebGLSampler;
  54276. new(): WebGLSampler;
  54277. };
  54278. interface WebGLSync extends WebGLObject {
  54279. }
  54280. declare var WebGLSync: {
  54281. prototype: WebGLSync;
  54282. new(): WebGLSync;
  54283. };
  54284. interface WebGLTransformFeedback extends WebGLObject {
  54285. }
  54286. declare var WebGLTransformFeedback: {
  54287. prototype: WebGLTransformFeedback;
  54288. new(): WebGLTransformFeedback;
  54289. };
  54290. interface WebGLVertexArrayObject extends WebGLObject {
  54291. }
  54292. declare var WebGLVertexArrayObject: {
  54293. prototype: WebGLVertexArrayObject;
  54294. new(): WebGLVertexArrayObject;
  54295. };
  54296. // Type definitions for WebVR API
  54297. // Project: https://w3c.github.io/webvr/
  54298. // Definitions by: six a <https://github.com/lostfictions>
  54299. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  54300. interface VRDisplay extends EventTarget {
  54301. /**
  54302. * Dictionary of capabilities describing the VRDisplay.
  54303. */
  54304. readonly capabilities: VRDisplayCapabilities;
  54305. /**
  54306. * z-depth defining the far plane of the eye view frustum
  54307. * enables mapping of values in the render target depth
  54308. * attachment to scene coordinates. Initially set to 10000.0.
  54309. */
  54310. depthFar: number;
  54311. /**
  54312. * z-depth defining the near plane of the eye view frustum
  54313. * enables mapping of values in the render target depth
  54314. * attachment to scene coordinates. Initially set to 0.01.
  54315. */
  54316. depthNear: number;
  54317. /**
  54318. * An identifier for this distinct VRDisplay. Used as an
  54319. * association point in the Gamepad API.
  54320. */
  54321. readonly displayId: number;
  54322. /**
  54323. * A display name, a user-readable name identifying it.
  54324. */
  54325. readonly displayName: string;
  54326. readonly isConnected: boolean;
  54327. readonly isPresenting: boolean;
  54328. /**
  54329. * If this VRDisplay supports room-scale experiences, the optional
  54330. * stage attribute contains details on the room-scale parameters.
  54331. */
  54332. readonly stageParameters: VRStageParameters | null;
  54333. /**
  54334. * Passing the value returned by `requestAnimationFrame` to
  54335. * `cancelAnimationFrame` will unregister the callback.
  54336. * @param handle Define the hanle of the request to cancel
  54337. */
  54338. cancelAnimationFrame(handle: number): void;
  54339. /**
  54340. * Stops presenting to the VRDisplay.
  54341. * @returns a promise to know when it stopped
  54342. */
  54343. exitPresent(): Promise<void>;
  54344. /**
  54345. * Return the current VREyeParameters for the given eye.
  54346. * @param whichEye Define the eye we want the parameter for
  54347. * @returns the eye parameters
  54348. */
  54349. getEyeParameters(whichEye: string): VREyeParameters;
  54350. /**
  54351. * Populates the passed VRFrameData with the information required to render
  54352. * the current frame.
  54353. * @param frameData Define the data structure to populate
  54354. * @returns true if ok otherwise false
  54355. */
  54356. getFrameData(frameData: VRFrameData): boolean;
  54357. /**
  54358. * Get the layers currently being presented.
  54359. * @returns the list of VR layers
  54360. */
  54361. getLayers(): VRLayer[];
  54362. /**
  54363. * Return a VRPose containing the future predicted pose of the VRDisplay
  54364. * when the current frame will be presented. The value returned will not
  54365. * change until JavaScript has returned control to the browser.
  54366. *
  54367. * The VRPose will contain the position, orientation, velocity,
  54368. * and acceleration of each of these properties.
  54369. * @returns the pose object
  54370. */
  54371. getPose(): VRPose;
  54372. /**
  54373. * Return the current instantaneous pose of the VRDisplay, with no
  54374. * prediction applied.
  54375. * @returns the current instantaneous pose
  54376. */
  54377. getImmediatePose(): VRPose;
  54378. /**
  54379. * The callback passed to `requestAnimationFrame` will be called
  54380. * any time a new frame should be rendered. When the VRDisplay is
  54381. * presenting the callback will be called at the native refresh
  54382. * rate of the HMD. When not presenting this function acts
  54383. * identically to how window.requestAnimationFrame acts. Content should
  54384. * make no assumptions of frame rate or vsync behavior as the HMD runs
  54385. * asynchronously from other displays and at differing refresh rates.
  54386. * @param callback Define the eaction to run next frame
  54387. * @returns the request handle it
  54388. */
  54389. requestAnimationFrame(callback: FrameRequestCallback): number;
  54390. /**
  54391. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  54392. * Repeat calls while already presenting will update the VRLayers being displayed.
  54393. * @param layers Define the list of layer to present
  54394. * @returns a promise to know when the request has been fulfilled
  54395. */
  54396. requestPresent(layers: VRLayer[]): Promise<void>;
  54397. /**
  54398. * Reset the pose for this display, treating its current position and
  54399. * orientation as the "origin/zero" values. VRPose.position,
  54400. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  54401. * updated when calling resetPose(). This should be called in only
  54402. * sitting-space experiences.
  54403. */
  54404. resetPose(): void;
  54405. /**
  54406. * The VRLayer provided to the VRDisplay will be captured and presented
  54407. * in the HMD. Calling this function has the same effect on the source
  54408. * canvas as any other operation that uses its source image, and canvases
  54409. * created without preserveDrawingBuffer set to true will be cleared.
  54410. * @param pose Define the pose to submit
  54411. */
  54412. submitFrame(pose?: VRPose): void;
  54413. }
  54414. declare var VRDisplay: {
  54415. prototype: VRDisplay;
  54416. new(): VRDisplay;
  54417. };
  54418. interface VRLayer {
  54419. leftBounds?: number[] | Float32Array | null;
  54420. rightBounds?: number[] | Float32Array | null;
  54421. source?: HTMLCanvasElement | null;
  54422. }
  54423. interface VRDisplayCapabilities {
  54424. readonly canPresent: boolean;
  54425. readonly hasExternalDisplay: boolean;
  54426. readonly hasOrientation: boolean;
  54427. readonly hasPosition: boolean;
  54428. readonly maxLayers: number;
  54429. }
  54430. interface VREyeParameters {
  54431. /** @deprecated */
  54432. readonly fieldOfView: VRFieldOfView;
  54433. readonly offset: Float32Array;
  54434. readonly renderHeight: number;
  54435. readonly renderWidth: number;
  54436. }
  54437. interface VRFieldOfView {
  54438. readonly downDegrees: number;
  54439. readonly leftDegrees: number;
  54440. readonly rightDegrees: number;
  54441. readonly upDegrees: number;
  54442. }
  54443. interface VRFrameData {
  54444. readonly leftProjectionMatrix: Float32Array;
  54445. readonly leftViewMatrix: Float32Array;
  54446. readonly pose: VRPose;
  54447. readonly rightProjectionMatrix: Float32Array;
  54448. readonly rightViewMatrix: Float32Array;
  54449. readonly timestamp: number;
  54450. }
  54451. interface VRPose {
  54452. readonly angularAcceleration: Float32Array | null;
  54453. readonly angularVelocity: Float32Array | null;
  54454. readonly linearAcceleration: Float32Array | null;
  54455. readonly linearVelocity: Float32Array | null;
  54456. readonly orientation: Float32Array | null;
  54457. readonly position: Float32Array | null;
  54458. readonly timestamp: number;
  54459. }
  54460. interface VRStageParameters {
  54461. sittingToStandingTransform?: Float32Array;
  54462. sizeX?: number;
  54463. sizeY?: number;
  54464. }
  54465. interface Navigator {
  54466. getVRDisplays(): Promise<VRDisplay[]>;
  54467. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  54468. }
  54469. interface Window {
  54470. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  54471. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  54472. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  54473. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54474. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  54475. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  54476. }
  54477. interface Gamepad {
  54478. readonly displayId: number;
  54479. }
  54480. interface XRDevice {
  54481. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  54482. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  54483. }
  54484. interface XRSession {
  54485. getInputSources(): Array<any>;
  54486. baseLayer: XRWebGLLayer;
  54487. requestFrameOfReference(type: string): Promise<void>;
  54488. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  54489. end(): Promise<void>;
  54490. requestAnimationFrame: Function;
  54491. addEventListener: Function;
  54492. }
  54493. interface XRSessionCreationOptions {
  54494. outputContext?: WebGLRenderingContext | null;
  54495. immersive?: boolean;
  54496. environmentIntegration?: boolean;
  54497. }
  54498. interface XRLayer {
  54499. getViewport: Function;
  54500. framebufferWidth: number;
  54501. framebufferHeight: number;
  54502. }
  54503. interface XRView {
  54504. projectionMatrix: Float32Array;
  54505. }
  54506. interface XRFrame {
  54507. getDevicePose: Function;
  54508. getInputPose: Function;
  54509. views: Array<XRView>;
  54510. baseLayer: XRLayer;
  54511. }
  54512. interface XRFrameOfReference {
  54513. }
  54514. interface XRWebGLLayer extends XRLayer {
  54515. framebuffer: WebGLFramebuffer;
  54516. }
  54517. declare var XRWebGLLayer: {
  54518. prototype: XRWebGLLayer;
  54519. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  54520. };